Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 3f12ca1..dd71bf8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf482=['remoteUri','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data5','data7','POST','https://login.microsoftonline.com/','/oauth2/token','access_token','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','4.0','value','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Bearer\x20','Attributes','remove','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','MetadataId','all','isNil','push','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test',')/Attributes(','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','UserLocalizedLabel','FalseOption','false','DisplayName','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','api','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','limit','Content-Range','update','then','end','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','length','nolimit','order','sort','where','VIRTUAL','merge','options','Dynamics365Account','count','includeAll','include','findAll','catch','show','params','fields','find','create','body','destroy','pick','filter','getConfigurations','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','Incident','PhoneCall','description','ownerid','caseorigincode','subject','phonecall_activity_parties','accountidname','accountidyominame','billedserviceunits','contactidname','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyyominame','createdon','createdonbehalfbyname','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','firstresponsebykpiidname','importsequencenumber','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','owneridname','owneridtype','owneridyominame','primarycontactidyominame','productidname','productserialnumber','resolveby','responseby','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','findOne','username','password'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0xf482,0xe4));var _0x2f48=function(_0x3f0228,_0x102e3f){_0x3f0228=_0x3f0228-0x0;var _0x848b65=_0xf482[_0x3f0228];return _0x848b65;};'use strict';var rp=require(_0x2f48('0x0'));var util=require(_0x2f48('0x1'));var _=require(_0x2f48('0x2'));var qs=require(_0x2f48('0x3'));var logger=require(_0x2f48('0x4'))(_0x2f48('0x5'));var db=require(_0x2f48('0x6'))['db'];var integrations=require(_0x2f48('0x7'));function respondWithResult(_0x975618,_0x52973f){_0x52973f=_0x52973f||0xc8;return function(_0xdcbbdb){if(_0xdcbbdb){return _0x975618[_0x2f48('0x8')](_0x52973f)[_0x2f48('0x9')](_0xdcbbdb);}};}function respondWithFilteredResult(_0x4dd869,_0x44bd3b){return function(_0x4f72ce){if(_0x4f72ce){var _0x34cb0a=typeof _0x44bd3b[_0x2f48('0xa')]===_0x2f48('0xb')&&typeof _0x44bd3b[_0x2f48('0xc')]===_0x2f48('0xb');var _0x1dce31=_0x4f72ce['count'];var _0x2c725a=_0x34cb0a?0x0:_0x44bd3b[_0x2f48('0xa')];var _0x154c78=_0x34cb0a?_0x4f72ce['count']:_0x44bd3b[_0x2f48('0xa')]+_0x44bd3b['limit'];var _0x396078;if(_0x154c78>=_0x1dce31){_0x154c78=_0x1dce31;_0x396078=0xc8;}else{_0x396078=0xce;}_0x4dd869[_0x2f48('0x8')](_0x396078);return _0x4dd869['set'](_0x2f48('0xd'),_0x2c725a+'-'+_0x154c78+'/'+_0x1dce31)[_0x2f48('0x9')](_0x4f72ce);}return null;};}function saveUpdates(_0x51b141){return function(_0x155482){if(_0x155482){return _0x155482[_0x2f48('0xe')](_0x51b141)[_0x2f48('0xf')](function(_0x160fb8){return _0x160fb8;});}return null;};}function removeEntity(_0x3c2ba9){return function(_0x40649b){if(_0x40649b){return _0x40649b['destroy']()[_0x2f48('0xf')](function(){_0x3c2ba9[_0x2f48('0x8')](0xcc)[_0x2f48('0x10')]();});}};}function handleEntityNotFound(_0x4c2f15){return function(_0x4b11cf){if(!_0x4b11cf){_0x4c2f15['sendStatus'](0x194);}return _0x4b11cf;};}function handleError(_0x13a511,_0x3adca1){_0x3adca1=_0x3adca1||0x1f4;return function(_0x42b69b){logger[_0x2f48('0x11')](_0x42b69b[_0x2f48('0x12')]);if(_0x42b69b[_0x2f48('0x13')]){delete _0x42b69b[_0x2f48('0x13')];}_0x13a511['status'](_0x3adca1)[_0x2f48('0x14')](_0x42b69b);};}exports['index']=function(_0x3386ae,_0x2f424c){var _0x48b068={},_0x1601be={},_0x40f4c7={'count':0x0,'rows':[]};var _0x52b1e0=_[_0x2f48('0x15')](db['Dynamics365Account'][_0x2f48('0x16')],function(_0x331a40){return{'name':_0x331a40[_0x2f48('0x17')],'type':_0x331a40[_0x2f48('0x18')][_0x2f48('0x19')]};});_0x1601be[_0x2f48('0x1a')]=_[_0x2f48('0x15')](_0x52b1e0,_0x2f48('0x13'));_0x1601be[_0x2f48('0x1b')]=_[_0x2f48('0x1c')](_0x3386ae[_0x2f48('0x1b')]);_0x1601be[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x1601be[_0x2f48('0x1a')],_0x1601be[_0x2f48('0x1b')]);_0x48b068[_0x2f48('0x1f')]=_[_0x2f48('0x1e')](_0x1601be[_0x2f48('0x1a')],qs['fields'](_0x3386ae[_0x2f48('0x1b')]['fields']));_0x48b068['attributes']=_0x48b068['attributes'][_0x2f48('0x20')]?_0x48b068[_0x2f48('0x1f')]:_0x1601be[_0x2f48('0x1a')];if(!_0x3386ae[_0x2f48('0x1b')]['hasOwnProperty'](_0x2f48('0x21'))){_0x48b068['limit']=qs[_0x2f48('0xc')](_0x3386ae['query'][_0x2f48('0xc')]);_0x48b068[_0x2f48('0xa')]=qs[_0x2f48('0xa')](_0x3386ae[_0x2f48('0x1b')][_0x2f48('0xa')]);}_0x48b068[_0x2f48('0x22')]=qs[_0x2f48('0x23')](_0x3386ae[_0x2f48('0x1b')][_0x2f48('0x23')]);_0x48b068[_0x2f48('0x24')]=qs[_0x2f48('0x1d')](_['pick'](_0x3386ae[_0x2f48('0x1b')],_0x1601be[_0x2f48('0x1d')]),_0x52b1e0);if(_0x3386ae['query']['filter']){_0x48b068[_0x2f48('0x24')]=_['merge'](_0x48b068[_0x2f48('0x24')],{'$or':_['map'](_0x52b1e0,function(_0x2071cb){if(_0x2071cb[_0x2f48('0x18')]!==_0x2f48('0x25')){var _0x53c7da={};_0x53c7da[_0x2071cb[_0x2f48('0x13')]]={'$like':'%'+_0x3386ae[_0x2f48('0x1b')]['filter']+'%'};return _0x53c7da;}})});}_0x48b068=_[_0x2f48('0x26')]({},_0x48b068,_0x3386ae[_0x2f48('0x27')]);var _0x3cd7e8={'where':_0x48b068[_0x2f48('0x24')]};return db[_0x2f48('0x28')][_0x2f48('0x29')](_0x3cd7e8)[_0x2f48('0xf')](function(_0x32d299){_0x40f4c7[_0x2f48('0x29')]=_0x32d299;if(_0x3386ae[_0x2f48('0x1b')][_0x2f48('0x2a')]){_0x48b068[_0x2f48('0x2b')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x2f48('0x2c')](_0x48b068);})[_0x2f48('0xf')](function(_0x257818){_0x40f4c7['rows']=_0x257818;return _0x40f4c7;})[_0x2f48('0xf')](respondWithFilteredResult(_0x2f424c,_0x48b068))[_0x2f48('0x2d')](handleError(_0x2f424c,null));};exports[_0x2f48('0x2e')]=function(_0x84818c,_0x5b98c9){var _0x35cadd={'raw':![],'where':{'id':_0x84818c[_0x2f48('0x2f')]['id']}},_0x52669b={};_0x52669b[_0x2f48('0x1a')]=_[_0x2f48('0x1c')](db['Dynamics365Account'][_0x2f48('0x16')]);_0x52669b['query']=_[_0x2f48('0x1c')](_0x84818c[_0x2f48('0x1b')]);_0x52669b[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x52669b[_0x2f48('0x1a')],_0x52669b[_0x2f48('0x1b')]);_0x35cadd[_0x2f48('0x1f')]=_[_0x2f48('0x1e')](_0x52669b[_0x2f48('0x1a')],qs[_0x2f48('0x30')](_0x84818c[_0x2f48('0x1b')][_0x2f48('0x30')]));_0x35cadd[_0x2f48('0x1f')]=_0x35cadd[_0x2f48('0x1f')]['length']?_0x35cadd[_0x2f48('0x1f')]:_0x52669b[_0x2f48('0x1a')];if(_0x84818c['query']['includeAll']){_0x35cadd[_0x2f48('0x2b')]=[{'all':!![]}];}_0x35cadd=_[_0x2f48('0x26')]({},_0x35cadd,_0x84818c[_0x2f48('0x27')]);return db[_0x2f48('0x28')][_0x2f48('0x31')](_0x35cadd)[_0x2f48('0xf')](handleEntityNotFound(_0x5b98c9,null))[_0x2f48('0xf')](respondWithResult(_0x5b98c9,null))['catch'](handleError(_0x5b98c9,null));};exports[_0x2f48('0x32')]=function(_0x151421,_0x10c7b8){return db[_0x2f48('0x28')][_0x2f48('0x32')](_0x151421['body'],{})[_0x2f48('0xf')](respondWithResult(_0x10c7b8,0xc9))[_0x2f48('0x2d')](handleError(_0x10c7b8,null));};exports[_0x2f48('0xe')]=function(_0x24becd,_0x3bca45){if(_0x24becd[_0x2f48('0x33')]['id']){delete _0x24becd[_0x2f48('0x33')]['id'];}return db[_0x2f48('0x28')][_0x2f48('0x31')]({'where':{'id':_0x24becd['params']['id']}})[_0x2f48('0xf')](handleEntityNotFound(_0x3bca45,null))[_0x2f48('0xf')](saveUpdates(_0x24becd[_0x2f48('0x33')],null))[_0x2f48('0xf')](respondWithResult(_0x3bca45,null))[_0x2f48('0x2d')](handleError(_0x3bca45,null));};exports[_0x2f48('0x34')]=function(_0x2aed38,_0x12d49a){return db[_0x2f48('0x28')][_0x2f48('0x31')]({'where':{'id':_0x2aed38[_0x2f48('0x2f')]['id']}})[_0x2f48('0xf')](handleEntityNotFound(_0x12d49a,null))[_0x2f48('0xf')](removeEntity(_0x12d49a,null))[_0x2f48('0x2d')](handleError(_0x12d49a,null));};exports['getConfigurations']=function(_0x5571aa,_0x1df93c){var _0x23b4ab={};var _0x4fe8e0={};var _0xcac0eb;var _0x32d0ab;return db['Dynamics365Account']['findOne']({'where':{'id':_0x5571aa['params']['id']}})['then'](handleEntityNotFound(_0x1df93c,null))[_0x2f48('0xf')](function(_0x442013){if(_0x442013){_0xcac0eb=_0x442013;_0x4fe8e0[_0x2f48('0x1a')]=_[_0x2f48('0x1c')](db['Dynamics365Configuration'][_0x2f48('0x16')]);_0x4fe8e0[_0x2f48('0x1b')]=_[_0x2f48('0x1c')](_0x5571aa['query']);_0x4fe8e0[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x4fe8e0[_0x2f48('0x1a')],_0x4fe8e0[_0x2f48('0x1b')]);_0x23b4ab['attributes']=_[_0x2f48('0x1e')](_0x4fe8e0[_0x2f48('0x1a')],qs[_0x2f48('0x30')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x30')]));_0x23b4ab[_0x2f48('0x1f')]=_0x23b4ab['attributes']['length']?_0x23b4ab[_0x2f48('0x1f')]:_0x4fe8e0[_0x2f48('0x1a')];_0x23b4ab[_0x2f48('0x22')]=qs[_0x2f48('0x23')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x23')]);_0x23b4ab[_0x2f48('0x24')]=qs[_0x2f48('0x1d')](_[_0x2f48('0x35')](_0x5571aa[_0x2f48('0x1b')],_0x4fe8e0[_0x2f48('0x1d')]));if(_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x36')]){_0x23b4ab['where']=_[_0x2f48('0x26')](_0x23b4ab['where'],{'$or':_[_0x2f48('0x15')](_0x23b4ab['attributes'],function(_0x10412){var _0x1ad537={};_0x1ad537[_0x10412]={'$like':'%'+_0x5571aa['query'][_0x2f48('0x36')]+'%'};return _0x1ad537;})});}_0x23b4ab=_[_0x2f48('0x26')]({},_0x23b4ab,_0x5571aa['options']);return _0xcac0eb[_0x2f48('0x37')](_0x23b4ab);}})['then'](function(_0x25c4d1){if(_0x25c4d1){_0x32d0ab=_0x25c4d1['length'];if(!_0x5571aa['query'][_0x2f48('0x38')](_0x2f48('0x21'))){_0x23b4ab[_0x2f48('0xc')]=qs[_0x2f48('0xc')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0xc')]);_0x23b4ab[_0x2f48('0xa')]=qs['offset'](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0xa')]);}return _0xcac0eb[_0x2f48('0x37')](_0x23b4ab);}})['then'](function(_0x15606e){if(_0x15606e){return _0x15606e?{'count':_0x32d0ab,'rows':_0x15606e}:null;}})[_0x2f48('0xf')](respondWithResult(_0x1df93c,null))[_0x2f48('0x2d')](handleError(_0x1df93c,null));};exports[_0x2f48('0x39')]=function(_0x509a66,_0x1eb32e){if(_0x509a66['body']['id']){delete _0x509a66['body']['id'];}return db[_0x2f48('0x28')]['findOne']({'where':{'id':_0x509a66['params']['id']}})['then'](handleEntityNotFound(_0x1eb32e,null))[_0x2f48('0xf')](function(_0x39fcd8){if(_0x39fcd8){_0x509a66[_0x2f48('0x33')][_0x2f48('0x3a')]=_0x39fcd8['id'];_0x509a66[_0x2f48('0x33')][_0x2f48('0x3b')]=integrations[_0x2f48('0x3c')](_0x509a66[_0x2f48('0x33')][_0x2f48('0x3d')],_0x509a66['body'][_0x2f48('0x18')]);_0x509a66[_0x2f48('0x33')]['Descriptions']=integrations[_0x2f48('0x3e')](_0x509a66[_0x2f48('0x33')][_0x2f48('0x3d')],_0x509a66[_0x2f48('0x33')][_0x2f48('0x18')]);return db['Dynamics365Configuration'][_0x2f48('0x32')](_0x509a66['body'],{'include':[{'model':db[_0x2f48('0x3f')],'as':_0x2f48('0x3b')},{'model':db[_0x2f48('0x3f')],'as':_0x2f48('0x40')}]});}return null;})[_0x2f48('0xf')](respondWithResult(_0x1eb32e,null))[_0x2f48('0x2d')](handleError(_0x1eb32e,null));};function sanitizeRemoteUri(_0x4c924a){var _0x350e1f=_0x4c924a[_0x2f48('0x41')](-0x1);if(_0x350e1f==='/')return _0x4c924a[_0x2f48('0x42')](0x0,_0x4c924a[_0x2f48('0x43')](_0x350e1f));return _0x4c924a;}function getWebApiUrl(_0x207dbd){return util[_0x2f48('0x44')](_0x2f48('0x45'),_0x207dbd);}exports[_0x2f48('0x46')]=function(_0x11d1d2,_0x4bb1ec){var _0x480b4f=_0x11d1d2['query'][_0x2f48('0x47')];var _0x47628e=_0x480b4f==='incident'?_0x2f48('0x48'):_0x2f48('0x49');var _0x557d26='';var _0x55ca59='';var _0x5629d6='';var _0x1abdf2='';var _0xcba5b6='';var _0x251dfa='';var _0x31b255='';var _0x51bc32='';var _0x457cd4=['title',_0x2f48('0x4a'),'customerid',_0x2f48('0x4b'),_0x2f48('0x4c'),_0x2f48('0x4d'),'phonenumber','regardingobjectid','directioncode',_0x2f48('0x4e')];var _0x3880bc=[_0x2f48('0x4f'),_0x2f48('0x50'),'actualserviceunits',_0x2f48('0x51'),_0x2f48('0x52'),'contactidyominame',_0x2f48('0x53'),_0x2f48('0x54'),_0x2f48('0x55'),_0x2f48('0x56'),'createdbyname',_0x2f48('0x57'),_0x2f48('0x58'),_0x2f48('0x59'),'createdonbehalfbyyominame','customeridname','customeridtype',_0x2f48('0x5a'),_0x2f48('0x5b'),_0x2f48('0x5c'),_0x2f48('0x5d'),_0x2f48('0x5e'),'escalatedon','exchangerate',_0x2f48('0x5f'),'followupby',_0x2f48('0x60'),'influencescore','kbarticleidname',_0x2f48('0x61'),_0x2f48('0x62'),_0x2f48('0x63'),_0x2f48('0x64'),_0x2f48('0x65'),_0x2f48('0x66'),'modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame',_0x2f48('0x67'),_0x2f48('0x68'),_0x2f48('0x69'),_0x2f48('0x6a'),'overriddencreatedon',_0x2f48('0x6b'),_0x2f48('0x6c'),_0x2f48('0x6d'),'parentcaseidname','primarycontactidname',_0x2f48('0x6e'),'prioritycodename',_0x2f48('0x6f'),_0x2f48('0x70'),_0x2f48('0x71'),'resolvebykpiidname',_0x2f48('0x72'),'responsiblecontactidname',_0x2f48('0x73'),_0x2f48('0x74'),_0x2f48('0x75'),_0x2f48('0x76'),_0x2f48('0x77'),_0x2f48('0x78'),_0x2f48('0x79'),'subjectidname',_0x2f48('0x7a'),_0x2f48('0x7b'),_0x2f48('0x7c'),_0x2f48('0x7d'),_0x2f48('0x7e'),_0x2f48('0x7f')];var _0x154e45=_0x457cd4[_0x2f48('0x80')](_0x3880bc);return db[_0x2f48('0x28')][_0x2f48('0x81')]({'where':{'id':_0x11d1d2[_0x2f48('0x2f')]['id']},'attributes':['id',_0x2f48('0x82'),_0x2f48('0x83'),_0x2f48('0x84'),_0x2f48('0x85'),_0x2f48('0x86'),_0x2f48('0x87'),_0x2f48('0x88')],'include':[{'model':db[_0x2f48('0x89')],'as':_0x2f48('0x89'),'attributes':['id',_0x2f48('0x8a'),_0x2f48('0x8b')]}]})[_0x2f48('0xf')](handleEntityNotFound(_0x4bb1ec,null))[_0x2f48('0xf')](function(_0x36b781){if(_0x36b781){if(_0x36b781[_0x2f48('0x88')]){_0x36b781['access_token']=_0x36b781[_0x2f48('0x89')][_0x2f48('0x8a')];_0x51bc32=sanitizeRemoteUri(_0x36b781[_0x2f48('0x89')][_0x2f48('0x8b')]);_0x31b255=getWebApiUrl(_0x51bc32);return _0x36b781;}_0x51bc32=sanitizeRemoteUri(_0x36b781['remoteUri']);_0x31b255=getWebApiUrl(_0x51bc32);var _0x357957={'method':_0x2f48('0x8c'),'uri':_0x2f48('0x8d')+_0x36b781[_0x2f48('0x85')]+_0x2f48('0x8e'),'form':{'client_id':_0x36b781['clientId'],'resource':_0x51bc32,'username':_0x36b781[_0x2f48('0x82')],'password':_0x36b781[_0x2f48('0x83')],'grant_type':_0x2f48('0x83'),'client_secret':_0x36b781[_0x2f48('0x87')]},'json':!![]};return rp(_0x357957);}})[_0x2f48('0xf')](function(_0x183698){_0x251dfa=_0x183698[_0x2f48('0x8f')];var _0x42def7={'method':_0x2f48('0x90'),'uri':encodeURI(_0x31b255+_0x2f48('0x91')+_0x47628e+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x251dfa,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0x42def7);})[_0x2f48('0xf')](function(_0x411294){var _0x4b90a8=_0x411294[_0x2f48('0x93')][0x0];var _0x4f2fce=_0x4b90a8['MetadataId'];var _0xdde592={'method':_0x2f48('0x90'),'uri':_0x31b255+_0x2f48('0x94')+_0x4f2fce+_0x2f48('0x95'),'headers':{'Authorization':_0x2f48('0x96')+_0x251dfa,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0xdde592);})[_0x2f48('0xf')](function(_0x20dd57){_0x557d26=_0x20dd57;_0x55ca59=_0x557d26[_0x2f48('0x97')];_0x55ca59=_[_0x2f48('0x98')](_0x55ca59,function(_0x3a23d9){return!_0x154e45['includes'](_0x3a23d9[_0x2f48('0x99')]);});var _0x1e3272=[];var _0x439c12=[];_0x55ca59[_0x2f48('0x9a')](function(_0x3a49f2){if(_0x3a49f2['@odata.type']){var _0x58f239=_0x3a49f2[_0x2f48('0x9b')][_0x2f48('0x42')](_0x3a49f2['@odata.type'][_0x2f48('0x43')]('.')+0x1);if(_0x58f239===_0x2f48('0x9c')){_0x1e3272['push'](getSelectList(_0x31b255,_0x480b4f,_0x439c12,_0x557d26[_0x2f48('0x9d')],_0x3a49f2['MetadataId'],_0x251dfa));}}});return Promise[_0x2f48('0x9e')](_0x1e3272);})[_0x2f48('0xf')](function(_0x5b1c11){_0x5629d6=_0x5b1c11[0x0];var _0x1d2b7c=[];var _0x55079a=[];_0x55ca59['forEach'](function(_0x35ab5e){if(!_[_0x2f48('0x9f')](_0x35ab5e['@odata.type'])){var _0x1f6ff3=_0x35ab5e['@odata.type']['substring'](_0x35ab5e['@odata.type'][_0x2f48('0x43')]('.')+0x1);if(_0x1f6ff3==='BooleanAttributeMetadata'){_0x1d2b7c[_0x2f48('0xa0')](getBooleanList(_0x31b255,_0x480b4f,_0x55079a,_0x557d26[_0x2f48('0x9d')],_0x35ab5e[_0x2f48('0x9d')],_0x251dfa));}}});return Promise['all'](_0x1d2b7c);})['then'](function(_0x574b1c){_0x1abdf2=_0x574b1c[0x0];var _0x58f517=[];var _0x58726a=[];_0x55ca59[_0x2f48('0x9a')](function(_0x1b02e4){if(_0x1b02e4[_0x2f48('0x9b')]){var _0x84c0a2=_0x1b02e4['@odata.type'][_0x2f48('0x42')](_0x1b02e4[_0x2f48('0x9b')]['lastIndexOf']('.')+0x1);if(_0x84c0a2===_0x2f48('0xa1')||_0x84c0a2==='DoubleAttributeMetadata'||_0x84c0a2===_0x2f48('0xa2')||_0x84c0a2===_0x2f48('0xa3')||_0x84c0a2===_0x2f48('0xa4')||_0x84c0a2==='DateTimeAttributeMetadata'||_0x84c0a2==='StatusAttributeMetadata'||_0x84c0a2===_0x2f48('0xa5')||_0x84c0a2===_0x2f48('0xa6')||_0x84c0a2===_0x2f48('0xa7')){_0x58f517['push'](getInputList(_0x31b255,_0x480b4f,_0x84c0a2,_0x58726a,_0x557d26[_0x2f48('0x9d')],_0x1b02e4[_0x2f48('0x9d')],_0x251dfa));}}});return Promise[_0x2f48('0x9e')](_0x58f517);})[_0x2f48('0xf')](function(_0x397d05){_0xcba5b6=_0x397d05[0x0];var _0x31d275=_0x5629d6[_0x2f48('0x80')](_0x1abdf2)[_0x2f48('0x80')](_0xcba5b6);var _0x73491a={'count':_0x31d275['length'],'rows':_0x31d275};return _0x73491a;})[_0x2f48('0xf')](respondWithResult(_0x4bb1ec,null))[_0x2f48('0x2d')](function(_0x248d46){var _0x58eb88=_0x11d1d2[_0x2f48('0x1b')][_0x2f48('0xa8')]?0x1f4:_0x248d46['statusCode']||0x1f4;logger[_0x2f48('0x11')](_0x248d46['stack']);delete _0x248d46['name'];if(_0x58eb88===0x191){_0x58eb88=0x190;}_0x4bb1ec[_0x2f48('0x8')](_0x58eb88)[_0x2f48('0x14')](_0x11d1d2['query'][_0x2f48('0xa8')]?{'message':'Wrong\x20credentials','statusCode':_0x248d46['statusCode']}:_0x248d46);});};function getSelectList(_0x5cf04a,_0x21adf9,_0x16c71b,_0x3ea445,_0x5bc483,_0x4dfbb6){var _0x5a1c54={'method':_0x2f48('0x90'),'uri':_0x5cf04a+_0x2f48('0x94')+_0x3ea445+_0x2f48('0xa9')+_0x5bc483+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+_0x2f48('0xaa'),'headers':{'Authorization':'Bearer\x20'+_0x4dfbb6,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x5a1c54)[_0x2f48('0xf')](function(_0x35bc4c){var _0x152491=[];var _0x53c9fc=_0x35bc4c[_0x2f48('0xab')][_0x2f48('0xac')];_0x53c9fc['forEach'](function(_0x21b6b3){_0x152491[_0x2f48('0xa0')]({'name':_0x21b6b3[_0x2f48('0xad')]['UserLocalizedLabel']['Label'],'value':String(_0x21b6b3['Value'])});});var _0x3f817e={'id':_0x21adf9+'_'+_0x35bc4c[_0x2f48('0x99')],'name':_0x35bc4c['DisplayName']['UserLocalizedLabel'][_0x2f48('0xad')],'custom':![],'options':_0x152491};_0x16c71b[_0x2f48('0xa0')](_0x3f817e);return _0x16c71b;});}function getBooleanList(_0x52a33a,_0x30ff0d,_0x1b4c15,_0x3cf15f,_0x488a8b,_0x4497b2){var _0x4371dd={'method':'GET','uri':_0x52a33a+_0x2f48('0x94')+_0x3cf15f+_0x2f48('0xa9')+_0x488a8b+_0x2f48('0xae'),'headers':{'Authorization':_0x2f48('0x96')+_0x4497b2,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x4371dd)[_0x2f48('0xf')](function(_0x216b05){var _0x7456ab=[];_0x7456ab[_0x2f48('0xa0')]({'name':_0x216b05[_0x2f48('0xab')]['TrueOption'][_0x2f48('0xad')][_0x2f48('0xaf')][_0x2f48('0xad')],'value':'true'},{'name':_0x216b05[_0x2f48('0xab')][_0x2f48('0xb0')][_0x2f48('0xad')][_0x2f48('0xaf')][_0x2f48('0xad')],'value':_0x2f48('0xb1')});var _0xa3860b={'id':_0x30ff0d+'_'+_0x216b05[_0x2f48('0x99')],'name':_0x216b05[_0x2f48('0xb2')][_0x2f48('0xaf')][_0x2f48('0xad')],'custom':![],'options':_0x7456ab};_0x1b4c15[_0x2f48('0xa0')](_0xa3860b);return _0x1b4c15;});}function getInputList(_0x12a84c,_0x2dc675,_0x48b8b4,_0x107209,_0x580466,_0x4d1f92,_0x537685){var _0x284b46={'method':_0x2f48('0x90'),'uri':_0x12a84c+_0x2f48('0x94')+_0x580466+_0x2f48('0xa9')+_0x4d1f92+')/Microsoft.Dynamics.CRM.'+_0x48b8b4+_0x2f48('0xb3'),'headers':{'Authorization':_0x2f48('0x96')+_0x537685,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0x284b46)[_0x2f48('0xf')](function(_0xa7d8da){var _0x4fa45={'id':_0x2dc675+'_'+_0xa7d8da[_0x2f48('0x99')],'name':_0xa7d8da['DisplayName'][_0x2f48('0xaf')]?_0xa7d8da[_0x2f48('0xb2')][_0x2f48('0xaf')][_0x2f48('0xad')]:_0xa7d8da[_0x2f48('0x99')],'custom':![],'options':[]};_0x107209['push'](_0x4fa45);return _0x107209;});}
\ No newline at end of file
+var _0x51a8=['utcconversiontimezonecode','versionnumber','concat','username','password','remoteUri','CloudProvider','data7','access_token','https://login.microsoftonline.com/','tenantId','/oauth2/token','clientId','clientSecret','value','MetadataId','GET','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Bearer\x20','4.0','Attributes','remove','includes','forEach','@odata.type','PicklistAttributeMetadata','push','all','isNil','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','StateAttributeMetadata','test','statusCode','send',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','OptionSet','Label','UserLocalizedLabel','Value','LogicalName','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','true','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','../../components/parsers/qs','api','../../components/integrations/configuration','status','offset','undefined','limit','count','set','Content-Range','json','update','then','destroy','end','sendStatus','error','stack','index','map','Dynamics365Account','rawAttributes','fieldName','type','model','name','query','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','keys','find','create','body','getConfigurations','findOne','pick','nolimit','addConfiguration','Subjects','getSubjects','channel','Descriptions','getDescriptions','Dynamics365Field','slice','substring','lastIndexOf','format','ticketType','incident','Incident','title','customerid','ownerid','caseorigincode','subject','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractidname','createdbyname','createdbyyominame','createdon','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','emailaddress','entitlementidname','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','resolveby','resolvebykpiidname','responseby','responsiblecontactidyominame','sentimentvalue','slainvokedidname','socialprofileidname','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath'];(function(_0x4c1b76,_0x2cdc2d){var _0x3ace6b=function(_0x40fac1){while(--_0x40fac1){_0x4c1b76['push'](_0x4c1b76['shift']());}};_0x3ace6b(++_0x2cdc2d);}(_0x51a8,0xec));var _0x851a=function(_0x2b677e,_0x5d6f61){_0x2b677e=_0x2b677e-0x0;var _0x115efc=_0x51a8[_0x2b677e];return _0x115efc;};'use strict';var rp=require(_0x851a('0x0'));var util=require(_0x851a('0x1'));var _=require('lodash');var qs=require(_0x851a('0x2'));var logger=require('../../config/logger')(_0x851a('0x3'));var db=require('../../mysqldb')['db'];var integrations=require(_0x851a('0x4'));function respondWithResult(_0x3fa2fa,_0x3e62cd){_0x3e62cd=_0x3e62cd||0xc8;return function(_0x284a2c){if(_0x284a2c){return _0x3fa2fa[_0x851a('0x5')](_0x3e62cd)['json'](_0x284a2c);}};}function respondWithFilteredResult(_0x317ead,_0x4775c2){return function(_0x233c96){if(_0x233c96){var _0x2814c6=typeof _0x4775c2[_0x851a('0x6')]===_0x851a('0x7')&&typeof _0x4775c2[_0x851a('0x8')]===_0x851a('0x7');var _0x1c6dd8=_0x233c96['count'];var _0x1e7d17=_0x2814c6?0x0:_0x4775c2[_0x851a('0x6')];var _0x4acfe9=_0x2814c6?_0x233c96[_0x851a('0x9')]:_0x4775c2[_0x851a('0x6')]+_0x4775c2[_0x851a('0x8')];var _0x322616;if(_0x4acfe9>=_0x1c6dd8){_0x4acfe9=_0x1c6dd8;_0x322616=0xc8;}else{_0x322616=0xce;}_0x317ead['status'](_0x322616);return _0x317ead[_0x851a('0xa')](_0x851a('0xb'),_0x1e7d17+'-'+_0x4acfe9+'/'+_0x1c6dd8)[_0x851a('0xc')](_0x233c96);}return null;};}function saveUpdates(_0x171db9){return function(_0x3ef339){if(_0x3ef339){return _0x3ef339[_0x851a('0xd')](_0x171db9)[_0x851a('0xe')](function(_0x25daa2){return _0x25daa2;});}return null;};}function removeEntity(_0x70496b){return function(_0x415cb4){if(_0x415cb4){return _0x415cb4[_0x851a('0xf')]()[_0x851a('0xe')](function(){_0x70496b[_0x851a('0x5')](0xcc)[_0x851a('0x10')]();});}};}function handleEntityNotFound(_0x3b4df8){return function(_0x1f3688){if(!_0x1f3688){_0x3b4df8[_0x851a('0x11')](0x194);}return _0x1f3688;};}function handleError(_0x23a3fc,_0x6c81f6){_0x6c81f6=_0x6c81f6||0x1f4;return function(_0x1a9141){logger[_0x851a('0x12')](_0x1a9141[_0x851a('0x13')]);if(_0x1a9141['name']){delete _0x1a9141['name'];}_0x23a3fc[_0x851a('0x5')](_0x6c81f6)['send'](_0x1a9141);};}exports[_0x851a('0x14')]=function(_0x4cb9a,_0x522e8f){var _0x21e65b={},_0x2fffb1={},_0x40ff8c={'count':0x0,'rows':[]};var _0x265bfc=_[_0x851a('0x15')](db[_0x851a('0x16')][_0x851a('0x17')],function(_0x185dbc){return{'name':_0x185dbc[_0x851a('0x18')],'type':_0x185dbc[_0x851a('0x19')]['key']};});_0x2fffb1[_0x851a('0x1a')]=_[_0x851a('0x15')](_0x265bfc,_0x851a('0x1b'));_0x2fffb1[_0x851a('0x1c')]=_['keys'](_0x4cb9a['query']);_0x2fffb1[_0x851a('0x1d')]=_['intersection'](_0x2fffb1[_0x851a('0x1a')],_0x2fffb1[_0x851a('0x1c')]);_0x21e65b[_0x851a('0x1e')]=_[_0x851a('0x1f')](_0x2fffb1['model'],qs['fields'](_0x4cb9a[_0x851a('0x1c')][_0x851a('0x20')]));_0x21e65b['attributes']=_0x21e65b['attributes'][_0x851a('0x21')]?_0x21e65b[_0x851a('0x1e')]:_0x2fffb1[_0x851a('0x1a')];if(!_0x4cb9a[_0x851a('0x1c')][_0x851a('0x22')]('nolimit')){_0x21e65b['limit']=qs['limit'](_0x4cb9a['query'][_0x851a('0x8')]);_0x21e65b[_0x851a('0x6')]=qs[_0x851a('0x6')](_0x4cb9a[_0x851a('0x1c')][_0x851a('0x6')]);}_0x21e65b[_0x851a('0x23')]=qs[_0x851a('0x24')](_0x4cb9a[_0x851a('0x1c')][_0x851a('0x24')]);_0x21e65b[_0x851a('0x25')]=qs['filters'](_['pick'](_0x4cb9a['query'],_0x2fffb1[_0x851a('0x1d')]),_0x265bfc);if(_0x4cb9a['query'][_0x851a('0x26')]){_0x21e65b[_0x851a('0x25')]=_[_0x851a('0x27')](_0x21e65b[_0x851a('0x25')],{'$or':_[_0x851a('0x15')](_0x265bfc,function(_0x26b232){if(_0x26b232['type']!==_0x851a('0x28')){var _0x260455={};_0x260455[_0x26b232[_0x851a('0x1b')]]={'$like':'%'+_0x4cb9a['query']['filter']+'%'};return _0x260455;}})});}_0x21e65b=_['merge']({},_0x21e65b,_0x4cb9a[_0x851a('0x29')]);var _0x3a049a={'where':_0x21e65b[_0x851a('0x25')]};return db[_0x851a('0x16')][_0x851a('0x9')](_0x3a049a)[_0x851a('0xe')](function(_0x541c22){_0x40ff8c[_0x851a('0x9')]=_0x541c22;if(_0x4cb9a[_0x851a('0x1c')][_0x851a('0x2a')]){_0x21e65b[_0x851a('0x2b')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x851a('0x2c')](_0x21e65b);})[_0x851a('0xe')](function(_0x1ccb58){_0x40ff8c['rows']=_0x1ccb58;return _0x40ff8c;})[_0x851a('0xe')](respondWithFilteredResult(_0x522e8f,_0x21e65b))[_0x851a('0x2d')](handleError(_0x522e8f,null));};exports[_0x851a('0x2e')]=function(_0x567fc2,_0x4a2be0){var _0x3ff91e={'raw':![],'where':{'id':_0x567fc2[_0x851a('0x2f')]['id']}},_0x46303e={};_0x46303e['model']=_[_0x851a('0x30')](db[_0x851a('0x16')][_0x851a('0x17')]);_0x46303e[_0x851a('0x1c')]=_[_0x851a('0x30')](_0x567fc2['query']);_0x46303e[_0x851a('0x1d')]=_[_0x851a('0x1f')](_0x46303e[_0x851a('0x1a')],_0x46303e[_0x851a('0x1c')]);_0x3ff91e[_0x851a('0x1e')]=_[_0x851a('0x1f')](_0x46303e['model'],qs['fields'](_0x567fc2[_0x851a('0x1c')]['fields']));_0x3ff91e['attributes']=_0x3ff91e[_0x851a('0x1e')][_0x851a('0x21')]?_0x3ff91e[_0x851a('0x1e')]:_0x46303e[_0x851a('0x1a')];if(_0x567fc2[_0x851a('0x1c')]['includeAll']){_0x3ff91e['include']=[{'all':!![]}];}_0x3ff91e=_[_0x851a('0x27')]({},_0x3ff91e,_0x567fc2[_0x851a('0x29')]);return db[_0x851a('0x16')][_0x851a('0x31')](_0x3ff91e)['then'](handleEntityNotFound(_0x4a2be0,null))[_0x851a('0xe')](respondWithResult(_0x4a2be0,null))[_0x851a('0x2d')](handleError(_0x4a2be0,null));};exports[_0x851a('0x32')]=function(_0x4e8663,_0x4f6fe9){return db[_0x851a('0x16')][_0x851a('0x32')](_0x4e8663[_0x851a('0x33')],{})[_0x851a('0xe')](respondWithResult(_0x4f6fe9,0xc9))[_0x851a('0x2d')](handleError(_0x4f6fe9,null));};exports['update']=function(_0x4a1abc,_0xc1de2a){if(_0x4a1abc[_0x851a('0x33')]['id']){delete _0x4a1abc[_0x851a('0x33')]['id'];}return db[_0x851a('0x16')]['find']({'where':{'id':_0x4a1abc[_0x851a('0x2f')]['id']}})[_0x851a('0xe')](handleEntityNotFound(_0xc1de2a,null))['then'](saveUpdates(_0x4a1abc[_0x851a('0x33')],null))[_0x851a('0xe')](respondWithResult(_0xc1de2a,null))[_0x851a('0x2d')](handleError(_0xc1de2a,null));};exports[_0x851a('0xf')]=function(_0xb54800,_0x53a8cf){return db['Dynamics365Account'][_0x851a('0x31')]({'where':{'id':_0xb54800[_0x851a('0x2f')]['id']}})[_0x851a('0xe')](handleEntityNotFound(_0x53a8cf,null))[_0x851a('0xe')](removeEntity(_0x53a8cf,null))[_0x851a('0x2d')](handleError(_0x53a8cf,null));};exports[_0x851a('0x34')]=function(_0x16088c,_0xdcd10f){var _0x3a5749={};var _0x127efe={};var _0x333bf6;var _0x554e3d;return db[_0x851a('0x16')][_0x851a('0x35')]({'where':{'id':_0x16088c[_0x851a('0x2f')]['id']}})[_0x851a('0xe')](handleEntityNotFound(_0xdcd10f,null))['then'](function(_0x2d1d9b){if(_0x2d1d9b){_0x333bf6=_0x2d1d9b;_0x127efe['model']=_[_0x851a('0x30')](db['Dynamics365Configuration'][_0x851a('0x17')]);_0x127efe[_0x851a('0x1c')]=_[_0x851a('0x30')](_0x16088c[_0x851a('0x1c')]);_0x127efe[_0x851a('0x1d')]=_[_0x851a('0x1f')](_0x127efe[_0x851a('0x1a')],_0x127efe['query']);_0x3a5749['attributes']=_[_0x851a('0x1f')](_0x127efe[_0x851a('0x1a')],qs['fields'](_0x16088c[_0x851a('0x1c')][_0x851a('0x20')]));_0x3a5749[_0x851a('0x1e')]=_0x3a5749[_0x851a('0x1e')][_0x851a('0x21')]?_0x3a5749[_0x851a('0x1e')]:_0x127efe[_0x851a('0x1a')];_0x3a5749['order']=qs[_0x851a('0x24')](_0x16088c[_0x851a('0x1c')][_0x851a('0x24')]);_0x3a5749[_0x851a('0x25')]=qs['filters'](_[_0x851a('0x36')](_0x16088c[_0x851a('0x1c')],_0x127efe['filters']));if(_0x16088c[_0x851a('0x1c')][_0x851a('0x26')]){_0x3a5749[_0x851a('0x25')]=_['merge'](_0x3a5749[_0x851a('0x25')],{'$or':_[_0x851a('0x15')](_0x3a5749[_0x851a('0x1e')],function(_0x5d21d2){var _0x2378ff={};_0x2378ff[_0x5d21d2]={'$like':'%'+_0x16088c[_0x851a('0x1c')]['filter']+'%'};return _0x2378ff;})});}_0x3a5749=_['merge']({},_0x3a5749,_0x16088c[_0x851a('0x29')]);return _0x333bf6[_0x851a('0x34')](_0x3a5749);}})[_0x851a('0xe')](function(_0x20be0c){if(_0x20be0c){_0x554e3d=_0x20be0c['length'];if(!_0x16088c[_0x851a('0x1c')]['hasOwnProperty'](_0x851a('0x37'))){_0x3a5749['limit']=qs[_0x851a('0x8')](_0x16088c[_0x851a('0x1c')][_0x851a('0x8')]);_0x3a5749[_0x851a('0x6')]=qs['offset'](_0x16088c['query']['offset']);}return _0x333bf6['getConfigurations'](_0x3a5749);}})[_0x851a('0xe')](function(_0x4dbf8){if(_0x4dbf8){return _0x4dbf8?{'count':_0x554e3d,'rows':_0x4dbf8}:null;}})[_0x851a('0xe')](respondWithResult(_0xdcd10f,null))[_0x851a('0x2d')](handleError(_0xdcd10f,null));};exports[_0x851a('0x38')]=function(_0x2ce735,_0x55e1ea){if(_0x2ce735[_0x851a('0x33')]['id']){delete _0x2ce735[_0x851a('0x33')]['id'];}return db[_0x851a('0x16')][_0x851a('0x35')]({'where':{'id':_0x2ce735['params']['id']}})['then'](handleEntityNotFound(_0x55e1ea,null))[_0x851a('0xe')](function(_0x478c0c){if(_0x478c0c){_0x2ce735['body']['AccountId']=_0x478c0c['id'];_0x2ce735[_0x851a('0x33')][_0x851a('0x39')]=integrations[_0x851a('0x3a')](_0x2ce735[_0x851a('0x33')][_0x851a('0x3b')],_0x2ce735[_0x851a('0x33')][_0x851a('0x19')]);_0x2ce735[_0x851a('0x33')][_0x851a('0x3c')]=integrations[_0x851a('0x3d')](_0x2ce735['body'][_0x851a('0x3b')],_0x2ce735[_0x851a('0x33')][_0x851a('0x19')]);return db['Dynamics365Configuration']['create'](_0x2ce735[_0x851a('0x33')],{'include':[{'model':db[_0x851a('0x3e')],'as':'Subjects'},{'model':db[_0x851a('0x3e')],'as':'Descriptions'}]});}return null;})[_0x851a('0xe')](respondWithResult(_0x55e1ea,null))[_0x851a('0x2d')](handleError(_0x55e1ea,null));};function sanitizeRemoteUri(_0x484780){var _0x3746c9=_0x484780[_0x851a('0x3f')](-0x1);if(_0x3746c9==='/')return _0x484780[_0x851a('0x40')](0x0,_0x484780[_0x851a('0x41')](_0x3746c9));return _0x484780;}function getWebApiUrl(_0x1a52c6){return util[_0x851a('0x42')]('%s/api/data/v9.0/',_0x1a52c6);}exports['getFields']=function(_0x37690a,_0x39518d){var _0x3a5f38=_0x37690a[_0x851a('0x1c')][_0x851a('0x43')];var _0x2a60f2=_0x3a5f38===_0x851a('0x44')?_0x851a('0x45'):'PhoneCall';var _0x3ba5f0='';var _0x47566a='';var _0x7e1456='';var _0x2da341='';var _0x38cc51='';var _0x26ed74='';var _0x809d0c='';var _0x3f8fb7='';var _0xd6698d=[_0x851a('0x46'),'description',_0x851a('0x47'),_0x851a('0x48'),_0x851a('0x49'),_0x851a('0x4a'),'phonenumber',_0x851a('0x4b'),_0x851a('0x4c'),_0x851a('0x4d')];var _0xc5c4f4=[_0x851a('0x4e'),'accountidyominame',_0x851a('0x4f'),_0x851a('0x50'),_0x851a('0x51'),_0x851a('0x52'),'contractdetailidname',_0x851a('0x53'),'createdbyexternalpartyname','createdbyexternalpartyyominame',_0x851a('0x54'),_0x851a('0x55'),_0x851a('0x56'),'createdonbehalfbyname',_0x851a('0x57'),_0x851a('0x58'),_0x851a('0x59'),_0x851a('0x5a'),_0x851a('0x5b'),_0x851a('0x5c'),'entityimage_timestamp',_0x851a('0x5d'),_0x851a('0x5e'),_0x851a('0x5f'),_0x851a('0x60'),'followupby',_0x851a('0x61'),_0x851a('0x62'),_0x851a('0x63'),_0x851a('0x64'),_0x851a('0x65'),'modifiedbyexternalpartyname',_0x851a('0x66'),_0x851a('0x67'),_0x851a('0x68'),_0x851a('0x69'),_0x851a('0x6a'),_0x851a('0x6b'),_0x851a('0x6c'),_0x851a('0x6d'),_0x851a('0x6e'),'onholdtime',_0x851a('0x6f'),'owneridname','owneridtype','owneridyominame',_0x851a('0x70'),_0x851a('0x71'),_0x851a('0x72'),_0x851a('0x73'),_0x851a('0x74'),'productserialnumber',_0x851a('0x75'),_0x851a('0x76'),_0x851a('0x77'),'responsiblecontactidname',_0x851a('0x78'),_0x851a('0x79'),_0x851a('0x7a'),'slaname',_0x851a('0x7b'),'statecode',_0x851a('0x7c'),_0x851a('0x7d'),_0x851a('0x7e'),_0x851a('0x7f'),_0x851a('0x80'),_0x851a('0x81'),_0x851a('0x82'),_0x851a('0x83')];var _0x237934=_0xd6698d[_0x851a('0x84')](_0xc5c4f4);return db['Dynamics365Account'][_0x851a('0x35')]({'where':{'id':_0x37690a[_0x851a('0x2f')]['id']},'attributes':['id',_0x851a('0x85'),_0x851a('0x86'),_0x851a('0x87'),'tenantId','clientId','clientSecret','modernAuthentication'],'include':[{'model':db[_0x851a('0x88')],'as':_0x851a('0x88'),'attributes':['id','data5',_0x851a('0x89')]}]})[_0x851a('0xe')](handleEntityNotFound(_0x39518d,null))['then'](function(_0x510ed2){if(_0x510ed2){if(_0x510ed2['modernAuthentication']){_0x510ed2[_0x851a('0x8a')]=_0x510ed2['CloudProvider']['data5'];_0x3f8fb7=sanitizeRemoteUri(_0x510ed2[_0x851a('0x88')][_0x851a('0x89')]);_0x809d0c=getWebApiUrl(_0x3f8fb7);return _0x510ed2;}_0x3f8fb7=sanitizeRemoteUri(_0x510ed2['remoteUri']);_0x809d0c=getWebApiUrl(_0x3f8fb7);var _0x33588b={'method':'POST','uri':_0x851a('0x8b')+_0x510ed2[_0x851a('0x8c')]+_0x851a('0x8d'),'form':{'client_id':_0x510ed2[_0x851a('0x8e')],'resource':_0x3f8fb7,'username':_0x510ed2[_0x851a('0x85')],'password':_0x510ed2[_0x851a('0x86')],'grant_type':_0x851a('0x86'),'client_secret':_0x510ed2[_0x851a('0x8f')]},'json':!![]};return rp(_0x33588b);}})[_0x851a('0xe')](function(_0x3789b7){_0x26ed74=_0x3789b7['access_token'];var _0x592a16={'method':'GET','uri':encodeURI(_0x809d0c+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x2a60f2+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x26ed74,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x592a16);})[_0x851a('0xe')](function(_0x2ca557){var _0x92671f=_0x2ca557[_0x851a('0x90')][0x0];var _0x5f236a=_0x92671f[_0x851a('0x91')];var _0x5e4917={'method':_0x851a('0x92'),'uri':_0x809d0c+_0x851a('0x93')+_0x5f236a+_0x851a('0x94'),'headers':{'Authorization':_0x851a('0x95')+_0x26ed74,'If-None-Match':null,'OData-Version':_0x851a('0x96')},'json':!![]};return rp(_0x5e4917);})[_0x851a('0xe')](function(_0x25af17){_0x3ba5f0=_0x25af17;_0x47566a=_0x3ba5f0[_0x851a('0x97')];_0x47566a=_[_0x851a('0x98')](_0x47566a,function(_0xd78c4f){return!_0x237934[_0x851a('0x99')](_0xd78c4f['LogicalName']);});var _0x2827c8=[];var _0x31665f=[];_0x47566a[_0x851a('0x9a')](function(_0x1411c1){if(_0x1411c1[_0x851a('0x9b')]){var _0x512b8b=_0x1411c1[_0x851a('0x9b')][_0x851a('0x40')](_0x1411c1[_0x851a('0x9b')][_0x851a('0x41')]('.')+0x1);if(_0x512b8b===_0x851a('0x9c')){_0x2827c8[_0x851a('0x9d')](getSelectList(_0x809d0c,_0x3a5f38,_0x31665f,_0x3ba5f0[_0x851a('0x91')],_0x1411c1[_0x851a('0x91')],_0x26ed74));}}});return Promise[_0x851a('0x9e')](_0x2827c8);})[_0x851a('0xe')](function(_0x2f2ebc){_0x7e1456=_0x2f2ebc[0x0];var _0x1503a3=[];var _0x249e7f=[];_0x47566a['forEach'](function(_0x515a7d){if(!_[_0x851a('0x9f')](_0x515a7d[_0x851a('0x9b')])){var _0x1599b5=_0x515a7d[_0x851a('0x9b')]['substring'](_0x515a7d[_0x851a('0x9b')][_0x851a('0x41')]('.')+0x1);if(_0x1599b5==='BooleanAttributeMetadata'){_0x1503a3[_0x851a('0x9d')](getBooleanList(_0x809d0c,_0x3a5f38,_0x249e7f,_0x3ba5f0['MetadataId'],_0x515a7d['MetadataId'],_0x26ed74));}}});return Promise[_0x851a('0x9e')](_0x1503a3);})['then'](function(_0x1c6e4c){_0x2da341=_0x1c6e4c[0x0];var _0x167aef=[];var _0xf3ba83=[];_0x47566a[_0x851a('0x9a')](function(_0x915faf){if(_0x915faf['@odata.type']){var _0x1402de=_0x915faf[_0x851a('0x9b')]['substring'](_0x915faf['@odata.type']['lastIndexOf']('.')+0x1);if(_0x1402de===_0x851a('0xa0')||_0x1402de==='DoubleAttributeMetadata'||_0x1402de===_0x851a('0xa1')||_0x1402de===_0x851a('0xa2')||_0x1402de==='MemoAttributeMetadata'||_0x1402de===_0x851a('0xa3')||_0x1402de===_0x851a('0xa4')||_0x1402de==='EntityNameAttributeMetadata'||_0x1402de===_0x851a('0xa5')||_0x1402de==='DecimalAttributeMetadata'){_0x167aef[_0x851a('0x9d')](getInputList(_0x809d0c,_0x3a5f38,_0x1402de,_0xf3ba83,_0x3ba5f0[_0x851a('0x91')],_0x915faf[_0x851a('0x91')],_0x26ed74));}}});return Promise['all'](_0x167aef);})[_0x851a('0xe')](function(_0x4507b2){_0x38cc51=_0x4507b2[0x0];var _0x2a878a=_0x7e1456[_0x851a('0x84')](_0x2da341)[_0x851a('0x84')](_0x38cc51);var _0x582b29={'count':_0x2a878a[_0x851a('0x21')],'rows':_0x2a878a};return _0x582b29;})[_0x851a('0xe')](respondWithResult(_0x39518d,null))[_0x851a('0x2d')](function(_0x225141){var _0x281ad8=_0x37690a[_0x851a('0x1c')][_0x851a('0xa6')]?0x1f4:_0x225141[_0x851a('0xa7')]||0x1f4;logger['error'](_0x225141['stack']);delete _0x225141[_0x851a('0x1b')];if(_0x281ad8===0x191){_0x281ad8=0x190;}_0x39518d[_0x851a('0x5')](_0x281ad8)[_0x851a('0xa8')](_0x37690a[_0x851a('0x1c')][_0x851a('0xa6')]?{'message':'Wrong\x20credentials','statusCode':_0x225141[_0x851a('0xa7')]}:_0x225141);});};function getSelectList(_0x46f4f6,_0x36bf8f,_0x7ea8f9,_0x4efcd9,_0x3602a3,_0x2027cb){var _0x2dd6a9={'method':_0x851a('0x92'),'uri':_0x46f4f6+'EntityDefinitions('+_0x4efcd9+_0x851a('0xa9')+_0x3602a3+_0x851a('0xaa')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':'Bearer\x20'+_0x2027cb,'If-None-Match':null,'OData-Version':_0x851a('0x96')},'json':!![]};return rp(_0x2dd6a9)[_0x851a('0xe')](function(_0x1720f7){var _0x23ae61=[];var _0x1950db=_0x1720f7[_0x851a('0xab')]['Options'];_0x1950db['forEach'](function(_0x40c783){_0x23ae61['push']({'name':_0x40c783[_0x851a('0xac')][_0x851a('0xad')][_0x851a('0xac')],'value':String(_0x40c783[_0x851a('0xae')])});});var _0x1bb0ea={'id':_0x36bf8f+'_'+_0x1720f7[_0x851a('0xaf')],'name':_0x1720f7[_0x851a('0xb0')]['UserLocalizedLabel'][_0x851a('0xac')],'custom':![],'options':_0x23ae61};_0x7ea8f9['push'](_0x1bb0ea);return _0x7ea8f9;});}function getBooleanList(_0x156d15,_0x5e258e,_0x256443,_0x67f7d9,_0x47f602,_0x238761){var _0x5aa4c1={'method':_0x851a('0x92'),'uri':_0x156d15+_0x851a('0x93')+_0x67f7d9+')/Attributes('+_0x47f602+_0x851a('0xb1'),'headers':{'Authorization':'Bearer\x20'+_0x238761,'If-None-Match':null,'OData-Version':_0x851a('0x96')},'json':!![]};return rp(_0x5aa4c1)['then'](function(_0x4eb0b8){var _0xcd79e3=[];_0xcd79e3[_0x851a('0x9d')]({'name':_0x4eb0b8[_0x851a('0xab')]['TrueOption'][_0x851a('0xac')][_0x851a('0xad')][_0x851a('0xac')],'value':_0x851a('0xb2')},{'name':_0x4eb0b8[_0x851a('0xab')][_0x851a('0xb3')][_0x851a('0xac')][_0x851a('0xad')][_0x851a('0xac')],'value':_0x851a('0xb4')});var _0x39d877={'id':_0x5e258e+'_'+_0x4eb0b8[_0x851a('0xaf')],'name':_0x4eb0b8[_0x851a('0xb0')]['UserLocalizedLabel']['Label'],'custom':![],'options':_0xcd79e3};_0x256443['push'](_0x39d877);return _0x256443;});}function getInputList(_0x5bb746,_0x34e7e,_0xda6b34,_0x19feb4,_0x3d4cd0,_0x730b33,_0x3e3e14){var _0x27e95b={'method':_0x851a('0x92'),'uri':_0x5bb746+_0x851a('0x93')+_0x3d4cd0+_0x851a('0xa9')+_0x730b33+_0x851a('0xb5')+_0xda6b34+_0x851a('0xb6'),'headers':{'Authorization':_0x851a('0x95')+_0x3e3e14,'If-None-Match':null,'OData-Version':_0x851a('0x96')},'json':!![]};return rp(_0x27e95b)[_0x851a('0xe')](function(_0x53cc91){var _0x4c09ad={'id':_0x34e7e+'_'+_0x53cc91['LogicalName'],'name':_0x53cc91[_0x851a('0xb0')]['UserLocalizedLabel']?_0x53cc91[_0x851a('0xb0')][_0x851a('0xad')][_0x851a('0xac')]:_0x53cc91[_0x851a('0xaf')],'custom':![],'options':[]};_0x19feb4[_0x851a('0x9d')](_0x4c09ad);return _0x19feb4;});}
\ No newline at end of file