Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index c754c18..df9e8a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x326f=['path','sox','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../components/integrations/configuration','jayson/promise','http','request','then','info','Dynamics365Account,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Account,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','json','count','limit','set','apply','reject','save','update','destroy','end','stack','name','send','index','map','rawAttributes','fieldName','type','key','keys','query','filters','intersection','attributes','model','fields','hasOwnProperty','offset','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','Dynamics365Account','create','body','find','findOne','Dynamics365Configuration','length','nolimit','getConfigurations','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','getFields','ticketType','incident','PhoneCall','title','description','customerid','ownerid','subject','directioncode','phonecall_activity_parties','actualserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyyominame','createdon','customeridname','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','followupby','influencescore','kbarticleidname','masteridname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','resolveby','resolvebykpiidname','responsiblecontactidname','responsiblecontactidyominame','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','subjectidname','ticketnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','password','tenantId','clientSecret','remoteUri','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','POST','https://login.microsoftonline.com/','/oauth2/token','clientId','access_token','GET','4.0','value','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Bearer\x20','Attributes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','MetadataId','all','BooleanAttributeMetadata','push','StringAttributeMetadata','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','statusCode','test',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','OptionSet','Options','Label','Value','UserLocalizedLabel','TrueOption','true','false','DisplayName',')/Microsoft.Dynamics.CRM.','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util'];(function(_0x3af68e,_0x384315){var _0x3e6d5b=function(_0x21e40c){while(--_0x21e40c){_0x3af68e['push'](_0x3af68e['shift']());}};_0x3e6d5b(++_0x384315);}(_0x326f,0xd1));var _0xf326=function(_0x47bd63,_0xb115ec){_0x47bd63=_0x47bd63-0x0;var _0x70dcee=_0x326f[_0x47bd63];return _0x70dcee;};'use strict';var pdf=require(_0xf326('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf326('0x1'));var jsonpatch=require(_0xf326('0x2'));var rp=require(_0xf326('0x3'));var moment=require(_0xf326('0x4'));var BPromise=require(_0xf326('0x5'));var Mustache=require(_0xf326('0x6'));var util=require(_0xf326('0x7'));var path=require(_0xf326('0x8'));var sox=require(_0xf326('0x9'));var csv=require(_0xf326('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0xf326('0x17'));var jayson=require(_0xf326('0x18'));var client=jayson['client'][_0xf326('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x472632,_0x3504eb,_0x17a098,_0x5c8483){return new BPromise(function(_0x45c1b6,_0x5204ee){var _0x54bd1a=_0x5c8483||client;return _0x54bd1a[_0xf326('0x1a')](_0x472632,_0x17a098)[_0xf326('0x1b')](function(_0x1f2e5a){logger[_0xf326('0x1c')](_0xf326('0x1d'),_0x3504eb,_0xf326('0x1e'));logger[_0xf326('0x1f')](_0xf326('0x20'),_0x3504eb,'request\x20sent',JSON[_0xf326('0x21')](_0x1f2e5a));if(_0x1f2e5a[_0xf326('0x22')]){if(_0x1f2e5a[_0xf326('0x22')][_0xf326('0x23')]===0x1f4){logger[_0xf326('0x22')](_0xf326('0x1d'),_0x3504eb,_0x1f2e5a['error']['message']);return _0x5204ee(_0x1f2e5a['error'][_0xf326('0x24')]);}logger[_0xf326('0x22')]('Dynamics365Account,\x20%s,\x20%s',_0x3504eb,_0x1f2e5a['error'][_0xf326('0x24')]);return _0x45c1b6(_0x1f2e5a['error']['message']);}else{logger[_0xf326('0x1c')](_0xf326('0x1d'),_0x3504eb,'request\x20sent');_0x45c1b6(_0x1f2e5a['result'][_0xf326('0x24')]);}})[_0xf326('0x25')](function(_0x5f21a2){logger[_0xf326('0x22')](_0xf326('0x1d'),_0x3504eb,_0x5f21a2);_0x5204ee(_0x5f21a2);});});}function respondWithStatusCode(_0x43c53e,_0x295752){_0x295752=_0x295752||0xcc;return function(_0x17c157){if(_0x17c157){return _0x43c53e[_0xf326('0x26')](_0x295752);}return _0x43c53e['status'](_0x295752)['end']();};}function respondWithResult(_0x4f31f6,_0x520d85){_0x520d85=_0x520d85||0xc8;return function(_0x1a2c4e){if(_0x1a2c4e){return _0x4f31f6[_0xf326('0x27')](_0x520d85)[_0xf326('0x28')](_0x1a2c4e);}};}function respondWithFilteredResult(_0x148953,_0x410237){return function(_0x5217d4){if(_0x5217d4){var _0x201d28=_0x5217d4[_0xf326('0x29')],_0xa3c0b=_0x410237['offset'],_0x212d5d=_0x410237['offset']+_0x410237[_0xf326('0x2a')],_0x581531;if(_0x212d5d>=_0x201d28){_0x212d5d=_0x201d28;_0x581531=0xc8;}else{_0x581531=0xce;}_0x148953[_0xf326('0x27')](_0x581531);return _0x148953[_0xf326('0x2b')]('Content-Range',_0xa3c0b+'-'+_0x212d5d+'/'+_0x201d28)[_0xf326('0x28')](_0x5217d4);}return null;};}function patchUpdates(_0x292500){return function(_0x55790d){try{jsonpatch[_0xf326('0x2c')](_0x55790d,_0x292500,!![]);}catch(_0x119ab8){return BPromise[_0xf326('0x2d')](_0x119ab8);}return _0x55790d[_0xf326('0x2e')]();};}function saveUpdates(_0xa80156,_0x269be9){return function(_0x161143){if(_0x161143){return _0x161143[_0xf326('0x2f')](_0xa80156)[_0xf326('0x1b')](function(_0x349a03){return _0x349a03;});}return null;};}function removeEntity(_0x4b52f2,_0x1035ed){return function(_0x424104){if(_0x424104){return _0x424104[_0xf326('0x30')]()['then'](function(){_0x4b52f2[_0xf326('0x27')](0xcc)[_0xf326('0x31')]();});}};}function handleEntityNotFound(_0x303dc6,_0x4df451){return function(_0x5b101d){if(!_0x5b101d){_0x303dc6[_0xf326('0x26')](0x194);}return _0x5b101d;};}function handleError(_0x46d75e,_0x9c3039){_0x9c3039=_0x9c3039||0x1f4;return function(_0xf53cf3){logger[_0xf326('0x22')](_0xf53cf3[_0xf326('0x32')]);if(_0xf53cf3[_0xf326('0x33')]){delete _0xf53cf3[_0xf326('0x33')];}_0x46d75e['status'](_0x9c3039)[_0xf326('0x34')](_0xf53cf3);};}exports[_0xf326('0x35')]=function(_0x51207a,_0x4083a2){var _0x4e5d7c={},_0xce1cbb={},_0x481b64={'count':0x0,'rows':[]};var _0x51f147=_[_0xf326('0x36')](db['Dynamics365Account'][_0xf326('0x37')],function(_0x57aa27){return{'name':_0x57aa27[_0xf326('0x38')],'type':_0x57aa27[_0xf326('0x39')][_0xf326('0x3a')]};});_0xce1cbb['model']=_[_0xf326('0x36')](_0x51f147,_0xf326('0x33'));_0xce1cbb['query']=_[_0xf326('0x3b')](_0x51207a[_0xf326('0x3c')]);_0xce1cbb[_0xf326('0x3d')]=_[_0xf326('0x3e')](_0xce1cbb['model'],_0xce1cbb[_0xf326('0x3c')]);_0x4e5d7c[_0xf326('0x3f')]=_[_0xf326('0x3e')](_0xce1cbb[_0xf326('0x40')],qs[_0xf326('0x41')](_0x51207a['query'][_0xf326('0x41')]));_0x4e5d7c[_0xf326('0x3f')]=_0x4e5d7c['attributes']['length']?_0x4e5d7c[_0xf326('0x3f')]:_0xce1cbb['model'];if(!_0x51207a['query'][_0xf326('0x42')]('nolimit')){_0x4e5d7c[_0xf326('0x2a')]=qs[_0xf326('0x2a')](_0x51207a[_0xf326('0x3c')][_0xf326('0x2a')]);_0x4e5d7c['offset']=qs[_0xf326('0x43')](_0x51207a[_0xf326('0x3c')][_0xf326('0x43')]);}_0x4e5d7c[_0xf326('0x44')]=qs[_0xf326('0x45')](_0x51207a[_0xf326('0x3c')][_0xf326('0x45')]);_0x4e5d7c[_0xf326('0x46')]=qs[_0xf326('0x3d')](_[_0xf326('0x47')](_0x51207a[_0xf326('0x3c')],_0xce1cbb[_0xf326('0x3d')]),_0x51f147);if(_0x51207a['query'][_0xf326('0x48')]){_0x4e5d7c[_0xf326('0x46')]=_[_0xf326('0x49')](_0x4e5d7c[_0xf326('0x46')],{'$or':_[_0xf326('0x36')](_0x51f147,function(_0x1a2d0d){if(_0x1a2d0d['type']!==_0xf326('0x4a')){var _0xbacd3c={};_0xbacd3c[_0x1a2d0d['name']]={'$like':'%'+_0x51207a[_0xf326('0x3c')][_0xf326('0x48')]+'%'};return _0xbacd3c;}})});}_0x4e5d7c=_[_0xf326('0x49')]({},_0x4e5d7c,_0x51207a[_0xf326('0x4b')]);var _0x427c34={'where':_0x4e5d7c['where']};return db['Dynamics365Account'][_0xf326('0x29')](_0x427c34)[_0xf326('0x1b')](function(_0x5ed62e){_0x481b64['count']=_0x5ed62e;if(_0x51207a[_0xf326('0x3c')][_0xf326('0x4c')]){_0x4e5d7c[_0xf326('0x4d')]=[{'all':!![]}];}return db['Dynamics365Account'][_0xf326('0x4e')](_0x4e5d7c);})[_0xf326('0x1b')](function(_0x2180d6){_0x481b64[_0xf326('0x4f')]=_0x2180d6;return _0x481b64;})[_0xf326('0x1b')](respondWithFilteredResult(_0x4083a2,_0x4e5d7c))[_0xf326('0x25')](handleError(_0x4083a2,null));};exports[_0xf326('0x50')]=function(_0x3b90dc,_0x3df9a8){var _0x27ced1={'raw':![],'where':{'id':_0x3b90dc[_0xf326('0x51')]['id']}},_0x1c76c8={};_0x1c76c8[_0xf326('0x40')]=_[_0xf326('0x3b')](db[_0xf326('0x52')]['rawAttributes']);_0x1c76c8[_0xf326('0x3c')]=_[_0xf326('0x3b')](_0x3b90dc[_0xf326('0x3c')]);_0x1c76c8[_0xf326('0x3d')]=_['intersection'](_0x1c76c8[_0xf326('0x40')],_0x1c76c8[_0xf326('0x3c')]);_0x27ced1[_0xf326('0x3f')]=_[_0xf326('0x3e')](_0x1c76c8['model'],qs[_0xf326('0x41')](_0x3b90dc[_0xf326('0x3c')][_0xf326('0x41')]));_0x27ced1[_0xf326('0x3f')]=_0x27ced1[_0xf326('0x3f')]['length']?_0x27ced1['attributes']:_0x1c76c8[_0xf326('0x40')];if(_0x3b90dc[_0xf326('0x3c')][_0xf326('0x4c')]){_0x27ced1['include']=[{'all':!![]}];}_0x27ced1=_[_0xf326('0x49')]({},_0x27ced1,_0x3b90dc[_0xf326('0x4b')]);return db[_0xf326('0x52')]['find'](_0x27ced1)['then'](handleEntityNotFound(_0x3df9a8,null))[_0xf326('0x1b')](respondWithResult(_0x3df9a8,null))['catch'](handleError(_0x3df9a8,null));};exports[_0xf326('0x53')]=function(_0x554277,_0x458e5f){return db[_0xf326('0x52')][_0xf326('0x53')](_0x554277[_0xf326('0x54')],{})[_0xf326('0x1b')](respondWithResult(_0x458e5f,0xc9))[_0xf326('0x25')](handleError(_0x458e5f,null));};exports[_0xf326('0x2f')]=function(_0x495a16,_0xcdaf3f){if(_0x495a16[_0xf326('0x54')]['id']){delete _0x495a16[_0xf326('0x54')]['id'];}return db['Dynamics365Account'][_0xf326('0x55')]({'where':{'id':_0x495a16[_0xf326('0x51')]['id']}})[_0xf326('0x1b')](handleEntityNotFound(_0xcdaf3f,null))[_0xf326('0x1b')](saveUpdates(_0x495a16[_0xf326('0x54')],null))['then'](respondWithResult(_0xcdaf3f,null))[_0xf326('0x25')](handleError(_0xcdaf3f,null));};exports[_0xf326('0x30')]=function(_0x287a97,_0x46a21f){return db['Dynamics365Account'][_0xf326('0x55')]({'where':{'id':_0x287a97[_0xf326('0x51')]['id']}})[_0xf326('0x1b')](handleEntityNotFound(_0x46a21f,null))[_0xf326('0x1b')](removeEntity(_0x46a21f,null))['catch'](handleError(_0x46a21f,null));};exports['getConfigurations']=function(_0x18b46e,_0x44d2ed,_0x55ca96){var _0x3cf6fa={};var _0x29de71={};var _0x316609;var _0x1258d1;return db['Dynamics365Account'][_0xf326('0x56')]({'where':{'id':_0x18b46e['params']['id']}})['then'](handleEntityNotFound(_0x44d2ed,null))[_0xf326('0x1b')](function(_0x51d466){if(_0x51d466){_0x316609=_0x51d466;_0x29de71[_0xf326('0x40')]=_[_0xf326('0x3b')](db[_0xf326('0x57')]['rawAttributes']);_0x29de71['query']=_[_0xf326('0x3b')](_0x18b46e[_0xf326('0x3c')]);_0x29de71[_0xf326('0x3d')]=_['intersection'](_0x29de71[_0xf326('0x40')],_0x29de71['query']);_0x3cf6fa[_0xf326('0x3f')]=_[_0xf326('0x3e')](_0x29de71[_0xf326('0x40')],qs[_0xf326('0x41')](_0x18b46e[_0xf326('0x3c')][_0xf326('0x41')]));_0x3cf6fa[_0xf326('0x3f')]=_0x3cf6fa[_0xf326('0x3f')][_0xf326('0x58')]?_0x3cf6fa[_0xf326('0x3f')]:_0x29de71[_0xf326('0x40')];_0x3cf6fa[_0xf326('0x44')]=qs[_0xf326('0x45')](_0x18b46e['query'][_0xf326('0x45')]);_0x3cf6fa['where']=qs[_0xf326('0x3d')](_[_0xf326('0x47')](_0x18b46e['query'],_0x29de71[_0xf326('0x3d')]));if(_0x18b46e['query'][_0xf326('0x48')]){_0x3cf6fa[_0xf326('0x46')]=_[_0xf326('0x49')](_0x3cf6fa[_0xf326('0x46')],{'$or':_[_0xf326('0x36')](_0x3cf6fa['attributes'],function(_0x4ec099){var _0x1209ca={};_0x1209ca[_0x4ec099]={'$like':'%'+_0x18b46e[_0xf326('0x3c')][_0xf326('0x48')]+'%'};return _0x1209ca;})});}_0x3cf6fa=_[_0xf326('0x49')]({},_0x3cf6fa,_0x18b46e[_0xf326('0x4b')]);return _0x316609['getConfigurations'](_0x3cf6fa);}})[_0xf326('0x1b')](function(_0x471da8){if(_0x471da8){_0x1258d1=_0x471da8['length'];if(!_0x18b46e['query']['hasOwnProperty'](_0xf326('0x59'))){_0x3cf6fa[_0xf326('0x2a')]=qs[_0xf326('0x2a')](_0x18b46e[_0xf326('0x3c')][_0xf326('0x2a')]);_0x3cf6fa[_0xf326('0x43')]=qs[_0xf326('0x43')](_0x18b46e['query'][_0xf326('0x43')]);}return _0x316609[_0xf326('0x5a')](_0x3cf6fa);}})[_0xf326('0x1b')](function(_0x13cf83){if(_0x13cf83){return _0x13cf83?{'count':_0x1258d1,'rows':_0x13cf83}:null;}})['then'](respondWithResult(_0x44d2ed,null))[_0xf326('0x25')](handleError(_0x44d2ed,null));};exports['addConfiguration']=function(_0x499b59,_0x2dd9e4,_0x540fa0){if(_0x499b59[_0xf326('0x54')]['id']){delete _0x499b59[_0xf326('0x54')]['id'];}return db[_0xf326('0x52')][_0xf326('0x56')]({'where':{'id':_0x499b59[_0xf326('0x51')]['id']}})['then'](handleEntityNotFound(_0x2dd9e4,null))['then'](function(_0x48d84a){if(_0x48d84a){_0x499b59[_0xf326('0x54')][_0xf326('0x5b')]=_0x48d84a['id'];_0x499b59[_0xf326('0x54')][_0xf326('0x5c')]=integrations[_0xf326('0x5d')](_0x499b59['body'][_0xf326('0x5e')],_0x499b59[_0xf326('0x54')][_0xf326('0x39')]);_0x499b59['body']['Descriptions']=integrations[_0xf326('0x5f')](_0x499b59[_0xf326('0x54')]['channel'],_0x499b59['body'][_0xf326('0x39')]);return db['Dynamics365Configuration'][_0xf326('0x53')](_0x499b59['body'],{'include':[{'model':db['Dynamics365Field'],'as':'Subjects'},{'model':db[_0xf326('0x60')],'as':_0xf326('0x61')}]});}return null;})[_0xf326('0x1b')](respondWithResult(_0x2dd9e4,null))['catch'](handleError(_0x2dd9e4,null));};exports[_0xf326('0x62')]=function(_0xdeceb9,_0x35e34d,_0x457f3d){var _0x2dcf6c=_0xdeceb9[_0xf326('0x3c')][_0xf326('0x63')];var _0x23cc31=_0x2dcf6c===_0xf326('0x64')?'Incident':_0xf326('0x65');var _0x5b1494='';var _0x2c81a7='';var _0x366312='';var _0x40ee66='';var _0x4ba982='';var _0x2465f8='';var _0x217fc2='';var _0x39c90d='';var _0x4dc8d7=[_0xf326('0x66'),_0xf326('0x67'),_0xf326('0x68'),_0xf326('0x69'),'caseorigincode',_0xf326('0x6a'),'phonenumber','regardingobjectid',_0xf326('0x6b'),_0xf326('0x6c')];var _0x5af6b7=['accountidname','accountidyominame',_0xf326('0x6d'),'billedserviceunits',_0xf326('0x6e'),_0xf326('0x6f'),_0xf326('0x70'),_0xf326('0x71'),_0xf326('0x72'),_0xf326('0x73'),'createdbyname',_0xf326('0x74'),_0xf326('0x75'),'createdonbehalfbyname','createdonbehalfbyyominame',_0xf326('0x76'),'customeridtype',_0xf326('0x77'),_0xf326('0x78'),_0xf326('0x79'),_0xf326('0x7a'),_0xf326('0x7b'),_0xf326('0x7c'),_0xf326('0x7d'),_0xf326('0x7e'),_0xf326('0x7f'),'importsequencenumber',_0xf326('0x80'),_0xf326('0x81'),'lastonholdtime',_0xf326('0x82'),'modifiedbyexternalpartyname',_0xf326('0x83'),_0xf326('0x84'),_0xf326('0x85'),'modifiedon',_0xf326('0x86'),_0xf326('0x87'),_0xf326('0x88'),_0xf326('0x89'),_0xf326('0x8a'),_0xf326('0x8b'),_0xf326('0x8c'),_0xf326('0x8d'),_0xf326('0x8e'),_0xf326('0x8f'),_0xf326('0x90'),_0xf326('0x91'),_0xf326('0x92'),_0xf326('0x93'),_0xf326('0x94'),'productserialnumber',_0xf326('0x95'),_0xf326('0x96'),'responseby',_0xf326('0x97'),_0xf326('0x98'),'sentimentvalue',_0xf326('0x99'),_0xf326('0x9a'),_0xf326('0x9b'),_0xf326('0x9c'),_0xf326('0x9d'),_0xf326('0x9e'),_0xf326('0x9f'),'timezoneruleversionnumber',_0xf326('0xa0'),_0xf326('0xa1'),_0xf326('0xa2'),_0xf326('0xa3')];var _0x316c8e=_0x4dc8d7[_0xf326('0xa4')](_0x5af6b7);return db[_0xf326('0x52')][_0xf326('0x56')]({'where':{'id':_0xdeceb9['params']['id']},'attributes':['id',_0xf326('0xa5'),_0xf326('0xa6'),'remoteUri',_0xf326('0xa7'),'clientId',_0xf326('0xa8')]})[_0xf326('0x1b')](handleEntityNotFound(_0x35e34d,null))[_0xf326('0x1b')](function(_0x2a0f36){if(_0x2a0f36){_0x39c90d=_0x2a0f36[_0xf326('0xa9')];var _0x3097cf=_0x39c90d[_0xf326('0xaa')](-0x1);if(_0x3097cf==='/'){_0x39c90d=_0x39c90d[_0xf326('0xab')](0x0,_0x39c90d[_0xf326('0xac')](_0x3097cf));}_0x217fc2=util[_0xf326('0xad')](_0xf326('0xae'),_0x39c90d);var _0x3face2={'method':_0xf326('0xaf'),'uri':_0xf326('0xb0')+_0x2a0f36['tenantId']+_0xf326('0xb1'),'form':{'client_id':_0x2a0f36[_0xf326('0xb2')],'resource':_0x39c90d,'username':_0x2a0f36[_0xf326('0xa5')],'password':_0x2a0f36[_0xf326('0xa6')],'grant_type':_0xf326('0xa6'),'client_secret':_0x2a0f36['clientSecret']},'json':!![]};return rp(_0x3face2);}})[_0xf326('0x1b')](function(_0x1b6a15){_0x2465f8=_0x1b6a15[_0xf326('0xb3')];var _0x1578ea={'method':_0xf326('0xb4'),'uri':encodeURI(_0x217fc2+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x23cc31+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x2465f8,'If-None-Match':null,'OData-Version':_0xf326('0xb5')},'json':!![]};return rp(_0x1578ea);})['then'](function(_0xedbcf2){var _0x143965=_0xedbcf2[_0xf326('0xb6')][0x0];var _0x4f35e3=_0x143965['MetadataId'];var _0x386c4c={'method':_0xf326('0xb4'),'uri':_0x217fc2+_0xf326('0xb7')+_0x4f35e3+_0xf326('0xb8'),'headers':{'Authorization':_0xf326('0xb9')+_0x2465f8,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x386c4c);})[_0xf326('0x1b')](function(_0x428eae){_0x5b1494=_0x428eae;_0x2c81a7=_0x5b1494[_0xf326('0xba')];_0x2c81a7=_['remove'](_0x2c81a7,function(_0x4cc620){return!_0x316c8e['includes'](_0x4cc620[_0xf326('0xbb')]);});var _0x17c96c=[];var _0x2d275d=[];_0x2c81a7[_0xf326('0xbc')](function(_0x58ef98){if(_0x58ef98[_0xf326('0xbd')]){var _0x36e21e=_0x58ef98['@odata.type']['substring'](_0x58ef98[_0xf326('0xbd')][_0xf326('0xac')]('.')+0x1);if(_0x36e21e===_0xf326('0xbe')){_0x17c96c['push'](getSelectList(_0x217fc2,_0x2dcf6c,_0x2d275d,_0x5b1494[_0xf326('0xbf')],_0x58ef98[_0xf326('0xbf')],_0x2465f8));}}});return Promise[_0xf326('0xc0')](_0x17c96c);})['then'](function(_0x39d16d){_0x366312=_0x39d16d[0x0];var _0x438733=[];var _0x267bae=[];_0x2c81a7[_0xf326('0xbc')](function(_0x4afbd5){if(!_['isNil'](_0x4afbd5['@odata.type'])){var _0x11c920=_0x4afbd5[_0xf326('0xbd')][_0xf326('0xab')](_0x4afbd5['@odata.type'][_0xf326('0xac')]('.')+0x1);if(_0x11c920===_0xf326('0xc1')){_0x438733[_0xf326('0xc2')](getBooleanList(_0x217fc2,_0x2dcf6c,_0x267bae,_0x5b1494['MetadataId'],_0x4afbd5[_0xf326('0xbf')],_0x2465f8));}}});return Promise[_0xf326('0xc0')](_0x438733);})[_0xf326('0x1b')](function(_0x218553){_0x40ee66=_0x218553[0x0];var _0x500011=[];var _0x435673=[];_0x2c81a7['forEach'](function(_0x2b94b8){if(_0x2b94b8[_0xf326('0xbd')]){var _0x4079ca=_0x2b94b8[_0xf326('0xbd')]['substring'](_0x2b94b8[_0xf326('0xbd')]['lastIndexOf']('.')+0x1);if(_0x4079ca===_0xf326('0xc3')||_0x4079ca===_0xf326('0xc4')||_0x4079ca===_0xf326('0xc5')||_0x4079ca===_0xf326('0xc6')||_0x4079ca===_0xf326('0xc7')||_0x4079ca==='DateTimeAttributeMetadata'||_0x4079ca==='StatusAttributeMetadata'||_0x4079ca===_0xf326('0xc8')||_0x4079ca===_0xf326('0xc9')||_0x4079ca===_0xf326('0xca')){_0x500011[_0xf326('0xc2')](getInputList(_0x217fc2,_0x2dcf6c,_0x4079ca,_0x435673,_0x5b1494['MetadataId'],_0x2b94b8[_0xf326('0xbf')],_0x2465f8));}}});return Promise['all'](_0x500011);})[_0xf326('0x1b')](function(_0x285ada){_0x4ba982=_0x285ada[0x0];var _0xb072ab=_0x366312['concat'](_0x40ee66)[_0xf326('0xa4')](_0x4ba982);var _0x42bbd7={'count':_0xb072ab[_0xf326('0x58')],'rows':_0xb072ab};return _0x42bbd7;})[_0xf326('0x1b')](respondWithResult(_0x35e34d,null))[_0xf326('0x25')](function(_0x4dc4bc){var _0x169e71=_0xdeceb9[_0xf326('0x3c')]['test']?0x1f4:_0x4dc4bc[_0xf326('0xcb')]||0x1f4;logger[_0xf326('0x22')](_0x4dc4bc[_0xf326('0x32')]);delete _0x4dc4bc[_0xf326('0x33')];if(_0x169e71===0x191){_0x169e71=0x190;}_0x35e34d['status'](_0x169e71)['send'](_0xdeceb9[_0xf326('0x3c')][_0xf326('0xcc')]?{'message':'Wrong\x20credentials','statusCode':_0x4dc4bc[_0xf326('0xcb')]}:_0x4dc4bc);});};function getSelectList(_0x5bd50c,_0x59eff9,_0x4cad0,_0x2590ed,_0x2e24eb,_0x37cd6f){var _0x16b5a2={'method':_0xf326('0xb4'),'uri':_0x5bd50c+_0xf326('0xb7')+_0x2590ed+_0xf326('0xcd')+_0x2e24eb+_0xf326('0xce')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0xf326('0xb9')+_0x37cd6f,'If-None-Match':null,'OData-Version':_0xf326('0xb5')},'json':!![]};return rp(_0x16b5a2)[_0xf326('0x1b')](function(_0x1c7f81){var _0x59d894=[];var _0x3e6a5d=_0x1c7f81[_0xf326('0xcf')][_0xf326('0xd0')];_0x3e6a5d[_0xf326('0xbc')](function(_0xc58057){_0x59d894['push']({'name':_0xc58057[_0xf326('0xd1')]['UserLocalizedLabel'][_0xf326('0xd1')],'value':String(_0xc58057[_0xf326('0xd2')])});});var _0xffd165={'id':_0x59eff9+'_'+_0x1c7f81[_0xf326('0xbb')],'name':_0x1c7f81['DisplayName'][_0xf326('0xd3')][_0xf326('0xd1')],'custom':![],'options':_0x59d894};_0x4cad0[_0xf326('0xc2')](_0xffd165);return _0x4cad0;});}function getBooleanList(_0x58d20b,_0x23451e,_0x1552b3,_0x423a6d,_0xc524c0,_0x5520db){var _0xf390a9={'method':_0xf326('0xb4'),'uri':_0x58d20b+_0xf326('0xb7')+_0x423a6d+_0xf326('0xcd')+_0xc524c0+')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','headers':{'Authorization':_0xf326('0xb9')+_0x5520db,'If-None-Match':null,'OData-Version':_0xf326('0xb5')},'json':!![]};return rp(_0xf390a9)[_0xf326('0x1b')](function(_0x48e7ab){var _0x2c0e5b=[];_0x2c0e5b[_0xf326('0xc2')]({'name':_0x48e7ab['OptionSet'][_0xf326('0xd4')][_0xf326('0xd1')][_0xf326('0xd3')][_0xf326('0xd1')],'value':_0xf326('0xd5')},{'name':_0x48e7ab[_0xf326('0xcf')]['FalseOption']['Label'][_0xf326('0xd3')][_0xf326('0xd1')],'value':_0xf326('0xd6')});var _0x2fa05b={'id':_0x23451e+'_'+_0x48e7ab[_0xf326('0xbb')],'name':_0x48e7ab[_0xf326('0xd7')]['UserLocalizedLabel'][_0xf326('0xd1')],'custom':![],'options':_0x2c0e5b};_0x1552b3[_0xf326('0xc2')](_0x2fa05b);return _0x1552b3;});}function getInputList(_0x44e0ac,_0x319483,_0x50d506,_0x204077,_0x160487,_0x478395,_0x342eb6){var _0x4e53f1={'method':_0xf326('0xb4'),'uri':_0x44e0ac+'EntityDefinitions('+_0x160487+')/Attributes('+_0x478395+_0xf326('0xd8')+_0x50d506+'?$select=DisplayName,LogicalName','headers':{'Authorization':_0xf326('0xb9')+_0x342eb6,'If-None-Match':null,'OData-Version':_0xf326('0xb5')},'json':!![]};return rp(_0x4e53f1)[_0xf326('0x1b')](function(_0x7ea54d){var _0x1602b7={'id':_0x319483+'_'+_0x7ea54d[_0xf326('0xbb')],'name':_0x7ea54d[_0xf326('0xd7')][_0xf326('0xd3')]?_0x7ea54d[_0xf326('0xd7')][_0xf326('0xd3')][_0xf326('0xd1')]:_0x7ea54d[_0xf326('0xbb')],'custom':![],'options':[]};_0x204077['push'](_0x1602b7);return _0x204077;});}
\ No newline at end of file
+var _0x0fc6=['UserLocalizedLabel','true','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../config/logger','api','../../mysqldb','status','offset','undefined','limit','count','set','update','then','destroy','end','sendStatus','error','name','send','index','map','Dynamics365Account','rawAttributes','fieldName','type','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','order','sort','filter','where','merge','includeAll','include','rows','catch','show','params','find','create','body','getConfigurations','findOne','Dynamics365Configuration','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','incident','Incident','PhoneCall','description','ownerid','caseorigincode','phonenumber','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractidname','createdbyexternalpartyname','createdbyname','createdon','createdonbehalfbyyominame','customeridyominame','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyyominame','modifiedon','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','slaname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','remoteUri','tenantId','clientId','clientSecret','CloudProvider','data5','modernAuthentication','access_token','data7','POST','https://login.microsoftonline.com/','/oauth2/token','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','value','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','4.0','remove','includes','LogicalName','@odata.type','PicklistAttributeMetadata','push','MetadataId','forEach','BooleanAttributeMetadata','StringAttributeMetadata','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','all','test','statusCode','Wrong\x20credentials',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','Bearer\x20','OptionSet','Options','Label','Value','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption'];(function(_0x2141e1,_0x523aff){var _0x59db37=function(_0x1ffc7c){while(--_0x1ffc7c){_0x2141e1['push'](_0x2141e1['shift']());}};_0x59db37(++_0x523aff);}(_0x0fc6,0x176));var _0x60fc=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x0fc6[_0x42cae2];return _0x5f256f;};'use strict';var rp=require(_0x60fc('0x0'));var util=require(_0x60fc('0x1'));var _=require(_0x60fc('0x2'));var qs=require('../../components/parsers/qs');var logger=require(_0x60fc('0x3'))(_0x60fc('0x4'));var db=require(_0x60fc('0x5'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithResult(_0x322322,_0x4eaa25){_0x4eaa25=_0x4eaa25||0xc8;return function(_0x23c1d7){if(_0x23c1d7){return _0x322322[_0x60fc('0x6')](_0x4eaa25)['json'](_0x23c1d7);}};}function respondWithFilteredResult(_0x3491cc,_0x823732){return function(_0x2b5923){if(_0x2b5923){var _0x1cf074=typeof _0x823732[_0x60fc('0x7')]===_0x60fc('0x8')&&typeof _0x823732[_0x60fc('0x9')]==='undefined';var _0x1de3a6=_0x2b5923[_0x60fc('0xa')];var _0x396740=_0x1cf074?0x0:_0x823732[_0x60fc('0x7')];var _0x5a7536=_0x1cf074?_0x2b5923[_0x60fc('0xa')]:_0x823732[_0x60fc('0x7')]+_0x823732['limit'];var _0x11d555;if(_0x5a7536>=_0x1de3a6){_0x5a7536=_0x1de3a6;_0x11d555=0xc8;}else{_0x11d555=0xce;}_0x3491cc[_0x60fc('0x6')](_0x11d555);return _0x3491cc[_0x60fc('0xb')]('Content-Range',_0x396740+'-'+_0x5a7536+'/'+_0x1de3a6)['json'](_0x2b5923);}return null;};}function saveUpdates(_0xb6d714){return function(_0x2c836a){if(_0x2c836a){return _0x2c836a[_0x60fc('0xc')](_0xb6d714)[_0x60fc('0xd')](function(_0x175070){return _0x175070;});}return null;};}function removeEntity(_0x58ef07){return function(_0x435f22){if(_0x435f22){return _0x435f22[_0x60fc('0xe')]()[_0x60fc('0xd')](function(){_0x58ef07[_0x60fc('0x6')](0xcc)[_0x60fc('0xf')]();});}};}function handleEntityNotFound(_0xc75a8c){return function(_0x4e9bf6){if(!_0x4e9bf6){_0xc75a8c[_0x60fc('0x10')](0x194);}return _0x4e9bf6;};}function handleError(_0x3816e2,_0x522902){_0x522902=_0x522902||0x1f4;return function(_0x4d76c2){logger[_0x60fc('0x11')](_0x4d76c2['stack']);if(_0x4d76c2['name']){delete _0x4d76c2[_0x60fc('0x12')];}_0x3816e2[_0x60fc('0x6')](_0x522902)[_0x60fc('0x13')](_0x4d76c2);};}exports[_0x60fc('0x14')]=function(_0x4f236f,_0x307e51){var _0x25e5e8={},_0x27ab90={},_0x37f09d={'count':0x0,'rows':[]};var _0x4a9b8e=_[_0x60fc('0x15')](db[_0x60fc('0x16')][_0x60fc('0x17')],function(_0x2284b0){return{'name':_0x2284b0[_0x60fc('0x18')],'type':_0x2284b0[_0x60fc('0x19')]['key']};});_0x27ab90['model']=_[_0x60fc('0x15')](_0x4a9b8e,_0x60fc('0x12'));_0x27ab90[_0x60fc('0x1a')]=_[_0x60fc('0x1b')](_0x4f236f[_0x60fc('0x1a')]);_0x27ab90[_0x60fc('0x1c')]=_[_0x60fc('0x1d')](_0x27ab90['model'],_0x27ab90[_0x60fc('0x1a')]);_0x25e5e8[_0x60fc('0x1e')]=_['intersection'](_0x27ab90[_0x60fc('0x1f')],qs[_0x60fc('0x20')](_0x4f236f['query']['fields']));_0x25e5e8[_0x60fc('0x1e')]=_0x25e5e8[_0x60fc('0x1e')][_0x60fc('0x21')]?_0x25e5e8[_0x60fc('0x1e')]:_0x27ab90[_0x60fc('0x1f')];if(!_0x4f236f[_0x60fc('0x1a')][_0x60fc('0x22')]('nolimit')){_0x25e5e8[_0x60fc('0x9')]=qs[_0x60fc('0x9')](_0x4f236f[_0x60fc('0x1a')][_0x60fc('0x9')]);_0x25e5e8[_0x60fc('0x7')]=qs[_0x60fc('0x7')](_0x4f236f[_0x60fc('0x1a')]['offset']);}_0x25e5e8[_0x60fc('0x23')]=qs[_0x60fc('0x24')](_0x4f236f[_0x60fc('0x1a')][_0x60fc('0x24')]);_0x25e5e8['where']=qs[_0x60fc('0x1c')](_['pick'](_0x4f236f[_0x60fc('0x1a')],_0x27ab90['filters']),_0x4a9b8e);if(_0x4f236f['query'][_0x60fc('0x25')]){_0x25e5e8[_0x60fc('0x26')]=_[_0x60fc('0x27')](_0x25e5e8['where'],{'$or':_[_0x60fc('0x15')](_0x4a9b8e,function(_0xdc3bc5){if(_0xdc3bc5[_0x60fc('0x19')]!=='VIRTUAL'){var _0x59dfd1={};_0x59dfd1[_0xdc3bc5[_0x60fc('0x12')]]={'$like':'%'+_0x4f236f[_0x60fc('0x1a')][_0x60fc('0x25')]+'%'};return _0x59dfd1;}})});}_0x25e5e8=_['merge']({},_0x25e5e8,_0x4f236f['options']);var _0x2fc68e={'where':_0x25e5e8[_0x60fc('0x26')]};return db[_0x60fc('0x16')][_0x60fc('0xa')](_0x2fc68e)[_0x60fc('0xd')](function(_0x5d30ab){_0x37f09d[_0x60fc('0xa')]=_0x5d30ab;if(_0x4f236f[_0x60fc('0x1a')][_0x60fc('0x28')]){_0x25e5e8[_0x60fc('0x29')]=[{'all':!![]}];}return db[_0x60fc('0x16')]['findAll'](_0x25e5e8);})[_0x60fc('0xd')](function(_0x3cb6ec){_0x37f09d[_0x60fc('0x2a')]=_0x3cb6ec;return _0x37f09d;})[_0x60fc('0xd')](respondWithFilteredResult(_0x307e51,_0x25e5e8))[_0x60fc('0x2b')](handleError(_0x307e51,null));};exports[_0x60fc('0x2c')]=function(_0x363a02,_0x70f9ce){var _0x43e1f8={'raw':![],'where':{'id':_0x363a02[_0x60fc('0x2d')]['id']}},_0x152e3={};_0x152e3[_0x60fc('0x1f')]=_['keys'](db[_0x60fc('0x16')][_0x60fc('0x17')]);_0x152e3[_0x60fc('0x1a')]=_[_0x60fc('0x1b')](_0x363a02[_0x60fc('0x1a')]);_0x152e3[_0x60fc('0x1c')]=_[_0x60fc('0x1d')](_0x152e3[_0x60fc('0x1f')],_0x152e3[_0x60fc('0x1a')]);_0x43e1f8[_0x60fc('0x1e')]=_[_0x60fc('0x1d')](_0x152e3[_0x60fc('0x1f')],qs['fields'](_0x363a02[_0x60fc('0x1a')][_0x60fc('0x20')]));_0x43e1f8['attributes']=_0x43e1f8[_0x60fc('0x1e')]['length']?_0x43e1f8[_0x60fc('0x1e')]:_0x152e3[_0x60fc('0x1f')];if(_0x363a02[_0x60fc('0x1a')][_0x60fc('0x28')]){_0x43e1f8[_0x60fc('0x29')]=[{'all':!![]}];}_0x43e1f8=_['merge']({},_0x43e1f8,_0x363a02['options']);return db[_0x60fc('0x16')][_0x60fc('0x2e')](_0x43e1f8)[_0x60fc('0xd')](handleEntityNotFound(_0x70f9ce,null))['then'](respondWithResult(_0x70f9ce,null))['catch'](handleError(_0x70f9ce,null));};exports[_0x60fc('0x2f')]=function(_0x45cc96,_0x1693dd){return db['Dynamics365Account'][_0x60fc('0x2f')](_0x45cc96[_0x60fc('0x30')],{})[_0x60fc('0xd')](respondWithResult(_0x1693dd,0xc9))['catch'](handleError(_0x1693dd,null));};exports['update']=function(_0x4aa923,_0x2474de){if(_0x4aa923[_0x60fc('0x30')]['id']){delete _0x4aa923['body']['id'];}return db[_0x60fc('0x16')][_0x60fc('0x2e')]({'where':{'id':_0x4aa923[_0x60fc('0x2d')]['id']}})[_0x60fc('0xd')](handleEntityNotFound(_0x2474de,null))[_0x60fc('0xd')](saveUpdates(_0x4aa923[_0x60fc('0x30')],null))[_0x60fc('0xd')](respondWithResult(_0x2474de,null))[_0x60fc('0x2b')](handleError(_0x2474de,null));};exports[_0x60fc('0xe')]=function(_0x8b8f6a,_0x524e17){return db[_0x60fc('0x16')]['find']({'where':{'id':_0x8b8f6a[_0x60fc('0x2d')]['id']}})['then'](handleEntityNotFound(_0x524e17,null))[_0x60fc('0xd')](removeEntity(_0x524e17,null))[_0x60fc('0x2b')](handleError(_0x524e17,null));};exports[_0x60fc('0x31')]=function(_0x24ec45,_0x58af1d){var _0x1dd032={};var _0x5b6a9c={};var _0xeee94d;var _0x5becaf;return db[_0x60fc('0x16')][_0x60fc('0x32')]({'where':{'id':_0x24ec45['params']['id']}})['then'](handleEntityNotFound(_0x58af1d,null))[_0x60fc('0xd')](function(_0x4669e3){if(_0x4669e3){_0xeee94d=_0x4669e3;_0x5b6a9c['model']=_[_0x60fc('0x1b')](db[_0x60fc('0x33')][_0x60fc('0x17')]);_0x5b6a9c[_0x60fc('0x1a')]=_[_0x60fc('0x1b')](_0x24ec45[_0x60fc('0x1a')]);_0x5b6a9c[_0x60fc('0x1c')]=_['intersection'](_0x5b6a9c[_0x60fc('0x1f')],_0x5b6a9c[_0x60fc('0x1a')]);_0x1dd032[_0x60fc('0x1e')]=_[_0x60fc('0x1d')](_0x5b6a9c[_0x60fc('0x1f')],qs[_0x60fc('0x20')](_0x24ec45[_0x60fc('0x1a')][_0x60fc('0x20')]));_0x1dd032[_0x60fc('0x1e')]=_0x1dd032[_0x60fc('0x1e')][_0x60fc('0x21')]?_0x1dd032[_0x60fc('0x1e')]:_0x5b6a9c['model'];_0x1dd032['order']=qs[_0x60fc('0x24')](_0x24ec45['query'][_0x60fc('0x24')]);_0x1dd032[_0x60fc('0x26')]=qs['filters'](_['pick'](_0x24ec45[_0x60fc('0x1a')],_0x5b6a9c['filters']));if(_0x24ec45[_0x60fc('0x1a')][_0x60fc('0x25')]){_0x1dd032[_0x60fc('0x26')]=_[_0x60fc('0x27')](_0x1dd032[_0x60fc('0x26')],{'$or':_[_0x60fc('0x15')](_0x1dd032['attributes'],function(_0x16c692){var _0x8fbd06={};_0x8fbd06[_0x16c692]={'$like':'%'+_0x24ec45['query'][_0x60fc('0x25')]+'%'};return _0x8fbd06;})});}_0x1dd032=_['merge']({},_0x1dd032,_0x24ec45['options']);return _0xeee94d[_0x60fc('0x31')](_0x1dd032);}})[_0x60fc('0xd')](function(_0x1f59fa){if(_0x1f59fa){_0x5becaf=_0x1f59fa['length'];if(!_0x24ec45[_0x60fc('0x1a')][_0x60fc('0x22')]('nolimit')){_0x1dd032[_0x60fc('0x9')]=qs['limit'](_0x24ec45[_0x60fc('0x1a')][_0x60fc('0x9')]);_0x1dd032[_0x60fc('0x7')]=qs[_0x60fc('0x7')](_0x24ec45[_0x60fc('0x1a')][_0x60fc('0x7')]);}return _0xeee94d[_0x60fc('0x31')](_0x1dd032);}})[_0x60fc('0xd')](function(_0xdcf72a){if(_0xdcf72a){return _0xdcf72a?{'count':_0x5becaf,'rows':_0xdcf72a}:null;}})[_0x60fc('0xd')](respondWithResult(_0x58af1d,null))[_0x60fc('0x2b')](handleError(_0x58af1d,null));};exports[_0x60fc('0x34')]=function(_0x56cba8,_0xed6430){if(_0x56cba8[_0x60fc('0x30')]['id']){delete _0x56cba8['body']['id'];}return db[_0x60fc('0x16')][_0x60fc('0x32')]({'where':{'id':_0x56cba8[_0x60fc('0x2d')]['id']}})[_0x60fc('0xd')](handleEntityNotFound(_0xed6430,null))['then'](function(_0x2323f0){if(_0x2323f0){_0x56cba8[_0x60fc('0x30')][_0x60fc('0x35')]=_0x2323f0['id'];_0x56cba8[_0x60fc('0x30')][_0x60fc('0x36')]=integrations[_0x60fc('0x37')](_0x56cba8[_0x60fc('0x30')][_0x60fc('0x38')],_0x56cba8[_0x60fc('0x30')][_0x60fc('0x19')]);_0x56cba8[_0x60fc('0x30')]['Descriptions']=integrations[_0x60fc('0x39')](_0x56cba8[_0x60fc('0x30')][_0x60fc('0x38')],_0x56cba8['body']['type']);return db[_0x60fc('0x33')][_0x60fc('0x2f')](_0x56cba8[_0x60fc('0x30')],{'include':[{'model':db[_0x60fc('0x3a')],'as':_0x60fc('0x36')},{'model':db[_0x60fc('0x3a')],'as':_0x60fc('0x3b')}]});}return null;})[_0x60fc('0xd')](respondWithResult(_0xed6430,null))['catch'](handleError(_0xed6430,null));};function sanitizeRemoteUri(_0x2da367){var _0x190694=_0x2da367[_0x60fc('0x3c')](-0x1);if(_0x190694==='/')return _0x2da367[_0x60fc('0x3d')](0x0,_0x2da367[_0x60fc('0x3e')](_0x190694));return _0x2da367;}function getWebApiUrl(_0x22ac78){return util[_0x60fc('0x3f')](_0x60fc('0x40'),_0x22ac78);}exports[_0x60fc('0x41')]=function(_0x89db9c,_0x3389d0){var _0x247dac=_0x89db9c[_0x60fc('0x1a')][_0x60fc('0x42')];var _0x3af3ea=_0x247dac===_0x60fc('0x43')?_0x60fc('0x44'):_0x60fc('0x45');var _0x5a24fa='';var _0x3c9492='';var _0x22292f='';var _0x405c9b='';var _0x258afe='';var _0x5a2a01='';var _0x197687='';var _0x146423='';var _0x381fee=['title',_0x60fc('0x46'),'customerid',_0x60fc('0x47'),_0x60fc('0x48'),'subject',_0x60fc('0x49'),_0x60fc('0x4a'),_0x60fc('0x4b'),_0x60fc('0x4c')];var _0x145986=[_0x60fc('0x4d'),_0x60fc('0x4e'),_0x60fc('0x4f'),_0x60fc('0x50'),_0x60fc('0x51'),_0x60fc('0x52'),'contractdetailidname',_0x60fc('0x53'),_0x60fc('0x54'),'createdbyexternalpartyyominame',_0x60fc('0x55'),'createdbyyominame',_0x60fc('0x56'),'createdonbehalfbyname',_0x60fc('0x57'),'customeridname','customeridtype',_0x60fc('0x58'),'emailaddress',_0x60fc('0x59'),_0x60fc('0x5a'),_0x60fc('0x5b'),_0x60fc('0x5c'),_0x60fc('0x5d'),_0x60fc('0x5e'),_0x60fc('0x5f'),_0x60fc('0x60'),_0x60fc('0x61'),_0x60fc('0x62'),_0x60fc('0x63'),_0x60fc('0x64'),_0x60fc('0x65'),_0x60fc('0x66'),'modifiedbyname',_0x60fc('0x67'),_0x60fc('0x68'),'modifiedonbehalfbyname','modifiedonbehalfbyyominame',_0x60fc('0x69'),_0x60fc('0x6a'),_0x60fc('0x6b'),_0x60fc('0x6c'),'overriddencreatedon','owneridname','owneridtype',_0x60fc('0x6d'),_0x60fc('0x6e'),_0x60fc('0x6f'),_0x60fc('0x70'),'prioritycodename','productidname','productserialnumber',_0x60fc('0x71'),_0x60fc('0x72'),_0x60fc('0x73'),_0x60fc('0x74'),_0x60fc('0x75'),'sentimentvalue','slainvokedidname',_0x60fc('0x76'),'socialprofileidname','statecode','statuscode','subjectidname',_0x60fc('0x77'),_0x60fc('0x78'),_0x60fc('0x79'),_0x60fc('0x7a'),_0x60fc('0x7b'),_0x60fc('0x7c')];var _0x17926f=_0x381fee[_0x60fc('0x7d')](_0x145986);return db[_0x60fc('0x16')][_0x60fc('0x32')]({'where':{'id':_0x89db9c['params']['id']},'attributes':['id',_0x60fc('0x7e'),'password',_0x60fc('0x7f'),_0x60fc('0x80'),_0x60fc('0x81'),_0x60fc('0x82'),'modernAuthentication'],'include':[{'model':db[_0x60fc('0x83')],'as':_0x60fc('0x83'),'attributes':['id',_0x60fc('0x84'),'data7']}]})[_0x60fc('0xd')](handleEntityNotFound(_0x3389d0,null))[_0x60fc('0xd')](function(_0x3e25fd){if(_0x3e25fd){if(_0x3e25fd[_0x60fc('0x85')]){_0x3e25fd[_0x60fc('0x86')]=_0x3e25fd['CloudProvider'][_0x60fc('0x84')];_0x146423=sanitizeRemoteUri(_0x3e25fd[_0x60fc('0x83')][_0x60fc('0x87')]);_0x197687=getWebApiUrl(_0x146423);return _0x3e25fd;}_0x146423=sanitizeRemoteUri(_0x3e25fd[_0x60fc('0x7f')]);_0x197687=getWebApiUrl(_0x146423);var _0x5a6ed4={'method':_0x60fc('0x88'),'uri':_0x60fc('0x89')+_0x3e25fd[_0x60fc('0x80')]+_0x60fc('0x8a'),'form':{'client_id':_0x3e25fd['clientId'],'resource':_0x146423,'username':_0x3e25fd['username'],'password':_0x3e25fd['password'],'grant_type':'password','client_secret':_0x3e25fd[_0x60fc('0x82')]},'json':!![]};return rp(_0x5a6ed4);}})[_0x60fc('0xd')](function(_0x49342a){_0x5a2a01=_0x49342a[_0x60fc('0x86')];var _0x1a68fd={'method':_0x60fc('0x8b'),'uri':encodeURI(_0x197687+_0x60fc('0x8c')+_0x3af3ea+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x5a2a01,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x1a68fd);})[_0x60fc('0xd')](function(_0x1f5740){var _0x89c4ed=_0x1f5740[_0x60fc('0x8d')][0x0];var _0x15fa99=_0x89c4ed['MetadataId'];var _0x18fee4={'method':_0x60fc('0x8b'),'uri':_0x197687+_0x60fc('0x8e')+_0x15fa99+_0x60fc('0x8f'),'headers':{'Authorization':'Bearer\x20'+_0x5a2a01,'If-None-Match':null,'OData-Version':_0x60fc('0x90')},'json':!![]};return rp(_0x18fee4);})['then'](function(_0x4669cb){_0x5a24fa=_0x4669cb;_0x3c9492=_0x5a24fa['Attributes'];_0x3c9492=_[_0x60fc('0x91')](_0x3c9492,function(_0x29c16a){return!_0x17926f[_0x60fc('0x92')](_0x29c16a[_0x60fc('0x93')]);});var _0x558069=[];var _0x12eb0c=[];_0x3c9492['forEach'](function(_0x5b2313){if(_0x5b2313[_0x60fc('0x94')]){var _0x1fc26d=_0x5b2313[_0x60fc('0x94')][_0x60fc('0x3d')](_0x5b2313[_0x60fc('0x94')][_0x60fc('0x3e')]('.')+0x1);if(_0x1fc26d===_0x60fc('0x95')){_0x558069[_0x60fc('0x96')](getSelectList(_0x197687,_0x247dac,_0x12eb0c,_0x5a24fa[_0x60fc('0x97')],_0x5b2313[_0x60fc('0x97')],_0x5a2a01));}}});return Promise['all'](_0x558069);})[_0x60fc('0xd')](function(_0x48cb52){_0x22292f=_0x48cb52[0x0];var _0x55f150=[];var _0x4a71bc=[];_0x3c9492[_0x60fc('0x98')](function(_0xe429b7){if(!_['isNil'](_0xe429b7[_0x60fc('0x94')])){var _0x3c9973=_0xe429b7[_0x60fc('0x94')]['substring'](_0xe429b7['@odata.type'][_0x60fc('0x3e')]('.')+0x1);if(_0x3c9973===_0x60fc('0x99')){_0x55f150[_0x60fc('0x96')](getBooleanList(_0x197687,_0x247dac,_0x4a71bc,_0x5a24fa['MetadataId'],_0xe429b7['MetadataId'],_0x5a2a01));}}});return Promise['all'](_0x55f150);})[_0x60fc('0xd')](function(_0x33d9fb){_0x405c9b=_0x33d9fb[0x0];var _0x1d9c5b=[];var _0x2ce374=[];_0x3c9492[_0x60fc('0x98')](function(_0x224e9c){if(_0x224e9c[_0x60fc('0x94')]){var _0x563d70=_0x224e9c[_0x60fc('0x94')][_0x60fc('0x3d')](_0x224e9c[_0x60fc('0x94')][_0x60fc('0x3e')]('.')+0x1);if(_0x563d70===_0x60fc('0x9a')||_0x563d70===_0x60fc('0x9b')||_0x563d70===_0x60fc('0x9c')||_0x563d70===_0x60fc('0x9d')||_0x563d70===_0x60fc('0x9e')||_0x563d70===_0x60fc('0x9f')||_0x563d70===_0x60fc('0xa0')||_0x563d70===_0x60fc('0xa1')||_0x563d70===_0x60fc('0xa2')||_0x563d70===_0x60fc('0xa3')){_0x1d9c5b[_0x60fc('0x96')](getInputList(_0x197687,_0x247dac,_0x563d70,_0x2ce374,_0x5a24fa[_0x60fc('0x97')],_0x224e9c[_0x60fc('0x97')],_0x5a2a01));}}});return Promise[_0x60fc('0xa4')](_0x1d9c5b);})['then'](function(_0x33e084){_0x258afe=_0x33e084[0x0];var _0x1e5738=_0x22292f[_0x60fc('0x7d')](_0x405c9b)[_0x60fc('0x7d')](_0x258afe);var _0xe0e255={'count':_0x1e5738[_0x60fc('0x21')],'rows':_0x1e5738};return _0xe0e255;})[_0x60fc('0xd')](respondWithResult(_0x3389d0,null))[_0x60fc('0x2b')](function(_0x396e18){var _0x19a4b3=_0x89db9c[_0x60fc('0x1a')][_0x60fc('0xa5')]?0x1f4:_0x396e18[_0x60fc('0xa6')]||0x1f4;logger[_0x60fc('0x11')](_0x396e18['stack']);delete _0x396e18[_0x60fc('0x12')];if(_0x19a4b3===0x191){_0x19a4b3=0x190;}_0x3389d0[_0x60fc('0x6')](_0x19a4b3)['send'](_0x89db9c[_0x60fc('0x1a')]['test']?{'message':_0x60fc('0xa7'),'statusCode':_0x396e18[_0x60fc('0xa6')]}:_0x396e18);});};function getSelectList(_0x56afb2,_0x5c7b05,_0x5444f1,_0x5015e5,_0x1d1651,_0x55096b){var _0x2361a9={'method':_0x60fc('0x8b'),'uri':_0x56afb2+_0x60fc('0x8e')+_0x5015e5+_0x60fc('0xa8')+_0x1d1651+_0x60fc('0xa9')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0x60fc('0xaa')+_0x55096b,'If-None-Match':null,'OData-Version':_0x60fc('0x90')},'json':!![]};return rp(_0x2361a9)[_0x60fc('0xd')](function(_0x5ce310){var _0x34cf67=[];var _0x2a2356=_0x5ce310[_0x60fc('0xab')][_0x60fc('0xac')];_0x2a2356['forEach'](function(_0x5361c9){_0x34cf67[_0x60fc('0x96')]({'name':_0x5361c9[_0x60fc('0xad')]['UserLocalizedLabel'][_0x60fc('0xad')],'value':String(_0x5361c9[_0x60fc('0xae')])});});var _0x4394d0={'id':_0x5c7b05+'_'+_0x5ce310[_0x60fc('0x93')],'name':_0x5ce310[_0x60fc('0xaf')]['UserLocalizedLabel']['Label'],'custom':![],'options':_0x34cf67};_0x5444f1[_0x60fc('0x96')](_0x4394d0);return _0x5444f1;});}function getBooleanList(_0x1775e6,_0x3b2a2c,_0x21074f,_0x300e39,_0x3ea096,_0x3897e2){var _0x2dbd0d={'method':_0x60fc('0x8b'),'uri':_0x1775e6+'EntityDefinitions('+_0x300e39+_0x60fc('0xa8')+_0x3ea096+_0x60fc('0xb0'),'headers':{'Authorization':_0x60fc('0xaa')+_0x3897e2,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x2dbd0d)['then'](function(_0x639680){var _0x58d11c=[];_0x58d11c[_0x60fc('0x96')]({'name':_0x639680['OptionSet'][_0x60fc('0xb1')][_0x60fc('0xad')][_0x60fc('0xb2')]['Label'],'value':_0x60fc('0xb3')},{'name':_0x639680['OptionSet'][_0x60fc('0xb4')][_0x60fc('0xad')][_0x60fc('0xb2')][_0x60fc('0xad')],'value':_0x60fc('0xb5')});var _0x578f91={'id':_0x3b2a2c+'_'+_0x639680[_0x60fc('0x93')],'name':_0x639680[_0x60fc('0xaf')][_0x60fc('0xb2')][_0x60fc('0xad')],'custom':![],'options':_0x58d11c};_0x21074f['push'](_0x578f91);return _0x21074f;});}function getInputList(_0x3cac52,_0x57a016,_0x34021d,_0x254df6,_0x2b2d57,_0x2d910a,_0x1e6520){var _0x89a297={'method':_0x60fc('0x8b'),'uri':_0x3cac52+'EntityDefinitions('+_0x2b2d57+_0x60fc('0xa8')+_0x2d910a+_0x60fc('0xb6')+_0x34021d+_0x60fc('0xb7'),'headers':{'Authorization':'Bearer\x20'+_0x1e6520,'If-None-Match':null,'OData-Version':_0x60fc('0x90')},'json':!![]};return rp(_0x89a297)[_0x60fc('0xd')](function(_0x4ad9f1){var _0x2f947c={'id':_0x57a016+'_'+_0x4ad9f1['LogicalName'],'name':_0x4ad9f1[_0x60fc('0xaf')][_0x60fc('0xb2')]?_0x4ad9f1[_0x60fc('0xaf')][_0x60fc('0xb2')][_0x60fc('0xad')]:_0x4ad9f1[_0x60fc('0x93')],'custom':![],'options':[]};_0x254df6[_0x60fc('0x96')](_0x2f947c);return _0x254df6;});}
\ No newline at end of file