Built motion from commit 994c64e1.|2.6.1
[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 _0x1d0d=['Label','UserLocalizedLabel','Value','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','OptionSet','TrueOption','true','FalseOption','false','?$select=DisplayName,LogicalName','util','lodash','../../components/integrations/configuration','json','offset','undefined','count','limit','status','set','update','then','destroy','end','sendStatus','error','stack','name','send','map','Dynamics365Account','fieldName','key','model','keys','filters','intersection','query','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','show','params','rawAttributes','length','find','catch','create','body','getConfigurations','addConfiguration','findOne','AccountId','getSubjects','channel','getDescriptions','Dynamics365Configuration','Subjects','Dynamics365Field','slice','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','incident','Incident','PhoneCall','title','description','customerid','ownerid','caseorigincode','subject','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedonbehalfbyname','msdyn_iotalertname','owneridname','owneridtype','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','productserialnumber','resolveby','resolvebykpiidname','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slaname','socialprofileidname','statecode','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','traversedpath','utcconversiontimezonecode','username','password','remoteUri','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data7','access_token','data5','POST','https://login.microsoftonline.com/','/oauth2/token','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','MetadataId','EntityDefinitions(','Attributes','remove','includes','LogicalName','@odata.type','substring','push','forEach','isNil','BooleanAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','EntityNameAttributeMetadata','all','concat','test','statusCode','Wrong\x20credentials','GET',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','Options'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x1d0d,0x183));var _0xd1d0=function(_0x48d045,_0x17b86b){_0x48d045=_0x48d045-0x0;var _0x626c5e=_0x1d0d[_0x48d045];return _0x626c5e;};'use strict';var rp=require('request-promise');var util=require(_0xd1d0('0x0'));var _=require(_0xd1d0('0x1'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var db=require('../../mysqldb')['db'];var integrations=require(_0xd1d0('0x2'));function respondWithResult(_0x3e0571,_0x2d29bd){_0x2d29bd=_0x2d29bd||0xc8;return function(_0x3bcd2f){if(_0x3bcd2f){return _0x3e0571['status'](_0x2d29bd)[_0xd1d0('0x3')](_0x3bcd2f);}};}function respondWithFilteredResult(_0x164819,_0x18f081){return function(_0xa70f9e){if(_0xa70f9e){var _0x439a3c=typeof _0x18f081[_0xd1d0('0x4')]===_0xd1d0('0x5')&&typeof _0x18f081['limit']==='undefined';var _0x4988a1=_0xa70f9e[_0xd1d0('0x6')];var _0x5e8c0a=_0x439a3c?0x0:_0x18f081[_0xd1d0('0x4')];var _0x38eb1b=_0x439a3c?_0xa70f9e[_0xd1d0('0x6')]:_0x18f081[_0xd1d0('0x4')]+_0x18f081[_0xd1d0('0x7')];var _0x3609ea;if(_0x38eb1b>=_0x4988a1){_0x38eb1b=_0x4988a1;_0x3609ea=0xc8;}else{_0x3609ea=0xce;}_0x164819[_0xd1d0('0x8')](_0x3609ea);return _0x164819[_0xd1d0('0x9')]('Content-Range',_0x5e8c0a+'-'+_0x38eb1b+'/'+_0x4988a1)[_0xd1d0('0x3')](_0xa70f9e);}return null;};}function saveUpdates(_0x211b21){return function(_0x34fdcc){if(_0x34fdcc){return _0x34fdcc[_0xd1d0('0xa')](_0x211b21)[_0xd1d0('0xb')](function(_0x20a04c){return _0x20a04c;});}return null;};}function removeEntity(_0x43c95e){return function(_0x117500){if(_0x117500){return _0x117500[_0xd1d0('0xc')]()['then'](function(){_0x43c95e[_0xd1d0('0x8')](0xcc)[_0xd1d0('0xd')]();});}};}function handleEntityNotFound(_0x2f6696){return function(_0x5b66e7){if(!_0x5b66e7){_0x2f6696[_0xd1d0('0xe')](0x194);}return _0x5b66e7;};}function handleError(_0x489d03,_0x46bb5d){_0x46bb5d=_0x46bb5d||0x1f4;return function(_0x4becb1){logger[_0xd1d0('0xf')](_0x4becb1[_0xd1d0('0x10')]);if(_0x4becb1[_0xd1d0('0x11')]){delete _0x4becb1[_0xd1d0('0x11')];}_0x489d03[_0xd1d0('0x8')](_0x46bb5d)[_0xd1d0('0x12')](_0x4becb1);};}exports['index']=function(_0x2ecf5e,_0x2378c0){var _0x11c218={},_0x403734={},_0x2abe5e={'count':0x0,'rows':[]};var _0x24996e=_[_0xd1d0('0x13')](db[_0xd1d0('0x14')]['rawAttributes'],function(_0x5300ef){return{'name':_0x5300ef[_0xd1d0('0x15')],'type':_0x5300ef['type'][_0xd1d0('0x16')]};});_0x403734[_0xd1d0('0x17')]=_['map'](_0x24996e,_0xd1d0('0x11'));_0x403734['query']=_[_0xd1d0('0x18')](_0x2ecf5e['query']);_0x403734[_0xd1d0('0x19')]=_[_0xd1d0('0x1a')](_0x403734[_0xd1d0('0x17')],_0x403734[_0xd1d0('0x1b')]);_0x11c218[_0xd1d0('0x1c')]=_['intersection'](_0x403734[_0xd1d0('0x17')],qs['fields'](_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x1d')]));_0x11c218[_0xd1d0('0x1c')]=_0x11c218[_0xd1d0('0x1c')]['length']?_0x11c218[_0xd1d0('0x1c')]:_0x403734['model'];if(!_0x2ecf5e['query'][_0xd1d0('0x1e')]('nolimit')){_0x11c218['limit']=qs[_0xd1d0('0x7')](_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x7')]);_0x11c218[_0xd1d0('0x4')]=qs[_0xd1d0('0x4')](_0x2ecf5e[_0xd1d0('0x1b')]['offset']);}_0x11c218[_0xd1d0('0x1f')]=qs[_0xd1d0('0x20')](_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x20')]);_0x11c218[_0xd1d0('0x21')]=qs[_0xd1d0('0x19')](_[_0xd1d0('0x22')](_0x2ecf5e[_0xd1d0('0x1b')],_0x403734[_0xd1d0('0x19')]),_0x24996e);if(_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x23')]){_0x11c218[_0xd1d0('0x21')]=_[_0xd1d0('0x24')](_0x11c218[_0xd1d0('0x21')],{'$or':_['map'](_0x24996e,function(_0x3d2bce){if(_0x3d2bce[_0xd1d0('0x25')]!==_0xd1d0('0x26')){var _0x352760={};_0x352760[_0x3d2bce[_0xd1d0('0x11')]]={'$like':'%'+_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x23')]+'%'};return _0x352760;}})});}_0x11c218=_[_0xd1d0('0x24')]({},_0x11c218,_0x2ecf5e[_0xd1d0('0x27')]);var _0x56605b={'where':_0x11c218['where']};return db[_0xd1d0('0x14')][_0xd1d0('0x6')](_0x56605b)[_0xd1d0('0xb')](function(_0x305467){_0x2abe5e[_0xd1d0('0x6')]=_0x305467;if(_0x2ecf5e[_0xd1d0('0x1b')][_0xd1d0('0x28')]){_0x11c218[_0xd1d0('0x29')]=[{'all':!![]}];}return db['Dynamics365Account'][_0xd1d0('0x2a')](_0x11c218);})['then'](function(_0x39a859){_0x2abe5e[_0xd1d0('0x2b')]=_0x39a859;return _0x2abe5e;})[_0xd1d0('0xb')](respondWithFilteredResult(_0x2378c0,_0x11c218))['catch'](handleError(_0x2378c0,null));};exports[_0xd1d0('0x2c')]=function(_0x172911,_0x106339){var _0xd3af76={'raw':![],'where':{'id':_0x172911[_0xd1d0('0x2d')]['id']}},_0x442cf1={};_0x442cf1[_0xd1d0('0x17')]=_['keys'](db[_0xd1d0('0x14')][_0xd1d0('0x2e')]);_0x442cf1[_0xd1d0('0x1b')]=_[_0xd1d0('0x18')](_0x172911[_0xd1d0('0x1b')]);_0x442cf1[_0xd1d0('0x19')]=_[_0xd1d0('0x1a')](_0x442cf1['model'],_0x442cf1['query']);_0xd3af76['attributes']=_[_0xd1d0('0x1a')](_0x442cf1[_0xd1d0('0x17')],qs['fields'](_0x172911[_0xd1d0('0x1b')][_0xd1d0('0x1d')]));_0xd3af76[_0xd1d0('0x1c')]=_0xd3af76[_0xd1d0('0x1c')][_0xd1d0('0x2f')]?_0xd3af76[_0xd1d0('0x1c')]:_0x442cf1['model'];if(_0x172911[_0xd1d0('0x1b')][_0xd1d0('0x28')]){_0xd3af76[_0xd1d0('0x29')]=[{'all':!![]}];}_0xd3af76=_[_0xd1d0('0x24')]({},_0xd3af76,_0x172911[_0xd1d0('0x27')]);return db[_0xd1d0('0x14')][_0xd1d0('0x30')](_0xd3af76)[_0xd1d0('0xb')](handleEntityNotFound(_0x106339,null))['then'](respondWithResult(_0x106339,null))[_0xd1d0('0x31')](handleError(_0x106339,null));};exports['create']=function(_0x1d3218,_0x123907){return db[_0xd1d0('0x14')][_0xd1d0('0x32')](_0x1d3218['body'],{})[_0xd1d0('0xb')](respondWithResult(_0x123907,0xc9))[_0xd1d0('0x31')](handleError(_0x123907,null));};exports['update']=function(_0x52ed5b,_0x3e71a8){if(_0x52ed5b['body']['id']){delete _0x52ed5b[_0xd1d0('0x33')]['id'];}return db[_0xd1d0('0x14')][_0xd1d0('0x30')]({'where':{'id':_0x52ed5b[_0xd1d0('0x2d')]['id']}})[_0xd1d0('0xb')](handleEntityNotFound(_0x3e71a8,null))[_0xd1d0('0xb')](saveUpdates(_0x52ed5b[_0xd1d0('0x33')],null))[_0xd1d0('0xb')](respondWithResult(_0x3e71a8,null))[_0xd1d0('0x31')](handleError(_0x3e71a8,null));};exports[_0xd1d0('0xc')]=function(_0x2034c4,_0x440e06){return db[_0xd1d0('0x14')][_0xd1d0('0x30')]({'where':{'id':_0x2034c4[_0xd1d0('0x2d')]['id']}})[_0xd1d0('0xb')](handleEntityNotFound(_0x440e06,null))[_0xd1d0('0xb')](removeEntity(_0x440e06,null))[_0xd1d0('0x31')](handleError(_0x440e06,null));};exports['getConfigurations']=function(_0x4b4ace,_0x336f07){var _0x6b9c8c={};var _0x201709={};var _0xa01ef6;var _0x569e2f;return db[_0xd1d0('0x14')]['findOne']({'where':{'id':_0x4b4ace[_0xd1d0('0x2d')]['id']}})['then'](handleEntityNotFound(_0x336f07,null))[_0xd1d0('0xb')](function(_0x58a1ca){if(_0x58a1ca){_0xa01ef6=_0x58a1ca;_0x201709['model']=_[_0xd1d0('0x18')](db['Dynamics365Configuration'][_0xd1d0('0x2e')]);_0x201709['query']=_[_0xd1d0('0x18')](_0x4b4ace[_0xd1d0('0x1b')]);_0x201709[_0xd1d0('0x19')]=_['intersection'](_0x201709[_0xd1d0('0x17')],_0x201709['query']);_0x6b9c8c['attributes']=_[_0xd1d0('0x1a')](_0x201709['model'],qs[_0xd1d0('0x1d')](_0x4b4ace['query'][_0xd1d0('0x1d')]));_0x6b9c8c['attributes']=_0x6b9c8c[_0xd1d0('0x1c')][_0xd1d0('0x2f')]?_0x6b9c8c['attributes']:_0x201709[_0xd1d0('0x17')];_0x6b9c8c[_0xd1d0('0x1f')]=qs[_0xd1d0('0x20')](_0x4b4ace[_0xd1d0('0x1b')][_0xd1d0('0x20')]);_0x6b9c8c[_0xd1d0('0x21')]=qs[_0xd1d0('0x19')](_['pick'](_0x4b4ace[_0xd1d0('0x1b')],_0x201709[_0xd1d0('0x19')]));if(_0x4b4ace['query']['filter']){_0x6b9c8c[_0xd1d0('0x21')]=_[_0xd1d0('0x24')](_0x6b9c8c[_0xd1d0('0x21')],{'$or':_[_0xd1d0('0x13')](_0x6b9c8c['attributes'],function(_0xa7920b){var _0x19228={};_0x19228[_0xa7920b]={'$like':'%'+_0x4b4ace[_0xd1d0('0x1b')][_0xd1d0('0x23')]+'%'};return _0x19228;})});}_0x6b9c8c=_['merge']({},_0x6b9c8c,_0x4b4ace[_0xd1d0('0x27')]);return _0xa01ef6[_0xd1d0('0x34')](_0x6b9c8c);}})[_0xd1d0('0xb')](function(_0x52f0a8){if(_0x52f0a8){_0x569e2f=_0x52f0a8[_0xd1d0('0x2f')];if(!_0x4b4ace[_0xd1d0('0x1b')]['hasOwnProperty']('nolimit')){_0x6b9c8c['limit']=qs['limit'](_0x4b4ace[_0xd1d0('0x1b')][_0xd1d0('0x7')]);_0x6b9c8c[_0xd1d0('0x4')]=qs['offset'](_0x4b4ace[_0xd1d0('0x1b')][_0xd1d0('0x4')]);}return _0xa01ef6['getConfigurations'](_0x6b9c8c);}})[_0xd1d0('0xb')](function(_0x4d6697){if(_0x4d6697){return _0x4d6697?{'count':_0x569e2f,'rows':_0x4d6697}:null;}})[_0xd1d0('0xb')](respondWithResult(_0x336f07,null))[_0xd1d0('0x31')](handleError(_0x336f07,null));};exports[_0xd1d0('0x35')]=function(_0x39f7d4,_0x5313bc){if(_0x39f7d4[_0xd1d0('0x33')]['id']){delete _0x39f7d4[_0xd1d0('0x33')]['id'];}return db[_0xd1d0('0x14')][_0xd1d0('0x36')]({'where':{'id':_0x39f7d4[_0xd1d0('0x2d')]['id']}})['then'](handleEntityNotFound(_0x5313bc,null))['then'](function(_0xb1a4e7){if(_0xb1a4e7){_0x39f7d4[_0xd1d0('0x33')][_0xd1d0('0x37')]=_0xb1a4e7['id'];_0x39f7d4['body']['Subjects']=integrations[_0xd1d0('0x38')](_0x39f7d4[_0xd1d0('0x33')][_0xd1d0('0x39')],_0x39f7d4[_0xd1d0('0x33')]['type']);_0x39f7d4[_0xd1d0('0x33')]['Descriptions']=integrations[_0xd1d0('0x3a')](_0x39f7d4[_0xd1d0('0x33')][_0xd1d0('0x39')],_0x39f7d4[_0xd1d0('0x33')][_0xd1d0('0x25')]);return db[_0xd1d0('0x3b')][_0xd1d0('0x32')](_0x39f7d4[_0xd1d0('0x33')],{'include':[{'model':db['Dynamics365Field'],'as':_0xd1d0('0x3c')},{'model':db[_0xd1d0('0x3d')],'as':'Descriptions'}]});}return null;})[_0xd1d0('0xb')](respondWithResult(_0x5313bc,null))[_0xd1d0('0x31')](handleError(_0x5313bc,null));};function sanitizeRemoteUri(_0x4aa648){var _0x388e48=_0x4aa648[_0xd1d0('0x3e')](-0x1);if(_0x388e48==='/')return _0x4aa648['substring'](0x0,_0x4aa648[_0xd1d0('0x3f')](_0x388e48));return _0x4aa648;}function getWebApiUrl(_0x43e771){return util[_0xd1d0('0x40')](_0xd1d0('0x41'),_0x43e771);}exports[_0xd1d0('0x42')]=function(_0x2a5fe3,_0x5760c7){var _0x1f35df=_0x2a5fe3[_0xd1d0('0x1b')][_0xd1d0('0x43')];var _0x29db1d=_0x1f35df===_0xd1d0('0x44')?_0xd1d0('0x45'):_0xd1d0('0x46');var _0x442838='';var _0x376c10='';var _0x1deb4b='';var _0x1831c9='';var _0x3e492f='';var _0x56758b='';var _0x4f5056='';var _0x302ee9='';var _0x384471=[_0xd1d0('0x47'),_0xd1d0('0x48'),_0xd1d0('0x49'),_0xd1d0('0x4a'),_0xd1d0('0x4b'),_0xd1d0('0x4c'),'phonenumber',_0xd1d0('0x4d'),_0xd1d0('0x4e'),_0xd1d0('0x4f')];var _0x3f1977=[_0xd1d0('0x50'),_0xd1d0('0x51'),_0xd1d0('0x52'),_0xd1d0('0x53'),'contactidname',_0xd1d0('0x54'),_0xd1d0('0x55'),_0xd1d0('0x56'),'createdbyexternalpartyname',_0xd1d0('0x57'),_0xd1d0('0x58'),_0xd1d0('0x59'),'createdon',_0xd1d0('0x5a'),_0xd1d0('0x5b'),_0xd1d0('0x5c'),_0xd1d0('0x5d'),_0xd1d0('0x5e'),_0xd1d0('0x5f'),_0xd1d0('0x60'),_0xd1d0('0x61'),'entityimage_url',_0xd1d0('0x62'),_0xd1d0('0x63'),_0xd1d0('0x64'),_0xd1d0('0x65'),_0xd1d0('0x66'),_0xd1d0('0x67'),_0xd1d0('0x68'),_0xd1d0('0x69'),_0xd1d0('0x6a'),_0xd1d0('0x6b'),_0xd1d0('0x6c'),_0xd1d0('0x6d'),_0xd1d0('0x6e'),'modifiedon',_0xd1d0('0x6f'),'modifiedonbehalfbyyominame','msdyn_incidenttypename',_0xd1d0('0x70'),'numberofchildincidents','onholdtime','overriddencreatedon',_0xd1d0('0x71'),_0xd1d0('0x72'),'owneridyominame',_0xd1d0('0x73'),_0xd1d0('0x74'),_0xd1d0('0x75'),_0xd1d0('0x76'),_0xd1d0('0x77'),_0xd1d0('0x78'),_0xd1d0('0x79'),_0xd1d0('0x7a'),'responseby',_0xd1d0('0x7b'),_0xd1d0('0x7c'),_0xd1d0('0x7d'),'slainvokedidname',_0xd1d0('0x7e'),_0xd1d0('0x7f'),_0xd1d0('0x80'),_0xd1d0('0x81'),_0xd1d0('0x82'),_0xd1d0('0x83'),_0xd1d0('0x84'),'transactioncurrencyidname',_0xd1d0('0x85'),_0xd1d0('0x86'),'versionnumber'];var _0x9a3eb6=_0x384471['concat'](_0x3f1977);return db[_0xd1d0('0x14')][_0xd1d0('0x36')]({'where':{'id':_0x2a5fe3['params']['id']},'attributes':['id',_0xd1d0('0x87'),_0xd1d0('0x88'),_0xd1d0('0x89'),_0xd1d0('0x8a'),_0xd1d0('0x8b'),_0xd1d0('0x8c'),_0xd1d0('0x8d')],'include':[{'model':db[_0xd1d0('0x8e')],'as':_0xd1d0('0x8e'),'attributes':['id','data5',_0xd1d0('0x8f')]}]})[_0xd1d0('0xb')](handleEntityNotFound(_0x5760c7,null))[_0xd1d0('0xb')](function(_0x1a46d7){if(_0x1a46d7){if(_0x1a46d7[_0xd1d0('0x8d')]){_0x1a46d7[_0xd1d0('0x90')]=_0x1a46d7[_0xd1d0('0x8e')][_0xd1d0('0x91')];_0x302ee9=sanitizeRemoteUri(_0x1a46d7[_0xd1d0('0x8e')]['data7']);_0x4f5056=getWebApiUrl(_0x302ee9);return _0x1a46d7;}_0x302ee9=sanitizeRemoteUri(_0x1a46d7[_0xd1d0('0x89')]);_0x4f5056=getWebApiUrl(_0x302ee9);var _0x2afb63={'method':_0xd1d0('0x92'),'uri':_0xd1d0('0x93')+_0x1a46d7[_0xd1d0('0x8a')]+_0xd1d0('0x94'),'form':{'client_id':_0x1a46d7[_0xd1d0('0x8b')],'resource':_0x302ee9,'username':_0x1a46d7['username'],'password':_0x1a46d7[_0xd1d0('0x88')],'grant_type':_0xd1d0('0x88'),'client_secret':_0x1a46d7[_0xd1d0('0x8c')]},'json':!![]};return rp(_0x2afb63);}})[_0xd1d0('0xb')](function(_0x2985af){_0x56758b=_0x2985af[_0xd1d0('0x90')];var _0x252f0a={'method':'GET','uri':encodeURI(_0x4f5056+_0xd1d0('0x95')+_0x29db1d+'\x27'),'headers':{'Authorization':_0xd1d0('0x96')+_0x56758b,'If-None-Match':null,'OData-Version':_0xd1d0('0x97')},'json':!![]};return rp(_0x252f0a);})[_0xd1d0('0xb')](function(_0xf4b1ca){var _0x5a08a3=_0xf4b1ca['value'][0x0];var _0x1995f2=_0x5a08a3[_0xd1d0('0x98')];var _0x5b6bff={'method':'GET','uri':_0x4f5056+_0xd1d0('0x99')+_0x1995f2+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0xd1d0('0x96')+_0x56758b,'If-None-Match':null,'OData-Version':_0xd1d0('0x97')},'json':!![]};return rp(_0x5b6bff);})[_0xd1d0('0xb')](function(_0x43256e){_0x442838=_0x43256e;_0x376c10=_0x442838[_0xd1d0('0x9a')];_0x376c10=_[_0xd1d0('0x9b')](_0x376c10,function(_0x5d3951){return!_0x9a3eb6[_0xd1d0('0x9c')](_0x5d3951[_0xd1d0('0x9d')]);});var _0x1ea7e3=[];var _0x508df9=[];_0x376c10['forEach'](function(_0x5e4100){if(_0x5e4100[_0xd1d0('0x9e')]){var _0xc55530=_0x5e4100[_0xd1d0('0x9e')][_0xd1d0('0x9f')](_0x5e4100[_0xd1d0('0x9e')][_0xd1d0('0x3f')]('.')+0x1);if(_0xc55530==='PicklistAttributeMetadata'){_0x1ea7e3[_0xd1d0('0xa0')](getSelectList(_0x4f5056,_0x1f35df,_0x508df9,_0x442838['MetadataId'],_0x5e4100[_0xd1d0('0x98')],_0x56758b));}}});return Promise['all'](_0x1ea7e3);})[_0xd1d0('0xb')](function(_0x4b520d){_0x1deb4b=_0x4b520d[0x0];var _0x2cb377=[];var _0x277cb4=[];_0x376c10[_0xd1d0('0xa1')](function(_0x28473e){if(!_[_0xd1d0('0xa2')](_0x28473e[_0xd1d0('0x9e')])){var _0x35f148=_0x28473e['@odata.type'][_0xd1d0('0x9f')](_0x28473e[_0xd1d0('0x9e')][_0xd1d0('0x3f')]('.')+0x1);if(_0x35f148===_0xd1d0('0xa3')){_0x2cb377[_0xd1d0('0xa0')](getBooleanList(_0x4f5056,_0x1f35df,_0x277cb4,_0x442838[_0xd1d0('0x98')],_0x28473e['MetadataId'],_0x56758b));}}});return Promise['all'](_0x2cb377);})['then'](function(_0x2094a5){_0x1831c9=_0x2094a5[0x0];var _0x3b5db6=[];var _0x3f8c3d=[];_0x376c10['forEach'](function(_0x15088b){if(_0x15088b[_0xd1d0('0x9e')]){var _0x27ccba=_0x15088b['@odata.type'][_0xd1d0('0x9f')](_0x15088b[_0xd1d0('0x9e')][_0xd1d0('0x3f')]('.')+0x1);if(_0x27ccba==='StringAttributeMetadata'||_0x27ccba==='DoubleAttributeMetadata'||_0x27ccba==='BigIntAttributeMetadata'||_0x27ccba===_0xd1d0('0xa4')||_0x27ccba===_0xd1d0('0xa5')||_0x27ccba===_0xd1d0('0xa6')||_0x27ccba==='StatusAttributeMetadata'||_0x27ccba===_0xd1d0('0xa7')||_0x27ccba==='StateAttributeMetadata'||_0x27ccba==='DecimalAttributeMetadata'){_0x3b5db6[_0xd1d0('0xa0')](getInputList(_0x4f5056,_0x1f35df,_0x27ccba,_0x3f8c3d,_0x442838[_0xd1d0('0x98')],_0x15088b[_0xd1d0('0x98')],_0x56758b));}}});return Promise[_0xd1d0('0xa8')](_0x3b5db6);})['then'](function(_0x31cd92){_0x3e492f=_0x31cd92[0x0];var _0x842210=_0x1deb4b[_0xd1d0('0xa9')](_0x1831c9)[_0xd1d0('0xa9')](_0x3e492f);var _0x25d79e={'count':_0x842210['length'],'rows':_0x842210};return _0x25d79e;})[_0xd1d0('0xb')](respondWithResult(_0x5760c7,null))[_0xd1d0('0x31')](function(_0x4fe7e8){var _0xe12cce=_0x2a5fe3[_0xd1d0('0x1b')][_0xd1d0('0xaa')]?0x1f4:_0x4fe7e8[_0xd1d0('0xab')]||0x1f4;logger[_0xd1d0('0xf')](_0x4fe7e8[_0xd1d0('0x10')]);delete _0x4fe7e8['name'];if(_0xe12cce===0x191){_0xe12cce=0x190;}_0x5760c7[_0xd1d0('0x8')](_0xe12cce)[_0xd1d0('0x12')](_0x2a5fe3['query'][_0xd1d0('0xaa')]?{'message':_0xd1d0('0xac'),'statusCode':_0x4fe7e8[_0xd1d0('0xab')]}:_0x4fe7e8);});};function getSelectList(_0x40837d,_0x1c0d94,_0x393f67,_0x5e0f91,_0x3e86a6,_0x157fd9){var _0x345c9f={'method':_0xd1d0('0xad'),'uri':_0x40837d+'EntityDefinitions('+_0x5e0f91+_0xd1d0('0xae')+_0x3e86a6+_0xd1d0('0xaf')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':'Bearer\x20'+_0x157fd9,'If-None-Match':null,'OData-Version':_0xd1d0('0x97')},'json':!![]};return rp(_0x345c9f)[_0xd1d0('0xb')](function(_0x5decec){var _0x52d6da=[];var _0x2fe162=_0x5decec['OptionSet'][_0xd1d0('0xb0')];_0x2fe162[_0xd1d0('0xa1')](function(_0x4bfa27){_0x52d6da[_0xd1d0('0xa0')]({'name':_0x4bfa27[_0xd1d0('0xb1')][_0xd1d0('0xb2')][_0xd1d0('0xb1')],'value':String(_0x4bfa27[_0xd1d0('0xb3')])});});var _0x5beeb0={'id':_0x1c0d94+'_'+_0x5decec['LogicalName'],'name':_0x5decec[_0xd1d0('0xb4')][_0xd1d0('0xb2')]['Label'],'custom':![],'options':_0x52d6da};_0x393f67[_0xd1d0('0xa0')](_0x5beeb0);return _0x393f67;});}function getBooleanList(_0x5921e3,_0x12d2ca,_0xb74601,_0x451e1f,_0x684e63,_0x489b99){var _0x3e46cd={'method':_0xd1d0('0xad'),'uri':_0x5921e3+'EntityDefinitions('+_0x451e1f+_0xd1d0('0xae')+_0x684e63+_0xd1d0('0xb5'),'headers':{'Authorization':'Bearer\x20'+_0x489b99,'If-None-Match':null,'OData-Version':_0xd1d0('0x97')},'json':!![]};return rp(_0x3e46cd)[_0xd1d0('0xb')](function(_0x5bf8bf){var _0x500361=[];_0x500361[_0xd1d0('0xa0')]({'name':_0x5bf8bf[_0xd1d0('0xb6')][_0xd1d0('0xb7')]['Label'][_0xd1d0('0xb2')][_0xd1d0('0xb1')],'value':_0xd1d0('0xb8')},{'name':_0x5bf8bf[_0xd1d0('0xb6')][_0xd1d0('0xb9')]['Label'][_0xd1d0('0xb2')]['Label'],'value':_0xd1d0('0xba')});var _0x3e551f={'id':_0x12d2ca+'_'+_0x5bf8bf[_0xd1d0('0x9d')],'name':_0x5bf8bf[_0xd1d0('0xb4')][_0xd1d0('0xb2')][_0xd1d0('0xb1')],'custom':![],'options':_0x500361};_0xb74601[_0xd1d0('0xa0')](_0x3e551f);return _0xb74601;});}function getInputList(_0x21a02b,_0x19d21b,_0x2ac19e,_0xa3c41,_0x4ef1d3,_0x95911,_0x3b05ed){var _0x2a3b78={'method':'GET','uri':_0x21a02b+'EntityDefinitions('+_0x4ef1d3+_0xd1d0('0xae')+_0x95911+')/Microsoft.Dynamics.CRM.'+_0x2ac19e+_0xd1d0('0xbb'),'headers':{'Authorization':_0xd1d0('0x96')+_0x3b05ed,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x2a3b78)['then'](function(_0x19f2db){var _0x3d2812={'id':_0x19d21b+'_'+_0x19f2db['LogicalName'],'name':_0x19f2db[_0xd1d0('0xb4')]['UserLocalizedLabel']?_0x19f2db[_0xd1d0('0xb4')][_0xd1d0('0xb2')]['Label']:_0x19f2db[_0xd1d0('0x9d')],'custom':![],'options':[]};_0xa3c41[_0xd1d0('0xa0')](_0x3d2812);return _0xa3c41;});}