Built motion from commit 06a208af.|2.6.26
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 4eaa197..a7ec225 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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;});}
\ No newline at end of file
+var _0x8c2e=['modernAuthentication','access_token','https://login.microsoftonline.com/','/oauth2/token','clientSecret','Bearer\x20',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','4.0','includes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','push','MetadataId','all','isNil','BooleanAttributeMetadata','StringAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','StatusAttributeMetadata','StateAttributeMetadata','statusCode','stack','send','test','Wrong\x20credentials',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','UserLocalizedLabel','Value','DisplayName','EntityDefinitions(',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','Label','true','FalseOption','GET','?$select=DisplayName,LogicalName','request-promise','lodash','../../components/parsers/qs','../../config/logger','api','../../mysqldb','../../components/integrations/configuration','json','offset','undefined','limit','count','update','then','destroy','status','end','sendStatus','error','name','index','map','Dynamics365Account','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','include','create','catch','body','find','getConfigurations','findOne','Dynamics365Configuration','order','pick','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','incident','PhoneCall','title','description','customerid','caseorigincode','subject','regardingobjectid','directioncode','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyname','customeridtype','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_iotalertname','numberofchildincidents','onholdtime','owneridname','owneridtype','parentcaseidname','primarycontactidyominame','prioritycodename','productidname','productserialnumber','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statuscode','subjectidname','ticketnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','password','remoteUri','clientId','CloudProvider','data5','data7'];(function(_0x413cfb,_0x102a87){var _0x14b43c=function(_0x2ddecb){while(--_0x2ddecb){_0x413cfb['push'](_0x413cfb['shift']());}};_0x14b43c(++_0x102a87);}(_0x8c2e,0xec));var _0xe8c2=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x8c2e[_0x3dd15e];return _0x231fd0;};'use strict';var rp=require(_0xe8c2('0x0'));var util=require('util');var _=require(_0xe8c2('0x1'));var qs=require(_0xe8c2('0x2'));var logger=require(_0xe8c2('0x3'))(_0xe8c2('0x4'));var db=require(_0xe8c2('0x5'))['db'];var integrations=require(_0xe8c2('0x6'));function respondWithResult(_0x1603a7,_0x14de48){_0x14de48=_0x14de48||0xc8;return function(_0x52da4e){if(_0x52da4e){return _0x1603a7['status'](_0x14de48)[_0xe8c2('0x7')](_0x52da4e);}};}function respondWithFilteredResult(_0x9041b,_0x49f3ac){return function(_0x1600c6){if(_0x1600c6){var _0x4b3318=typeof _0x49f3ac[_0xe8c2('0x8')]===_0xe8c2('0x9')&&typeof _0x49f3ac[_0xe8c2('0xa')]==='undefined';var _0xad00b6=_0x1600c6[_0xe8c2('0xb')];var _0x4e0299=_0x4b3318?0x0:_0x49f3ac[_0xe8c2('0x8')];var _0x3b0d15=_0x4b3318?_0x1600c6[_0xe8c2('0xb')]:_0x49f3ac[_0xe8c2('0x8')]+_0x49f3ac[_0xe8c2('0xa')];var _0x2b0b9e;if(_0x3b0d15>=_0xad00b6){_0x3b0d15=_0xad00b6;_0x2b0b9e=0xc8;}else{_0x2b0b9e=0xce;}_0x9041b['status'](_0x2b0b9e);return _0x9041b['set']('Content-Range',_0x4e0299+'-'+_0x3b0d15+'/'+_0xad00b6)[_0xe8c2('0x7')](_0x1600c6);}return null;};}function saveUpdates(_0x487dbc){return function(_0x58dec0){if(_0x58dec0){return _0x58dec0[_0xe8c2('0xc')](_0x487dbc)[_0xe8c2('0xd')](function(_0x29183e){return _0x29183e;});}return null;};}function removeEntity(_0x11bb41){return function(_0x4f4644){if(_0x4f4644){return _0x4f4644[_0xe8c2('0xe')]()[_0xe8c2('0xd')](function(){_0x11bb41[_0xe8c2('0xf')](0xcc)[_0xe8c2('0x10')]();});}};}function handleEntityNotFound(_0xa7bdc){return function(_0x41847e){if(!_0x41847e){_0xa7bdc[_0xe8c2('0x11')](0x194);}return _0x41847e;};}function handleError(_0x334767,_0x47d4e7){_0x47d4e7=_0x47d4e7||0x1f4;return function(_0x5aaf80){logger[_0xe8c2('0x12')](_0x5aaf80['stack']);if(_0x5aaf80['name']){delete _0x5aaf80[_0xe8c2('0x13')];}_0x334767[_0xe8c2('0xf')](_0x47d4e7)['send'](_0x5aaf80);};}exports[_0xe8c2('0x14')]=function(_0x219190,_0x4fed86){var _0x85abc5={},_0x2e8da9={},_0xa1bf={'count':0x0,'rows':[]};var _0xbdca93=_[_0xe8c2('0x15')](db[_0xe8c2('0x16')][_0xe8c2('0x17')],function(_0x122a09){return{'name':_0x122a09['fieldName'],'type':_0x122a09[_0xe8c2('0x18')][_0xe8c2('0x19')]};});_0x2e8da9[_0xe8c2('0x1a')]=_[_0xe8c2('0x15')](_0xbdca93,_0xe8c2('0x13'));_0x2e8da9[_0xe8c2('0x1b')]=_[_0xe8c2('0x1c')](_0x219190['query']);_0x2e8da9[_0xe8c2('0x1d')]=_[_0xe8c2('0x1e')](_0x2e8da9[_0xe8c2('0x1a')],_0x2e8da9['query']);_0x85abc5[_0xe8c2('0x1f')]=_['intersection'](_0x2e8da9[_0xe8c2('0x1a')],qs[_0xe8c2('0x20')](_0x219190[_0xe8c2('0x1b')][_0xe8c2('0x20')]));_0x85abc5[_0xe8c2('0x1f')]=_0x85abc5['attributes'][_0xe8c2('0x21')]?_0x85abc5[_0xe8c2('0x1f')]:_0x2e8da9[_0xe8c2('0x1a')];if(!_0x219190[_0xe8c2('0x1b')][_0xe8c2('0x22')](_0xe8c2('0x23'))){_0x85abc5[_0xe8c2('0xa')]=qs['limit'](_0x219190[_0xe8c2('0x1b')][_0xe8c2('0xa')]);_0x85abc5[_0xe8c2('0x8')]=qs[_0xe8c2('0x8')](_0x219190['query']['offset']);}_0x85abc5['order']=qs[_0xe8c2('0x24')](_0x219190[_0xe8c2('0x1b')][_0xe8c2('0x24')]);_0x85abc5[_0xe8c2('0x25')]=qs['filters'](_['pick'](_0x219190[_0xe8c2('0x1b')],_0x2e8da9[_0xe8c2('0x1d')]),_0xbdca93);if(_0x219190[_0xe8c2('0x1b')][_0xe8c2('0x26')]){_0x85abc5[_0xe8c2('0x25')]=_[_0xe8c2('0x27')](_0x85abc5['where'],{'$or':_[_0xe8c2('0x15')](_0xbdca93,function(_0x287e27){if(_0x287e27[_0xe8c2('0x18')]!==_0xe8c2('0x28')){var _0x128d43={};_0x128d43[_0x287e27[_0xe8c2('0x13')]]={'$like':'%'+_0x219190[_0xe8c2('0x1b')][_0xe8c2('0x26')]+'%'};return _0x128d43;}})});}_0x85abc5=_['merge']({},_0x85abc5,_0x219190[_0xe8c2('0x29')]);var _0x7271cc={'where':_0x85abc5[_0xe8c2('0x25')]};return db['Dynamics365Account'][_0xe8c2('0xb')](_0x7271cc)[_0xe8c2('0xd')](function(_0x5aae4a){_0xa1bf[_0xe8c2('0xb')]=_0x5aae4a;if(_0x219190['query'][_0xe8c2('0x2a')]){_0x85abc5['include']=[{'all':!![]}];}return db[_0xe8c2('0x16')][_0xe8c2('0x2b')](_0x85abc5);})[_0xe8c2('0xd')](function(_0x279f3f){_0xa1bf[_0xe8c2('0x2c')]=_0x279f3f;return _0xa1bf;})[_0xe8c2('0xd')](respondWithFilteredResult(_0x4fed86,_0x85abc5))['catch'](handleError(_0x4fed86,null));};exports[_0xe8c2('0x2d')]=function(_0x48d41b,_0x3e0b48){var _0x32e050={'raw':![],'where':{'id':_0x48d41b[_0xe8c2('0x2e')]['id']}},_0x2baaf8={};_0x2baaf8[_0xe8c2('0x1a')]=_['keys'](db[_0xe8c2('0x16')][_0xe8c2('0x17')]);_0x2baaf8[_0xe8c2('0x1b')]=_[_0xe8c2('0x1c')](_0x48d41b['query']);_0x2baaf8['filters']=_[_0xe8c2('0x1e')](_0x2baaf8[_0xe8c2('0x1a')],_0x2baaf8[_0xe8c2('0x1b')]);_0x32e050[_0xe8c2('0x1f')]=_[_0xe8c2('0x1e')](_0x2baaf8['model'],qs[_0xe8c2('0x20')](_0x48d41b['query'][_0xe8c2('0x20')]));_0x32e050[_0xe8c2('0x1f')]=_0x32e050['attributes'][_0xe8c2('0x21')]?_0x32e050[_0xe8c2('0x1f')]:_0x2baaf8[_0xe8c2('0x1a')];if(_0x48d41b[_0xe8c2('0x1b')][_0xe8c2('0x2a')]){_0x32e050[_0xe8c2('0x2f')]=[{'all':!![]}];}_0x32e050=_[_0xe8c2('0x27')]({},_0x32e050,_0x48d41b[_0xe8c2('0x29')]);return db[_0xe8c2('0x16')]['find'](_0x32e050)['then'](handleEntityNotFound(_0x3e0b48,null))[_0xe8c2('0xd')](respondWithResult(_0x3e0b48,null))['catch'](handleError(_0x3e0b48,null));};exports[_0xe8c2('0x30')]=function(_0x42d743,_0x5b0151){return db[_0xe8c2('0x16')][_0xe8c2('0x30')](_0x42d743['body'],{})[_0xe8c2('0xd')](respondWithResult(_0x5b0151,0xc9))[_0xe8c2('0x31')](handleError(_0x5b0151,null));};exports[_0xe8c2('0xc')]=function(_0x244499,_0x478c7c){if(_0x244499[_0xe8c2('0x32')]['id']){delete _0x244499[_0xe8c2('0x32')]['id'];}return db[_0xe8c2('0x16')][_0xe8c2('0x33')]({'where':{'id':_0x244499['params']['id']}})[_0xe8c2('0xd')](handleEntityNotFound(_0x478c7c,null))[_0xe8c2('0xd')](saveUpdates(_0x244499['body'],null))[_0xe8c2('0xd')](respondWithResult(_0x478c7c,null))['catch'](handleError(_0x478c7c,null));};exports[_0xe8c2('0xe')]=function(_0x2811d7,_0x157980){return db[_0xe8c2('0x16')][_0xe8c2('0x33')]({'where':{'id':_0x2811d7[_0xe8c2('0x2e')]['id']}})[_0xe8c2('0xd')](handleEntityNotFound(_0x157980,null))['then'](removeEntity(_0x157980,null))[_0xe8c2('0x31')](handleError(_0x157980,null));};exports[_0xe8c2('0x34')]=function(_0x1e0a54,_0x30f133){var _0xad0b72={};var _0xce0c0b={};var _0x666202;var _0x4be222;return db[_0xe8c2('0x16')][_0xe8c2('0x35')]({'where':{'id':_0x1e0a54[_0xe8c2('0x2e')]['id']}})[_0xe8c2('0xd')](handleEntityNotFound(_0x30f133,null))['then'](function(_0x52d1fb){if(_0x52d1fb){_0x666202=_0x52d1fb;_0xce0c0b[_0xe8c2('0x1a')]=_[_0xe8c2('0x1c')](db[_0xe8c2('0x36')][_0xe8c2('0x17')]);_0xce0c0b[_0xe8c2('0x1b')]=_[_0xe8c2('0x1c')](_0x1e0a54['query']);_0xce0c0b[_0xe8c2('0x1d')]=_[_0xe8c2('0x1e')](_0xce0c0b[_0xe8c2('0x1a')],_0xce0c0b[_0xe8c2('0x1b')]);_0xad0b72['attributes']=_[_0xe8c2('0x1e')](_0xce0c0b[_0xe8c2('0x1a')],qs['fields'](_0x1e0a54[_0xe8c2('0x1b')][_0xe8c2('0x20')]));_0xad0b72[_0xe8c2('0x1f')]=_0xad0b72[_0xe8c2('0x1f')]['length']?_0xad0b72['attributes']:_0xce0c0b[_0xe8c2('0x1a')];_0xad0b72[_0xe8c2('0x37')]=qs[_0xe8c2('0x24')](_0x1e0a54['query']['sort']);_0xad0b72['where']=qs[_0xe8c2('0x1d')](_[_0xe8c2('0x38')](_0x1e0a54['query'],_0xce0c0b[_0xe8c2('0x1d')]));if(_0x1e0a54[_0xe8c2('0x1b')][_0xe8c2('0x26')]){_0xad0b72[_0xe8c2('0x25')]=_[_0xe8c2('0x27')](_0xad0b72[_0xe8c2('0x25')],{'$or':_[_0xe8c2('0x15')](_0xad0b72['attributes'],function(_0x2aa590){var _0xe7e69d={};_0xe7e69d[_0x2aa590]={'$like':'%'+_0x1e0a54[_0xe8c2('0x1b')][_0xe8c2('0x26')]+'%'};return _0xe7e69d;})});}_0xad0b72=_['merge']({},_0xad0b72,_0x1e0a54['options']);return _0x666202[_0xe8c2('0x34')](_0xad0b72);}})[_0xe8c2('0xd')](function(_0x1c7a75){if(_0x1c7a75){_0x4be222=_0x1c7a75[_0xe8c2('0x21')];if(!_0x1e0a54['query'][_0xe8c2('0x22')]('nolimit')){_0xad0b72[_0xe8c2('0xa')]=qs[_0xe8c2('0xa')](_0x1e0a54[_0xe8c2('0x1b')]['limit']);_0xad0b72[_0xe8c2('0x8')]=qs[_0xe8c2('0x8')](_0x1e0a54[_0xe8c2('0x1b')][_0xe8c2('0x8')]);}return _0x666202['getConfigurations'](_0xad0b72);}})[_0xe8c2('0xd')](function(_0x6515a1){if(_0x6515a1){return _0x6515a1?{'count':_0x4be222,'rows':_0x6515a1}:null;}})[_0xe8c2('0xd')](respondWithResult(_0x30f133,null))[_0xe8c2('0x31')](handleError(_0x30f133,null));};exports[_0xe8c2('0x39')]=function(_0x1fdddd,_0x4cf4ba){if(_0x1fdddd[_0xe8c2('0x32')]['id']){delete _0x1fdddd[_0xe8c2('0x32')]['id'];}return db['Dynamics365Account']['findOne']({'where':{'id':_0x1fdddd[_0xe8c2('0x2e')]['id']}})[_0xe8c2('0xd')](handleEntityNotFound(_0x4cf4ba,null))['then'](function(_0xe55beb){if(_0xe55beb){_0x1fdddd[_0xe8c2('0x32')][_0xe8c2('0x3a')]=_0xe55beb['id'];_0x1fdddd[_0xe8c2('0x32')][_0xe8c2('0x3b')]=integrations[_0xe8c2('0x3c')](_0x1fdddd[_0xe8c2('0x32')][_0xe8c2('0x3d')],_0x1fdddd[_0xe8c2('0x32')][_0xe8c2('0x18')]);_0x1fdddd[_0xe8c2('0x32')]['Descriptions']=integrations[_0xe8c2('0x3e')](_0x1fdddd[_0xe8c2('0x32')][_0xe8c2('0x3d')],_0x1fdddd['body']['type']);return db[_0xe8c2('0x36')][_0xe8c2('0x30')](_0x1fdddd['body'],{'include':[{'model':db[_0xe8c2('0x3f')],'as':_0xe8c2('0x3b')},{'model':db[_0xe8c2('0x3f')],'as':_0xe8c2('0x40')}]});}return null;})[_0xe8c2('0xd')](respondWithResult(_0x4cf4ba,null))[_0xe8c2('0x31')](handleError(_0x4cf4ba,null));};function sanitizeRemoteUri(_0x16099d){var _0xf3a96a=_0x16099d[_0xe8c2('0x41')](-0x1);if(_0xf3a96a==='/')return _0x16099d[_0xe8c2('0x42')](0x0,_0x16099d[_0xe8c2('0x43')](_0xf3a96a));return _0x16099d;}function getWebApiUrl(_0x46877e){return util[_0xe8c2('0x44')](_0xe8c2('0x45'),_0x46877e);}exports[_0xe8c2('0x46')]=function(_0x31a75f,_0x555b8e){var _0x2e8343=_0x31a75f[_0xe8c2('0x1b')][_0xe8c2('0x47')];var _0x4da3d8=_0x2e8343===_0xe8c2('0x48')?'Incident':_0xe8c2('0x49');var _0x4cac98='';var _0x3cf982='';var _0xfafdc3='';var _0x266201='';var _0x284603='';var _0xd2964c='';var _0x52d15e='';var _0x139f05='';var _0x2fcbb5=[_0xe8c2('0x4a'),_0xe8c2('0x4b'),_0xe8c2('0x4c'),'ownerid',_0xe8c2('0x4d'),_0xe8c2('0x4e'),'phonenumber',_0xe8c2('0x4f'),_0xe8c2('0x50'),'phonecall_activity_parties'];var _0x182e6c=[_0xe8c2('0x51'),_0xe8c2('0x52'),_0xe8c2('0x53'),_0xe8c2('0x54'),_0xe8c2('0x55'),_0xe8c2('0x56'),_0xe8c2('0x57'),_0xe8c2('0x58'),_0xe8c2('0x59'),_0xe8c2('0x5a'),_0xe8c2('0x5b'),_0xe8c2('0x5c'),_0xe8c2('0x5d'),_0xe8c2('0x5e'),'createdonbehalfbyyominame','customeridname',_0xe8c2('0x5f'),'customeridyominame',_0xe8c2('0x60'),_0xe8c2('0x61'),_0xe8c2('0x62'),_0xe8c2('0x63'),_0xe8c2('0x64'),_0xe8c2('0x65'),_0xe8c2('0x66'),_0xe8c2('0x67'),_0xe8c2('0x68'),_0xe8c2('0x69'),_0xe8c2('0x6a'),_0xe8c2('0x6b'),_0xe8c2('0x6c'),_0xe8c2('0x6d'),'modifiedbyexternalpartyyominame','modifiedbyname',_0xe8c2('0x6e'),_0xe8c2('0x6f'),_0xe8c2('0x70'),_0xe8c2('0x71'),'msdyn_incidenttypename',_0xe8c2('0x72'),_0xe8c2('0x73'),_0xe8c2('0x74'),'overriddencreatedon',_0xe8c2('0x75'),_0xe8c2('0x76'),'owneridyominame',_0xe8c2('0x77'),'primarycontactidname',_0xe8c2('0x78'),_0xe8c2('0x79'),_0xe8c2('0x7a'),_0xe8c2('0x7b'),_0xe8c2('0x7c'),_0xe8c2('0x7d'),_0xe8c2('0x7e'),_0xe8c2('0x7f'),_0xe8c2('0x80'),_0xe8c2('0x81'),_0xe8c2('0x82'),_0xe8c2('0x83'),_0xe8c2('0x84'),'statecode',_0xe8c2('0x85'),_0xe8c2('0x86'),_0xe8c2('0x87'),'timezoneruleversionnumber',_0xe8c2('0x88'),_0xe8c2('0x89'),_0xe8c2('0x8a'),_0xe8c2('0x8b')];var _0x396029=_0x2fcbb5[_0xe8c2('0x8c')](_0x182e6c);return db[_0xe8c2('0x16')][_0xe8c2('0x35')]({'where':{'id':_0x31a75f[_0xe8c2('0x2e')]['id']},'attributes':['id',_0xe8c2('0x8d'),_0xe8c2('0x8e'),_0xe8c2('0x8f'),'tenantId',_0xe8c2('0x90'),'clientSecret','modernAuthentication'],'include':[{'model':db[_0xe8c2('0x91')],'as':_0xe8c2('0x91'),'attributes':['id',_0xe8c2('0x92'),_0xe8c2('0x93')]}]})[_0xe8c2('0xd')](handleEntityNotFound(_0x555b8e,null))[_0xe8c2('0xd')](function(_0xf035dd){if(_0xf035dd){if(_0xf035dd[_0xe8c2('0x94')]){_0xf035dd[_0xe8c2('0x95')]=_0xf035dd[_0xe8c2('0x91')][_0xe8c2('0x92')];_0x139f05=sanitizeRemoteUri(_0xf035dd[_0xe8c2('0x91')]['data7']);_0x52d15e=getWebApiUrl(_0x139f05);return _0xf035dd;}_0x139f05=sanitizeRemoteUri(_0xf035dd[_0xe8c2('0x8f')]);_0x52d15e=getWebApiUrl(_0x139f05);var _0xb9b70a={'method':'POST','uri':_0xe8c2('0x96')+_0xf035dd['tenantId']+_0xe8c2('0x97'),'form':{'client_id':_0xf035dd[_0xe8c2('0x90')],'resource':_0x139f05,'username':_0xf035dd[_0xe8c2('0x8d')],'password':_0xf035dd[_0xe8c2('0x8e')],'grant_type':_0xe8c2('0x8e'),'client_secret':_0xf035dd[_0xe8c2('0x98')]},'json':!![]};return rp(_0xb9b70a);}})[_0xe8c2('0xd')](function(_0x17571f){_0xd2964c=_0x17571f['access_token'];var _0x3f2bab={'method':'GET','uri':encodeURI(_0x52d15e+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x4da3d8+'\x27'),'headers':{'Authorization':_0xe8c2('0x99')+_0xd2964c,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x3f2bab);})[_0xe8c2('0xd')](function(_0xdaf81){var _0x54a3d9=_0xdaf81['value'][0x0];var _0x23244c=_0x54a3d9['MetadataId'];var _0x510717={'method':'GET','uri':_0x52d15e+'EntityDefinitions('+_0x23244c+_0xe8c2('0x9a'),'headers':{'Authorization':_0xe8c2('0x99')+_0xd2964c,'If-None-Match':null,'OData-Version':_0xe8c2('0x9b')},'json':!![]};return rp(_0x510717);})[_0xe8c2('0xd')](function(_0x22ac49){_0x4cac98=_0x22ac49;_0x3cf982=_0x4cac98['Attributes'];_0x3cf982=_['remove'](_0x3cf982,function(_0x17de7e){return!_0x396029[_0xe8c2('0x9c')](_0x17de7e[_0xe8c2('0x9d')]);});var _0x86ce=[];var _0xb7dfb9=[];_0x3cf982[_0xe8c2('0x9e')](function(_0x8f0914){if(_0x8f0914[_0xe8c2('0x9f')]){var _0x49d4b9=_0x8f0914[_0xe8c2('0x9f')]['substring'](_0x8f0914[_0xe8c2('0x9f')][_0xe8c2('0x43')]('.')+0x1);if(_0x49d4b9===_0xe8c2('0xa0')){_0x86ce[_0xe8c2('0xa1')](getSelectList(_0x52d15e,_0x2e8343,_0xb7dfb9,_0x4cac98[_0xe8c2('0xa2')],_0x8f0914[_0xe8c2('0xa2')],_0xd2964c));}}});return Promise[_0xe8c2('0xa3')](_0x86ce);})['then'](function(_0x4220ea){_0xfafdc3=_0x4220ea[0x0];var _0x45706f=[];var _0x1bda30=[];_0x3cf982[_0xe8c2('0x9e')](function(_0x506217){if(!_[_0xe8c2('0xa4')](_0x506217['@odata.type'])){var _0xf3ebd1=_0x506217[_0xe8c2('0x9f')][_0xe8c2('0x42')](_0x506217[_0xe8c2('0x9f')][_0xe8c2('0x43')]('.')+0x1);if(_0xf3ebd1===_0xe8c2('0xa5')){_0x45706f[_0xe8c2('0xa1')](getBooleanList(_0x52d15e,_0x2e8343,_0x1bda30,_0x4cac98[_0xe8c2('0xa2')],_0x506217[_0xe8c2('0xa2')],_0xd2964c));}}});return Promise['all'](_0x45706f);})[_0xe8c2('0xd')](function(_0xf318e3){_0x266201=_0xf318e3[0x0];var _0x2b46d0=[];var _0x385669=[];_0x3cf982[_0xe8c2('0x9e')](function(_0x30a4f0){if(_0x30a4f0[_0xe8c2('0x9f')]){var _0x46cc5b=_0x30a4f0[_0xe8c2('0x9f')][_0xe8c2('0x42')](_0x30a4f0['@odata.type'][_0xe8c2('0x43')]('.')+0x1);if(_0x46cc5b===_0xe8c2('0xa6')||_0x46cc5b==='DoubleAttributeMetadata'||_0x46cc5b==='BigIntAttributeMetadata'||_0x46cc5b===_0xe8c2('0xa7')||_0x46cc5b===_0xe8c2('0xa8')||_0x46cc5b==='DateTimeAttributeMetadata'||_0x46cc5b===_0xe8c2('0xa9')||_0x46cc5b==='EntityNameAttributeMetadata'||_0x46cc5b===_0xe8c2('0xaa')||_0x46cc5b==='DecimalAttributeMetadata'){_0x2b46d0[_0xe8c2('0xa1')](getInputList(_0x52d15e,_0x2e8343,_0x46cc5b,_0x385669,_0x4cac98[_0xe8c2('0xa2')],_0x30a4f0[_0xe8c2('0xa2')],_0xd2964c));}}});return Promise[_0xe8c2('0xa3')](_0x2b46d0);})[_0xe8c2('0xd')](function(_0x4c2da7){_0x284603=_0x4c2da7[0x0];var _0x5f519c=_0xfafdc3['concat'](_0x266201)[_0xe8c2('0x8c')](_0x284603);var _0x5396ea={'count':_0x5f519c[_0xe8c2('0x21')],'rows':_0x5f519c};return _0x5396ea;})[_0xe8c2('0xd')](respondWithResult(_0x555b8e,null))[_0xe8c2('0x31')](function(_0x4fa0aa){var _0x4adbf6=_0x31a75f[_0xe8c2('0x1b')]['test']?0x1f4:_0x4fa0aa[_0xe8c2('0xab')]||0x1f4;logger[_0xe8c2('0x12')](_0x4fa0aa[_0xe8c2('0xac')]);delete _0x4fa0aa[_0xe8c2('0x13')];if(_0x4adbf6===0x191){_0x4adbf6=0x190;}_0x555b8e[_0xe8c2('0xf')](_0x4adbf6)[_0xe8c2('0xad')](_0x31a75f[_0xe8c2('0x1b')][_0xe8c2('0xae')]?{'message':_0xe8c2('0xaf'),'statusCode':_0x4fa0aa[_0xe8c2('0xab')]}:_0x4fa0aa);});};function getSelectList(_0x34a10c,_0x4f8ffc,_0x30be97,_0x38a342,_0x4fb191,_0x4b2580){var _0x4b73ed={'method':'GET','uri':_0x34a10c+'EntityDefinitions('+_0x38a342+_0xe8c2('0xb0')+_0x4fb191+_0xe8c2('0xb1')+_0xe8c2('0xb2'),'headers':{'Authorization':_0xe8c2('0x99')+_0x4b2580,'If-None-Match':null,'OData-Version':_0xe8c2('0x9b')},'json':!![]};return rp(_0x4b73ed)['then'](function(_0x4ff9ec){var _0x3d5ddb=[];var _0x284ed1=_0x4ff9ec[_0xe8c2('0xb3')][_0xe8c2('0xb4')];_0x284ed1[_0xe8c2('0x9e')](function(_0x27691c){_0x3d5ddb[_0xe8c2('0xa1')]({'name':_0x27691c['Label'][_0xe8c2('0xb5')]['Label'],'value':String(_0x27691c[_0xe8c2('0xb6')])});});var _0x9871e7={'id':_0x4f8ffc+'_'+_0x4ff9ec[_0xe8c2('0x9d')],'name':_0x4ff9ec[_0xe8c2('0xb7')][_0xe8c2('0xb5')]['Label'],'custom':![],'options':_0x3d5ddb};_0x30be97[_0xe8c2('0xa1')](_0x9871e7);return _0x30be97;});}function getBooleanList(_0x236829,_0xfd90a1,_0x4365f6,_0x3f76a9,_0x360a57,_0x6e9235){var _0x1d6656={'method':'GET','uri':_0x236829+_0xe8c2('0xb8')+_0x3f76a9+_0xe8c2('0xb0')+_0x360a57+_0xe8c2('0xb9'),'headers':{'Authorization':_0xe8c2('0x99')+_0x6e9235,'If-None-Match':null,'OData-Version':_0xe8c2('0x9b')},'json':!![]};return rp(_0x1d6656)[_0xe8c2('0xd')](function(_0x27b21d){var _0x1a9a4b=[];_0x1a9a4b[_0xe8c2('0xa1')]({'name':_0x27b21d[_0xe8c2('0xb3')][_0xe8c2('0xba')][_0xe8c2('0xbb')][_0xe8c2('0xb5')][_0xe8c2('0xbb')],'value':_0xe8c2('0xbc')},{'name':_0x27b21d['OptionSet'][_0xe8c2('0xbd')][_0xe8c2('0xbb')][_0xe8c2('0xb5')][_0xe8c2('0xbb')],'value':'false'});var _0x421546={'id':_0xfd90a1+'_'+_0x27b21d[_0xe8c2('0x9d')],'name':_0x27b21d[_0xe8c2('0xb7')][_0xe8c2('0xb5')]['Label'],'custom':![],'options':_0x1a9a4b};_0x4365f6['push'](_0x421546);return _0x4365f6;});}function getInputList(_0x5d762a,_0x4f81a6,_0x5a4db7,_0x453362,_0x4df406,_0x4ed585,_0x5b42e9){var _0x134f02={'method':_0xe8c2('0xbe'),'uri':_0x5d762a+'EntityDefinitions('+_0x4df406+_0xe8c2('0xb0')+_0x4ed585+')/Microsoft.Dynamics.CRM.'+_0x5a4db7+_0xe8c2('0xbf'),'headers':{'Authorization':_0xe8c2('0x99')+_0x5b42e9,'If-None-Match':null,'OData-Version':_0xe8c2('0x9b')},'json':!![]};return rp(_0x134f02)[_0xe8c2('0xd')](function(_0x1b82b8){var _0x2d5fff={'id':_0x4f81a6+'_'+_0x1b82b8[_0xe8c2('0x9d')],'name':_0x1b82b8['DisplayName']['UserLocalizedLabel']?_0x1b82b8[_0xe8c2('0xb7')]['UserLocalizedLabel']['Label']:_0x1b82b8[_0xe8c2('0x9d')],'custom':![],'options':[]};_0x453362[_0xe8c2('0xa1')](_0x2d5fff);return _0x453362;});}
\ No newline at end of file