Built motion from commit 9d0783e6.|2.6.13
[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 _0x8a2a=['filter','merge','VIRTUAL','options','include','catch','show','params','keys','length','find','create','getConfigurations','Dynamics365Configuration','order','addConfiguration','body','findOne','AccountId','Subjects','channel','Descriptions','Dynamics365Field','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','incident','Incident','PhoneCall','title','description','customerid','ownerid','caseorigincode','subject','regardingobjectid','phonecall_activity_parties','accountidname','actualserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','emailaddress','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','modifiedon','modifiedonbehalfbyyominame','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slainvokedidname','socialprofileidname','statecode','subjectidname','timezoneruleversionnumber','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','password','clientId','clientSecret','CloudProvider','data5','data7','modernAuthentication','access_token','remoteUri','https://login.microsoftonline.com/','tenantId','/oauth2/token','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','4.0','MetadataId','GET',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','remove','LogicalName','forEach','@odata.type','push','all','isNil','BooleanAttributeMetadata','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode','stack','Wrong\x20credentials','EntityDefinitions(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','Options','UserLocalizedLabel','Value','DisplayName','Label',')/Attributes(',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','FalseOption','false','?$select=DisplayName,LogicalName','util','../../components/parsers/qs','../../config/logger','api','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','count','limit','set','Content-Range','update','then','destroy','end','sendStatus','error','send','index','map','Dynamics365Account','rawAttributes','fieldName','type','model','name','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick'];(function(_0x3c6894,_0x813a7f){var _0x4c8ec1=function(_0x967ee6){while(--_0x967ee6){_0x3c6894['push'](_0x3c6894['shift']());}};_0x4c8ec1(++_0x813a7f);}(_0x8a2a,0x8d));var _0xa8a2=function(_0x22ffbf,_0x16f31e){_0x22ffbf=_0x22ffbf-0x0;var _0x360c17=_0x8a2a[_0x22ffbf];return _0x360c17;};'use strict';var rp=require('request-promise');var util=require(_0xa8a2('0x0'));var _=require('lodash');var qs=require(_0xa8a2('0x1'));var logger=require(_0xa8a2('0x2'))(_0xa8a2('0x3'));var db=require(_0xa8a2('0x4'))['db'];var integrations=require(_0xa8a2('0x5'));function respondWithResult(_0xc62edd,_0x4e0c4a){_0x4e0c4a=_0x4e0c4a||0xc8;return function(_0x2ddde7){if(_0x2ddde7){return _0xc62edd[_0xa8a2('0x6')](_0x4e0c4a)[_0xa8a2('0x7')](_0x2ddde7);}};}function respondWithFilteredResult(_0x313bb0,_0x5dcd18){return function(_0x10ef08){if(_0x10ef08){var _0x1230d9=typeof _0x5dcd18[_0xa8a2('0x8')]==='undefined'&&typeof _0x5dcd18['limit']===_0xa8a2('0x9');var _0x27f31f=_0x10ef08[_0xa8a2('0xa')];var _0x4984ec=_0x1230d9?0x0:_0x5dcd18[_0xa8a2('0x8')];var _0x37fd88=_0x1230d9?_0x10ef08[_0xa8a2('0xa')]:_0x5dcd18[_0xa8a2('0x8')]+_0x5dcd18[_0xa8a2('0xb')];var _0x1f3004;if(_0x37fd88>=_0x27f31f){_0x37fd88=_0x27f31f;_0x1f3004=0xc8;}else{_0x1f3004=0xce;}_0x313bb0[_0xa8a2('0x6')](_0x1f3004);return _0x313bb0[_0xa8a2('0xc')](_0xa8a2('0xd'),_0x4984ec+'-'+_0x37fd88+'/'+_0x27f31f)['json'](_0x10ef08);}return null;};}function saveUpdates(_0x477ca5){return function(_0x29990f){if(_0x29990f){return _0x29990f[_0xa8a2('0xe')](_0x477ca5)[_0xa8a2('0xf')](function(_0x4bbb7d){return _0x4bbb7d;});}return null;};}function removeEntity(_0x5e0609){return function(_0x454193){if(_0x454193){return _0x454193[_0xa8a2('0x10')]()[_0xa8a2('0xf')](function(){_0x5e0609[_0xa8a2('0x6')](0xcc)[_0xa8a2('0x11')]();});}};}function handleEntityNotFound(_0x1eb72d){return function(_0x514d8a){if(!_0x514d8a){_0x1eb72d[_0xa8a2('0x12')](0x194);}return _0x514d8a;};}function handleError(_0x5bf9f3,_0x3b92ed){_0x3b92ed=_0x3b92ed||0x1f4;return function(_0x3e56e3){logger[_0xa8a2('0x13')](_0x3e56e3['stack']);if(_0x3e56e3['name']){delete _0x3e56e3['name'];}_0x5bf9f3[_0xa8a2('0x6')](_0x3b92ed)[_0xa8a2('0x14')](_0x3e56e3);};}exports[_0xa8a2('0x15')]=function(_0x4df78f,_0x723a88){var _0x571e48={},_0x5a1122={},_0x755291={'count':0x0,'rows':[]};var _0xbffa67=_[_0xa8a2('0x16')](db[_0xa8a2('0x17')][_0xa8a2('0x18')],function(_0x417d43){return{'name':_0x417d43[_0xa8a2('0x19')],'type':_0x417d43[_0xa8a2('0x1a')]['key']};});_0x5a1122[_0xa8a2('0x1b')]=_[_0xa8a2('0x16')](_0xbffa67,_0xa8a2('0x1c'));_0x5a1122[_0xa8a2('0x1d')]=_['keys'](_0x4df78f[_0xa8a2('0x1d')]);_0x5a1122[_0xa8a2('0x1e')]=_[_0xa8a2('0x1f')](_0x5a1122[_0xa8a2('0x1b')],_0x5a1122[_0xa8a2('0x1d')]);_0x571e48[_0xa8a2('0x20')]=_[_0xa8a2('0x1f')](_0x5a1122[_0xa8a2('0x1b')],qs[_0xa8a2('0x21')](_0x4df78f['query']['fields']));_0x571e48[_0xa8a2('0x20')]=_0x571e48['attributes']['length']?_0x571e48[_0xa8a2('0x20')]:_0x5a1122[_0xa8a2('0x1b')];if(!_0x4df78f['query'][_0xa8a2('0x22')](_0xa8a2('0x23'))){_0x571e48[_0xa8a2('0xb')]=qs[_0xa8a2('0xb')](_0x4df78f[_0xa8a2('0x1d')][_0xa8a2('0xb')]);_0x571e48[_0xa8a2('0x8')]=qs[_0xa8a2('0x8')](_0x4df78f[_0xa8a2('0x1d')][_0xa8a2('0x8')]);}_0x571e48['order']=qs[_0xa8a2('0x24')](_0x4df78f[_0xa8a2('0x1d')][_0xa8a2('0x24')]);_0x571e48[_0xa8a2('0x25')]=qs[_0xa8a2('0x1e')](_[_0xa8a2('0x26')](_0x4df78f[_0xa8a2('0x1d')],_0x5a1122[_0xa8a2('0x1e')]),_0xbffa67);if(_0x4df78f[_0xa8a2('0x1d')][_0xa8a2('0x27')]){_0x571e48[_0xa8a2('0x25')]=_[_0xa8a2('0x28')](_0x571e48[_0xa8a2('0x25')],{'$or':_[_0xa8a2('0x16')](_0xbffa67,function(_0x15443c){if(_0x15443c[_0xa8a2('0x1a')]!==_0xa8a2('0x29')){var _0x57a0f5={};_0x57a0f5[_0x15443c[_0xa8a2('0x1c')]]={'$like':'%'+_0x4df78f['query'][_0xa8a2('0x27')]+'%'};return _0x57a0f5;}})});}_0x571e48=_[_0xa8a2('0x28')]({},_0x571e48,_0x4df78f[_0xa8a2('0x2a')]);var _0x1c25fc={'where':_0x571e48[_0xa8a2('0x25')]};return db['Dynamics365Account']['count'](_0x1c25fc)['then'](function(_0x417113){_0x755291['count']=_0x417113;if(_0x4df78f['query']['includeAll']){_0x571e48[_0xa8a2('0x2b')]=[{'all':!![]}];}return db[_0xa8a2('0x17')]['findAll'](_0x571e48);})[_0xa8a2('0xf')](function(_0x558715){_0x755291['rows']=_0x558715;return _0x755291;})['then'](respondWithFilteredResult(_0x723a88,_0x571e48))[_0xa8a2('0x2c')](handleError(_0x723a88,null));};exports[_0xa8a2('0x2d')]=function(_0x17e4b2,_0x279049){var _0x5cdb61={'raw':![],'where':{'id':_0x17e4b2[_0xa8a2('0x2e')]['id']}},_0x42003f={};_0x42003f[_0xa8a2('0x1b')]=_[_0xa8a2('0x2f')](db[_0xa8a2('0x17')][_0xa8a2('0x18')]);_0x42003f['query']=_[_0xa8a2('0x2f')](_0x17e4b2[_0xa8a2('0x1d')]);_0x42003f[_0xa8a2('0x1e')]=_['intersection'](_0x42003f['model'],_0x42003f[_0xa8a2('0x1d')]);_0x5cdb61['attributes']=_[_0xa8a2('0x1f')](_0x42003f['model'],qs['fields'](_0x17e4b2['query'][_0xa8a2('0x21')]));_0x5cdb61[_0xa8a2('0x20')]=_0x5cdb61[_0xa8a2('0x20')][_0xa8a2('0x30')]?_0x5cdb61['attributes']:_0x42003f[_0xa8a2('0x1b')];if(_0x17e4b2[_0xa8a2('0x1d')]['includeAll']){_0x5cdb61[_0xa8a2('0x2b')]=[{'all':!![]}];}_0x5cdb61=_[_0xa8a2('0x28')]({},_0x5cdb61,_0x17e4b2[_0xa8a2('0x2a')]);return db['Dynamics365Account'][_0xa8a2('0x31')](_0x5cdb61)[_0xa8a2('0xf')](handleEntityNotFound(_0x279049,null))[_0xa8a2('0xf')](respondWithResult(_0x279049,null))[_0xa8a2('0x2c')](handleError(_0x279049,null));};exports[_0xa8a2('0x32')]=function(_0x3483c2,_0x567490){return db[_0xa8a2('0x17')][_0xa8a2('0x32')](_0x3483c2['body'],{})[_0xa8a2('0xf')](respondWithResult(_0x567490,0xc9))[_0xa8a2('0x2c')](handleError(_0x567490,null));};exports[_0xa8a2('0xe')]=function(_0x5bc29d,_0x4068a8){if(_0x5bc29d['body']['id']){delete _0x5bc29d['body']['id'];}return db[_0xa8a2('0x17')]['find']({'where':{'id':_0x5bc29d['params']['id']}})[_0xa8a2('0xf')](handleEntityNotFound(_0x4068a8,null))[_0xa8a2('0xf')](saveUpdates(_0x5bc29d['body'],null))[_0xa8a2('0xf')](respondWithResult(_0x4068a8,null))['catch'](handleError(_0x4068a8,null));};exports[_0xa8a2('0x10')]=function(_0x2c78e2,_0x22e229){return db['Dynamics365Account']['find']({'where':{'id':_0x2c78e2[_0xa8a2('0x2e')]['id']}})[_0xa8a2('0xf')](handleEntityNotFound(_0x22e229,null))[_0xa8a2('0xf')](removeEntity(_0x22e229,null))[_0xa8a2('0x2c')](handleError(_0x22e229,null));};exports[_0xa8a2('0x33')]=function(_0x554cd8,_0x5a3212){var _0x5c25f3={};var _0x32d896={};var _0x424071;var _0x2f2b36;return db[_0xa8a2('0x17')]['findOne']({'where':{'id':_0x554cd8['params']['id']}})[_0xa8a2('0xf')](handleEntityNotFound(_0x5a3212,null))[_0xa8a2('0xf')](function(_0x4d0519){if(_0x4d0519){_0x424071=_0x4d0519;_0x32d896[_0xa8a2('0x1b')]=_['keys'](db[_0xa8a2('0x34')][_0xa8a2('0x18')]);_0x32d896[_0xa8a2('0x1d')]=_[_0xa8a2('0x2f')](_0x554cd8['query']);_0x32d896[_0xa8a2('0x1e')]=_[_0xa8a2('0x1f')](_0x32d896['model'],_0x32d896[_0xa8a2('0x1d')]);_0x5c25f3[_0xa8a2('0x20')]=_['intersection'](_0x32d896[_0xa8a2('0x1b')],qs[_0xa8a2('0x21')](_0x554cd8[_0xa8a2('0x1d')][_0xa8a2('0x21')]));_0x5c25f3[_0xa8a2('0x20')]=_0x5c25f3[_0xa8a2('0x20')]['length']?_0x5c25f3[_0xa8a2('0x20')]:_0x32d896[_0xa8a2('0x1b')];_0x5c25f3[_0xa8a2('0x35')]=qs[_0xa8a2('0x24')](_0x554cd8[_0xa8a2('0x1d')]['sort']);_0x5c25f3[_0xa8a2('0x25')]=qs[_0xa8a2('0x1e')](_[_0xa8a2('0x26')](_0x554cd8[_0xa8a2('0x1d')],_0x32d896[_0xa8a2('0x1e')]));if(_0x554cd8[_0xa8a2('0x1d')][_0xa8a2('0x27')]){_0x5c25f3[_0xa8a2('0x25')]=_[_0xa8a2('0x28')](_0x5c25f3['where'],{'$or':_['map'](_0x5c25f3['attributes'],function(_0xbb5583){var _0x351916={};_0x351916[_0xbb5583]={'$like':'%'+_0x554cd8[_0xa8a2('0x1d')][_0xa8a2('0x27')]+'%'};return _0x351916;})});}_0x5c25f3=_[_0xa8a2('0x28')]({},_0x5c25f3,_0x554cd8[_0xa8a2('0x2a')]);return _0x424071[_0xa8a2('0x33')](_0x5c25f3);}})[_0xa8a2('0xf')](function(_0x36bef4){if(_0x36bef4){_0x2f2b36=_0x36bef4[_0xa8a2('0x30')];if(!_0x554cd8['query'][_0xa8a2('0x22')](_0xa8a2('0x23'))){_0x5c25f3[_0xa8a2('0xb')]=qs[_0xa8a2('0xb')](_0x554cd8[_0xa8a2('0x1d')][_0xa8a2('0xb')]);_0x5c25f3[_0xa8a2('0x8')]=qs[_0xa8a2('0x8')](_0x554cd8[_0xa8a2('0x1d')][_0xa8a2('0x8')]);}return _0x424071[_0xa8a2('0x33')](_0x5c25f3);}})[_0xa8a2('0xf')](function(_0x3fc5bd){if(_0x3fc5bd){return _0x3fc5bd?{'count':_0x2f2b36,'rows':_0x3fc5bd}:null;}})['then'](respondWithResult(_0x5a3212,null))[_0xa8a2('0x2c')](handleError(_0x5a3212,null));};exports[_0xa8a2('0x36')]=function(_0x3cd16c,_0x12d905){if(_0x3cd16c['body']['id']){delete _0x3cd16c[_0xa8a2('0x37')]['id'];}return db['Dynamics365Account'][_0xa8a2('0x38')]({'where':{'id':_0x3cd16c[_0xa8a2('0x2e')]['id']}})[_0xa8a2('0xf')](handleEntityNotFound(_0x12d905,null))[_0xa8a2('0xf')](function(_0x28d043){if(_0x28d043){_0x3cd16c[_0xa8a2('0x37')][_0xa8a2('0x39')]=_0x28d043['id'];_0x3cd16c[_0xa8a2('0x37')][_0xa8a2('0x3a')]=integrations['getSubjects'](_0x3cd16c[_0xa8a2('0x37')][_0xa8a2('0x3b')],_0x3cd16c[_0xa8a2('0x37')]['type']);_0x3cd16c['body'][_0xa8a2('0x3c')]=integrations['getDescriptions'](_0x3cd16c[_0xa8a2('0x37')]['channel'],_0x3cd16c[_0xa8a2('0x37')][_0xa8a2('0x1a')]);return db[_0xa8a2('0x34')]['create'](_0x3cd16c[_0xa8a2('0x37')],{'include':[{'model':db[_0xa8a2('0x3d')],'as':_0xa8a2('0x3a')},{'model':db[_0xa8a2('0x3d')],'as':_0xa8a2('0x3c')}]});}return null;})['then'](respondWithResult(_0x12d905,null))[_0xa8a2('0x2c')](handleError(_0x12d905,null));};function sanitizeRemoteUri(_0x3d080b){var _0xf2284f=_0x3d080b['slice'](-0x1);if(_0xf2284f==='/')return _0x3d080b[_0xa8a2('0x3e')](0x0,_0x3d080b[_0xa8a2('0x3f')](_0xf2284f));return _0x3d080b;}function getWebApiUrl(_0x2b0b0c){return util[_0xa8a2('0x40')](_0xa8a2('0x41'),_0x2b0b0c);}exports[_0xa8a2('0x42')]=function(_0x4afa0a,_0xb3633){var _0x1b1829=_0x4afa0a[_0xa8a2('0x1d')]['ticketType'];var _0xd7b15=_0x1b1829===_0xa8a2('0x43')?_0xa8a2('0x44'):_0xa8a2('0x45');var _0x3ced6f='';var _0xcb4f1b='';var _0x366f2d='';var _0x1aa96c='';var _0x211edf='';var _0x39f3e1='';var _0x3bd68a='';var _0x571041='';var _0x1d3604=[_0xa8a2('0x46'),_0xa8a2('0x47'),_0xa8a2('0x48'),_0xa8a2('0x49'),_0xa8a2('0x4a'),_0xa8a2('0x4b'),'phonenumber',_0xa8a2('0x4c'),'directioncode',_0xa8a2('0x4d')];var _0x90cf50=[_0xa8a2('0x4e'),'accountidyominame',_0xa8a2('0x4f'),'billedserviceunits',_0xa8a2('0x50'),_0xa8a2('0x51'),_0xa8a2('0x52'),_0xa8a2('0x53'),_0xa8a2('0x54'),_0xa8a2('0x55'),_0xa8a2('0x56'),_0xa8a2('0x57'),_0xa8a2('0x58'),_0xa8a2('0x59'),_0xa8a2('0x5a'),_0xa8a2('0x5b'),_0xa8a2('0x5c'),_0xa8a2('0x5d'),_0xa8a2('0x5e'),'entitlementidname',_0xa8a2('0x5f'),_0xa8a2('0x60'),_0xa8a2('0x61'),_0xa8a2('0x62'),'firstresponsebykpiidname',_0xa8a2('0x63'),_0xa8a2('0x64'),_0xa8a2('0x65'),_0xa8a2('0x66'),_0xa8a2('0x67'),'masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame',_0xa8a2('0x68'),'modifiedonbehalfbyname',_0xa8a2('0x69'),'msdyn_incidenttypename','msdyn_iotalertname',_0xa8a2('0x6a'),_0xa8a2('0x6b'),_0xa8a2('0x6c'),_0xa8a2('0x6d'),'owneridtype','owneridyominame',_0xa8a2('0x6e'),_0xa8a2('0x6f'),_0xa8a2('0x70'),_0xa8a2('0x71'),'productidname','productserialnumber','resolveby',_0xa8a2('0x72'),_0xa8a2('0x73'),_0xa8a2('0x74'),_0xa8a2('0x75'),_0xa8a2('0x76'),_0xa8a2('0x77'),'slaname',_0xa8a2('0x78'),_0xa8a2('0x79'),'statuscode',_0xa8a2('0x7a'),'ticketnumber',_0xa8a2('0x7b'),'transactioncurrencyidname',_0xa8a2('0x7c'),_0xa8a2('0x7d'),_0xa8a2('0x7e')];var _0x4f8777=_0x1d3604[_0xa8a2('0x7f')](_0x90cf50);return db[_0xa8a2('0x17')][_0xa8a2('0x38')]({'where':{'id':_0x4afa0a[_0xa8a2('0x2e')]['id']},'attributes':['id',_0xa8a2('0x80'),_0xa8a2('0x81'),'remoteUri','tenantId',_0xa8a2('0x82'),_0xa8a2('0x83'),'modernAuthentication'],'include':[{'model':db[_0xa8a2('0x84')],'as':'CloudProvider','attributes':['id',_0xa8a2('0x85'),_0xa8a2('0x86')]}]})['then'](handleEntityNotFound(_0xb3633,null))[_0xa8a2('0xf')](function(_0x1cd711){if(_0x1cd711){if(_0x1cd711[_0xa8a2('0x87')]){_0x1cd711[_0xa8a2('0x88')]=_0x1cd711[_0xa8a2('0x84')]['data5'];_0x571041=sanitizeRemoteUri(_0x1cd711[_0xa8a2('0x84')][_0xa8a2('0x86')]);_0x3bd68a=getWebApiUrl(_0x571041);return _0x1cd711;}_0x571041=sanitizeRemoteUri(_0x1cd711[_0xa8a2('0x89')]);_0x3bd68a=getWebApiUrl(_0x571041);var _0x28376f={'method':'POST','uri':_0xa8a2('0x8a')+_0x1cd711[_0xa8a2('0x8b')]+_0xa8a2('0x8c'),'form':{'client_id':_0x1cd711[_0xa8a2('0x82')],'resource':_0x571041,'username':_0x1cd711[_0xa8a2('0x80')],'password':_0x1cd711['password'],'grant_type':_0xa8a2('0x81'),'client_secret':_0x1cd711['clientSecret']},'json':!![]};return rp(_0x28376f);}})[_0xa8a2('0xf')](function(_0x2aec94){_0x39f3e1=_0x2aec94[_0xa8a2('0x88')];var _0x506acb={'method':'GET','uri':encodeURI(_0x3bd68a+_0xa8a2('0x8d')+_0xd7b15+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x39f3e1,'If-None-Match':null,'OData-Version':_0xa8a2('0x8e')},'json':!![]};return rp(_0x506acb);})[_0xa8a2('0xf')](function(_0xc3703f){var _0x4e7798=_0xc3703f['value'][0x0];var _0x1c70e8=_0x4e7798[_0xa8a2('0x8f')];var _0x402aee={'method':_0xa8a2('0x90'),'uri':_0x3bd68a+'EntityDefinitions('+_0x1c70e8+_0xa8a2('0x91'),'headers':{'Authorization':'Bearer\x20'+_0x39f3e1,'If-None-Match':null,'OData-Version':_0xa8a2('0x8e')},'json':!![]};return rp(_0x402aee);})['then'](function(_0x744d5e){_0x3ced6f=_0x744d5e;_0xcb4f1b=_0x3ced6f[_0xa8a2('0x92')];_0xcb4f1b=_[_0xa8a2('0x93')](_0xcb4f1b,function(_0x3c2fe9){return!_0x4f8777['includes'](_0x3c2fe9[_0xa8a2('0x94')]);});var _0x4c226f=[];var _0x3bb005=[];_0xcb4f1b[_0xa8a2('0x95')](function(_0x114a52){if(_0x114a52[_0xa8a2('0x96')]){var _0x3598c2=_0x114a52[_0xa8a2('0x96')][_0xa8a2('0x3e')](_0x114a52[_0xa8a2('0x96')]['lastIndexOf']('.')+0x1);if(_0x3598c2==='PicklistAttributeMetadata'){_0x4c226f[_0xa8a2('0x97')](getSelectList(_0x3bd68a,_0x1b1829,_0x3bb005,_0x3ced6f['MetadataId'],_0x114a52[_0xa8a2('0x8f')],_0x39f3e1));}}});return Promise[_0xa8a2('0x98')](_0x4c226f);})['then'](function(_0x1877e5){_0x366f2d=_0x1877e5[0x0];var _0x19ad5a=[];var _0x59e4cd=[];_0xcb4f1b[_0xa8a2('0x95')](function(_0xe85531){if(!_[_0xa8a2('0x99')](_0xe85531['@odata.type'])){var _0x2f19a1=_0xe85531[_0xa8a2('0x96')][_0xa8a2('0x3e')](_0xe85531[_0xa8a2('0x96')][_0xa8a2('0x3f')]('.')+0x1);if(_0x2f19a1===_0xa8a2('0x9a')){_0x19ad5a[_0xa8a2('0x97')](getBooleanList(_0x3bd68a,_0x1b1829,_0x59e4cd,_0x3ced6f[_0xa8a2('0x8f')],_0xe85531['MetadataId'],_0x39f3e1));}}});return Promise[_0xa8a2('0x98')](_0x19ad5a);})[_0xa8a2('0xf')](function(_0x33627e){_0x1aa96c=_0x33627e[0x0];var _0x391fe7=[];var _0x4416bb=[];_0xcb4f1b[_0xa8a2('0x95')](function(_0x314a98){if(_0x314a98[_0xa8a2('0x96')]){var _0x57ee32=_0x314a98['@odata.type'][_0xa8a2('0x3e')](_0x314a98[_0xa8a2('0x96')][_0xa8a2('0x3f')]('.')+0x1);if(_0x57ee32===_0xa8a2('0x9b')||_0x57ee32==='DoubleAttributeMetadata'||_0x57ee32===_0xa8a2('0x9c')||_0x57ee32===_0xa8a2('0x9d')||_0x57ee32===_0xa8a2('0x9e')||_0x57ee32===_0xa8a2('0x9f')||_0x57ee32===_0xa8a2('0xa0')||_0x57ee32===_0xa8a2('0xa1')||_0x57ee32===_0xa8a2('0xa2')||_0x57ee32===_0xa8a2('0xa3')){_0x391fe7[_0xa8a2('0x97')](getInputList(_0x3bd68a,_0x1b1829,_0x57ee32,_0x4416bb,_0x3ced6f['MetadataId'],_0x314a98[_0xa8a2('0x8f')],_0x39f3e1));}}});return Promise[_0xa8a2('0x98')](_0x391fe7);})[_0xa8a2('0xf')](function(_0x52fb24){_0x211edf=_0x52fb24[0x0];var _0x20016f=_0x366f2d['concat'](_0x1aa96c)[_0xa8a2('0x7f')](_0x211edf);var _0x2ac632={'count':_0x20016f[_0xa8a2('0x30')],'rows':_0x20016f};return _0x2ac632;})[_0xa8a2('0xf')](respondWithResult(_0xb3633,null))[_0xa8a2('0x2c')](function(_0x575211){var _0x2831dc=_0x4afa0a[_0xa8a2('0x1d')][_0xa8a2('0xa4')]?0x1f4:_0x575211[_0xa8a2('0xa5')]||0x1f4;logger[_0xa8a2('0x13')](_0x575211[_0xa8a2('0xa6')]);delete _0x575211[_0xa8a2('0x1c')];if(_0x2831dc===0x191){_0x2831dc=0x190;}_0xb3633[_0xa8a2('0x6')](_0x2831dc)['send'](_0x4afa0a[_0xa8a2('0x1d')][_0xa8a2('0xa4')]?{'message':_0xa8a2('0xa7'),'statusCode':_0x575211[_0xa8a2('0xa5')]}:_0x575211);});};function getSelectList(_0x59a165,_0x43c1e,_0x1bcaa1,_0x43423e,_0x2b9bf4,_0x57fc9e){var _0x571a8b={'method':_0xa8a2('0x90'),'uri':_0x59a165+_0xa8a2('0xa8')+_0x43423e+')/Attributes('+_0x2b9bf4+_0xa8a2('0xa9')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':'Bearer\x20'+_0x57fc9e,'If-None-Match':null,'OData-Version':_0xa8a2('0x8e')},'json':!![]};return rp(_0x571a8b)[_0xa8a2('0xf')](function(_0x1623c1){var _0x19909=[];var _0x2df28a=_0x1623c1['OptionSet'][_0xa8a2('0xaa')];_0x2df28a[_0xa8a2('0x95')](function(_0x4741d0){_0x19909[_0xa8a2('0x97')]({'name':_0x4741d0['Label'][_0xa8a2('0xab')]['Label'],'value':String(_0x4741d0[_0xa8a2('0xac')])});});var _0xd42696={'id':_0x43c1e+'_'+_0x1623c1[_0xa8a2('0x94')],'name':_0x1623c1[_0xa8a2('0xad')][_0xa8a2('0xab')][_0xa8a2('0xae')],'custom':![],'options':_0x19909};_0x1bcaa1['push'](_0xd42696);return _0x1bcaa1;});}function getBooleanList(_0x4dfc1a,_0x2b1415,_0x457e86,_0x3ba0c7,_0x5f07ae,_0x52b5e3){var _0x95a354={'method':_0xa8a2('0x90'),'uri':_0x4dfc1a+_0xa8a2('0xa8')+_0x3ba0c7+_0xa8a2('0xaf')+_0x5f07ae+_0xa8a2('0xb0'),'headers':{'Authorization':'Bearer\x20'+_0x52b5e3,'If-None-Match':null,'OData-Version':_0xa8a2('0x8e')},'json':!![]};return rp(_0x95a354)['then'](function(_0x33229e){var _0x5c1073=[];_0x5c1073[_0xa8a2('0x97')]({'name':_0x33229e['OptionSet']['TrueOption'][_0xa8a2('0xae')]['UserLocalizedLabel'][_0xa8a2('0xae')],'value':'true'},{'name':_0x33229e['OptionSet'][_0xa8a2('0xb1')]['Label']['UserLocalizedLabel'][_0xa8a2('0xae')],'value':_0xa8a2('0xb2')});var _0x2441c8={'id':_0x2b1415+'_'+_0x33229e['LogicalName'],'name':_0x33229e['DisplayName'][_0xa8a2('0xab')][_0xa8a2('0xae')],'custom':![],'options':_0x5c1073};_0x457e86[_0xa8a2('0x97')](_0x2441c8);return _0x457e86;});}function getInputList(_0x324a1e,_0x312220,_0x5a3389,_0x1f0a4,_0x1dd68b,_0x2c9247,_0x513967){var _0x37ced3={'method':_0xa8a2('0x90'),'uri':_0x324a1e+_0xa8a2('0xa8')+_0x1dd68b+_0xa8a2('0xaf')+_0x2c9247+')/Microsoft.Dynamics.CRM.'+_0x5a3389+_0xa8a2('0xb3'),'headers':{'Authorization':'Bearer\x20'+_0x513967,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x37ced3)[_0xa8a2('0xf')](function(_0x397764){var _0x220c54={'id':_0x312220+'_'+_0x397764[_0xa8a2('0x94')],'name':_0x397764[_0xa8a2('0xad')][_0xa8a2('0xab')]?_0x397764[_0xa8a2('0xad')][_0xa8a2('0xab')][_0xa8a2('0xae')]:_0x397764[_0xa8a2('0x94')],'custom':![],'options':[]};_0x1f0a4[_0xa8a2('0x97')](_0x220c54);return _0x1f0a4;});}