Built motion from commit 71df090e.|2.6.31
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 69baa2e..9a492e7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2bc1=['contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdon','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','entityimage_timestamp','entityimage_url','escalatedon','firstresponsebykpiidname','influencescore','kbarticleidname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','numberofchildincidents','overriddencreatedon','owneridname','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','productserialnumber','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','sentimentvalue','slainvokedidname','slaname','socialprofileidname','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','concat','username','password','remoteUri','clientId','clientSecret','modernAuthentication','data5','data7','access_token','CloudProvider','POST','tenantId','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','value','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','includes','forEach','@odata.type','push','MetadataId','all','isNil','lastIndexOf','BooleanAttributeMetadata','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','statusCode','error','stack','test','Wrong\x20credentials','GET',')/Attributes(','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','UserLocalizedLabel','Label','LogicalName','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','FalseOption',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','util','lodash','../../config/logger','../../mysqldb','../../components/integrations/configuration','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','status','sendStatus','name','send','map','Dynamics365Account','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','includeAll','catch','params','include','find','create','body','findOne','getConfigurations','hasOwnProperty','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','Dynamics365Configuration','Dynamics365Field','slice','substring','format','%s/api/data/v9.0/','getFields','incident','Incident','PhoneCall','title','subject','phonenumber','regardingobjectid','phonecall_activity_parties','accountidname','accountidyominame','billedserviceunits'];(function(_0x5d8542,_0x31a3b8){var _0x500853=function(_0x3329e0){while(--_0x3329e0){_0x5d8542['push'](_0x5d8542['shift']());}};_0x500853(++_0x31a3b8);}(_0x2bc1,0x11e));var _0x12bc=function(_0x118c0d,_0x3d8aa7){_0x118c0d=_0x118c0d-0x0;var _0x5c723e=_0x2bc1[_0x118c0d];return _0x5c723e;};'use strict';var rp=require('request-promise');var util=require(_0x12bc('0x0'));var _=require(_0x12bc('0x1'));var qs=require('../../components/parsers/qs');var logger=require(_0x12bc('0x2'))('api');var db=require(_0x12bc('0x3'))['db'];var integrations=require(_0x12bc('0x4'));function respondWithResult(_0x30c854,_0x14a764){_0x14a764=_0x14a764||0xc8;return function(_0x4fcc0d){if(_0x4fcc0d){return _0x30c854['status'](_0x14a764)[_0x12bc('0x5')](_0x4fcc0d);}};}function respondWithFilteredResult(_0x28b14e,_0x31f56e){return function(_0x2b5b68){if(_0x2b5b68){var _0xd60229=typeof _0x31f56e[_0x12bc('0x6')]===_0x12bc('0x7')&&typeof _0x31f56e[_0x12bc('0x8')]===_0x12bc('0x7');var _0x327643=_0x2b5b68[_0x12bc('0x9')];var _0x5a3828=_0xd60229?0x0:_0x31f56e[_0x12bc('0x6')];var _0x38ee4a=_0xd60229?_0x2b5b68[_0x12bc('0x9')]:_0x31f56e[_0x12bc('0x6')]+_0x31f56e[_0x12bc('0x8')];var _0x479a99;if(_0x38ee4a>=_0x327643){_0x38ee4a=_0x327643;_0x479a99=0xc8;}else{_0x479a99=0xce;}_0x28b14e['status'](_0x479a99);return _0x28b14e[_0x12bc('0xa')](_0x12bc('0xb'),_0x5a3828+'-'+_0x38ee4a+'/'+_0x327643)[_0x12bc('0x5')](_0x2b5b68);}return null;};}function saveUpdates(_0x3da572){return function(_0x5a7c4d){if(_0x5a7c4d){return _0x5a7c4d[_0x12bc('0xc')](_0x3da572)[_0x12bc('0xd')](function(_0x5d09ed){return _0x5d09ed;});}return null;};}function removeEntity(_0x4003dc){return function(_0x4ba81b){if(_0x4ba81b){return _0x4ba81b[_0x12bc('0xe')]()['then'](function(){_0x4003dc[_0x12bc('0xf')](0xcc)['end']();});}};}function handleEntityNotFound(_0x30e10d){return function(_0x3ebe68){if(!_0x3ebe68){_0x30e10d[_0x12bc('0x10')](0x194);}return _0x3ebe68;};}function handleError(_0x5ab9e7,_0x417a61){_0x417a61=_0x417a61||0x1f4;return function(_0x58ab55){logger['error'](_0x58ab55['stack']);if(_0x58ab55[_0x12bc('0x11')]){delete _0x58ab55[_0x12bc('0x11')];}_0x5ab9e7['status'](_0x417a61)[_0x12bc('0x12')](_0x58ab55);};}exports['index']=function(_0x4cee78,_0xea63e6){var _0x4cb3f0={},_0x43454f={},_0x29f940={'count':0x0,'rows':[]};var _0xa20c5e=_[_0x12bc('0x13')](db[_0x12bc('0x14')][_0x12bc('0x15')],function(_0x3086bf){return{'name':_0x3086bf[_0x12bc('0x16')],'type':_0x3086bf['type'][_0x12bc('0x17')]};});_0x43454f[_0x12bc('0x18')]=_['map'](_0xa20c5e,_0x12bc('0x11'));_0x43454f[_0x12bc('0x19')]=_[_0x12bc('0x1a')](_0x4cee78[_0x12bc('0x19')]);_0x43454f[_0x12bc('0x1b')]=_[_0x12bc('0x1c')](_0x43454f[_0x12bc('0x18')],_0x43454f[_0x12bc('0x19')]);_0x4cb3f0[_0x12bc('0x1d')]=_[_0x12bc('0x1c')](_0x43454f['model'],qs[_0x12bc('0x1e')](_0x4cee78['query'][_0x12bc('0x1e')]));_0x4cb3f0[_0x12bc('0x1d')]=_0x4cb3f0[_0x12bc('0x1d')][_0x12bc('0x1f')]?_0x4cb3f0['attributes']:_0x43454f['model'];if(!_0x4cee78[_0x12bc('0x19')]['hasOwnProperty'](_0x12bc('0x20'))){_0x4cb3f0[_0x12bc('0x8')]=qs[_0x12bc('0x8')](_0x4cee78['query'][_0x12bc('0x8')]);_0x4cb3f0[_0x12bc('0x6')]=qs[_0x12bc('0x6')](_0x4cee78[_0x12bc('0x19')]['offset']);}_0x4cb3f0[_0x12bc('0x21')]=qs[_0x12bc('0x22')](_0x4cee78[_0x12bc('0x19')][_0x12bc('0x22')]);_0x4cb3f0['where']=qs['filters'](_[_0x12bc('0x23')](_0x4cee78[_0x12bc('0x19')],_0x43454f['filters']),_0xa20c5e);if(_0x4cee78[_0x12bc('0x19')][_0x12bc('0x24')]){_0x4cb3f0[_0x12bc('0x25')]=_[_0x12bc('0x26')](_0x4cb3f0[_0x12bc('0x25')],{'$or':_[_0x12bc('0x13')](_0xa20c5e,function(_0x3d5e84){if(_0x3d5e84[_0x12bc('0x27')]!==_0x12bc('0x28')){var _0x38a5ad={};_0x38a5ad[_0x3d5e84[_0x12bc('0x11')]]={'$like':'%'+_0x4cee78[_0x12bc('0x19')][_0x12bc('0x24')]+'%'};return _0x38a5ad;}})});}_0x4cb3f0=_[_0x12bc('0x26')]({},_0x4cb3f0,_0x4cee78[_0x12bc('0x29')]);var _0x353db7={'where':_0x4cb3f0[_0x12bc('0x25')]};return db[_0x12bc('0x14')][_0x12bc('0x9')](_0x353db7)[_0x12bc('0xd')](function(_0x4f85cb){_0x29f940[_0x12bc('0x9')]=_0x4f85cb;if(_0x4cee78[_0x12bc('0x19')][_0x12bc('0x2a')]){_0x4cb3f0['include']=[{'all':!![]}];}return db[_0x12bc('0x14')]['findAll'](_0x4cb3f0);})[_0x12bc('0xd')](function(_0x3fe4d2){_0x29f940['rows']=_0x3fe4d2;return _0x29f940;})[_0x12bc('0xd')](respondWithFilteredResult(_0xea63e6,_0x4cb3f0))[_0x12bc('0x2b')](handleError(_0xea63e6,null));};exports['show']=function(_0x2bb88d,_0x4e4d10){var _0xe3b1ba={'raw':![],'where':{'id':_0x2bb88d[_0x12bc('0x2c')]['id']}},_0x5c3c8a={};_0x5c3c8a[_0x12bc('0x18')]=_[_0x12bc('0x1a')](db[_0x12bc('0x14')][_0x12bc('0x15')]);_0x5c3c8a['query']=_[_0x12bc('0x1a')](_0x2bb88d[_0x12bc('0x19')]);_0x5c3c8a[_0x12bc('0x1b')]=_[_0x12bc('0x1c')](_0x5c3c8a['model'],_0x5c3c8a['query']);_0xe3b1ba[_0x12bc('0x1d')]=_[_0x12bc('0x1c')](_0x5c3c8a['model'],qs[_0x12bc('0x1e')](_0x2bb88d['query'][_0x12bc('0x1e')]));_0xe3b1ba['attributes']=_0xe3b1ba[_0x12bc('0x1d')]['length']?_0xe3b1ba[_0x12bc('0x1d')]:_0x5c3c8a[_0x12bc('0x18')];if(_0x2bb88d[_0x12bc('0x19')]['includeAll']){_0xe3b1ba[_0x12bc('0x2d')]=[{'all':!![]}];}_0xe3b1ba=_[_0x12bc('0x26')]({},_0xe3b1ba,_0x2bb88d[_0x12bc('0x29')]);return db[_0x12bc('0x14')][_0x12bc('0x2e')](_0xe3b1ba)['then'](handleEntityNotFound(_0x4e4d10,null))[_0x12bc('0xd')](respondWithResult(_0x4e4d10,null))[_0x12bc('0x2b')](handleError(_0x4e4d10,null));};exports['create']=function(_0x18d85c,_0x17c56b){return db[_0x12bc('0x14')][_0x12bc('0x2f')](_0x18d85c[_0x12bc('0x30')],{})[_0x12bc('0xd')](respondWithResult(_0x17c56b,0xc9))[_0x12bc('0x2b')](handleError(_0x17c56b,null));};exports[_0x12bc('0xc')]=function(_0x4b4c8,_0x1d7133){if(_0x4b4c8[_0x12bc('0x30')]['id']){delete _0x4b4c8[_0x12bc('0x30')]['id'];}return db[_0x12bc('0x14')]['find']({'where':{'id':_0x4b4c8[_0x12bc('0x2c')]['id']}})[_0x12bc('0xd')](handleEntityNotFound(_0x1d7133,null))[_0x12bc('0xd')](saveUpdates(_0x4b4c8['body'],null))['then'](respondWithResult(_0x1d7133,null))[_0x12bc('0x2b')](handleError(_0x1d7133,null));};exports[_0x12bc('0xe')]=function(_0x162309,_0xc2a1c8){return db[_0x12bc('0x14')]['find']({'where':{'id':_0x162309[_0x12bc('0x2c')]['id']}})[_0x12bc('0xd')](handleEntityNotFound(_0xc2a1c8,null))['then'](removeEntity(_0xc2a1c8,null))[_0x12bc('0x2b')](handleError(_0xc2a1c8,null));};exports['getConfigurations']=function(_0x431e0d,_0x4c2718){var _0x509bd3={};var _0x2aa71c={};var _0x23fce3;var _0x12e67a;return db['Dynamics365Account'][_0x12bc('0x31')]({'where':{'id':_0x431e0d['params']['id']}})[_0x12bc('0xd')](handleEntityNotFound(_0x4c2718,null))[_0x12bc('0xd')](function(_0x6ba7f3){if(_0x6ba7f3){_0x23fce3=_0x6ba7f3;_0x2aa71c[_0x12bc('0x18')]=_['keys'](db['Dynamics365Configuration'][_0x12bc('0x15')]);_0x2aa71c[_0x12bc('0x19')]=_['keys'](_0x431e0d[_0x12bc('0x19')]);_0x2aa71c[_0x12bc('0x1b')]=_[_0x12bc('0x1c')](_0x2aa71c['model'],_0x2aa71c['query']);_0x509bd3[_0x12bc('0x1d')]=_[_0x12bc('0x1c')](_0x2aa71c[_0x12bc('0x18')],qs[_0x12bc('0x1e')](_0x431e0d[_0x12bc('0x19')]['fields']));_0x509bd3[_0x12bc('0x1d')]=_0x509bd3[_0x12bc('0x1d')][_0x12bc('0x1f')]?_0x509bd3[_0x12bc('0x1d')]:_0x2aa71c[_0x12bc('0x18')];_0x509bd3['order']=qs['sort'](_0x431e0d[_0x12bc('0x19')]['sort']);_0x509bd3[_0x12bc('0x25')]=qs[_0x12bc('0x1b')](_['pick'](_0x431e0d[_0x12bc('0x19')],_0x2aa71c[_0x12bc('0x1b')]));if(_0x431e0d[_0x12bc('0x19')][_0x12bc('0x24')]){_0x509bd3['where']=_[_0x12bc('0x26')](_0x509bd3[_0x12bc('0x25')],{'$or':_[_0x12bc('0x13')](_0x509bd3[_0x12bc('0x1d')],function(_0x4d3c3d){var _0x1945e4={};_0x1945e4[_0x4d3c3d]={'$like':'%'+_0x431e0d[_0x12bc('0x19')]['filter']+'%'};return _0x1945e4;})});}_0x509bd3=_[_0x12bc('0x26')]({},_0x509bd3,_0x431e0d[_0x12bc('0x29')]);return _0x23fce3[_0x12bc('0x32')](_0x509bd3);}})[_0x12bc('0xd')](function(_0x5d5c23){if(_0x5d5c23){_0x12e67a=_0x5d5c23[_0x12bc('0x1f')];if(!_0x431e0d[_0x12bc('0x19')][_0x12bc('0x33')]('nolimit')){_0x509bd3[_0x12bc('0x8')]=qs[_0x12bc('0x8')](_0x431e0d[_0x12bc('0x19')][_0x12bc('0x8')]);_0x509bd3[_0x12bc('0x6')]=qs[_0x12bc('0x6')](_0x431e0d[_0x12bc('0x19')][_0x12bc('0x6')]);}return _0x23fce3[_0x12bc('0x32')](_0x509bd3);}})[_0x12bc('0xd')](function(_0x41ed75){if(_0x41ed75){return _0x41ed75?{'count':_0x12e67a,'rows':_0x41ed75}:null;}})['then'](respondWithResult(_0x4c2718,null))[_0x12bc('0x2b')](handleError(_0x4c2718,null));};exports['addConfiguration']=function(_0x55c6f0,_0x422cf8){if(_0x55c6f0[_0x12bc('0x30')]['id']){delete _0x55c6f0[_0x12bc('0x30')]['id'];}return db[_0x12bc('0x14')][_0x12bc('0x31')]({'where':{'id':_0x55c6f0[_0x12bc('0x2c')]['id']}})['then'](handleEntityNotFound(_0x422cf8,null))[_0x12bc('0xd')](function(_0x354cea){if(_0x354cea){_0x55c6f0['body'][_0x12bc('0x34')]=_0x354cea['id'];_0x55c6f0['body'][_0x12bc('0x35')]=integrations[_0x12bc('0x36')](_0x55c6f0[_0x12bc('0x30')][_0x12bc('0x37')],_0x55c6f0['body'][_0x12bc('0x27')]);_0x55c6f0[_0x12bc('0x30')][_0x12bc('0x38')]=integrations[_0x12bc('0x39')](_0x55c6f0[_0x12bc('0x30')][_0x12bc('0x37')],_0x55c6f0[_0x12bc('0x30')]['type']);return db[_0x12bc('0x3a')][_0x12bc('0x2f')](_0x55c6f0['body'],{'include':[{'model':db[_0x12bc('0x3b')],'as':_0x12bc('0x35')},{'model':db[_0x12bc('0x3b')],'as':_0x12bc('0x38')}]});}return null;})[_0x12bc('0xd')](respondWithResult(_0x422cf8,null))[_0x12bc('0x2b')](handleError(_0x422cf8,null));};function sanitizeRemoteUri(_0x4916b4){var _0x24d36e=_0x4916b4[_0x12bc('0x3c')](-0x1);if(_0x24d36e==='/')return _0x4916b4[_0x12bc('0x3d')](0x0,_0x4916b4['lastIndexOf'](_0x24d36e));return _0x4916b4;}function getWebApiUrl(_0x528f48){return util[_0x12bc('0x3e')](_0x12bc('0x3f'),_0x528f48);}exports[_0x12bc('0x40')]=function(_0x2107d6,_0x49ab7a){var _0x1e1001=_0x2107d6['query']['ticketType'];var _0x552b3d=_0x1e1001===_0x12bc('0x41')?_0x12bc('0x42'):_0x12bc('0x43');var _0x50d90d='';var _0x42a2c2='';var _0x1ff35e='';var _0x26b32a='';var _0x1d40c1='';var _0x3a6be1='';var _0x358cad='';var _0x5ae7c1='';var _0x5bab9d=[_0x12bc('0x44'),'description','customerid','ownerid','caseorigincode',_0x12bc('0x45'),_0x12bc('0x46'),_0x12bc('0x47'),'directioncode',_0x12bc('0x48')];var _0xd002ed=[_0x12bc('0x49'),_0x12bc('0x4a'),'actualserviceunits',_0x12bc('0x4b'),_0x12bc('0x4c'),_0x12bc('0x4d'),_0x12bc('0x4e'),_0x12bc('0x4f'),_0x12bc('0x50'),_0x12bc('0x51'),_0x12bc('0x52'),'createdbyyominame',_0x12bc('0x53'),_0x12bc('0x54'),_0x12bc('0x55'),_0x12bc('0x56'),_0x12bc('0x57'),'customeridyominame','emailaddress','entitlementidname',_0x12bc('0x58'),_0x12bc('0x59'),_0x12bc('0x5a'),'exchangerate',_0x12bc('0x5b'),'followupby','importsequencenumber',_0x12bc('0x5c'),_0x12bc('0x5d'),'lastonholdtime','masteridname','modifiedbyexternalpartyname',_0x12bc('0x5e'),_0x12bc('0x5f'),_0x12bc('0x60'),'modifiedon',_0x12bc('0x61'),_0x12bc('0x62'),_0x12bc('0x63'),'msdyn_iotalertname',_0x12bc('0x64'),'onholdtime',_0x12bc('0x65'),_0x12bc('0x66'),'owneridtype',_0x12bc('0x67'),_0x12bc('0x68'),_0x12bc('0x69'),_0x12bc('0x6a'),_0x12bc('0x6b'),_0x12bc('0x6c'),_0x12bc('0x6d'),_0x12bc('0x6e'),_0x12bc('0x6f'),_0x12bc('0x70'),_0x12bc('0x71'),'responsiblecontactidyominame',_0x12bc('0x72'),_0x12bc('0x73'),_0x12bc('0x74'),_0x12bc('0x75'),'statecode','statuscode',_0x12bc('0x76'),_0x12bc('0x77'),_0x12bc('0x78'),_0x12bc('0x79'),_0x12bc('0x7a'),_0x12bc('0x7b'),'versionnumber'];var _0x5d7a20=_0x5bab9d[_0x12bc('0x7c')](_0xd002ed);return db['Dynamics365Account'][_0x12bc('0x31')]({'where':{'id':_0x2107d6[_0x12bc('0x2c')]['id']},'attributes':['id',_0x12bc('0x7d'),_0x12bc('0x7e'),_0x12bc('0x7f'),'tenantId',_0x12bc('0x80'),_0x12bc('0x81'),_0x12bc('0x82')],'include':[{'model':db['CloudProvider'],'as':'CloudProvider','attributes':['id',_0x12bc('0x83'),_0x12bc('0x84')]}]})['then'](handleEntityNotFound(_0x49ab7a,null))[_0x12bc('0xd')](function(_0x1e1cf7){if(_0x1e1cf7){if(_0x1e1cf7[_0x12bc('0x82')]){_0x1e1cf7[_0x12bc('0x85')]=_0x1e1cf7[_0x12bc('0x86')][_0x12bc('0x83')];_0x5ae7c1=sanitizeRemoteUri(_0x1e1cf7[_0x12bc('0x86')][_0x12bc('0x84')]);_0x358cad=getWebApiUrl(_0x5ae7c1);return _0x1e1cf7;}_0x5ae7c1=sanitizeRemoteUri(_0x1e1cf7[_0x12bc('0x7f')]);_0x358cad=getWebApiUrl(_0x5ae7c1);var _0x3b65d6={'method':_0x12bc('0x87'),'uri':'https://login.microsoftonline.com/'+_0x1e1cf7[_0x12bc('0x88')]+'/oauth2/token','form':{'client_id':_0x1e1cf7[_0x12bc('0x80')],'resource':_0x5ae7c1,'username':_0x1e1cf7[_0x12bc('0x7d')],'password':_0x1e1cf7[_0x12bc('0x7e')],'grant_type':_0x12bc('0x7e'),'client_secret':_0x1e1cf7['clientSecret']},'json':!![]};return rp(_0x3b65d6);}})[_0x12bc('0xd')](function(_0x5d73c9){_0x3a6be1=_0x5d73c9[_0x12bc('0x85')];var _0x1c2cb8={'method':'GET','uri':encodeURI(_0x358cad+_0x12bc('0x89')+_0x552b3d+'\x27'),'headers':{'Authorization':_0x12bc('0x8a')+_0x3a6be1,'If-None-Match':null,'OData-Version':_0x12bc('0x8b')},'json':!![]};return rp(_0x1c2cb8);})[_0x12bc('0xd')](function(_0x48cae4){var _0x1a3bb0=_0x48cae4[_0x12bc('0x8c')][0x0];var _0xabd9a3=_0x1a3bb0['MetadataId'];var _0x35328a={'method':'GET','uri':_0x358cad+_0x12bc('0x8d')+_0xabd9a3+_0x12bc('0x8e'),'headers':{'Authorization':_0x12bc('0x8a')+_0x3a6be1,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x35328a);})[_0x12bc('0xd')](function(_0x2e58c0){_0x50d90d=_0x2e58c0;_0x42a2c2=_0x50d90d[_0x12bc('0x8f')];_0x42a2c2=_['remove'](_0x42a2c2,function(_0x490c60){return!_0x5d7a20[_0x12bc('0x90')](_0x490c60['LogicalName']);});var _0x3313f1=[];var _0x5ac721=[];_0x42a2c2[_0x12bc('0x91')](function(_0x26ad23){if(_0x26ad23[_0x12bc('0x92')]){var _0x5e2855=_0x26ad23['@odata.type'][_0x12bc('0x3d')](_0x26ad23[_0x12bc('0x92')]['lastIndexOf']('.')+0x1);if(_0x5e2855==='PicklistAttributeMetadata'){_0x3313f1[_0x12bc('0x93')](getSelectList(_0x358cad,_0x1e1001,_0x5ac721,_0x50d90d[_0x12bc('0x94')],_0x26ad23[_0x12bc('0x94')],_0x3a6be1));}}});return Promise[_0x12bc('0x95')](_0x3313f1);})[_0x12bc('0xd')](function(_0x2d14ab){_0x1ff35e=_0x2d14ab[0x0];var _0x2076c0=[];var _0x4c931b=[];_0x42a2c2['forEach'](function(_0x4209c6){if(!_[_0x12bc('0x96')](_0x4209c6['@odata.type'])){var _0xac794d=_0x4209c6[_0x12bc('0x92')]['substring'](_0x4209c6[_0x12bc('0x92')][_0x12bc('0x97')]('.')+0x1);if(_0xac794d===_0x12bc('0x98')){_0x2076c0[_0x12bc('0x93')](getBooleanList(_0x358cad,_0x1e1001,_0x4c931b,_0x50d90d[_0x12bc('0x94')],_0x4209c6[_0x12bc('0x94')],_0x3a6be1));}}});return Promise['all'](_0x2076c0);})[_0x12bc('0xd')](function(_0x510ddb){_0x26b32a=_0x510ddb[0x0];var _0x5043d3=[];var _0x5a9e49=[];_0x42a2c2[_0x12bc('0x91')](function(_0x552dd2){if(_0x552dd2['@odata.type']){var _0x1adca1=_0x552dd2['@odata.type']['substring'](_0x552dd2[_0x12bc('0x92')][_0x12bc('0x97')]('.')+0x1);if(_0x1adca1===_0x12bc('0x99')||_0x1adca1==='DoubleAttributeMetadata'||_0x1adca1===_0x12bc('0x9a')||_0x1adca1===_0x12bc('0x9b')||_0x1adca1===_0x12bc('0x9c')||_0x1adca1===_0x12bc('0x9d')||_0x1adca1===_0x12bc('0x9e')||_0x1adca1===_0x12bc('0x9f')||_0x1adca1===_0x12bc('0xa0')||_0x1adca1===_0x12bc('0xa1')){_0x5043d3['push'](getInputList(_0x358cad,_0x1e1001,_0x1adca1,_0x5a9e49,_0x50d90d[_0x12bc('0x94')],_0x552dd2[_0x12bc('0x94')],_0x3a6be1));}}});return Promise[_0x12bc('0x95')](_0x5043d3);})[_0x12bc('0xd')](function(_0x36af9a){_0x1d40c1=_0x36af9a[0x0];var _0x325124=_0x1ff35e['concat'](_0x26b32a)[_0x12bc('0x7c')](_0x1d40c1);var _0x599712={'count':_0x325124['length'],'rows':_0x325124};return _0x599712;})[_0x12bc('0xd')](respondWithResult(_0x49ab7a,null))[_0x12bc('0x2b')](function(_0x599e07){var _0x55a29a=_0x2107d6[_0x12bc('0x19')]['test']?0x1f4:_0x599e07[_0x12bc('0xa2')]||0x1f4;logger[_0x12bc('0xa3')](_0x599e07[_0x12bc('0xa4')]);delete _0x599e07['name'];if(_0x55a29a===0x191){_0x55a29a=0x190;}_0x49ab7a[_0x12bc('0xf')](_0x55a29a)['send'](_0x2107d6[_0x12bc('0x19')][_0x12bc('0xa5')]?{'message':_0x12bc('0xa6'),'statusCode':_0x599e07[_0x12bc('0xa2')]}:_0x599e07);});};function getSelectList(_0x520091,_0x1bc47f,_0x483c6e,_0x342d1e,_0x3e89ac,_0x3074d5){var _0x4d04d5={'method':_0x12bc('0xa7'),'uri':_0x520091+'EntityDefinitions('+_0x342d1e+_0x12bc('0xa8')+_0x3e89ac+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+_0x12bc('0xa9'),'headers':{'Authorization':_0x12bc('0x8a')+_0x3074d5,'If-None-Match':null,'OData-Version':_0x12bc('0x8b')},'json':!![]};return rp(_0x4d04d5)[_0x12bc('0xd')](function(_0x35f394){var _0x375545=[];var _0xde26d8=_0x35f394[_0x12bc('0xaa')][_0x12bc('0xab')];_0xde26d8[_0x12bc('0x91')](function(_0x390a52){_0x375545[_0x12bc('0x93')]({'name':_0x390a52['Label'][_0x12bc('0xac')][_0x12bc('0xad')],'value':String(_0x390a52['Value'])});});var _0x4d9cd3={'id':_0x1bc47f+'_'+_0x35f394[_0x12bc('0xae')],'name':_0x35f394[_0x12bc('0xaf')][_0x12bc('0xac')][_0x12bc('0xad')],'custom':![],'options':_0x375545};_0x483c6e[_0x12bc('0x93')](_0x4d9cd3);return _0x483c6e;});}function getBooleanList(_0x24c832,_0x4847df,_0x569933,_0x3a7d20,_0x31a0fc,_0x4a58f9){var _0x811911={'method':_0x12bc('0xa7'),'uri':_0x24c832+_0x12bc('0x8d')+_0x3a7d20+_0x12bc('0xa8')+_0x31a0fc+_0x12bc('0xb0'),'headers':{'Authorization':'Bearer\x20'+_0x4a58f9,'If-None-Match':null,'OData-Version':_0x12bc('0x8b')},'json':!![]};return rp(_0x811911)['then'](function(_0x40b947){var _0x209ac8=[];_0x209ac8[_0x12bc('0x93')]({'name':_0x40b947[_0x12bc('0xaa')][_0x12bc('0xb1')][_0x12bc('0xad')][_0x12bc('0xac')][_0x12bc('0xad')],'value':'true'},{'name':_0x40b947[_0x12bc('0xaa')][_0x12bc('0xb2')][_0x12bc('0xad')][_0x12bc('0xac')][_0x12bc('0xad')],'value':'false'});var _0x45356f={'id':_0x4847df+'_'+_0x40b947[_0x12bc('0xae')],'name':_0x40b947[_0x12bc('0xaf')]['UserLocalizedLabel'][_0x12bc('0xad')],'custom':![],'options':_0x209ac8};_0x569933[_0x12bc('0x93')](_0x45356f);return _0x569933;});}function getInputList(_0x3c32f5,_0x14471d,_0x42acde,_0x56a685,_0x1781a6,_0x5b33fc,_0x308cc6){var _0x4cbf3a={'method':'GET','uri':_0x3c32f5+_0x12bc('0x8d')+_0x1781a6+_0x12bc('0xa8')+_0x5b33fc+_0x12bc('0xb3')+_0x42acde+_0x12bc('0xb4'),'headers':{'Authorization':'Bearer\x20'+_0x308cc6,'If-None-Match':null,'OData-Version':_0x12bc('0x8b')},'json':!![]};return rp(_0x4cbf3a)[_0x12bc('0xd')](function(_0x3e58a6){var _0x38678e={'id':_0x14471d+'_'+_0x3e58a6[_0x12bc('0xae')],'name':_0x3e58a6[_0x12bc('0xaf')][_0x12bc('0xac')]?_0x3e58a6[_0x12bc('0xaf')][_0x12bc('0xac')]['Label']:_0x3e58a6[_0x12bc('0xae')],'custom':![],'options':[]};_0x56a685['push'](_0x38678e);return _0x56a685;});}
\ No newline at end of file
+var _0x636f=['name','map','Dynamics365Account','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','fields','find','create','body','getConfigurations','findOne','AccountId','Subjects','getSubjects','channel','Descriptions','Dynamics365Configuration','Dynamics365Field','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','ticketType','Incident','PhoneCall','title','description','customerid','caseorigincode','subject','phonenumber','regardingobjectid','directioncode','phonecall_activity_parties','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','entitlementidname','entityimage_url','escalatedon','firstresponsebykpiidname','followupby','importsequencenumber','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','productidname','productserialnumber','resolveby','resolvebykpiidname','responseby','sentimentvalue','slainvokedidname','socialprofileidname','statecode','statuscode','subjectidname','ticketnumber','traversedpath','utcconversiontimezonecode','versionnumber','concat','password','tenantId','clientId','clientSecret','access_token','CloudProvider','data5','data7','POST','https://login.microsoftonline.com/','/oauth2/token','username','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','value','EntityDefinitions(','Attributes','includes','LogicalName','@odata.type','push','MetadataId','all','forEach','isNil','BooleanAttributeMetadata','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode','send','Wrong\x20credentials',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label','UserLocalizedLabel','Value','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','true','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','api','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','then','destroy','end','sendStatus','error','stack'];(function(_0x23f50a,_0x1e0fbc){var _0x3d48e2=function(_0x103d6e){while(--_0x103d6e){_0x23f50a['push'](_0x23f50a['shift']());}};_0x3d48e2(++_0x1e0fbc);}(_0x636f,0x164));var _0xf636=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x636f[_0x3b380d];return _0x54502b;};'use strict';var rp=require(_0xf636('0x0'));var util=require(_0xf636('0x1'));var _=require(_0xf636('0x2'));var qs=require(_0xf636('0x3'));var logger=require('../../config/logger')(_0xf636('0x4'));var db=require('../../mysqldb')['db'];var integrations=require(_0xf636('0x5'));function respondWithResult(_0xcf976e,_0x5368db){_0x5368db=_0x5368db||0xc8;return function(_0x4abe0f){if(_0x4abe0f){return _0xcf976e[_0xf636('0x6')](_0x5368db)[_0xf636('0x7')](_0x4abe0f);}};}function respondWithFilteredResult(_0x2396af,_0x82fad8){return function(_0x1dbb4c){if(_0x1dbb4c){var _0x2211dd=typeof _0x82fad8[_0xf636('0x8')]===_0xf636('0x9')&&typeof _0x82fad8[_0xf636('0xa')]==='undefined';var _0x25bf2c=_0x1dbb4c[_0xf636('0xb')];var _0x1dff36=_0x2211dd?0x0:_0x82fad8[_0xf636('0x8')];var _0x369c1d=_0x2211dd?_0x1dbb4c[_0xf636('0xb')]:_0x82fad8[_0xf636('0x8')]+_0x82fad8[_0xf636('0xa')];var _0x2b5261;if(_0x369c1d>=_0x25bf2c){_0x369c1d=_0x25bf2c;_0x2b5261=0xc8;}else{_0x2b5261=0xce;}_0x2396af['status'](_0x2b5261);return _0x2396af[_0xf636('0xc')](_0xf636('0xd'),_0x1dff36+'-'+_0x369c1d+'/'+_0x25bf2c)[_0xf636('0x7')](_0x1dbb4c);}return null;};}function saveUpdates(_0x55cea4){return function(_0xea8f64){if(_0xea8f64){return _0xea8f64['update'](_0x55cea4)[_0xf636('0xe')](function(_0x1eb797){return _0x1eb797;});}return null;};}function removeEntity(_0x89a3b){return function(_0x4dc489){if(_0x4dc489){return _0x4dc489[_0xf636('0xf')]()[_0xf636('0xe')](function(){_0x89a3b[_0xf636('0x6')](0xcc)[_0xf636('0x10')]();});}};}function handleEntityNotFound(_0x315224){return function(_0x5afae7){if(!_0x5afae7){_0x315224[_0xf636('0x11')](0x194);}return _0x5afae7;};}function handleError(_0x3f9cfc,_0x3349aa){_0x3349aa=_0x3349aa||0x1f4;return function(_0x29731e){logger[_0xf636('0x12')](_0x29731e[_0xf636('0x13')]);if(_0x29731e[_0xf636('0x14')]){delete _0x29731e[_0xf636('0x14')];}_0x3f9cfc[_0xf636('0x6')](_0x3349aa)['send'](_0x29731e);};}exports['index']=function(_0x31b0de,_0x542af0){var _0x4608f7={},_0x1fecf2={},_0x12ccd1={'count':0x0,'rows':[]};var _0x37d8e0=_[_0xf636('0x15')](db[_0xf636('0x16')][_0xf636('0x17')],function(_0x371705){return{'name':_0x371705[_0xf636('0x18')],'type':_0x371705[_0xf636('0x19')][_0xf636('0x1a')]};});_0x1fecf2[_0xf636('0x1b')]=_[_0xf636('0x15')](_0x37d8e0,'name');_0x1fecf2['query']=_[_0xf636('0x1c')](_0x31b0de[_0xf636('0x1d')]);_0x1fecf2[_0xf636('0x1e')]=_[_0xf636('0x1f')](_0x1fecf2[_0xf636('0x1b')],_0x1fecf2[_0xf636('0x1d')]);_0x4608f7['attributes']=_[_0xf636('0x1f')](_0x1fecf2[_0xf636('0x1b')],qs['fields'](_0x31b0de[_0xf636('0x1d')]['fields']));_0x4608f7[_0xf636('0x20')]=_0x4608f7[_0xf636('0x20')][_0xf636('0x21')]?_0x4608f7['attributes']:_0x1fecf2[_0xf636('0x1b')];if(!_0x31b0de['query'][_0xf636('0x22')](_0xf636('0x23'))){_0x4608f7[_0xf636('0xa')]=qs[_0xf636('0xa')](_0x31b0de[_0xf636('0x1d')][_0xf636('0xa')]);_0x4608f7[_0xf636('0x8')]=qs['offset'](_0x31b0de[_0xf636('0x1d')][_0xf636('0x8')]);}_0x4608f7[_0xf636('0x24')]=qs[_0xf636('0x25')](_0x31b0de[_0xf636('0x1d')]['sort']);_0x4608f7[_0xf636('0x26')]=qs[_0xf636('0x1e')](_[_0xf636('0x27')](_0x31b0de[_0xf636('0x1d')],_0x1fecf2[_0xf636('0x1e')]),_0x37d8e0);if(_0x31b0de[_0xf636('0x1d')][_0xf636('0x28')]){_0x4608f7['where']=_[_0xf636('0x29')](_0x4608f7[_0xf636('0x26')],{'$or':_[_0xf636('0x15')](_0x37d8e0,function(_0xa9e63a){if(_0xa9e63a[_0xf636('0x19')]!==_0xf636('0x2a')){var _0x3cc488={};_0x3cc488[_0xa9e63a['name']]={'$like':'%'+_0x31b0de[_0xf636('0x1d')][_0xf636('0x28')]+'%'};return _0x3cc488;}})});}_0x4608f7=_[_0xf636('0x29')]({},_0x4608f7,_0x31b0de[_0xf636('0x2b')]);var _0x1184d1={'where':_0x4608f7[_0xf636('0x26')]};return db[_0xf636('0x16')]['count'](_0x1184d1)[_0xf636('0xe')](function(_0x3f3886){_0x12ccd1[_0xf636('0xb')]=_0x3f3886;if(_0x31b0de['query'][_0xf636('0x2c')]){_0x4608f7[_0xf636('0x2d')]=[{'all':!![]}];}return db[_0xf636('0x16')][_0xf636('0x2e')](_0x4608f7);})['then'](function(_0x2dad23){_0x12ccd1[_0xf636('0x2f')]=_0x2dad23;return _0x12ccd1;})[_0xf636('0xe')](respondWithFilteredResult(_0x542af0,_0x4608f7))[_0xf636('0x30')](handleError(_0x542af0,null));};exports[_0xf636('0x31')]=function(_0x3bc9a5,_0x19f28b){var _0x36261d={'raw':![],'where':{'id':_0x3bc9a5[_0xf636('0x32')]['id']}},_0x2c83be={};_0x2c83be[_0xf636('0x1b')]=_['keys'](db[_0xf636('0x16')][_0xf636('0x17')]);_0x2c83be[_0xf636('0x1d')]=_[_0xf636('0x1c')](_0x3bc9a5[_0xf636('0x1d')]);_0x2c83be[_0xf636('0x1e')]=_['intersection'](_0x2c83be[_0xf636('0x1b')],_0x2c83be[_0xf636('0x1d')]);_0x36261d[_0xf636('0x20')]=_['intersection'](_0x2c83be['model'],qs[_0xf636('0x33')](_0x3bc9a5[_0xf636('0x1d')][_0xf636('0x33')]));_0x36261d[_0xf636('0x20')]=_0x36261d[_0xf636('0x20')]['length']?_0x36261d[_0xf636('0x20')]:_0x2c83be[_0xf636('0x1b')];if(_0x3bc9a5['query']['includeAll']){_0x36261d[_0xf636('0x2d')]=[{'all':!![]}];}_0x36261d=_[_0xf636('0x29')]({},_0x36261d,_0x3bc9a5[_0xf636('0x2b')]);return db['Dynamics365Account'][_0xf636('0x34')](_0x36261d)[_0xf636('0xe')](handleEntityNotFound(_0x19f28b,null))[_0xf636('0xe')](respondWithResult(_0x19f28b,null))['catch'](handleError(_0x19f28b,null));};exports[_0xf636('0x35')]=function(_0x5c9390,_0x30a27c){return db[_0xf636('0x16')][_0xf636('0x35')](_0x5c9390['body'],{})['then'](respondWithResult(_0x30a27c,0xc9))[_0xf636('0x30')](handleError(_0x30a27c,null));};exports['update']=function(_0x1c4e06,_0x3ac1ee){if(_0x1c4e06[_0xf636('0x36')]['id']){delete _0x1c4e06[_0xf636('0x36')]['id'];}return db[_0xf636('0x16')][_0xf636('0x34')]({'where':{'id':_0x1c4e06['params']['id']}})['then'](handleEntityNotFound(_0x3ac1ee,null))[_0xf636('0xe')](saveUpdates(_0x1c4e06[_0xf636('0x36')],null))[_0xf636('0xe')](respondWithResult(_0x3ac1ee,null))['catch'](handleError(_0x3ac1ee,null));};exports[_0xf636('0xf')]=function(_0x2dc8f6,_0x453ed7){return db[_0xf636('0x16')][_0xf636('0x34')]({'where':{'id':_0x2dc8f6[_0xf636('0x32')]['id']}})[_0xf636('0xe')](handleEntityNotFound(_0x453ed7,null))[_0xf636('0xe')](removeEntity(_0x453ed7,null))[_0xf636('0x30')](handleError(_0x453ed7,null));};exports[_0xf636('0x37')]=function(_0x140fc5,_0x1bc605){var _0x6c6cdc={};var _0x2ca6a6={};var _0x14e01d;var _0x24176d;return db[_0xf636('0x16')][_0xf636('0x38')]({'where':{'id':_0x140fc5[_0xf636('0x32')]['id']}})['then'](handleEntityNotFound(_0x1bc605,null))[_0xf636('0xe')](function(_0x472e13){if(_0x472e13){_0x14e01d=_0x472e13;_0x2ca6a6[_0xf636('0x1b')]=_[_0xf636('0x1c')](db['Dynamics365Configuration']['rawAttributes']);_0x2ca6a6[_0xf636('0x1d')]=_[_0xf636('0x1c')](_0x140fc5[_0xf636('0x1d')]);_0x2ca6a6[_0xf636('0x1e')]=_['intersection'](_0x2ca6a6[_0xf636('0x1b')],_0x2ca6a6[_0xf636('0x1d')]);_0x6c6cdc['attributes']=_[_0xf636('0x1f')](_0x2ca6a6[_0xf636('0x1b')],qs[_0xf636('0x33')](_0x140fc5['query'][_0xf636('0x33')]));_0x6c6cdc['attributes']=_0x6c6cdc['attributes'][_0xf636('0x21')]?_0x6c6cdc[_0xf636('0x20')]:_0x2ca6a6['model'];_0x6c6cdc[_0xf636('0x24')]=qs[_0xf636('0x25')](_0x140fc5[_0xf636('0x1d')]['sort']);_0x6c6cdc[_0xf636('0x26')]=qs[_0xf636('0x1e')](_['pick'](_0x140fc5[_0xf636('0x1d')],_0x2ca6a6[_0xf636('0x1e')]));if(_0x140fc5[_0xf636('0x1d')][_0xf636('0x28')]){_0x6c6cdc[_0xf636('0x26')]=_[_0xf636('0x29')](_0x6c6cdc[_0xf636('0x26')],{'$or':_[_0xf636('0x15')](_0x6c6cdc[_0xf636('0x20')],function(_0x1c5df9){var _0x4646b6={};_0x4646b6[_0x1c5df9]={'$like':'%'+_0x140fc5[_0xf636('0x1d')]['filter']+'%'};return _0x4646b6;})});}_0x6c6cdc=_[_0xf636('0x29')]({},_0x6c6cdc,_0x140fc5[_0xf636('0x2b')]);return _0x14e01d[_0xf636('0x37')](_0x6c6cdc);}})[_0xf636('0xe')](function(_0xcce43f){if(_0xcce43f){_0x24176d=_0xcce43f[_0xf636('0x21')];if(!_0x140fc5[_0xf636('0x1d')]['hasOwnProperty'](_0xf636('0x23'))){_0x6c6cdc[_0xf636('0xa')]=qs[_0xf636('0xa')](_0x140fc5[_0xf636('0x1d')]['limit']);_0x6c6cdc['offset']=qs[_0xf636('0x8')](_0x140fc5[_0xf636('0x1d')]['offset']);}return _0x14e01d['getConfigurations'](_0x6c6cdc);}})[_0xf636('0xe')](function(_0x406d9c){if(_0x406d9c){return _0x406d9c?{'count':_0x24176d,'rows':_0x406d9c}:null;}})['then'](respondWithResult(_0x1bc605,null))[_0xf636('0x30')](handleError(_0x1bc605,null));};exports['addConfiguration']=function(_0x262db8,_0x3dd29e){if(_0x262db8[_0xf636('0x36')]['id']){delete _0x262db8['body']['id'];}return db[_0xf636('0x16')][_0xf636('0x38')]({'where':{'id':_0x262db8[_0xf636('0x32')]['id']}})[_0xf636('0xe')](handleEntityNotFound(_0x3dd29e,null))[_0xf636('0xe')](function(_0x1afcf0){if(_0x1afcf0){_0x262db8[_0xf636('0x36')][_0xf636('0x39')]=_0x1afcf0['id'];_0x262db8[_0xf636('0x36')][_0xf636('0x3a')]=integrations[_0xf636('0x3b')](_0x262db8[_0xf636('0x36')][_0xf636('0x3c')],_0x262db8[_0xf636('0x36')][_0xf636('0x19')]);_0x262db8[_0xf636('0x36')][_0xf636('0x3d')]=integrations['getDescriptions'](_0x262db8['body'][_0xf636('0x3c')],_0x262db8[_0xf636('0x36')][_0xf636('0x19')]);return db[_0xf636('0x3e')][_0xf636('0x35')](_0x262db8[_0xf636('0x36')],{'include':[{'model':db[_0xf636('0x3f')],'as':'Subjects'},{'model':db[_0xf636('0x3f')],'as':_0xf636('0x3d')}]});}return null;})['then'](respondWithResult(_0x3dd29e,null))[_0xf636('0x30')](handleError(_0x3dd29e,null));};function sanitizeRemoteUri(_0x237cd8){var _0x16f794=_0x237cd8[_0xf636('0x40')](-0x1);if(_0x16f794==='/')return _0x237cd8[_0xf636('0x41')](0x0,_0x237cd8[_0xf636('0x42')](_0x16f794));return _0x237cd8;}function getWebApiUrl(_0x43b03c){return util[_0xf636('0x43')](_0xf636('0x44'),_0x43b03c);}exports['getFields']=function(_0x2793ea,_0x46df60){var _0x9d1949=_0x2793ea[_0xf636('0x1d')][_0xf636('0x45')];var _0x2e92c0=_0x9d1949==='incident'?_0xf636('0x46'):_0xf636('0x47');var _0xa6358d='';var _0x267253='';var _0x46d286='';var _0x4bcf55='';var _0x801dea='';var _0x37eb2a='';var _0x4297b4='';var _0x39a7b3='';var _0x692eb8=[_0xf636('0x48'),_0xf636('0x49'),_0xf636('0x4a'),'ownerid',_0xf636('0x4b'),_0xf636('0x4c'),_0xf636('0x4d'),_0xf636('0x4e'),_0xf636('0x4f'),_0xf636('0x50')];var _0x45ad24=['accountidname',_0xf636('0x51'),_0xf636('0x52'),_0xf636('0x53'),_0xf636('0x54'),_0xf636('0x55'),_0xf636('0x56'),_0xf636('0x57'),_0xf636('0x58'),_0xf636('0x59'),_0xf636('0x5a'),_0xf636('0x5b'),'createdon',_0xf636('0x5c'),_0xf636('0x5d'),_0xf636('0x5e'),_0xf636('0x5f'),_0xf636('0x60'),'emailaddress',_0xf636('0x61'),'entityimage_timestamp',_0xf636('0x62'),_0xf636('0x63'),'exchangerate',_0xf636('0x64'),_0xf636('0x65'),_0xf636('0x66'),'influencescore','kbarticleidname','lastonholdtime',_0xf636('0x67'),_0xf636('0x68'),_0xf636('0x69'),'modifiedbyname','modifiedbyyominame','modifiedon',_0xf636('0x6a'),_0xf636('0x6b'),_0xf636('0x6c'),_0xf636('0x6d'),_0xf636('0x6e'),_0xf636('0x6f'),_0xf636('0x70'),_0xf636('0x71'),_0xf636('0x72'),_0xf636('0x73'),'parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename',_0xf636('0x74'),_0xf636('0x75'),_0xf636('0x76'),_0xf636('0x77'),_0xf636('0x78'),'responsiblecontactidname','responsiblecontactidyominame',_0xf636('0x79'),_0xf636('0x7a'),'slaname',_0xf636('0x7b'),_0xf636('0x7c'),_0xf636('0x7d'),_0xf636('0x7e'),_0xf636('0x7f'),'timezoneruleversionnumber','transactioncurrencyidname',_0xf636('0x80'),_0xf636('0x81'),_0xf636('0x82')];var _0x49c7e6=_0x692eb8[_0xf636('0x83')](_0x45ad24);return db[_0xf636('0x16')][_0xf636('0x38')]({'where':{'id':_0x2793ea[_0xf636('0x32')]['id']},'attributes':['id','username',_0xf636('0x84'),'remoteUri',_0xf636('0x85'),_0xf636('0x86'),_0xf636('0x87'),'modernAuthentication'],'include':[{'model':db['CloudProvider'],'as':'CloudProvider','attributes':['id','data5','data7']}]})[_0xf636('0xe')](handleEntityNotFound(_0x46df60,null))['then'](function(_0x45fac5){if(_0x45fac5){if(_0x45fac5['modernAuthentication']){_0x45fac5[_0xf636('0x88')]=_0x45fac5[_0xf636('0x89')][_0xf636('0x8a')];_0x39a7b3=sanitizeRemoteUri(_0x45fac5[_0xf636('0x89')][_0xf636('0x8b')]);_0x4297b4=getWebApiUrl(_0x39a7b3);return _0x45fac5;}_0x39a7b3=sanitizeRemoteUri(_0x45fac5['remoteUri']);_0x4297b4=getWebApiUrl(_0x39a7b3);var _0x43bd70={'method':_0xf636('0x8c'),'uri':_0xf636('0x8d')+_0x45fac5[_0xf636('0x85')]+_0xf636('0x8e'),'form':{'client_id':_0x45fac5['clientId'],'resource':_0x39a7b3,'username':_0x45fac5[_0xf636('0x8f')],'password':_0x45fac5[_0xf636('0x84')],'grant_type':'password','client_secret':_0x45fac5[_0xf636('0x87')]},'json':!![]};return rp(_0x43bd70);}})[_0xf636('0xe')](function(_0x13d28f){_0x37eb2a=_0x13d28f[_0xf636('0x88')];var _0x47349b={'method':_0xf636('0x90'),'uri':encodeURI(_0x4297b4+_0xf636('0x91')+_0x2e92c0+'\x27'),'headers':{'Authorization':_0xf636('0x92')+_0x37eb2a,'If-None-Match':null,'OData-Version':_0xf636('0x93')},'json':!![]};return rp(_0x47349b);})[_0xf636('0xe')](function(_0x3ef721){var _0x36a9d2=_0x3ef721[_0xf636('0x94')][0x0];var _0x33f1f1=_0x36a9d2['MetadataId'];var _0x4da94a={'method':_0xf636('0x90'),'uri':_0x4297b4+_0xf636('0x95')+_0x33f1f1+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0xf636('0x92')+_0x37eb2a,'If-None-Match':null,'OData-Version':_0xf636('0x93')},'json':!![]};return rp(_0x4da94a);})[_0xf636('0xe')](function(_0x2b86fa){_0xa6358d=_0x2b86fa;_0x267253=_0xa6358d[_0xf636('0x96')];_0x267253=_['remove'](_0x267253,function(_0x1bac5a){return!_0x49c7e6[_0xf636('0x97')](_0x1bac5a[_0xf636('0x98')]);});var _0x40467c=[];var _0x43c075=[];_0x267253['forEach'](function(_0x5cac0f){if(_0x5cac0f[_0xf636('0x99')]){var _0x4efa51=_0x5cac0f[_0xf636('0x99')][_0xf636('0x41')](_0x5cac0f['@odata.type']['lastIndexOf']('.')+0x1);if(_0x4efa51==='PicklistAttributeMetadata'){_0x40467c[_0xf636('0x9a')](getSelectList(_0x4297b4,_0x9d1949,_0x43c075,_0xa6358d[_0xf636('0x9b')],_0x5cac0f['MetadataId'],_0x37eb2a));}}});return Promise[_0xf636('0x9c')](_0x40467c);})['then'](function(_0x1b1d19){_0x46d286=_0x1b1d19[0x0];var _0x5ef833=[];var _0x229700=[];_0x267253[_0xf636('0x9d')](function(_0x1905b8){if(!_[_0xf636('0x9e')](_0x1905b8['@odata.type'])){var _0x232009=_0x1905b8[_0xf636('0x99')][_0xf636('0x41')](_0x1905b8['@odata.type'][_0xf636('0x42')]('.')+0x1);if(_0x232009===_0xf636('0x9f')){_0x5ef833[_0xf636('0x9a')](getBooleanList(_0x4297b4,_0x9d1949,_0x229700,_0xa6358d[_0xf636('0x9b')],_0x1905b8[_0xf636('0x9b')],_0x37eb2a));}}});return Promise[_0xf636('0x9c')](_0x5ef833);})[_0xf636('0xe')](function(_0x5cb4a3){_0x4bcf55=_0x5cb4a3[0x0];var _0x443478=[];var _0x5b7720=[];_0x267253[_0xf636('0x9d')](function(_0x50a1be){if(_0x50a1be['@odata.type']){var _0x332df9=_0x50a1be['@odata.type']['substring'](_0x50a1be[_0xf636('0x99')][_0xf636('0x42')]('.')+0x1);if(_0x332df9==='StringAttributeMetadata'||_0x332df9===_0xf636('0xa0')||_0x332df9===_0xf636('0xa1')||_0x332df9===_0xf636('0xa2')||_0x332df9==='MemoAttributeMetadata'||_0x332df9===_0xf636('0xa3')||_0x332df9===_0xf636('0xa4')||_0x332df9===_0xf636('0xa5')||_0x332df9===_0xf636('0xa6')||_0x332df9===_0xf636('0xa7')){_0x443478[_0xf636('0x9a')](getInputList(_0x4297b4,_0x9d1949,_0x332df9,_0x5b7720,_0xa6358d[_0xf636('0x9b')],_0x50a1be['MetadataId'],_0x37eb2a));}}});return Promise['all'](_0x443478);})[_0xf636('0xe')](function(_0x415506){_0x801dea=_0x415506[0x0];var _0x6cd52=_0x46d286[_0xf636('0x83')](_0x4bcf55)[_0xf636('0x83')](_0x801dea);var _0x2f6fb8={'count':_0x6cd52[_0xf636('0x21')],'rows':_0x6cd52};return _0x2f6fb8;})[_0xf636('0xe')](respondWithResult(_0x46df60,null))[_0xf636('0x30')](function(_0x36c026){var _0x56a55e=_0x2793ea[_0xf636('0x1d')][_0xf636('0xa8')]?0x1f4:_0x36c026[_0xf636('0xa9')]||0x1f4;logger['error'](_0x36c026[_0xf636('0x13')]);delete _0x36c026[_0xf636('0x14')];if(_0x56a55e===0x191){_0x56a55e=0x190;}_0x46df60[_0xf636('0x6')](_0x56a55e)[_0xf636('0xaa')](_0x2793ea['query']['test']?{'message':_0xf636('0xab'),'statusCode':_0x36c026[_0xf636('0xa9')]}:_0x36c026);});};function getSelectList(_0x3d4dab,_0x2472a6,_0x1e3374,_0x1347f3,_0x35e592,_0x28ee7b){var _0x13280f={'method':_0xf636('0x90'),'uri':_0x3d4dab+_0xf636('0x95')+_0x1347f3+_0xf636('0xac')+_0x35e592+_0xf636('0xad')+_0xf636('0xae'),'headers':{'Authorization':_0xf636('0x92')+_0x28ee7b,'If-None-Match':null,'OData-Version':_0xf636('0x93')},'json':!![]};return rp(_0x13280f)['then'](function(_0x273714){var _0x4eae81=[];var _0x21b5d6=_0x273714[_0xf636('0xaf')][_0xf636('0xb0')];_0x21b5d6[_0xf636('0x9d')](function(_0x57eab9){_0x4eae81[_0xf636('0x9a')]({'name':_0x57eab9[_0xf636('0xb1')][_0xf636('0xb2')][_0xf636('0xb1')],'value':String(_0x57eab9[_0xf636('0xb3')])});});var _0x538406={'id':_0x2472a6+'_'+_0x273714[_0xf636('0x98')],'name':_0x273714[_0xf636('0xb4')]['UserLocalizedLabel'][_0xf636('0xb1')],'custom':![],'options':_0x4eae81};_0x1e3374[_0xf636('0x9a')](_0x538406);return _0x1e3374;});}function getBooleanList(_0x3c1c85,_0x8b1c17,_0x4bc0a8,_0x25a319,_0x36de46,_0x395c7e){var _0x45fd25={'method':_0xf636('0x90'),'uri':_0x3c1c85+'EntityDefinitions('+_0x25a319+_0xf636('0xac')+_0x36de46+_0xf636('0xb5'),'headers':{'Authorization':_0xf636('0x92')+_0x395c7e,'If-None-Match':null,'OData-Version':_0xf636('0x93')},'json':!![]};return rp(_0x45fd25)[_0xf636('0xe')](function(_0xc7a985){var _0x1e1529=[];_0x1e1529[_0xf636('0x9a')]({'name':_0xc7a985[_0xf636('0xaf')][_0xf636('0xb6')][_0xf636('0xb1')][_0xf636('0xb2')][_0xf636('0xb1')],'value':_0xf636('0xb7')},{'name':_0xc7a985[_0xf636('0xaf')][_0xf636('0xb8')]['Label'][_0xf636('0xb2')]['Label'],'value':_0xf636('0xb9')});var _0x57c43a={'id':_0x8b1c17+'_'+_0xc7a985[_0xf636('0x98')],'name':_0xc7a985[_0xf636('0xb4')][_0xf636('0xb2')][_0xf636('0xb1')],'custom':![],'options':_0x1e1529};_0x4bc0a8[_0xf636('0x9a')](_0x57c43a);return _0x4bc0a8;});}function getInputList(_0x24e39d,_0x2b025c,_0x932402,_0x7b01f1,_0xa1f6e4,_0x41614a,_0x11e539){var _0x458acf={'method':_0xf636('0x90'),'uri':_0x24e39d+_0xf636('0x95')+_0xa1f6e4+_0xf636('0xac')+_0x41614a+_0xf636('0xba')+_0x932402+_0xf636('0xbb'),'headers':{'Authorization':_0xf636('0x92')+_0x11e539,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x458acf)[_0xf636('0xe')](function(_0x4c51bc){var _0x171949={'id':_0x2b025c+'_'+_0x4c51bc['LogicalName'],'name':_0x4c51bc[_0xf636('0xb4')]['UserLocalizedLabel']?_0x4c51bc[_0xf636('0xb4')]['UserLocalizedLabel'][_0xf636('0xb1')]:_0x4c51bc['LogicalName'],'custom':![],'options':[]};_0x7b01f1[_0xf636('0x9a')](_0x171949);return _0x7b01f1;});}
\ No newline at end of file