Built motion from commit c738b9ac.|2.6.25
[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 _0x0f58=['rawAttributes','fieldName','type','key','keys','query','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','name','merge','options','includeAll','include','findAll','rows','catch','show','find','create','body','params','getConfigurations','findOne','Dynamics365Configuration','addConfiguration','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','format','%s/api/data/v9.0/','ticketType','Incident','PhoneCall','title','description','customerid','caseorigincode','subject','phonenumber','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','entityimage_timestamp','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','productserialnumber','resolveby','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','statecode','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','concat','username','remoteUri','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data7','access_token','data5','https://login.microsoftonline.com/','/oauth2/token','password','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','value','MetadataId',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','remove','includes','LogicalName','@odata.type','PicklistAttributeMetadata','push','all','forEach','substring','lastIndexOf','DoubleAttributeMetadata','BigIntAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','OptionSet','Options','Label','UserLocalizedLabel','Value','DisplayName','EntityDefinitions(','TrueOption','true','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','../../mysqldb','../../components/integrations/configuration','status','json','undefined','count','offset','limit','update','destroy','then','end','sendStatus','error','stack','send','index','map','Dynamics365Account'];(function(_0x538ce3,_0x25415d){var _0x230f2c=function(_0xe1f502){while(--_0xe1f502){_0x538ce3['push'](_0x538ce3['shift']());}};_0x230f2c(++_0x25415d);}(_0x0f58,0x164));var _0x80f5=function(_0x1c81be,_0x38517f){_0x1c81be=_0x1c81be-0x0;var _0x3be677=_0x0f58[_0x1c81be];return _0x3be677;};'use strict';var rp=require(_0x80f5('0x0'));var util=require(_0x80f5('0x1'));var _=require(_0x80f5('0x2'));var qs=require(_0x80f5('0x3'));var logger=require(_0x80f5('0x4'))('api');var db=require(_0x80f5('0x5'))['db'];var integrations=require(_0x80f5('0x6'));function respondWithResult(_0x14bc8c,_0x54a59c){_0x54a59c=_0x54a59c||0xc8;return function(_0x2925a8){if(_0x2925a8){return _0x14bc8c[_0x80f5('0x7')](_0x54a59c)[_0x80f5('0x8')](_0x2925a8);}};}function respondWithFilteredResult(_0x418af5,_0x2bec6d){return function(_0x5a8aaf){if(_0x5a8aaf){var _0x1e981f=typeof _0x2bec6d['offset']===_0x80f5('0x9')&&typeof _0x2bec6d['limit']===_0x80f5('0x9');var _0x124f61=_0x5a8aaf[_0x80f5('0xa')];var _0x3da407=_0x1e981f?0x0:_0x2bec6d[_0x80f5('0xb')];var _0x5e9501=_0x1e981f?_0x5a8aaf[_0x80f5('0xa')]:_0x2bec6d['offset']+_0x2bec6d[_0x80f5('0xc')];var _0x1d5376;if(_0x5e9501>=_0x124f61){_0x5e9501=_0x124f61;_0x1d5376=0xc8;}else{_0x1d5376=0xce;}_0x418af5[_0x80f5('0x7')](_0x1d5376);return _0x418af5['set']('Content-Range',_0x3da407+'-'+_0x5e9501+'/'+_0x124f61)['json'](_0x5a8aaf);}return null;};}function saveUpdates(_0x36357d){return function(_0x389249){if(_0x389249){return _0x389249[_0x80f5('0xd')](_0x36357d)['then'](function(_0xb4c5cd){return _0xb4c5cd;});}return null;};}function removeEntity(_0x48b8f4){return function(_0x26fc9a){if(_0x26fc9a){return _0x26fc9a[_0x80f5('0xe')]()[_0x80f5('0xf')](function(){_0x48b8f4[_0x80f5('0x7')](0xcc)[_0x80f5('0x10')]();});}};}function handleEntityNotFound(_0x19ac56){return function(_0x4242bc){if(!_0x4242bc){_0x19ac56[_0x80f5('0x11')](0x194);}return _0x4242bc;};}function handleError(_0x34fa1a,_0x3f07e2){_0x3f07e2=_0x3f07e2||0x1f4;return function(_0x2df7e8){logger[_0x80f5('0x12')](_0x2df7e8[_0x80f5('0x13')]);if(_0x2df7e8['name']){delete _0x2df7e8['name'];}_0x34fa1a[_0x80f5('0x7')](_0x3f07e2)[_0x80f5('0x14')](_0x2df7e8);};}exports[_0x80f5('0x15')]=function(_0x4c4822,_0x19260a){var _0x3f35a7={},_0x1f5947={},_0x38ecf0={'count':0x0,'rows':[]};var _0x176bd0=_[_0x80f5('0x16')](db[_0x80f5('0x17')][_0x80f5('0x18')],function(_0x10485d){return{'name':_0x10485d[_0x80f5('0x19')],'type':_0x10485d[_0x80f5('0x1a')][_0x80f5('0x1b')]};});_0x1f5947['model']=_[_0x80f5('0x16')](_0x176bd0,'name');_0x1f5947['query']=_[_0x80f5('0x1c')](_0x4c4822[_0x80f5('0x1d')]);_0x1f5947[_0x80f5('0x1e')]=_[_0x80f5('0x1f')](_0x1f5947['model'],_0x1f5947[_0x80f5('0x1d')]);_0x3f35a7[_0x80f5('0x20')]=_[_0x80f5('0x1f')](_0x1f5947[_0x80f5('0x21')],qs[_0x80f5('0x22')](_0x4c4822[_0x80f5('0x1d')][_0x80f5('0x22')]));_0x3f35a7[_0x80f5('0x20')]=_0x3f35a7['attributes'][_0x80f5('0x23')]?_0x3f35a7[_0x80f5('0x20')]:_0x1f5947[_0x80f5('0x21')];if(!_0x4c4822[_0x80f5('0x1d')][_0x80f5('0x24')](_0x80f5('0x25'))){_0x3f35a7[_0x80f5('0xc')]=qs[_0x80f5('0xc')](_0x4c4822['query'][_0x80f5('0xc')]);_0x3f35a7[_0x80f5('0xb')]=qs['offset'](_0x4c4822['query'][_0x80f5('0xb')]);}_0x3f35a7[_0x80f5('0x26')]=qs[_0x80f5('0x27')](_0x4c4822[_0x80f5('0x1d')]['sort']);_0x3f35a7[_0x80f5('0x28')]=qs[_0x80f5('0x1e')](_[_0x80f5('0x29')](_0x4c4822[_0x80f5('0x1d')],_0x1f5947[_0x80f5('0x1e')]),_0x176bd0);if(_0x4c4822[_0x80f5('0x1d')][_0x80f5('0x2a')]){_0x3f35a7[_0x80f5('0x28')]=_['merge'](_0x3f35a7['where'],{'$or':_[_0x80f5('0x16')](_0x176bd0,function(_0x3610b9){if(_0x3610b9[_0x80f5('0x1a')]!=='VIRTUAL'){var _0x417689={};_0x417689[_0x3610b9[_0x80f5('0x2b')]]={'$like':'%'+_0x4c4822[_0x80f5('0x1d')]['filter']+'%'};return _0x417689;}})});}_0x3f35a7=_[_0x80f5('0x2c')]({},_0x3f35a7,_0x4c4822[_0x80f5('0x2d')]);var _0x12fed5={'where':_0x3f35a7[_0x80f5('0x28')]};return db['Dynamics365Account'][_0x80f5('0xa')](_0x12fed5)[_0x80f5('0xf')](function(_0x19ea42){_0x38ecf0[_0x80f5('0xa')]=_0x19ea42;if(_0x4c4822[_0x80f5('0x1d')][_0x80f5('0x2e')]){_0x3f35a7[_0x80f5('0x2f')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x80f5('0x30')](_0x3f35a7);})[_0x80f5('0xf')](function(_0x457941){_0x38ecf0[_0x80f5('0x31')]=_0x457941;return _0x38ecf0;})[_0x80f5('0xf')](respondWithFilteredResult(_0x19260a,_0x3f35a7))[_0x80f5('0x32')](handleError(_0x19260a,null));};exports[_0x80f5('0x33')]=function(_0x23ced3,_0x3280c7){var _0x436af9={'raw':![],'where':{'id':_0x23ced3['params']['id']}},_0x49b8e5={};_0x49b8e5[_0x80f5('0x21')]=_[_0x80f5('0x1c')](db[_0x80f5('0x17')][_0x80f5('0x18')]);_0x49b8e5[_0x80f5('0x1d')]=_[_0x80f5('0x1c')](_0x23ced3[_0x80f5('0x1d')]);_0x49b8e5[_0x80f5('0x1e')]=_[_0x80f5('0x1f')](_0x49b8e5[_0x80f5('0x21')],_0x49b8e5[_0x80f5('0x1d')]);_0x436af9[_0x80f5('0x20')]=_[_0x80f5('0x1f')](_0x49b8e5[_0x80f5('0x21')],qs[_0x80f5('0x22')](_0x23ced3['query'][_0x80f5('0x22')]));_0x436af9[_0x80f5('0x20')]=_0x436af9['attributes'][_0x80f5('0x23')]?_0x436af9[_0x80f5('0x20')]:_0x49b8e5['model'];if(_0x23ced3[_0x80f5('0x1d')][_0x80f5('0x2e')]){_0x436af9[_0x80f5('0x2f')]=[{'all':!![]}];}_0x436af9=_['merge']({},_0x436af9,_0x23ced3[_0x80f5('0x2d')]);return db[_0x80f5('0x17')][_0x80f5('0x34')](_0x436af9)[_0x80f5('0xf')](handleEntityNotFound(_0x3280c7,null))[_0x80f5('0xf')](respondWithResult(_0x3280c7,null))[_0x80f5('0x32')](handleError(_0x3280c7,null));};exports[_0x80f5('0x35')]=function(_0x3a4cf6,_0x45188b){return db[_0x80f5('0x17')][_0x80f5('0x35')](_0x3a4cf6[_0x80f5('0x36')],{})[_0x80f5('0xf')](respondWithResult(_0x45188b,0xc9))[_0x80f5('0x32')](handleError(_0x45188b,null));};exports[_0x80f5('0xd')]=function(_0x54a646,_0x2915da){if(_0x54a646['body']['id']){delete _0x54a646[_0x80f5('0x36')]['id'];}return db[_0x80f5('0x17')][_0x80f5('0x34')]({'where':{'id':_0x54a646[_0x80f5('0x37')]['id']}})['then'](handleEntityNotFound(_0x2915da,null))['then'](saveUpdates(_0x54a646[_0x80f5('0x36')],null))[_0x80f5('0xf')](respondWithResult(_0x2915da,null))['catch'](handleError(_0x2915da,null));};exports[_0x80f5('0xe')]=function(_0x3e7f5c,_0x1d8f8c){return db[_0x80f5('0x17')]['find']({'where':{'id':_0x3e7f5c[_0x80f5('0x37')]['id']}})[_0x80f5('0xf')](handleEntityNotFound(_0x1d8f8c,null))[_0x80f5('0xf')](removeEntity(_0x1d8f8c,null))[_0x80f5('0x32')](handleError(_0x1d8f8c,null));};exports[_0x80f5('0x38')]=function(_0x722053,_0x1ad1a9){var _0x27d0fe={};var _0x319a16={};var _0x2d98d2;var _0x2e0b28;return db['Dynamics365Account'][_0x80f5('0x39')]({'where':{'id':_0x722053[_0x80f5('0x37')]['id']}})['then'](handleEntityNotFound(_0x1ad1a9,null))[_0x80f5('0xf')](function(_0x2e96d9){if(_0x2e96d9){_0x2d98d2=_0x2e96d9;_0x319a16[_0x80f5('0x21')]=_[_0x80f5('0x1c')](db[_0x80f5('0x3a')]['rawAttributes']);_0x319a16[_0x80f5('0x1d')]=_[_0x80f5('0x1c')](_0x722053[_0x80f5('0x1d')]);_0x319a16['filters']=_[_0x80f5('0x1f')](_0x319a16[_0x80f5('0x21')],_0x319a16[_0x80f5('0x1d')]);_0x27d0fe[_0x80f5('0x20')]=_[_0x80f5('0x1f')](_0x319a16[_0x80f5('0x21')],qs[_0x80f5('0x22')](_0x722053[_0x80f5('0x1d')][_0x80f5('0x22')]));_0x27d0fe[_0x80f5('0x20')]=_0x27d0fe[_0x80f5('0x20')]['length']?_0x27d0fe[_0x80f5('0x20')]:_0x319a16['model'];_0x27d0fe[_0x80f5('0x26')]=qs[_0x80f5('0x27')](_0x722053[_0x80f5('0x1d')][_0x80f5('0x27')]);_0x27d0fe[_0x80f5('0x28')]=qs[_0x80f5('0x1e')](_['pick'](_0x722053['query'],_0x319a16[_0x80f5('0x1e')]));if(_0x722053[_0x80f5('0x1d')][_0x80f5('0x2a')]){_0x27d0fe[_0x80f5('0x28')]=_[_0x80f5('0x2c')](_0x27d0fe['where'],{'$or':_[_0x80f5('0x16')](_0x27d0fe[_0x80f5('0x20')],function(_0x28651f){var _0x3649cd={};_0x3649cd[_0x28651f]={'$like':'%'+_0x722053[_0x80f5('0x1d')][_0x80f5('0x2a')]+'%'};return _0x3649cd;})});}_0x27d0fe=_['merge']({},_0x27d0fe,_0x722053[_0x80f5('0x2d')]);return _0x2d98d2[_0x80f5('0x38')](_0x27d0fe);}})[_0x80f5('0xf')](function(_0x2a1b5b){if(_0x2a1b5b){_0x2e0b28=_0x2a1b5b['length'];if(!_0x722053[_0x80f5('0x1d')][_0x80f5('0x24')]('nolimit')){_0x27d0fe[_0x80f5('0xc')]=qs[_0x80f5('0xc')](_0x722053[_0x80f5('0x1d')][_0x80f5('0xc')]);_0x27d0fe['offset']=qs['offset'](_0x722053['query']['offset']);}return _0x2d98d2[_0x80f5('0x38')](_0x27d0fe);}})[_0x80f5('0xf')](function(_0x1d433d){if(_0x1d433d){return _0x1d433d?{'count':_0x2e0b28,'rows':_0x1d433d}:null;}})[_0x80f5('0xf')](respondWithResult(_0x1ad1a9,null))[_0x80f5('0x32')](handleError(_0x1ad1a9,null));};exports[_0x80f5('0x3b')]=function(_0xc8aa2b,_0x505411){if(_0xc8aa2b[_0x80f5('0x36')]['id']){delete _0xc8aa2b[_0x80f5('0x36')]['id'];}return db[_0x80f5('0x17')][_0x80f5('0x39')]({'where':{'id':_0xc8aa2b['params']['id']}})['then'](handleEntityNotFound(_0x505411,null))[_0x80f5('0xf')](function(_0x24d8e5){if(_0x24d8e5){_0xc8aa2b[_0x80f5('0x36')]['AccountId']=_0x24d8e5['id'];_0xc8aa2b[_0x80f5('0x36')][_0x80f5('0x3c')]=integrations[_0x80f5('0x3d')](_0xc8aa2b['body'][_0x80f5('0x3e')],_0xc8aa2b[_0x80f5('0x36')][_0x80f5('0x1a')]);_0xc8aa2b['body']['Descriptions']=integrations[_0x80f5('0x3f')](_0xc8aa2b[_0x80f5('0x36')][_0x80f5('0x3e')],_0xc8aa2b['body'][_0x80f5('0x1a')]);return db[_0x80f5('0x3a')][_0x80f5('0x35')](_0xc8aa2b[_0x80f5('0x36')],{'include':[{'model':db[_0x80f5('0x40')],'as':_0x80f5('0x3c')},{'model':db[_0x80f5('0x40')],'as':_0x80f5('0x41')}]});}return null;})[_0x80f5('0xf')](respondWithResult(_0x505411,null))[_0x80f5('0x32')](handleError(_0x505411,null));};function sanitizeRemoteUri(_0x3683aa){var _0x3bd6aa=_0x3683aa[_0x80f5('0x42')](-0x1);if(_0x3bd6aa==='/')return _0x3683aa['substring'](0x0,_0x3683aa['lastIndexOf'](_0x3bd6aa));return _0x3683aa;}function getWebApiUrl(_0x5bcbde){return util[_0x80f5('0x43')](_0x80f5('0x44'),_0x5bcbde);}exports['getFields']=function(_0x2c24d1,_0x4513cc){var _0x4743c2=_0x2c24d1[_0x80f5('0x1d')][_0x80f5('0x45')];var _0x27f82e=_0x4743c2==='incident'?_0x80f5('0x46'):_0x80f5('0x47');var _0x53eea3='';var _0x1fe78c='';var _0x1460e2='';var _0x4826c1='';var _0x348308='';var _0xab94b='';var _0x2bb275='';var _0x717768='';var _0x2a7621=[_0x80f5('0x48'),_0x80f5('0x49'),_0x80f5('0x4a'),'ownerid',_0x80f5('0x4b'),_0x80f5('0x4c'),_0x80f5('0x4d'),_0x80f5('0x4e'),_0x80f5('0x4f'),_0x80f5('0x50')];var _0x7891d9=[_0x80f5('0x51'),_0x80f5('0x52'),_0x80f5('0x53'),_0x80f5('0x54'),_0x80f5('0x55'),_0x80f5('0x56'),_0x80f5('0x57'),_0x80f5('0x58'),_0x80f5('0x59'),_0x80f5('0x5a'),_0x80f5('0x5b'),_0x80f5('0x5c'),'createdon',_0x80f5('0x5d'),_0x80f5('0x5e'),_0x80f5('0x5f'),_0x80f5('0x60'),'customeridyominame','emailaddress','entitlementidname',_0x80f5('0x61'),'entityimage_url',_0x80f5('0x62'),_0x80f5('0x63'),_0x80f5('0x64'),_0x80f5('0x65'),_0x80f5('0x66'),_0x80f5('0x67'),'kbarticleidname','lastonholdtime',_0x80f5('0x68'),_0x80f5('0x69'),_0x80f5('0x6a'),_0x80f5('0x6b'),_0x80f5('0x6c'),_0x80f5('0x6d'),_0x80f5('0x6e'),_0x80f5('0x6f'),'msdyn_incidenttypename','msdyn_iotalertname',_0x80f5('0x70'),_0x80f5('0x71'),_0x80f5('0x72'),_0x80f5('0x73'),_0x80f5('0x74'),_0x80f5('0x75'),_0x80f5('0x76'),_0x80f5('0x77'),_0x80f5('0x78'),_0x80f5('0x79'),_0x80f5('0x7a'),_0x80f5('0x7b'),_0x80f5('0x7c'),'resolvebykpiidname','responseby','responsiblecontactidname',_0x80f5('0x7d'),_0x80f5('0x7e'),_0x80f5('0x7f'),_0x80f5('0x80'),'socialprofileidname',_0x80f5('0x81'),'statuscode',_0x80f5('0x82'),_0x80f5('0x83'),_0x80f5('0x84'),_0x80f5('0x85'),_0x80f5('0x86'),'utcconversiontimezonecode','versionnumber'];var _0x47f2ae=_0x2a7621[_0x80f5('0x87')](_0x7891d9);return db[_0x80f5('0x17')]['findOne']({'where':{'id':_0x2c24d1[_0x80f5('0x37')]['id']},'attributes':['id',_0x80f5('0x88'),'password',_0x80f5('0x89'),_0x80f5('0x8a'),_0x80f5('0x8b'),_0x80f5('0x8c'),_0x80f5('0x8d')],'include':[{'model':db[_0x80f5('0x8e')],'as':_0x80f5('0x8e'),'attributes':['id','data5',_0x80f5('0x8f')]}]})[_0x80f5('0xf')](handleEntityNotFound(_0x4513cc,null))[_0x80f5('0xf')](function(_0x17af15){if(_0x17af15){if(_0x17af15['modernAuthentication']){_0x17af15[_0x80f5('0x90')]=_0x17af15['CloudProvider'][_0x80f5('0x91')];_0x717768=sanitizeRemoteUri(_0x17af15[_0x80f5('0x8e')]['data7']);_0x2bb275=getWebApiUrl(_0x717768);return _0x17af15;}_0x717768=sanitizeRemoteUri(_0x17af15[_0x80f5('0x89')]);_0x2bb275=getWebApiUrl(_0x717768);var _0x1c279b={'method':'POST','uri':_0x80f5('0x92')+_0x17af15[_0x80f5('0x8a')]+_0x80f5('0x93'),'form':{'client_id':_0x17af15[_0x80f5('0x8b')],'resource':_0x717768,'username':_0x17af15['username'],'password':_0x17af15[_0x80f5('0x94')],'grant_type':_0x80f5('0x94'),'client_secret':_0x17af15[_0x80f5('0x8c')]},'json':!![]};return rp(_0x1c279b);}})['then'](function(_0x33c9ad){_0xab94b=_0x33c9ad['access_token'];var _0x21c84f={'method':_0x80f5('0x95'),'uri':encodeURI(_0x2bb275+_0x80f5('0x96')+_0x27f82e+'\x27'),'headers':{'Authorization':_0x80f5('0x97')+_0xab94b,'If-None-Match':null,'OData-Version':_0x80f5('0x98')},'json':!![]};return rp(_0x21c84f);})[_0x80f5('0xf')](function(_0x2ae41c){var _0x471db0=_0x2ae41c[_0x80f5('0x99')][0x0];var _0x8ba400=_0x471db0[_0x80f5('0x9a')];var _0x237a12={'method':_0x80f5('0x95'),'uri':_0x2bb275+'EntityDefinitions('+_0x8ba400+_0x80f5('0x9b'),'headers':{'Authorization':_0x80f5('0x97')+_0xab94b,'If-None-Match':null,'OData-Version':_0x80f5('0x98')},'json':!![]};return rp(_0x237a12);})[_0x80f5('0xf')](function(_0x4dcd17){_0x53eea3=_0x4dcd17;_0x1fe78c=_0x53eea3[_0x80f5('0x9c')];_0x1fe78c=_[_0x80f5('0x9d')](_0x1fe78c,function(_0x216fb0){return!_0x47f2ae[_0x80f5('0x9e')](_0x216fb0[_0x80f5('0x9f')]);});var _0x419e26=[];var _0x5ec274=[];_0x1fe78c['forEach'](function(_0xa8ac35){if(_0xa8ac35['@odata.type']){var _0x46c40a=_0xa8ac35[_0x80f5('0xa0')]['substring'](_0xa8ac35[_0x80f5('0xa0')]['lastIndexOf']('.')+0x1);if(_0x46c40a===_0x80f5('0xa1')){_0x419e26[_0x80f5('0xa2')](getSelectList(_0x2bb275,_0x4743c2,_0x5ec274,_0x53eea3[_0x80f5('0x9a')],_0xa8ac35[_0x80f5('0x9a')],_0xab94b));}}});return Promise[_0x80f5('0xa3')](_0x419e26);})['then'](function(_0x1d4266){_0x1460e2=_0x1d4266[0x0];var _0x28d815=[];var _0x4fe36f=[];_0x1fe78c[_0x80f5('0xa4')](function(_0xc033d6){if(!_['isNil'](_0xc033d6['@odata.type'])){var _0x321d40=_0xc033d6[_0x80f5('0xa0')][_0x80f5('0xa5')](_0xc033d6['@odata.type'][_0x80f5('0xa6')]('.')+0x1);if(_0x321d40==='BooleanAttributeMetadata'){_0x28d815[_0x80f5('0xa2')](getBooleanList(_0x2bb275,_0x4743c2,_0x4fe36f,_0x53eea3[_0x80f5('0x9a')],_0xc033d6[_0x80f5('0x9a')],_0xab94b));}}});return Promise[_0x80f5('0xa3')](_0x28d815);})[_0x80f5('0xf')](function(_0x3087e1){_0x4826c1=_0x3087e1[0x0];var _0x2c5b02=[];var _0x15e811=[];_0x1fe78c[_0x80f5('0xa4')](function(_0x3e0ca4){if(_0x3e0ca4['@odata.type']){var _0xb66964=_0x3e0ca4[_0x80f5('0xa0')][_0x80f5('0xa5')](_0x3e0ca4['@odata.type'][_0x80f5('0xa6')]('.')+0x1);if(_0xb66964==='StringAttributeMetadata'||_0xb66964===_0x80f5('0xa7')||_0xb66964===_0x80f5('0xa8')||_0xb66964==='IntegerAttributeMetadata'||_0xb66964==='MemoAttributeMetadata'||_0xb66964===_0x80f5('0xa9')||_0xb66964===_0x80f5('0xaa')||_0xb66964==='EntityNameAttributeMetadata'||_0xb66964===_0x80f5('0xab')||_0xb66964===_0x80f5('0xac')){_0x2c5b02[_0x80f5('0xa2')](getInputList(_0x2bb275,_0x4743c2,_0xb66964,_0x15e811,_0x53eea3['MetadataId'],_0x3e0ca4[_0x80f5('0x9a')],_0xab94b));}}});return Promise['all'](_0x2c5b02);})['then'](function(_0x20e40d){_0x348308=_0x20e40d[0x0];var _0x27bd1f=_0x1460e2[_0x80f5('0x87')](_0x4826c1)[_0x80f5('0x87')](_0x348308);var _0x266752={'count':_0x27bd1f['length'],'rows':_0x27bd1f};return _0x266752;})['then'](respondWithResult(_0x4513cc,null))[_0x80f5('0x32')](function(_0xe2217e){var _0x2655ea=_0x2c24d1[_0x80f5('0x1d')][_0x80f5('0xad')]?0x1f4:_0xe2217e[_0x80f5('0xae')]||0x1f4;logger[_0x80f5('0x12')](_0xe2217e['stack']);delete _0xe2217e[_0x80f5('0x2b')];if(_0x2655ea===0x191){_0x2655ea=0x190;}_0x4513cc[_0x80f5('0x7')](_0x2655ea)[_0x80f5('0x14')](_0x2c24d1[_0x80f5('0x1d')][_0x80f5('0xad')]?{'message':'Wrong\x20credentials','statusCode':_0xe2217e['statusCode']}:_0xe2217e);});};function getSelectList(_0x1b5197,_0x514b09,_0x2a07fc,_0x3f179e,_0x4a40ba,_0x180e75){var _0x12ff60={'method':_0x80f5('0x95'),'uri':_0x1b5197+'EntityDefinitions('+_0x3f179e+_0x80f5('0xaf')+_0x4a40ba+_0x80f5('0xb0')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0x80f5('0x97')+_0x180e75,'If-None-Match':null,'OData-Version':_0x80f5('0x98')},'json':!![]};return rp(_0x12ff60)[_0x80f5('0xf')](function(_0x366ed6){var _0x282771=[];var _0x2c1236=_0x366ed6[_0x80f5('0xb1')][_0x80f5('0xb2')];_0x2c1236[_0x80f5('0xa4')](function(_0xb4805d){_0x282771[_0x80f5('0xa2')]({'name':_0xb4805d[_0x80f5('0xb3')][_0x80f5('0xb4')]['Label'],'value':String(_0xb4805d[_0x80f5('0xb5')])});});var _0x3cc170={'id':_0x514b09+'_'+_0x366ed6['LogicalName'],'name':_0x366ed6[_0x80f5('0xb6')][_0x80f5('0xb4')]['Label'],'custom':![],'options':_0x282771};_0x2a07fc[_0x80f5('0xa2')](_0x3cc170);return _0x2a07fc;});}function getBooleanList(_0x43f4d9,_0x32f979,_0x25d6d2,_0xb74d97,_0x59d8fa,_0xe108b5){var _0x50be43={'method':_0x80f5('0x95'),'uri':_0x43f4d9+_0x80f5('0xb7')+_0xb74d97+_0x80f5('0xaf')+_0x59d8fa+')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','headers':{'Authorization':_0x80f5('0x97')+_0xe108b5,'If-None-Match':null,'OData-Version':_0x80f5('0x98')},'json':!![]};return rp(_0x50be43)['then'](function(_0x1b1fc1){var _0x2ca1d8=[];_0x2ca1d8[_0x80f5('0xa2')]({'name':_0x1b1fc1[_0x80f5('0xb1')][_0x80f5('0xb8')]['Label'][_0x80f5('0xb4')]['Label'],'value':_0x80f5('0xb9')},{'name':_0x1b1fc1['OptionSet'][_0x80f5('0xba')][_0x80f5('0xb3')][_0x80f5('0xb4')][_0x80f5('0xb3')],'value':_0x80f5('0xbb')});var _0x398fac={'id':_0x32f979+'_'+_0x1b1fc1[_0x80f5('0x9f')],'name':_0x1b1fc1[_0x80f5('0xb6')]['UserLocalizedLabel']['Label'],'custom':![],'options':_0x2ca1d8};_0x25d6d2[_0x80f5('0xa2')](_0x398fac);return _0x25d6d2;});}function getInputList(_0x583620,_0x4b0edd,_0x119137,_0x16b507,_0x375f00,_0x18f60a,_0x294540){var _0xafffa9={'method':_0x80f5('0x95'),'uri':_0x583620+'EntityDefinitions('+_0x375f00+_0x80f5('0xaf')+_0x18f60a+_0x80f5('0xbc')+_0x119137+_0x80f5('0xbd'),'headers':{'Authorization':_0x80f5('0x97')+_0x294540,'If-None-Match':null,'OData-Version':_0x80f5('0x98')},'json':!![]};return rp(_0xafffa9)[_0x80f5('0xf')](function(_0x3e6caa){var _0x37941c={'id':_0x4b0edd+'_'+_0x3e6caa[_0x80f5('0x9f')],'name':_0x3e6caa[_0x80f5('0xb6')][_0x80f5('0xb4')]?_0x3e6caa[_0x80f5('0xb6')]['UserLocalizedLabel'][_0x80f5('0xb3')]:_0x3e6caa[_0x80f5('0x9f')],'custom':![],'options':[]};_0x16b507[_0x80f5('0xa2')](_0x37941c);return _0x16b507;});}