Built motion from commit caf7d5f0.|2.5.39
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x295f=['Dynamics365Account','includeAll','include','rows','catch','show','params','keys','intersection','length','find','create','body','findOne','Dynamics365Configuration','rawAttributes','getConfigurations','addConfiguration','Subjects','getSubjects','channel','Descriptions','getDescriptions','Dynamics365Field','getFields','incident','Incident','PhoneCall','title','customerid','caseorigincode','subject','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyname','customeridname','customeridtype','customeridyominame','emailaddress','entityimage_timestamp','entityimage_url','escalatedon','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedonbehalfbyname','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','owneridname','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','productserialnumber','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','subjectidname','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','password','remoteUri','tenantId','clientId','substring','lastIndexOf','format','%s/api/data/v9.0/','https://login.microsoftonline.com/','/oauth2/token','clientSecret','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','value','MetadataId',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','4.0','Attributes','includes','LogicalName','@odata.type','push','all','isNil','BooleanAttributeMetadata','forEach','StringAttributeMetadata','DoubleAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','StatusAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','Wrong\x20credentials','EntityDefinitions(',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label','UserLocalizedLabel','Value','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','rimraf','zip-dir','fast-json-patch','moment','bluebird','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','save','update','destroy','then','error','stack','name','send','index','map','key','model','query','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','options'];(function(_0x4e302a,_0x204d18){var _0x2cae78=function(_0x549896){while(--_0x549896){_0x4e302a['push'](_0x4e302a['shift']());}};_0x2cae78(++_0x204d18);}(_0x295f,0x168));var _0xf295=function(_0x43b518,_0x38c007){_0x43b518=_0x43b518-0x0;var _0x541b8e=_0x295f[_0x43b518];return _0x541b8e;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf295('0x0'));var zipdir=require(_0xf295('0x1'));var jsonpatch=require(_0xf295('0x2'));var rp=require('request-promise');var moment=require(_0xf295('0x3'));var BPromise=require(_0xf295('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf295('0x5'));var sox=require(_0xf295('0x6'));var csv=require(_0xf295('0x7'));var ejs=require(_0xf295('0x8'));var fs=require('fs');var fs_extra=require(_0xf295('0x9'));var _=require('lodash');var squel=require(_0xf295('0xa'));var crypto=require(_0xf295('0xb'));var jsforce=require(_0xf295('0xc'));var deskjs=require(_0xf295('0xd'));var toCsv=require(_0xf295('0x7'));var querystring=require(_0xf295('0xe'));var Papa=require(_0xf295('0xf'));var Redis=require(_0xf295('0x10'));var authService=require(_0xf295('0x11'));var qs=require(_0xf295('0x12'));var as=require(_0xf295('0x13'));var hardwareService=require(_0xf295('0x14'));var logger=require('../../config/logger')(_0xf295('0x15'));var utils=require(_0xf295('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf295('0x17'));var db=require(_0xf295('0x18'))['db'];var integrations=require(_0xf295('0x19'));function respondWithStatusCode(_0x416d04,_0x11063a){_0x11063a=_0x11063a||0xcc;return function(_0x50c4ba){if(_0x50c4ba){return _0x416d04[_0xf295('0x1a')](_0x11063a);}return _0x416d04[_0xf295('0x1b')](_0x11063a)[_0xf295('0x1c')]();};}function respondWithResult(_0x3f0981,_0x1724d0){_0x1724d0=_0x1724d0||0xc8;return function(_0x6267ce){if(_0x6267ce){return _0x3f0981[_0xf295('0x1b')](_0x1724d0)[_0xf295('0x1d')](_0x6267ce);}};}function respondWithFilteredResult(_0x11f3b0,_0x1d31e6){return function(_0xa42735){if(_0xa42735){var _0x42d8c8=typeof _0x1d31e6['offset']==='undefined'&&typeof _0x1d31e6[_0xf295('0x1e')]===_0xf295('0x1f');var _0x58d1a3=_0xa42735[_0xf295('0x20')];var _0x5d18e1=_0x42d8c8?0x0:_0x1d31e6[_0xf295('0x21')];var _0x4deacb=_0x42d8c8?_0xa42735['count']:_0x1d31e6[_0xf295('0x21')]+_0x1d31e6[_0xf295('0x1e')];var _0x4dca5d;if(_0x4deacb>=_0x58d1a3){_0x4deacb=_0x58d1a3;_0x4dca5d=0xc8;}else{_0x4dca5d=0xce;}_0x11f3b0['status'](_0x4dca5d);return _0x11f3b0[_0xf295('0x22')](_0xf295('0x23'),_0x5d18e1+'-'+_0x4deacb+'/'+_0x58d1a3)[_0xf295('0x1d')](_0xa42735);}return null;};}function patchUpdates(_0x28fa70){return function(_0x476db5){try{jsonpatch[_0xf295('0x24')](_0x476db5,_0x28fa70,!![]);}catch(_0x50ad96){return BPromise['reject'](_0x50ad96);}return _0x476db5[_0xf295('0x25')]();};}function saveUpdates(_0x5154b0,_0x2ef08a){return function(_0x39dc96){if(_0x39dc96){return _0x39dc96[_0xf295('0x26')](_0x5154b0)['then'](function(_0x3c1be4){return _0x3c1be4;});}return null;};}function removeEntity(_0x2e079e,_0x493aed){return function(_0x250939){if(_0x250939){return _0x250939[_0xf295('0x27')]()[_0xf295('0x28')](function(){_0x2e079e[_0xf295('0x1b')](0xcc)[_0xf295('0x1c')]();});}};}function handleEntityNotFound(_0x490cc3,_0x615ded){return function(_0x90d6e5){if(!_0x90d6e5){_0x490cc3['sendStatus'](0x194);}return _0x90d6e5;};}function handleError(_0x4b7850,_0x1ba1dd){_0x1ba1dd=_0x1ba1dd||0x1f4;return function(_0x74d71f){logger[_0xf295('0x29')](_0x74d71f[_0xf295('0x2a')]);if(_0x74d71f[_0xf295('0x2b')]){delete _0x74d71f[_0xf295('0x2b')];}_0x4b7850[_0xf295('0x1b')](_0x1ba1dd)[_0xf295('0x2c')](_0x74d71f);};}exports[_0xf295('0x2d')]=function(_0x5dae12,_0x1f5a89){var _0x19ec3a={},_0x2d98bd={},_0x41aa44={'count':0x0,'rows':[]};var _0x46cc58=_[_0xf295('0x2e')](db['Dynamics365Account']['rawAttributes'],function(_0x50a7b7){return{'name':_0x50a7b7['fieldName'],'type':_0x50a7b7['type'][_0xf295('0x2f')]};});_0x2d98bd[_0xf295('0x30')]=_[_0xf295('0x2e')](_0x46cc58,'name');_0x2d98bd[_0xf295('0x31')]=_['keys'](_0x5dae12[_0xf295('0x31')]);_0x2d98bd['filters']=_['intersection'](_0x2d98bd[_0xf295('0x30')],_0x2d98bd[_0xf295('0x31')]);_0x19ec3a[_0xf295('0x32')]=_['intersection'](_0x2d98bd[_0xf295('0x30')],qs[_0xf295('0x33')](_0x5dae12[_0xf295('0x31')][_0xf295('0x33')]));_0x19ec3a[_0xf295('0x32')]=_0x19ec3a[_0xf295('0x32')]['length']?_0x19ec3a[_0xf295('0x32')]:_0x2d98bd[_0xf295('0x30')];if(!_0x5dae12[_0xf295('0x31')][_0xf295('0x34')](_0xf295('0x35'))){_0x19ec3a['limit']=qs[_0xf295('0x1e')](_0x5dae12[_0xf295('0x31')]['limit']);_0x19ec3a[_0xf295('0x21')]=qs[_0xf295('0x21')](_0x5dae12[_0xf295('0x31')]['offset']);}_0x19ec3a[_0xf295('0x36')]=qs[_0xf295('0x37')](_0x5dae12[_0xf295('0x31')][_0xf295('0x37')]);_0x19ec3a[_0xf295('0x38')]=qs[_0xf295('0x39')](_[_0xf295('0x3a')](_0x5dae12[_0xf295('0x31')],_0x2d98bd[_0xf295('0x39')]),_0x46cc58);if(_0x5dae12[_0xf295('0x31')][_0xf295('0x3b')]){_0x19ec3a[_0xf295('0x38')]=_[_0xf295('0x3c')](_0x19ec3a['where'],{'$or':_[_0xf295('0x2e')](_0x46cc58,function(_0x3f0b45){if(_0x3f0b45[_0xf295('0x3d')]!==_0xf295('0x3e')){var _0x3a746e={};_0x3a746e[_0x3f0b45[_0xf295('0x2b')]]={'$like':'%'+_0x5dae12['query']['filter']+'%'};return _0x3a746e;}})});}_0x19ec3a=_[_0xf295('0x3c')]({},_0x19ec3a,_0x5dae12[_0xf295('0x3f')]);var _0x51c37a={'where':_0x19ec3a['where']};return db[_0xf295('0x40')][_0xf295('0x20')](_0x51c37a)[_0xf295('0x28')](function(_0x57beef){_0x41aa44[_0xf295('0x20')]=_0x57beef;if(_0x5dae12[_0xf295('0x31')][_0xf295('0x41')]){_0x19ec3a[_0xf295('0x42')]=[{'all':!![]}];}return db[_0xf295('0x40')]['findAll'](_0x19ec3a);})[_0xf295('0x28')](function(_0x3fd4be){_0x41aa44[_0xf295('0x43')]=_0x3fd4be;return _0x41aa44;})['then'](respondWithFilteredResult(_0x1f5a89,_0x19ec3a))[_0xf295('0x44')](handleError(_0x1f5a89,null));};exports[_0xf295('0x45')]=function(_0x386422,_0x80fb8a){var _0x4fd3f8={'raw':![],'where':{'id':_0x386422[_0xf295('0x46')]['id']}},_0x5e8bb3={};_0x5e8bb3['model']=_[_0xf295('0x47')](db[_0xf295('0x40')]['rawAttributes']);_0x5e8bb3[_0xf295('0x31')]=_[_0xf295('0x47')](_0x386422[_0xf295('0x31')]);_0x5e8bb3[_0xf295('0x39')]=_[_0xf295('0x48')](_0x5e8bb3[_0xf295('0x30')],_0x5e8bb3[_0xf295('0x31')]);_0x4fd3f8['attributes']=_['intersection'](_0x5e8bb3[_0xf295('0x30')],qs[_0xf295('0x33')](_0x386422[_0xf295('0x31')][_0xf295('0x33')]));_0x4fd3f8[_0xf295('0x32')]=_0x4fd3f8[_0xf295('0x32')][_0xf295('0x49')]?_0x4fd3f8[_0xf295('0x32')]:_0x5e8bb3[_0xf295('0x30')];if(_0x386422[_0xf295('0x31')]['includeAll']){_0x4fd3f8[_0xf295('0x42')]=[{'all':!![]}];}_0x4fd3f8=_['merge']({},_0x4fd3f8,_0x386422[_0xf295('0x3f')]);return db['Dynamics365Account'][_0xf295('0x4a')](_0x4fd3f8)['then'](handleEntityNotFound(_0x80fb8a,null))[_0xf295('0x28')](respondWithResult(_0x80fb8a,null))[_0xf295('0x44')](handleError(_0x80fb8a,null));};exports[_0xf295('0x4b')]=function(_0x5ab7ce,_0xe556ca){return db[_0xf295('0x40')]['create'](_0x5ab7ce[_0xf295('0x4c')],{})['then'](respondWithResult(_0xe556ca,0xc9))[_0xf295('0x44')](handleError(_0xe556ca,null));};exports['update']=function(_0x4beb0d,_0x362dc7){if(_0x4beb0d[_0xf295('0x4c')]['id']){delete _0x4beb0d[_0xf295('0x4c')]['id'];}return db['Dynamics365Account'][_0xf295('0x4a')]({'where':{'id':_0x4beb0d['params']['id']}})[_0xf295('0x28')](handleEntityNotFound(_0x362dc7,null))[_0xf295('0x28')](saveUpdates(_0x4beb0d[_0xf295('0x4c')],null))[_0xf295('0x28')](respondWithResult(_0x362dc7,null))['catch'](handleError(_0x362dc7,null));};exports[_0xf295('0x27')]=function(_0x4987a2,_0x249d95){return db[_0xf295('0x40')][_0xf295('0x4a')]({'where':{'id':_0x4987a2[_0xf295('0x46')]['id']}})['then'](handleEntityNotFound(_0x249d95,null))[_0xf295('0x28')](removeEntity(_0x249d95,null))[_0xf295('0x44')](handleError(_0x249d95,null));};exports['getConfigurations']=function(_0x3e9121,_0x2cee88,_0x37ec22){var _0x56a9ef={};var _0x57525c={};var _0x117952;var _0x3b4d7b;return db[_0xf295('0x40')][_0xf295('0x4d')]({'where':{'id':_0x3e9121['params']['id']}})[_0xf295('0x28')](handleEntityNotFound(_0x2cee88,null))[_0xf295('0x28')](function(_0x5cdc47){if(_0x5cdc47){_0x117952=_0x5cdc47;_0x57525c['model']=_['keys'](db[_0xf295('0x4e')][_0xf295('0x4f')]);_0x57525c[_0xf295('0x31')]=_[_0xf295('0x47')](_0x3e9121[_0xf295('0x31')]);_0x57525c[_0xf295('0x39')]=_[_0xf295('0x48')](_0x57525c[_0xf295('0x30')],_0x57525c[_0xf295('0x31')]);_0x56a9ef[_0xf295('0x32')]=_['intersection'](_0x57525c['model'],qs['fields'](_0x3e9121[_0xf295('0x31')][_0xf295('0x33')]));_0x56a9ef[_0xf295('0x32')]=_0x56a9ef[_0xf295('0x32')][_0xf295('0x49')]?_0x56a9ef[_0xf295('0x32')]:_0x57525c[_0xf295('0x30')];_0x56a9ef['order']=qs['sort'](_0x3e9121[_0xf295('0x31')][_0xf295('0x37')]);_0x56a9ef[_0xf295('0x38')]=qs['filters'](_[_0xf295('0x3a')](_0x3e9121[_0xf295('0x31')],_0x57525c[_0xf295('0x39')]));if(_0x3e9121['query'][_0xf295('0x3b')]){_0x56a9ef['where']=_[_0xf295('0x3c')](_0x56a9ef[_0xf295('0x38')],{'$or':_[_0xf295('0x2e')](_0x56a9ef[_0xf295('0x32')],function(_0x339e84){var _0x669436={};_0x669436[_0x339e84]={'$like':'%'+_0x3e9121[_0xf295('0x31')][_0xf295('0x3b')]+'%'};return _0x669436;})});}_0x56a9ef=_[_0xf295('0x3c')]({},_0x56a9ef,_0x3e9121['options']);return _0x117952['getConfigurations'](_0x56a9ef);}})[_0xf295('0x28')](function(_0x511df3){if(_0x511df3){_0x3b4d7b=_0x511df3[_0xf295('0x49')];if(!_0x3e9121[_0xf295('0x31')][_0xf295('0x34')](_0xf295('0x35'))){_0x56a9ef['limit']=qs['limit'](_0x3e9121[_0xf295('0x31')]['limit']);_0x56a9ef[_0xf295('0x21')]=qs[_0xf295('0x21')](_0x3e9121['query'][_0xf295('0x21')]);}return _0x117952[_0xf295('0x50')](_0x56a9ef);}})[_0xf295('0x28')](function(_0x4aa3c2){if(_0x4aa3c2){return _0x4aa3c2?{'count':_0x3b4d7b,'rows':_0x4aa3c2}:null;}})[_0xf295('0x28')](respondWithResult(_0x2cee88,null))[_0xf295('0x44')](handleError(_0x2cee88,null));};exports[_0xf295('0x51')]=function(_0x14a917,_0x3c037b,_0xa2d5ee){if(_0x14a917[_0xf295('0x4c')]['id']){delete _0x14a917[_0xf295('0x4c')]['id'];}return db[_0xf295('0x40')]['findOne']({'where':{'id':_0x14a917['params']['id']}})[_0xf295('0x28')](handleEntityNotFound(_0x3c037b,null))[_0xf295('0x28')](function(_0xcf3990){if(_0xcf3990){_0x14a917[_0xf295('0x4c')]['AccountId']=_0xcf3990['id'];_0x14a917['body'][_0xf295('0x52')]=integrations[_0xf295('0x53')](_0x14a917[_0xf295('0x4c')][_0xf295('0x54')],_0x14a917[_0xf295('0x4c')][_0xf295('0x3d')]);_0x14a917['body'][_0xf295('0x55')]=integrations[_0xf295('0x56')](_0x14a917[_0xf295('0x4c')]['channel'],_0x14a917[_0xf295('0x4c')][_0xf295('0x3d')]);return db['Dynamics365Configuration'][_0xf295('0x4b')](_0x14a917[_0xf295('0x4c')],{'include':[{'model':db[_0xf295('0x57')],'as':_0xf295('0x52')},{'model':db[_0xf295('0x57')],'as':_0xf295('0x55')}]});}return null;})[_0xf295('0x28')](respondWithResult(_0x3c037b,null))['catch'](handleError(_0x3c037b,null));};exports[_0xf295('0x58')]=function(_0x45347d,_0x37e14b,_0x2a0098){var _0x2b776b=_0x45347d[_0xf295('0x31')]['ticketType'];var _0x523874=_0x2b776b===_0xf295('0x59')?_0xf295('0x5a'):_0xf295('0x5b');var _0x17af87='';var _0x30e3e7='';var _0x200cab='';var _0x469ec0='';var _0x25cb9a='';var _0x40e9c4='';var _0x45f5a6='';var _0x3eb268='';var _0x10c87d=[_0xf295('0x5c'),'description',_0xf295('0x5d'),'ownerid',_0xf295('0x5e'),_0xf295('0x5f'),'phonenumber',_0xf295('0x60'),_0xf295('0x61'),_0xf295('0x62')];var _0x536cbc=[_0xf295('0x63'),_0xf295('0x64'),_0xf295('0x65'),_0xf295('0x66'),_0xf295('0x67'),_0xf295('0x68'),_0xf295('0x69'),_0xf295('0x6a'),_0xf295('0x6b'),_0xf295('0x6c'),_0xf295('0x6d'),_0xf295('0x6e'),_0xf295('0x6f'),_0xf295('0x70'),'createdonbehalfbyyominame',_0xf295('0x71'),_0xf295('0x72'),_0xf295('0x73'),_0xf295('0x74'),'entitlementidname',_0xf295('0x75'),_0xf295('0x76'),_0xf295('0x77'),'exchangerate',_0xf295('0x78'),_0xf295('0x79'),_0xf295('0x7a'),_0xf295('0x7b'),_0xf295('0x7c'),_0xf295('0x7d'),_0xf295('0x7e'),_0xf295('0x7f'),_0xf295('0x80'),_0xf295('0x81'),_0xf295('0x82'),'modifiedon',_0xf295('0x83'),'modifiedonbehalfbyyominame','msdyn_incidenttypename',_0xf295('0x84'),_0xf295('0x85'),'onholdtime',_0xf295('0x86'),_0xf295('0x87'),'owneridtype',_0xf295('0x88'),_0xf295('0x89'),_0xf295('0x8a'),_0xf295('0x8b'),'prioritycodename','productidname',_0xf295('0x8c'),_0xf295('0x8d'),_0xf295('0x8e'),_0xf295('0x8f'),_0xf295('0x90'),_0xf295('0x91'),_0xf295('0x92'),_0xf295('0x93'),_0xf295('0x94'),_0xf295('0x95'),_0xf295('0x96'),_0xf295('0x97'),_0xf295('0x98'),'ticketnumber',_0xf295('0x99'),_0xf295('0x9a'),_0xf295('0x9b'),_0xf295('0x9c'),_0xf295('0x9d')];var _0xad756f=_0x10c87d[_0xf295('0x9e')](_0x536cbc);return db['Dynamics365Account']['findOne']({'where':{'id':_0x45347d[_0xf295('0x46')]['id']},'attributes':['id',_0xf295('0x9f'),_0xf295('0xa0'),_0xf295('0xa1'),_0xf295('0xa2'),_0xf295('0xa3'),'clientSecret']})[_0xf295('0x28')](handleEntityNotFound(_0x37e14b,null))[_0xf295('0x28')](function(_0x368cc8){if(_0x368cc8){_0x3eb268=_0x368cc8[_0xf295('0xa1')];var _0x17779d=_0x3eb268['slice'](-0x1);if(_0x17779d==='/'){_0x3eb268=_0x3eb268[_0xf295('0xa4')](0x0,_0x3eb268[_0xf295('0xa5')](_0x17779d));}_0x45f5a6=util[_0xf295('0xa6')](_0xf295('0xa7'),_0x3eb268);var _0xc1b4fe={'method':'POST','uri':_0xf295('0xa8')+_0x368cc8['tenantId']+_0xf295('0xa9'),'form':{'client_id':_0x368cc8['clientId'],'resource':_0x3eb268,'username':_0x368cc8[_0xf295('0x9f')],'password':_0x368cc8['password'],'grant_type':_0xf295('0xa0'),'client_secret':_0x368cc8[_0xf295('0xaa')]},'json':!![]};return rp(_0xc1b4fe);}})['then'](function(_0x1cf2f6){_0x40e9c4=_0x1cf2f6['access_token'];var _0xe5c447={'method':_0xf295('0xab'),'uri':encodeURI(_0x45f5a6+_0xf295('0xac')+_0x523874+'\x27'),'headers':{'Authorization':_0xf295('0xad')+_0x40e9c4,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0xe5c447);})['then'](function(_0xb7f466){var _0xe4a071=_0xb7f466[_0xf295('0xae')][0x0];var _0x504e91=_0xe4a071[_0xf295('0xaf')];var _0x5a6082={'method':_0xf295('0xab'),'uri':_0x45f5a6+'EntityDefinitions('+_0x504e91+_0xf295('0xb0'),'headers':{'Authorization':'Bearer\x20'+_0x40e9c4,'If-None-Match':null,'OData-Version':_0xf295('0xb1')},'json':!![]};return rp(_0x5a6082);})['then'](function(_0x488055){_0x17af87=_0x488055;_0x30e3e7=_0x17af87[_0xf295('0xb2')];_0x30e3e7=_['remove'](_0x30e3e7,function(_0xcaa7ce){return!_0xad756f[_0xf295('0xb3')](_0xcaa7ce[_0xf295('0xb4')]);});var _0x1c9646=[];var _0x2d4aa8=[];_0x30e3e7['forEach'](function(_0x51bebe){if(_0x51bebe[_0xf295('0xb5')]){var _0x1b2c67=_0x51bebe['@odata.type'][_0xf295('0xa4')](_0x51bebe[_0xf295('0xb5')][_0xf295('0xa5')]('.')+0x1);if(_0x1b2c67==='PicklistAttributeMetadata'){_0x1c9646[_0xf295('0xb6')](getSelectList(_0x45f5a6,_0x2b776b,_0x2d4aa8,_0x17af87['MetadataId'],_0x51bebe[_0xf295('0xaf')],_0x40e9c4));}}});return Promise[_0xf295('0xb7')](_0x1c9646);})[_0xf295('0x28')](function(_0x2f6332){_0x200cab=_0x2f6332[0x0];var _0x1ab7be=[];var _0x41bc00=[];_0x30e3e7['forEach'](function(_0x274d7a){if(!_[_0xf295('0xb8')](_0x274d7a['@odata.type'])){var _0x394860=_0x274d7a[_0xf295('0xb5')][_0xf295('0xa4')](_0x274d7a[_0xf295('0xb5')][_0xf295('0xa5')]('.')+0x1);if(_0x394860===_0xf295('0xb9')){_0x1ab7be[_0xf295('0xb6')](getBooleanList(_0x45f5a6,_0x2b776b,_0x41bc00,_0x17af87[_0xf295('0xaf')],_0x274d7a['MetadataId'],_0x40e9c4));}}});return Promise[_0xf295('0xb7')](_0x1ab7be);})['then'](function(_0x560031){_0x469ec0=_0x560031[0x0];var _0x2b2715=[];var _0x1b7da2=[];_0x30e3e7[_0xf295('0xba')](function(_0x134536){if(_0x134536[_0xf295('0xb5')]){var _0x2107da=_0x134536[_0xf295('0xb5')][_0xf295('0xa4')](_0x134536[_0xf295('0xb5')]['lastIndexOf']('.')+0x1);if(_0x2107da===_0xf295('0xbb')||_0x2107da===_0xf295('0xbc')||_0x2107da==='BigIntAttributeMetadata'||_0x2107da===_0xf295('0xbd')||_0x2107da===_0xf295('0xbe')||_0x2107da==='DateTimeAttributeMetadata'||_0x2107da===_0xf295('0xbf')||_0x2107da==='EntityNameAttributeMetadata'||_0x2107da===_0xf295('0xc0')||_0x2107da===_0xf295('0xc1')){_0x2b2715[_0xf295('0xb6')](getInputList(_0x45f5a6,_0x2b776b,_0x2107da,_0x1b7da2,_0x17af87[_0xf295('0xaf')],_0x134536['MetadataId'],_0x40e9c4));}}});return Promise[_0xf295('0xb7')](_0x2b2715);})[_0xf295('0x28')](function(_0x4a8ead){_0x25cb9a=_0x4a8ead[0x0];var _0x45c95d=_0x200cab[_0xf295('0x9e')](_0x469ec0)[_0xf295('0x9e')](_0x25cb9a);var _0x4ba5bf={'count':_0x45c95d[_0xf295('0x49')],'rows':_0x45c95d};return _0x4ba5bf;})['then'](respondWithResult(_0x37e14b,null))['catch'](function(_0x54367b){var _0x4537ba=_0x45347d[_0xf295('0x31')][_0xf295('0xc2')]?0x1f4:_0x54367b['statusCode']||0x1f4;logger[_0xf295('0x29')](_0x54367b['stack']);delete _0x54367b[_0xf295('0x2b')];if(_0x4537ba===0x191){_0x4537ba=0x190;}_0x37e14b[_0xf295('0x1b')](_0x4537ba)[_0xf295('0x2c')](_0x45347d[_0xf295('0x31')]['test']?{'message':_0xf295('0xc3'),'statusCode':_0x54367b['statusCode']}:_0x54367b);});};function getSelectList(_0x26857b,_0x46e97c,_0x5a93c6,_0xcb1492,_0x9f1720,_0x58de8f){var _0x58ff97={'method':_0xf295('0xab'),'uri':_0x26857b+_0xf295('0xc4')+_0xcb1492+_0xf295('0xc5')+_0x9f1720+_0xf295('0xc6')+_0xf295('0xc7'),'headers':{'Authorization':_0xf295('0xad')+_0x58de8f,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x58ff97)[_0xf295('0x28')](function(_0x5702f7){var _0x112019=[];var _0x24530d=_0x5702f7[_0xf295('0xc8')][_0xf295('0xc9')];_0x24530d['forEach'](function(_0x2cce52){_0x112019[_0xf295('0xb6')]({'name':_0x2cce52[_0xf295('0xca')][_0xf295('0xcb')]['Label'],'value':String(_0x2cce52[_0xf295('0xcc')])});});var _0x1f8309={'id':_0x46e97c+'_'+_0x5702f7[_0xf295('0xb4')],'name':_0x5702f7[_0xf295('0xcd')]['UserLocalizedLabel'][_0xf295('0xca')],'custom':![],'options':_0x112019};_0x5a93c6[_0xf295('0xb6')](_0x1f8309);return _0x5a93c6;});}function getBooleanList(_0x25612d,_0x1b2621,_0x5e732f,_0x492353,_0x7f6c8b,_0x14363d){var _0x13e582={'method':_0xf295('0xab'),'uri':_0x25612d+_0xf295('0xc4')+_0x492353+_0xf295('0xc5')+_0x7f6c8b+_0xf295('0xce'),'headers':{'Authorization':'Bearer\x20'+_0x14363d,'If-None-Match':null,'OData-Version':_0xf295('0xb1')},'json':!![]};return rp(_0x13e582)['then'](function(_0x3cbc36){var _0x9a5ded=[];_0x9a5ded[_0xf295('0xb6')]({'name':_0x3cbc36['OptionSet'][_0xf295('0xcf')][_0xf295('0xca')][_0xf295('0xcb')][_0xf295('0xca')],'value':'true'},{'name':_0x3cbc36[_0xf295('0xc8')][_0xf295('0xd0')][_0xf295('0xca')][_0xf295('0xcb')][_0xf295('0xca')],'value':_0xf295('0xd1')});var _0x2cc776={'id':_0x1b2621+'_'+_0x3cbc36[_0xf295('0xb4')],'name':_0x3cbc36[_0xf295('0xcd')][_0xf295('0xcb')][_0xf295('0xca')],'custom':![],'options':_0x9a5ded};_0x5e732f['push'](_0x2cc776);return _0x5e732f;});}function getInputList(_0xe6d6ff,_0x5589e6,_0x4f7c6f,_0x4acd0b,_0x292d1c,_0x3fe622,_0x7ba965){var _0x4e3890={'method':_0xf295('0xab'),'uri':_0xe6d6ff+_0xf295('0xc4')+_0x292d1c+_0xf295('0xc5')+_0x3fe622+_0xf295('0xd2')+_0x4f7c6f+_0xf295('0xd3'),'headers':{'Authorization':_0xf295('0xad')+_0x7ba965,'If-None-Match':null,'OData-Version':_0xf295('0xb1')},'json':!![]};return rp(_0x4e3890)[_0xf295('0x28')](function(_0x1b41df){var _0x793b93={'id':_0x5589e6+'_'+_0x1b41df[_0xf295('0xb4')],'name':_0x1b41df[_0xf295('0xcd')][_0xf295('0xcb')]?_0x1b41df['DisplayName'][_0xf295('0xcb')][_0xf295('0xca')]:_0x1b41df[_0xf295('0xb4')],'custom':![],'options':[]};_0x4acd0b['push'](_0x793b93);return _0x4acd0b;});}