Built motion from commit 616d3211.|2.6.4
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index e30b753..d3aba72 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa4fb=['create','body','getConfigurations','findOne','Dynamics365Configuration','options','hasOwnProperty','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','Dynamics365Field','getFields','incident','Incident','PhoneCall','description','customerid','ownerid','regardingobjectid','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyyominame','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedon','modifiedonbehalfbyname','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','owneridname','owneridtype','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productserialnumber','resolvebykpiidname','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','socialprofileidname','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','utcconversiontimezonecode','versionnumber','concat','username','remoteUri','tenantId','clientId','clientSecret','substring','format','%s/api/data/v9.0/','POST','https://login.microsoftonline.com/','/oauth2/token','password','access_token','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','4.0','MetadataId','GET','EntityDefinitions(','Bearer\x20','Attributes','includes','LogicalName','@odata.type','all','forEach','isNil','lastIndexOf','BooleanAttributeMetadata','push','StringAttributeMetadata','DoubleAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','statusCode','test',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label','UserLocalizedLabel',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','FalseOption','false','DisplayName','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','error','stack','name','send','map','Dynamics365Account','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','catch','params','find'];(function(_0x4670cb,_0x3ed3b8){var _0x2af1e6=function(_0x5376f6){while(--_0x5376f6){_0x4670cb['push'](_0x4670cb['shift']());}};_0x2af1e6(++_0x3ed3b8);}(_0xa4fb,0x150));var _0xba4f=function(_0xfb0281,_0x3ff38b){_0xfb0281=_0xfb0281-0x0;var _0x408dd3=_0xa4fb[_0xfb0281];return _0x408dd3;};'use strict';var emlformat=require(_0xba4f('0x0'));var rimraf=require(_0xba4f('0x1'));var zipdir=require(_0xba4f('0x2'));var jsonpatch=require(_0xba4f('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xba4f('0x4'));var Mustache=require(_0xba4f('0x5'));var util=require(_0xba4f('0x6'));var path=require('path');var sox=require(_0xba4f('0x7'));var csv=require(_0xba4f('0x8'));var ejs=require(_0xba4f('0x9'));var fs=require('fs');var fs_extra=require(_0xba4f('0xa'));var _=require(_0xba4f('0xb'));var squel=require(_0xba4f('0xc'));var crypto=require(_0xba4f('0xd'));var jsforce=require(_0xba4f('0xe'));var deskjs=require(_0xba4f('0xf'));var toCsv=require(_0xba4f('0x8'));var querystring=require('querystring');var Papa=require(_0xba4f('0x10'));var Redis=require('ioredis');var authService=require(_0xba4f('0x11'));var qs=require(_0xba4f('0x12'));var as=require(_0xba4f('0x13'));var hardwareService=require(_0xba4f('0x14'));var logger=require(_0xba4f('0x15'))(_0xba4f('0x16'));var utils=require('../../config/utils');var config=require(_0xba4f('0x17'));var licenseUtil=require(_0xba4f('0x18'));var db=require(_0xba4f('0x19'))['db'];var integrations=require(_0xba4f('0x1a'));function respondWithStatusCode(_0x3a0216,_0x2e4e37){_0x2e4e37=_0x2e4e37||0xcc;return function(_0x2e4ee5){if(_0x2e4ee5){return _0x3a0216[_0xba4f('0x1b')](_0x2e4e37);}return _0x3a0216[_0xba4f('0x1c')](_0x2e4e37)[_0xba4f('0x1d')]();};}function respondWithResult(_0x4b9e86,_0x4200a5){_0x4200a5=_0x4200a5||0xc8;return function(_0x10be67){if(_0x10be67){return _0x4b9e86[_0xba4f('0x1c')](_0x4200a5)['json'](_0x10be67);}};}function respondWithFilteredResult(_0x5ad1e3,_0x5a1e59){return function(_0x26d144){if(_0x26d144){var _0x104caf=typeof _0x5a1e59[_0xba4f('0x1e')]===_0xba4f('0x1f')&&typeof _0x5a1e59[_0xba4f('0x20')]===_0xba4f('0x1f');var _0x53964e=_0x26d144[_0xba4f('0x21')];var _0x315359=_0x104caf?0x0:_0x5a1e59['offset'];var _0x1aa774=_0x104caf?_0x26d144['count']:_0x5a1e59[_0xba4f('0x1e')]+_0x5a1e59[_0xba4f('0x20')];var _0x26e470;if(_0x1aa774>=_0x53964e){_0x1aa774=_0x53964e;_0x26e470=0xc8;}else{_0x26e470=0xce;}_0x5ad1e3[_0xba4f('0x1c')](_0x26e470);return _0x5ad1e3[_0xba4f('0x22')](_0xba4f('0x23'),_0x315359+'-'+_0x1aa774+'/'+_0x53964e)['json'](_0x26d144);}return null;};}function patchUpdates(_0x254ef9){return function(_0x44e6c2){try{jsonpatch[_0xba4f('0x24')](_0x44e6c2,_0x254ef9,!![]);}catch(_0x5ab4fb){return BPromise[_0xba4f('0x25')](_0x5ab4fb);}return _0x44e6c2['save']();};}function saveUpdates(_0x4bdddc,_0x2a7f19){return function(_0x46c07d){if(_0x46c07d){return _0x46c07d[_0xba4f('0x26')](_0x4bdddc)[_0xba4f('0x27')](function(_0x1c68a1){return _0x1c68a1;});}return null;};}function removeEntity(_0x277f93,_0x1e9b4f){return function(_0x5b9899){if(_0x5b9899){return _0x5b9899['destroy']()[_0xba4f('0x27')](function(){_0x277f93[_0xba4f('0x1c')](0xcc)[_0xba4f('0x1d')]();});}};}function handleEntityNotFound(_0x1ebac8,_0x335d37){return function(_0x57a169){if(!_0x57a169){_0x1ebac8['sendStatus'](0x194);}return _0x57a169;};}function handleError(_0x140fc7,_0x103f21){_0x103f21=_0x103f21||0x1f4;return function(_0x1d639a){logger[_0xba4f('0x28')](_0x1d639a[_0xba4f('0x29')]);if(_0x1d639a[_0xba4f('0x2a')]){delete _0x1d639a[_0xba4f('0x2a')];}_0x140fc7[_0xba4f('0x1c')](_0x103f21)[_0xba4f('0x2b')](_0x1d639a);};}exports['index']=function(_0x5871d0,_0x4944ca){var _0x9f5d82={},_0x196546={},_0x5949aa={'count':0x0,'rows':[]};var _0x3bc2ea=_[_0xba4f('0x2c')](db[_0xba4f('0x2d')][_0xba4f('0x2e')],function(_0x28ce12){return{'name':_0x28ce12[_0xba4f('0x2f')],'type':_0x28ce12[_0xba4f('0x30')][_0xba4f('0x31')]};});_0x196546[_0xba4f('0x32')]=_[_0xba4f('0x2c')](_0x3bc2ea,_0xba4f('0x2a'));_0x196546[_0xba4f('0x33')]=_[_0xba4f('0x34')](_0x5871d0[_0xba4f('0x33')]);_0x196546[_0xba4f('0x35')]=_[_0xba4f('0x36')](_0x196546[_0xba4f('0x32')],_0x196546['query']);_0x9f5d82[_0xba4f('0x37')]=_[_0xba4f('0x36')](_0x196546[_0xba4f('0x32')],qs[_0xba4f('0x38')](_0x5871d0['query'][_0xba4f('0x38')]));_0x9f5d82[_0xba4f('0x37')]=_0x9f5d82[_0xba4f('0x37')][_0xba4f('0x39')]?_0x9f5d82[_0xba4f('0x37')]:_0x196546['model'];if(!_0x5871d0['query']['hasOwnProperty']('nolimit')){_0x9f5d82[_0xba4f('0x20')]=qs['limit'](_0x5871d0['query'][_0xba4f('0x20')]);_0x9f5d82[_0xba4f('0x1e')]=qs[_0xba4f('0x1e')](_0x5871d0[_0xba4f('0x33')][_0xba4f('0x1e')]);}_0x9f5d82[_0xba4f('0x3a')]=qs[_0xba4f('0x3b')](_0x5871d0[_0xba4f('0x33')][_0xba4f('0x3b')]);_0x9f5d82[_0xba4f('0x3c')]=qs['filters'](_[_0xba4f('0x3d')](_0x5871d0['query'],_0x196546[_0xba4f('0x35')]),_0x3bc2ea);if(_0x5871d0[_0xba4f('0x33')][_0xba4f('0x3e')]){_0x9f5d82['where']=_[_0xba4f('0x3f')](_0x9f5d82[_0xba4f('0x3c')],{'$or':_['map'](_0x3bc2ea,function(_0x18055d){if(_0x18055d[_0xba4f('0x30')]!==_0xba4f('0x40')){var _0x5816e7={};_0x5816e7[_0x18055d[_0xba4f('0x2a')]]={'$like':'%'+_0x5871d0[_0xba4f('0x33')][_0xba4f('0x3e')]+'%'};return _0x5816e7;}})});}_0x9f5d82=_[_0xba4f('0x3f')]({},_0x9f5d82,_0x5871d0['options']);var _0x4fecbc={'where':_0x9f5d82[_0xba4f('0x3c')]};return db['Dynamics365Account'][_0xba4f('0x21')](_0x4fecbc)[_0xba4f('0x27')](function(_0x6055f7){_0x5949aa[_0xba4f('0x21')]=_0x6055f7;if(_0x5871d0[_0xba4f('0x33')][_0xba4f('0x41')]){_0x9f5d82[_0xba4f('0x42')]=[{'all':!![]}];}return db[_0xba4f('0x2d')][_0xba4f('0x43')](_0x9f5d82);})[_0xba4f('0x27')](function(_0x348a38){_0x5949aa[_0xba4f('0x44')]=_0x348a38;return _0x5949aa;})[_0xba4f('0x27')](respondWithFilteredResult(_0x4944ca,_0x9f5d82))[_0xba4f('0x45')](handleError(_0x4944ca,null));};exports['show']=function(_0x33eab5,_0x454454){var _0xa996b3={'raw':![],'where':{'id':_0x33eab5[_0xba4f('0x46')]['id']}},_0x597cdf={};_0x597cdf[_0xba4f('0x32')]=_[_0xba4f('0x34')](db['Dynamics365Account']['rawAttributes']);_0x597cdf[_0xba4f('0x33')]=_['keys'](_0x33eab5[_0xba4f('0x33')]);_0x597cdf['filters']=_[_0xba4f('0x36')](_0x597cdf['model'],_0x597cdf[_0xba4f('0x33')]);_0xa996b3[_0xba4f('0x37')]=_[_0xba4f('0x36')](_0x597cdf[_0xba4f('0x32')],qs[_0xba4f('0x38')](_0x33eab5['query'][_0xba4f('0x38')]));_0xa996b3[_0xba4f('0x37')]=_0xa996b3['attributes'][_0xba4f('0x39')]?_0xa996b3[_0xba4f('0x37')]:_0x597cdf[_0xba4f('0x32')];if(_0x33eab5[_0xba4f('0x33')][_0xba4f('0x41')]){_0xa996b3[_0xba4f('0x42')]=[{'all':!![]}];}_0xa996b3=_[_0xba4f('0x3f')]({},_0xa996b3,_0x33eab5['options']);return db[_0xba4f('0x2d')][_0xba4f('0x47')](_0xa996b3)[_0xba4f('0x27')](handleEntityNotFound(_0x454454,null))[_0xba4f('0x27')](respondWithResult(_0x454454,null))[_0xba4f('0x45')](handleError(_0x454454,null));};exports[_0xba4f('0x48')]=function(_0x4e265b,_0x3f0eb){return db[_0xba4f('0x2d')][_0xba4f('0x48')](_0x4e265b[_0xba4f('0x49')],{})[_0xba4f('0x27')](respondWithResult(_0x3f0eb,0xc9))[_0xba4f('0x45')](handleError(_0x3f0eb,null));};exports[_0xba4f('0x26')]=function(_0x301b22,_0x2d7f7b){if(_0x301b22[_0xba4f('0x49')]['id']){delete _0x301b22[_0xba4f('0x49')]['id'];}return db[_0xba4f('0x2d')][_0xba4f('0x47')]({'where':{'id':_0x301b22[_0xba4f('0x46')]['id']}})[_0xba4f('0x27')](handleEntityNotFound(_0x2d7f7b,null))['then'](saveUpdates(_0x301b22[_0xba4f('0x49')],null))['then'](respondWithResult(_0x2d7f7b,null))[_0xba4f('0x45')](handleError(_0x2d7f7b,null));};exports['destroy']=function(_0x41806b,_0x5ca242){return db[_0xba4f('0x2d')][_0xba4f('0x47')]({'where':{'id':_0x41806b[_0xba4f('0x46')]['id']}})[_0xba4f('0x27')](handleEntityNotFound(_0x5ca242,null))[_0xba4f('0x27')](removeEntity(_0x5ca242,null))['catch'](handleError(_0x5ca242,null));};exports[_0xba4f('0x4a')]=function(_0x32a70b,_0x1c2ba9,_0x39c8c9){var _0x4ecacf={};var _0x3809f1={};var _0x3e7999;var _0x307819;return db[_0xba4f('0x2d')][_0xba4f('0x4b')]({'where':{'id':_0x32a70b[_0xba4f('0x46')]['id']}})[_0xba4f('0x27')](handleEntityNotFound(_0x1c2ba9,null))[_0xba4f('0x27')](function(_0x1f1dbc){if(_0x1f1dbc){_0x3e7999=_0x1f1dbc;_0x3809f1['model']=_[_0xba4f('0x34')](db[_0xba4f('0x4c')]['rawAttributes']);_0x3809f1['query']=_[_0xba4f('0x34')](_0x32a70b[_0xba4f('0x33')]);_0x3809f1[_0xba4f('0x35')]=_['intersection'](_0x3809f1[_0xba4f('0x32')],_0x3809f1['query']);_0x4ecacf[_0xba4f('0x37')]=_['intersection'](_0x3809f1[_0xba4f('0x32')],qs['fields'](_0x32a70b[_0xba4f('0x33')][_0xba4f('0x38')]));_0x4ecacf['attributes']=_0x4ecacf[_0xba4f('0x37')]['length']?_0x4ecacf[_0xba4f('0x37')]:_0x3809f1[_0xba4f('0x32')];_0x4ecacf['order']=qs[_0xba4f('0x3b')](_0x32a70b[_0xba4f('0x33')][_0xba4f('0x3b')]);_0x4ecacf[_0xba4f('0x3c')]=qs[_0xba4f('0x35')](_[_0xba4f('0x3d')](_0x32a70b['query'],_0x3809f1[_0xba4f('0x35')]));if(_0x32a70b[_0xba4f('0x33')]['filter']){_0x4ecacf[_0xba4f('0x3c')]=_['merge'](_0x4ecacf[_0xba4f('0x3c')],{'$or':_[_0xba4f('0x2c')](_0x4ecacf[_0xba4f('0x37')],function(_0x379a45){var _0x5ec545={};_0x5ec545[_0x379a45]={'$like':'%'+_0x32a70b['query'][_0xba4f('0x3e')]+'%'};return _0x5ec545;})});}_0x4ecacf=_[_0xba4f('0x3f')]({},_0x4ecacf,_0x32a70b[_0xba4f('0x4d')]);return _0x3e7999['getConfigurations'](_0x4ecacf);}})[_0xba4f('0x27')](function(_0x559c2d){if(_0x559c2d){_0x307819=_0x559c2d[_0xba4f('0x39')];if(!_0x32a70b[_0xba4f('0x33')][_0xba4f('0x4e')](_0xba4f('0x4f'))){_0x4ecacf[_0xba4f('0x20')]=qs[_0xba4f('0x20')](_0x32a70b[_0xba4f('0x33')][_0xba4f('0x20')]);_0x4ecacf[_0xba4f('0x1e')]=qs[_0xba4f('0x1e')](_0x32a70b[_0xba4f('0x33')]['offset']);}return _0x3e7999[_0xba4f('0x4a')](_0x4ecacf);}})[_0xba4f('0x27')](function(_0x47efdc){if(_0x47efdc){return _0x47efdc?{'count':_0x307819,'rows':_0x47efdc}:null;}})[_0xba4f('0x27')](respondWithResult(_0x1c2ba9,null))['catch'](handleError(_0x1c2ba9,null));};exports[_0xba4f('0x50')]=function(_0x3b0039,_0x36f84a,_0xe53283){if(_0x3b0039[_0xba4f('0x49')]['id']){delete _0x3b0039[_0xba4f('0x49')]['id'];}return db[_0xba4f('0x2d')][_0xba4f('0x4b')]({'where':{'id':_0x3b0039[_0xba4f('0x46')]['id']}})[_0xba4f('0x27')](handleEntityNotFound(_0x36f84a,null))[_0xba4f('0x27')](function(_0x38c9a0){if(_0x38c9a0){_0x3b0039[_0xba4f('0x49')][_0xba4f('0x51')]=_0x38c9a0['id'];_0x3b0039[_0xba4f('0x49')][_0xba4f('0x52')]=integrations[_0xba4f('0x53')](_0x3b0039[_0xba4f('0x49')][_0xba4f('0x54')],_0x3b0039[_0xba4f('0x49')][_0xba4f('0x30')]);_0x3b0039['body'][_0xba4f('0x55')]=integrations[_0xba4f('0x56')](_0x3b0039[_0xba4f('0x49')][_0xba4f('0x54')],_0x3b0039['body'][_0xba4f('0x30')]);return db[_0xba4f('0x4c')][_0xba4f('0x48')](_0x3b0039['body'],{'include':[{'model':db[_0xba4f('0x57')],'as':_0xba4f('0x52')},{'model':db[_0xba4f('0x57')],'as':_0xba4f('0x55')}]});}return null;})[_0xba4f('0x27')](respondWithResult(_0x36f84a,null))['catch'](handleError(_0x36f84a,null));};exports[_0xba4f('0x58')]=function(_0x512701,_0x409d37,_0xce0ae9){var _0x2e43d4=_0x512701[_0xba4f('0x33')]['ticketType'];var _0x17fe5a=_0x2e43d4===_0xba4f('0x59')?_0xba4f('0x5a'):_0xba4f('0x5b');var _0x4ea249='';var _0x3b9e2b='';var _0x476911='';var _0x438045='';var _0x4948b1='';var _0x58019a='';var _0x2c062c='';var _0x17ea97='';var _0x5d992b=['title',_0xba4f('0x5c'),_0xba4f('0x5d'),_0xba4f('0x5e'),'caseorigincode','subject','phonenumber',_0xba4f('0x5f'),'directioncode',_0xba4f('0x60')];var _0x51ce67=[_0xba4f('0x61'),_0xba4f('0x62'),_0xba4f('0x63'),_0xba4f('0x64'),_0xba4f('0x65'),_0xba4f('0x66'),_0xba4f('0x67'),_0xba4f('0x68'),_0xba4f('0x69'),'createdbyexternalpartyyominame','createdbyname',_0xba4f('0x6a'),'createdon',_0xba4f('0x6b'),_0xba4f('0x6c'),_0xba4f('0x6d'),_0xba4f('0x6e'),_0xba4f('0x6f'),_0xba4f('0x70'),_0xba4f('0x71'),_0xba4f('0x72'),'entityimage_url',_0xba4f('0x73'),_0xba4f('0x74'),_0xba4f('0x75'),_0xba4f('0x76'),_0xba4f('0x77'),'influencescore',_0xba4f('0x78'),_0xba4f('0x79'),_0xba4f('0x7a'),_0xba4f('0x7b'),_0xba4f('0x7c'),_0xba4f('0x7d'),'modifiedbyyominame',_0xba4f('0x7e'),_0xba4f('0x7f'),'modifiedonbehalfbyyominame',_0xba4f('0x80'),_0xba4f('0x81'),_0xba4f('0x82'),'onholdtime',_0xba4f('0x83'),_0xba4f('0x84'),_0xba4f('0x85'),'owneridyominame',_0xba4f('0x86'),_0xba4f('0x87'),_0xba4f('0x88'),_0xba4f('0x89'),'productidname',_0xba4f('0x8a'),'resolveby',_0xba4f('0x8b'),'responseby',_0xba4f('0x8c'),_0xba4f('0x8d'),_0xba4f('0x8e'),'slainvokedidname','slaname',_0xba4f('0x8f'),'statecode',_0xba4f('0x90'),_0xba4f('0x91'),_0xba4f('0x92'),_0xba4f('0x93'),_0xba4f('0x94'),'traversedpath',_0xba4f('0x95'),_0xba4f('0x96')];var _0x334986=_0x5d992b[_0xba4f('0x97')](_0x51ce67);return db[_0xba4f('0x2d')][_0xba4f('0x4b')]({'where':{'id':_0x512701['params']['id']},'attributes':['id',_0xba4f('0x98'),'password',_0xba4f('0x99'),_0xba4f('0x9a'),_0xba4f('0x9b'),_0xba4f('0x9c')]})[_0xba4f('0x27')](handleEntityNotFound(_0x409d37,null))[_0xba4f('0x27')](function(_0x192187){if(_0x192187){_0x17ea97=_0x192187[_0xba4f('0x99')];var _0x3cdab4=_0x17ea97['slice'](-0x1);if(_0x3cdab4==='/'){_0x17ea97=_0x17ea97[_0xba4f('0x9d')](0x0,_0x17ea97['lastIndexOf'](_0x3cdab4));}_0x2c062c=util[_0xba4f('0x9e')](_0xba4f('0x9f'),_0x17ea97);var _0x54cf44={'method':_0xba4f('0xa0'),'uri':_0xba4f('0xa1')+_0x192187['tenantId']+_0xba4f('0xa2'),'form':{'client_id':_0x192187['clientId'],'resource':_0x17ea97,'username':_0x192187[_0xba4f('0x98')],'password':_0x192187[_0xba4f('0xa3')],'grant_type':'password','client_secret':_0x192187[_0xba4f('0x9c')]},'json':!![]};return rp(_0x54cf44);}})[_0xba4f('0x27')](function(_0x77c0dd){_0x58019a=_0x77c0dd[_0xba4f('0xa4')];var _0x285fa2={'method':'GET','uri':encodeURI(_0x2c062c+_0xba4f('0xa5')+_0x17fe5a+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x58019a,'If-None-Match':null,'OData-Version':_0xba4f('0xa6')},'json':!![]};return rp(_0x285fa2);})[_0xba4f('0x27')](function(_0x35a21c){var _0x22d4c0=_0x35a21c['value'][0x0];var _0x3c3cef=_0x22d4c0[_0xba4f('0xa7')];var _0x3ac8b2={'method':_0xba4f('0xa8'),'uri':_0x2c062c+_0xba4f('0xa9')+_0x3c3cef+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0xba4f('0xaa')+_0x58019a,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x3ac8b2);})[_0xba4f('0x27')](function(_0x179c5e){_0x4ea249=_0x179c5e;_0x3b9e2b=_0x4ea249[_0xba4f('0xab')];_0x3b9e2b=_['remove'](_0x3b9e2b,function(_0xf351a5){return!_0x334986[_0xba4f('0xac')](_0xf351a5[_0xba4f('0xad')]);});var _0x3dda20=[];var _0x1d96aa=[];_0x3b9e2b['forEach'](function(_0x35403a){if(_0x35403a[_0xba4f('0xae')]){var _0x479e45=_0x35403a[_0xba4f('0xae')][_0xba4f('0x9d')](_0x35403a['@odata.type']['lastIndexOf']('.')+0x1);if(_0x479e45==='PicklistAttributeMetadata'){_0x3dda20['push'](getSelectList(_0x2c062c,_0x2e43d4,_0x1d96aa,_0x4ea249[_0xba4f('0xa7')],_0x35403a[_0xba4f('0xa7')],_0x58019a));}}});return Promise[_0xba4f('0xaf')](_0x3dda20);})[_0xba4f('0x27')](function(_0x197a5c){_0x476911=_0x197a5c[0x0];var _0xa3f3c5=[];var _0x265a7b=[];_0x3b9e2b[_0xba4f('0xb0')](function(_0x3b1960){if(!_[_0xba4f('0xb1')](_0x3b1960[_0xba4f('0xae')])){var _0x2eef8d=_0x3b1960[_0xba4f('0xae')]['substring'](_0x3b1960[_0xba4f('0xae')][_0xba4f('0xb2')]('.')+0x1);if(_0x2eef8d===_0xba4f('0xb3')){_0xa3f3c5[_0xba4f('0xb4')](getBooleanList(_0x2c062c,_0x2e43d4,_0x265a7b,_0x4ea249['MetadataId'],_0x3b1960['MetadataId'],_0x58019a));}}});return Promise['all'](_0xa3f3c5);})['then'](function(_0x5dea0a){_0x438045=_0x5dea0a[0x0];var _0x2ed0b5=[];var _0x1bc25c=[];_0x3b9e2b['forEach'](function(_0x312f10){if(_0x312f10[_0xba4f('0xae')]){var _0x139fd3=_0x312f10[_0xba4f('0xae')][_0xba4f('0x9d')](_0x312f10[_0xba4f('0xae')]['lastIndexOf']('.')+0x1);if(_0x139fd3===_0xba4f('0xb5')||_0x139fd3===_0xba4f('0xb6')||_0x139fd3==='BigIntAttributeMetadata'||_0x139fd3===_0xba4f('0xb7')||_0x139fd3===_0xba4f('0xb8')||_0x139fd3===_0xba4f('0xb9')||_0x139fd3===_0xba4f('0xba')||_0x139fd3===_0xba4f('0xbb')||_0x139fd3===_0xba4f('0xbc')||_0x139fd3===_0xba4f('0xbd')){_0x2ed0b5[_0xba4f('0xb4')](getInputList(_0x2c062c,_0x2e43d4,_0x139fd3,_0x1bc25c,_0x4ea249[_0xba4f('0xa7')],_0x312f10[_0xba4f('0xa7')],_0x58019a));}}});return Promise['all'](_0x2ed0b5);})[_0xba4f('0x27')](function(_0x20efcd){_0x4948b1=_0x20efcd[0x0];var _0x3d8b9f=_0x476911[_0xba4f('0x97')](_0x438045)[_0xba4f('0x97')](_0x4948b1);var _0x4a4c24={'count':_0x3d8b9f['length'],'rows':_0x3d8b9f};return _0x4a4c24;})[_0xba4f('0x27')](respondWithResult(_0x409d37,null))['catch'](function(_0x35b886){var _0x302019=_0x512701['query']['test']?0x1f4:_0x35b886[_0xba4f('0xbe')]||0x1f4;logger[_0xba4f('0x28')](_0x35b886['stack']);delete _0x35b886[_0xba4f('0x2a')];if(_0x302019===0x191){_0x302019=0x190;}_0x409d37[_0xba4f('0x1c')](_0x302019)[_0xba4f('0x2b')](_0x512701[_0xba4f('0x33')][_0xba4f('0xbf')]?{'message':'Wrong\x20credentials','statusCode':_0x35b886[_0xba4f('0xbe')]}:_0x35b886);});};function getSelectList(_0x2daa60,_0x53abe3,_0x3a24cc,_0x4f78b5,_0x28cf03,_0x37ee5b){var _0x5e397a={'method':_0xba4f('0xa8'),'uri':_0x2daa60+_0xba4f('0xa9')+_0x4f78b5+_0xba4f('0xc0')+_0x28cf03+_0xba4f('0xc1')+_0xba4f('0xc2'),'headers':{'Authorization':_0xba4f('0xaa')+_0x37ee5b,'If-None-Match':null,'OData-Version':_0xba4f('0xa6')},'json':!![]};return rp(_0x5e397a)[_0xba4f('0x27')](function(_0x4873a1){var _0x290e1e=[];var _0x5d0aef=_0x4873a1[_0xba4f('0xc3')][_0xba4f('0xc4')];_0x5d0aef[_0xba4f('0xb0')](function(_0x3b5da8){_0x290e1e['push']({'name':_0x3b5da8[_0xba4f('0xc5')][_0xba4f('0xc6')]['Label'],'value':String(_0x3b5da8['Value'])});});var _0x3019e9={'id':_0x53abe3+'_'+_0x4873a1['LogicalName'],'name':_0x4873a1['DisplayName']['UserLocalizedLabel'][_0xba4f('0xc5')],'custom':![],'options':_0x290e1e};_0x3a24cc['push'](_0x3019e9);return _0x3a24cc;});}function getBooleanList(_0x48dda1,_0x3e1ec3,_0x43af6c,_0x2dd9a6,_0x2a7c6b,_0x29c133){var _0x56ee52={'method':_0xba4f('0xa8'),'uri':_0x48dda1+_0xba4f('0xa9')+_0x2dd9a6+_0xba4f('0xc0')+_0x2a7c6b+_0xba4f('0xc7'),'headers':{'Authorization':_0xba4f('0xaa')+_0x29c133,'If-None-Match':null,'OData-Version':_0xba4f('0xa6')},'json':!![]};return rp(_0x56ee52)[_0xba4f('0x27')](function(_0x50d041){var _0x376898=[];_0x376898[_0xba4f('0xb4')]({'name':_0x50d041[_0xba4f('0xc3')][_0xba4f('0xc8')][_0xba4f('0xc5')][_0xba4f('0xc6')][_0xba4f('0xc5')],'value':'true'},{'name':_0x50d041[_0xba4f('0xc3')][_0xba4f('0xc9')][_0xba4f('0xc5')][_0xba4f('0xc6')][_0xba4f('0xc5')],'value':_0xba4f('0xca')});var _0x5db882={'id':_0x3e1ec3+'_'+_0x50d041[_0xba4f('0xad')],'name':_0x50d041[_0xba4f('0xcb')][_0xba4f('0xc6')][_0xba4f('0xc5')],'custom':![],'options':_0x376898};_0x43af6c['push'](_0x5db882);return _0x43af6c;});}function getInputList(_0x2eb3a6,_0x4fccf0,_0x2fd63d,_0x228170,_0x407196,_0xe98c65,_0x4f32ad){var _0x30705e={'method':_0xba4f('0xa8'),'uri':_0x2eb3a6+'EntityDefinitions('+_0x407196+_0xba4f('0xc0')+_0xe98c65+')/Microsoft.Dynamics.CRM.'+_0x2fd63d+'?$select=DisplayName,LogicalName','headers':{'Authorization':_0xba4f('0xaa')+_0x4f32ad,'If-None-Match':null,'OData-Version':_0xba4f('0xa6')},'json':!![]};return rp(_0x30705e)[_0xba4f('0x27')](function(_0x54775e){var _0x4119ea={'id':_0x4fccf0+'_'+_0x54775e[_0xba4f('0xad')],'name':_0x54775e[_0xba4f('0xcb')][_0xba4f('0xc6')]?_0x54775e[_0xba4f('0xcb')][_0xba4f('0xc6')][_0xba4f('0xc5')]:_0x54775e['LogicalName'],'custom':![],'options':[]};_0x228170[_0xba4f('0xb4')](_0x4119ea);return _0x228170;});}
\ No newline at end of file
+var _0x91c8=['VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','create','body','find','getConfigurations','findOne','Dynamics365Configuration','order','addConfiguration','AccountId','Subjects','channel','type','Descriptions','getDescriptions','Dynamics365Field','slice','substring','lastIndexOf','format','getFields','Incident','PhoneCall','title','description','customerid','ownerid','subject','phonenumber','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','billedserviceunits','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyyominame','createdon','createdonbehalfbyname','customeridtype','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','followupby','influencescore','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','owneridtype','owneridyominame','primarycontactidname','productidname','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','versionnumber','concat','username','password','tenantId','clientId','modernAuthentication','CloudProvider','data5','data7','access_token','remoteUri','POST','https://login.microsoftonline.com/','/oauth2/token','clientSecret','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','4.0','value','MetadataId','EntityDefinitions(','Bearer\x20','Attributes','remove','includes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','isNil','BooleanAttributeMetadata','push','all','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','OptionSet','Options','Label','UserLocalizedLabel','DisplayName',')/Attributes(',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','true','FalseOption','false','?$select=DisplayName,LogicalName','request-promise','lodash','../../components/parsers/qs','api','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','end','error','stack','name','send','index','map','Dynamics365Account','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge'];(function(_0x3aa53a,_0x3fefc9){var _0x25acfd=function(_0x66f54){while(--_0x66f54){_0x3aa53a['push'](_0x3aa53a['shift']());}};_0x25acfd(++_0x3fefc9);}(_0x91c8,0x93));var _0x891c=function(_0x37ec2f,_0x3476f9){_0x37ec2f=_0x37ec2f-0x0;var _0x4f5f9f=_0x91c8[_0x37ec2f];return _0x4f5f9f;};'use strict';var rp=require(_0x891c('0x0'));var util=require('util');var _=require(_0x891c('0x1'));var qs=require(_0x891c('0x2'));var logger=require('../../config/logger')(_0x891c('0x3'));var db=require('../../mysqldb')['db'];var integrations=require(_0x891c('0x4'));function respondWithResult(_0x435e59,_0x37c4ca){_0x37c4ca=_0x37c4ca||0xc8;return function(_0x3c6d0a){if(_0x3c6d0a){return _0x435e59[_0x891c('0x5')](_0x37c4ca)[_0x891c('0x6')](_0x3c6d0a);}};}function respondWithFilteredResult(_0x2a63d8,_0x13773b){return function(_0x454aab){if(_0x454aab){var _0x45e28f=typeof _0x13773b[_0x891c('0x7')]===_0x891c('0x8')&&typeof _0x13773b[_0x891c('0x9')]===_0x891c('0x8');var _0x44187c=_0x454aab['count'];var _0x13d2f7=_0x45e28f?0x0:_0x13773b[_0x891c('0x7')];var _0x99fc25=_0x45e28f?_0x454aab[_0x891c('0xa')]:_0x13773b['offset']+_0x13773b[_0x891c('0x9')];var _0x123d1f;if(_0x99fc25>=_0x44187c){_0x99fc25=_0x44187c;_0x123d1f=0xc8;}else{_0x123d1f=0xce;}_0x2a63d8[_0x891c('0x5')](_0x123d1f);return _0x2a63d8[_0x891c('0xb')](_0x891c('0xc'),_0x13d2f7+'-'+_0x99fc25+'/'+_0x44187c)[_0x891c('0x6')](_0x454aab);}return null;};}function saveUpdates(_0xd6b06a){return function(_0x4b083f){if(_0x4b083f){return _0x4b083f[_0x891c('0xd')](_0xd6b06a)[_0x891c('0xe')](function(_0x854c81){return _0x854c81;});}return null;};}function removeEntity(_0x314ed8){return function(_0xd27182){if(_0xd27182){return _0xd27182[_0x891c('0xf')]()[_0x891c('0xe')](function(){_0x314ed8[_0x891c('0x5')](0xcc)[_0x891c('0x10')]();});}};}function handleEntityNotFound(_0x32e9d4){return function(_0x33358a){if(!_0x33358a){_0x32e9d4['sendStatus'](0x194);}return _0x33358a;};}function handleError(_0x34edfd,_0x42a885){_0x42a885=_0x42a885||0x1f4;return function(_0x5046fa){logger[_0x891c('0x11')](_0x5046fa[_0x891c('0x12')]);if(_0x5046fa[_0x891c('0x13')]){delete _0x5046fa['name'];}_0x34edfd['status'](_0x42a885)[_0x891c('0x14')](_0x5046fa);};}exports[_0x891c('0x15')]=function(_0x70527c,_0xf49dd5){var _0x4b592a={},_0x5c2a76={},_0x4230df={'count':0x0,'rows':[]};var _0x3491b9=_[_0x891c('0x16')](db[_0x891c('0x17')][_0x891c('0x18')],function(_0x2ab8f2){return{'name':_0x2ab8f2[_0x891c('0x19')],'type':_0x2ab8f2['type'][_0x891c('0x1a')]};});_0x5c2a76[_0x891c('0x1b')]=_['map'](_0x3491b9,_0x891c('0x13'));_0x5c2a76[_0x891c('0x1c')]=_['keys'](_0x70527c[_0x891c('0x1c')]);_0x5c2a76[_0x891c('0x1d')]=_[_0x891c('0x1e')](_0x5c2a76[_0x891c('0x1b')],_0x5c2a76['query']);_0x4b592a[_0x891c('0x1f')]=_[_0x891c('0x1e')](_0x5c2a76['model'],qs[_0x891c('0x20')](_0x70527c[_0x891c('0x1c')]['fields']));_0x4b592a[_0x891c('0x1f')]=_0x4b592a[_0x891c('0x1f')][_0x891c('0x21')]?_0x4b592a[_0x891c('0x1f')]:_0x5c2a76[_0x891c('0x1b')];if(!_0x70527c['query'][_0x891c('0x22')](_0x891c('0x23'))){_0x4b592a['limit']=qs[_0x891c('0x9')](_0x70527c['query'][_0x891c('0x9')]);_0x4b592a[_0x891c('0x7')]=qs[_0x891c('0x7')](_0x70527c[_0x891c('0x1c')][_0x891c('0x7')]);}_0x4b592a['order']=qs[_0x891c('0x24')](_0x70527c[_0x891c('0x1c')][_0x891c('0x24')]);_0x4b592a[_0x891c('0x25')]=qs[_0x891c('0x1d')](_[_0x891c('0x26')](_0x70527c[_0x891c('0x1c')],_0x5c2a76[_0x891c('0x1d')]),_0x3491b9);if(_0x70527c[_0x891c('0x1c')][_0x891c('0x27')]){_0x4b592a[_0x891c('0x25')]=_[_0x891c('0x28')](_0x4b592a[_0x891c('0x25')],{'$or':_[_0x891c('0x16')](_0x3491b9,function(_0x3df4c1){if(_0x3df4c1['type']!==_0x891c('0x29')){var _0x5191ce={};_0x5191ce[_0x3df4c1[_0x891c('0x13')]]={'$like':'%'+_0x70527c[_0x891c('0x1c')][_0x891c('0x27')]+'%'};return _0x5191ce;}})});}_0x4b592a=_[_0x891c('0x28')]({},_0x4b592a,_0x70527c[_0x891c('0x2a')]);var _0x38f8e7={'where':_0x4b592a['where']};return db[_0x891c('0x17')][_0x891c('0xa')](_0x38f8e7)[_0x891c('0xe')](function(_0x384cf7){_0x4230df['count']=_0x384cf7;if(_0x70527c['query'][_0x891c('0x2b')]){_0x4b592a[_0x891c('0x2c')]=[{'all':!![]}];}return db[_0x891c('0x17')][_0x891c('0x2d')](_0x4b592a);})[_0x891c('0xe')](function(_0x2d2b62){_0x4230df[_0x891c('0x2e')]=_0x2d2b62;return _0x4230df;})[_0x891c('0xe')](respondWithFilteredResult(_0xf49dd5,_0x4b592a))[_0x891c('0x2f')](handleError(_0xf49dd5,null));};exports[_0x891c('0x30')]=function(_0x297b27,_0x555361){var _0x1a75e8={'raw':![],'where':{'id':_0x297b27[_0x891c('0x31')]['id']}},_0x23df66={};_0x23df66['model']=_[_0x891c('0x32')](db['Dynamics365Account']['rawAttributes']);_0x23df66[_0x891c('0x1c')]=_['keys'](_0x297b27[_0x891c('0x1c')]);_0x23df66[_0x891c('0x1d')]=_[_0x891c('0x1e')](_0x23df66[_0x891c('0x1b')],_0x23df66['query']);_0x1a75e8[_0x891c('0x1f')]=_[_0x891c('0x1e')](_0x23df66['model'],qs['fields'](_0x297b27['query'][_0x891c('0x20')]));_0x1a75e8[_0x891c('0x1f')]=_0x1a75e8[_0x891c('0x1f')][_0x891c('0x21')]?_0x1a75e8['attributes']:_0x23df66[_0x891c('0x1b')];if(_0x297b27['query'][_0x891c('0x2b')]){_0x1a75e8['include']=[{'all':!![]}];}_0x1a75e8=_[_0x891c('0x28')]({},_0x1a75e8,_0x297b27[_0x891c('0x2a')]);return db[_0x891c('0x17')]['find'](_0x1a75e8)[_0x891c('0xe')](handleEntityNotFound(_0x555361,null))[_0x891c('0xe')](respondWithResult(_0x555361,null))[_0x891c('0x2f')](handleError(_0x555361,null));};exports[_0x891c('0x33')]=function(_0x2837b8,_0x3a5383){return db['Dynamics365Account']['create'](_0x2837b8[_0x891c('0x34')],{})[_0x891c('0xe')](respondWithResult(_0x3a5383,0xc9))[_0x891c('0x2f')](handleError(_0x3a5383,null));};exports[_0x891c('0xd')]=function(_0x2dac4f,_0x372076){if(_0x2dac4f[_0x891c('0x34')]['id']){delete _0x2dac4f['body']['id'];}return db[_0x891c('0x17')]['find']({'where':{'id':_0x2dac4f[_0x891c('0x31')]['id']}})[_0x891c('0xe')](handleEntityNotFound(_0x372076,null))[_0x891c('0xe')](saveUpdates(_0x2dac4f[_0x891c('0x34')],null))[_0x891c('0xe')](respondWithResult(_0x372076,null))[_0x891c('0x2f')](handleError(_0x372076,null));};exports[_0x891c('0xf')]=function(_0x5d51d6,_0x2b7849){return db[_0x891c('0x17')][_0x891c('0x35')]({'where':{'id':_0x5d51d6[_0x891c('0x31')]['id']}})[_0x891c('0xe')](handleEntityNotFound(_0x2b7849,null))['then'](removeEntity(_0x2b7849,null))['catch'](handleError(_0x2b7849,null));};exports[_0x891c('0x36')]=function(_0xbb4413,_0x8add5a){var _0x18b7e5={};var _0x41ac5b={};var _0x566dce;var _0x17be00;return db[_0x891c('0x17')][_0x891c('0x37')]({'where':{'id':_0xbb4413[_0x891c('0x31')]['id']}})[_0x891c('0xe')](handleEntityNotFound(_0x8add5a,null))[_0x891c('0xe')](function(_0x18c956){if(_0x18c956){_0x566dce=_0x18c956;_0x41ac5b[_0x891c('0x1b')]=_['keys'](db[_0x891c('0x38')]['rawAttributes']);_0x41ac5b[_0x891c('0x1c')]=_['keys'](_0xbb4413[_0x891c('0x1c')]);_0x41ac5b['filters']=_['intersection'](_0x41ac5b[_0x891c('0x1b')],_0x41ac5b[_0x891c('0x1c')]);_0x18b7e5['attributes']=_[_0x891c('0x1e')](_0x41ac5b[_0x891c('0x1b')],qs[_0x891c('0x20')](_0xbb4413['query'][_0x891c('0x20')]));_0x18b7e5[_0x891c('0x1f')]=_0x18b7e5[_0x891c('0x1f')]['length']?_0x18b7e5[_0x891c('0x1f')]:_0x41ac5b[_0x891c('0x1b')];_0x18b7e5[_0x891c('0x39')]=qs['sort'](_0xbb4413[_0x891c('0x1c')][_0x891c('0x24')]);_0x18b7e5['where']=qs[_0x891c('0x1d')](_[_0x891c('0x26')](_0xbb4413[_0x891c('0x1c')],_0x41ac5b[_0x891c('0x1d')]));if(_0xbb4413[_0x891c('0x1c')][_0x891c('0x27')]){_0x18b7e5[_0x891c('0x25')]=_[_0x891c('0x28')](_0x18b7e5['where'],{'$or':_[_0x891c('0x16')](_0x18b7e5[_0x891c('0x1f')],function(_0xb6aaa6){var _0x2d053f={};_0x2d053f[_0xb6aaa6]={'$like':'%'+_0xbb4413[_0x891c('0x1c')]['filter']+'%'};return _0x2d053f;})});}_0x18b7e5=_['merge']({},_0x18b7e5,_0xbb4413['options']);return _0x566dce[_0x891c('0x36')](_0x18b7e5);}})[_0x891c('0xe')](function(_0x2b140c){if(_0x2b140c){_0x17be00=_0x2b140c['length'];if(!_0xbb4413['query'][_0x891c('0x22')](_0x891c('0x23'))){_0x18b7e5[_0x891c('0x9')]=qs[_0x891c('0x9')](_0xbb4413['query'][_0x891c('0x9')]);_0x18b7e5[_0x891c('0x7')]=qs['offset'](_0xbb4413[_0x891c('0x1c')]['offset']);}return _0x566dce['getConfigurations'](_0x18b7e5);}})['then'](function(_0x7f72f4){if(_0x7f72f4){return _0x7f72f4?{'count':_0x17be00,'rows':_0x7f72f4}:null;}})[_0x891c('0xe')](respondWithResult(_0x8add5a,null))[_0x891c('0x2f')](handleError(_0x8add5a,null));};exports[_0x891c('0x3a')]=function(_0x476e3d,_0x5b581b){if(_0x476e3d['body']['id']){delete _0x476e3d[_0x891c('0x34')]['id'];}return db[_0x891c('0x17')][_0x891c('0x37')]({'where':{'id':_0x476e3d[_0x891c('0x31')]['id']}})[_0x891c('0xe')](handleEntityNotFound(_0x5b581b,null))[_0x891c('0xe')](function(_0x3d2a78){if(_0x3d2a78){_0x476e3d[_0x891c('0x34')][_0x891c('0x3b')]=_0x3d2a78['id'];_0x476e3d['body'][_0x891c('0x3c')]=integrations['getSubjects'](_0x476e3d[_0x891c('0x34')][_0x891c('0x3d')],_0x476e3d[_0x891c('0x34')][_0x891c('0x3e')]);_0x476e3d[_0x891c('0x34')][_0x891c('0x3f')]=integrations[_0x891c('0x40')](_0x476e3d[_0x891c('0x34')]['channel'],_0x476e3d[_0x891c('0x34')][_0x891c('0x3e')]);return db[_0x891c('0x38')][_0x891c('0x33')](_0x476e3d[_0x891c('0x34')],{'include':[{'model':db[_0x891c('0x41')],'as':'Subjects'},{'model':db[_0x891c('0x41')],'as':'Descriptions'}]});}return null;})[_0x891c('0xe')](respondWithResult(_0x5b581b,null))[_0x891c('0x2f')](handleError(_0x5b581b,null));};function sanitizeRemoteUri(_0x325889){var _0xa9d727=_0x325889[_0x891c('0x42')](-0x1);if(_0xa9d727==='/')return _0x325889[_0x891c('0x43')](0x0,_0x325889[_0x891c('0x44')](_0xa9d727));return _0x325889;}function getWebApiUrl(_0x374dbe){return util[_0x891c('0x45')]('%s/api/data/v9.0/',_0x374dbe);}exports[_0x891c('0x46')]=function(_0x2e9491,_0x5798fa){var _0x7b9644=_0x2e9491['query']['ticketType'];var _0x402512=_0x7b9644==='incident'?_0x891c('0x47'):_0x891c('0x48');var _0x4c50ae='';var _0x5b34d8='';var _0x1a4ed0='';var _0x1a7535='';var _0x1f0805='';var _0x1e84d0='';var _0x430e67='';var _0x57d2b2='';var _0x4ab9e2=[_0x891c('0x49'),_0x891c('0x4a'),_0x891c('0x4b'),_0x891c('0x4c'),'caseorigincode',_0x891c('0x4d'),_0x891c('0x4e'),_0x891c('0x4f'),_0x891c('0x50'),_0x891c('0x51')];var _0x1a1ca1=[_0x891c('0x52'),_0x891c('0x53'),'actualserviceunits',_0x891c('0x54'),'contactidname',_0x891c('0x55'),_0x891c('0x56'),_0x891c('0x57'),_0x891c('0x58'),'createdbyexternalpartyyominame','createdbyname',_0x891c('0x59'),_0x891c('0x5a'),_0x891c('0x5b'),'createdonbehalfbyyominame','customeridname',_0x891c('0x5c'),'customeridyominame','emailaddress',_0x891c('0x5d'),_0x891c('0x5e'),_0x891c('0x5f'),_0x891c('0x60'),_0x891c('0x61'),'firstresponsebykpiidname',_0x891c('0x62'),'importsequencenumber',_0x891c('0x63'),'kbarticleidname',_0x891c('0x64'),_0x891c('0x65'),_0x891c('0x66'),_0x891c('0x67'),_0x891c('0x68'),_0x891c('0x69'),_0x891c('0x6a'),'modifiedonbehalfbyname',_0x891c('0x6b'),_0x891c('0x6c'),_0x891c('0x6d'),_0x891c('0x6e'),_0x891c('0x6f'),'overriddencreatedon','owneridname',_0x891c('0x70'),_0x891c('0x71'),'parentcaseidname',_0x891c('0x72'),'primarycontactidyominame','prioritycodename',_0x891c('0x73'),'productserialnumber',_0x891c('0x74'),_0x891c('0x75'),_0x891c('0x76'),_0x891c('0x77'),_0x891c('0x78'),_0x891c('0x79'),_0x891c('0x7a'),_0x891c('0x7b'),_0x891c('0x7c'),_0x891c('0x7d'),_0x891c('0x7e'),_0x891c('0x7f'),_0x891c('0x80'),_0x891c('0x81'),_0x891c('0x82'),_0x891c('0x83'),'utcconversiontimezonecode',_0x891c('0x84')];var _0x432de5=_0x4ab9e2[_0x891c('0x85')](_0x1a1ca1);return db[_0x891c('0x17')][_0x891c('0x37')]({'where':{'id':_0x2e9491[_0x891c('0x31')]['id']},'attributes':['id',_0x891c('0x86'),_0x891c('0x87'),'remoteUri',_0x891c('0x88'),_0x891c('0x89'),'clientSecret',_0x891c('0x8a')],'include':[{'model':db[_0x891c('0x8b')],'as':_0x891c('0x8b'),'attributes':['id',_0x891c('0x8c'),_0x891c('0x8d')]}]})[_0x891c('0xe')](handleEntityNotFound(_0x5798fa,null))['then'](function(_0x28ebc6){if(_0x28ebc6){if(_0x28ebc6['modernAuthentication']){_0x28ebc6[_0x891c('0x8e')]=_0x28ebc6[_0x891c('0x8b')][_0x891c('0x8c')];_0x57d2b2=sanitizeRemoteUri(_0x28ebc6[_0x891c('0x8b')][_0x891c('0x8d')]);_0x430e67=getWebApiUrl(_0x57d2b2);return _0x28ebc6;}_0x57d2b2=sanitizeRemoteUri(_0x28ebc6[_0x891c('0x8f')]);_0x430e67=getWebApiUrl(_0x57d2b2);var _0x348d53={'method':_0x891c('0x90'),'uri':_0x891c('0x91')+_0x28ebc6['tenantId']+_0x891c('0x92'),'form':{'client_id':_0x28ebc6['clientId'],'resource':_0x57d2b2,'username':_0x28ebc6[_0x891c('0x86')],'password':_0x28ebc6['password'],'grant_type':_0x891c('0x87'),'client_secret':_0x28ebc6[_0x891c('0x93')]},'json':!![]};return rp(_0x348d53);}})[_0x891c('0xe')](function(_0x190c09){_0x1e84d0=_0x190c09[_0x891c('0x8e')];var _0x4a5b2c={'method':_0x891c('0x94'),'uri':encodeURI(_0x430e67+_0x891c('0x95')+_0x402512+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x1e84d0,'If-None-Match':null,'OData-Version':_0x891c('0x96')},'json':!![]};return rp(_0x4a5b2c);})[_0x891c('0xe')](function(_0x47da99){var _0x4cf7eb=_0x47da99[_0x891c('0x97')][0x0];var _0x57d521=_0x4cf7eb[_0x891c('0x98')];var _0x5cd8d0={'method':_0x891c('0x94'),'uri':_0x430e67+_0x891c('0x99')+_0x57d521+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0x891c('0x9a')+_0x1e84d0,'If-None-Match':null,'OData-Version':_0x891c('0x96')},'json':!![]};return rp(_0x5cd8d0);})[_0x891c('0xe')](function(_0x3938bc){_0x4c50ae=_0x3938bc;_0x5b34d8=_0x4c50ae[_0x891c('0x9b')];_0x5b34d8=_[_0x891c('0x9c')](_0x5b34d8,function(_0x1f0012){return!_0x432de5[_0x891c('0x9d')](_0x1f0012[_0x891c('0x9e')]);});var _0x5634ea=[];var _0x4dc496=[];_0x5b34d8[_0x891c('0x9f')](function(_0x28464e){if(_0x28464e[_0x891c('0xa0')]){var _0x17e043=_0x28464e[_0x891c('0xa0')][_0x891c('0x43')](_0x28464e[_0x891c('0xa0')]['lastIndexOf']('.')+0x1);if(_0x17e043===_0x891c('0xa1')){_0x5634ea['push'](getSelectList(_0x430e67,_0x7b9644,_0x4dc496,_0x4c50ae[_0x891c('0x98')],_0x28464e[_0x891c('0x98')],_0x1e84d0));}}});return Promise['all'](_0x5634ea);})['then'](function(_0x7009d){_0x1a4ed0=_0x7009d[0x0];var _0x3a6de5=[];var _0x5654aa=[];_0x5b34d8[_0x891c('0x9f')](function(_0x4b860c){if(!_[_0x891c('0xa2')](_0x4b860c['@odata.type'])){var _0x3a05ab=_0x4b860c['@odata.type'][_0x891c('0x43')](_0x4b860c[_0x891c('0xa0')][_0x891c('0x44')]('.')+0x1);if(_0x3a05ab===_0x891c('0xa3')){_0x3a6de5[_0x891c('0xa4')](getBooleanList(_0x430e67,_0x7b9644,_0x5654aa,_0x4c50ae['MetadataId'],_0x4b860c[_0x891c('0x98')],_0x1e84d0));}}});return Promise[_0x891c('0xa5')](_0x3a6de5);})['then'](function(_0x151daa){_0x1a7535=_0x151daa[0x0];var _0x1ec91e=[];var _0x3042cc=[];_0x5b34d8[_0x891c('0x9f')](function(_0x51bbef){if(_0x51bbef[_0x891c('0xa0')]){var _0x44f362=_0x51bbef[_0x891c('0xa0')][_0x891c('0x43')](_0x51bbef[_0x891c('0xa0')]['lastIndexOf']('.')+0x1);if(_0x44f362==='StringAttributeMetadata'||_0x44f362===_0x891c('0xa6')||_0x44f362===_0x891c('0xa7')||_0x44f362===_0x891c('0xa8')||_0x44f362===_0x891c('0xa9')||_0x44f362==='DateTimeAttributeMetadata'||_0x44f362===_0x891c('0xaa')||_0x44f362===_0x891c('0xab')||_0x44f362===_0x891c('0xac')||_0x44f362===_0x891c('0xad')){_0x1ec91e['push'](getInputList(_0x430e67,_0x7b9644,_0x44f362,_0x3042cc,_0x4c50ae[_0x891c('0x98')],_0x51bbef[_0x891c('0x98')],_0x1e84d0));}}});return Promise['all'](_0x1ec91e);})[_0x891c('0xe')](function(_0x3bd652){_0x1f0805=_0x3bd652[0x0];var _0x41a981=_0x1a4ed0[_0x891c('0x85')](_0x1a7535)['concat'](_0x1f0805);var _0x25db60={'count':_0x41a981[_0x891c('0x21')],'rows':_0x41a981};return _0x25db60;})['then'](respondWithResult(_0x5798fa,null))['catch'](function(_0x144f98){var _0x3f2258=_0x2e9491[_0x891c('0x1c')][_0x891c('0xae')]?0x1f4:_0x144f98[_0x891c('0xaf')]||0x1f4;logger[_0x891c('0x11')](_0x144f98[_0x891c('0x12')]);delete _0x144f98[_0x891c('0x13')];if(_0x3f2258===0x191){_0x3f2258=0x190;}_0x5798fa[_0x891c('0x5')](_0x3f2258)[_0x891c('0x14')](_0x2e9491['query'][_0x891c('0xae')]?{'message':'Wrong\x20credentials','statusCode':_0x144f98[_0x891c('0xaf')]}:_0x144f98);});};function getSelectList(_0x3f29a2,_0x43cabd,_0x262690,_0x18272f,_0x18d771,_0x2b2d32){var _0x3cc965={'method':_0x891c('0x94'),'uri':_0x3f29a2+'EntityDefinitions('+_0x18272f+')/Attributes('+_0x18d771+_0x891c('0xb0')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0x891c('0x9a')+_0x2b2d32,'If-None-Match':null,'OData-Version':_0x891c('0x96')},'json':!![]};return rp(_0x3cc965)[_0x891c('0xe')](function(_0xac8235){var _0x3ac218=[];var _0x58170a=_0xac8235[_0x891c('0xb1')][_0x891c('0xb2')];_0x58170a[_0x891c('0x9f')](function(_0x5d48fe){_0x3ac218[_0x891c('0xa4')]({'name':_0x5d48fe[_0x891c('0xb3')][_0x891c('0xb4')][_0x891c('0xb3')],'value':String(_0x5d48fe['Value'])});});var _0xbcb829={'id':_0x43cabd+'_'+_0xac8235[_0x891c('0x9e')],'name':_0xac8235[_0x891c('0xb5')][_0x891c('0xb4')][_0x891c('0xb3')],'custom':![],'options':_0x3ac218};_0x262690[_0x891c('0xa4')](_0xbcb829);return _0x262690;});}function getBooleanList(_0x90ffcb,_0x5c75b9,_0x2e4260,_0xd62536,_0x7d444b,_0x579aac){var _0x1d6e0e={'method':_0x891c('0x94'),'uri':_0x90ffcb+_0x891c('0x99')+_0xd62536+_0x891c('0xb6')+_0x7d444b+_0x891c('0xb7'),'headers':{'Authorization':_0x891c('0x9a')+_0x579aac,'If-None-Match':null,'OData-Version':_0x891c('0x96')},'json':!![]};return rp(_0x1d6e0e)[_0x891c('0xe')](function(_0x105180){var _0x5e1643=[];_0x5e1643[_0x891c('0xa4')]({'name':_0x105180[_0x891c('0xb1')]['TrueOption'][_0x891c('0xb3')]['UserLocalizedLabel'][_0x891c('0xb3')],'value':_0x891c('0xb8')},{'name':_0x105180[_0x891c('0xb1')][_0x891c('0xb9')][_0x891c('0xb3')]['UserLocalizedLabel'][_0x891c('0xb3')],'value':_0x891c('0xba')});var _0x1cfab4={'id':_0x5c75b9+'_'+_0x105180['LogicalName'],'name':_0x105180[_0x891c('0xb5')][_0x891c('0xb4')][_0x891c('0xb3')],'custom':![],'options':_0x5e1643};_0x2e4260[_0x891c('0xa4')](_0x1cfab4);return _0x2e4260;});}function getInputList(_0x274773,_0x4ab95e,_0xbb90bc,_0x2332df,_0x29e0ba,_0x151aaf,_0x342d0b){var _0x5241b9={'method':_0x891c('0x94'),'uri':_0x274773+_0x891c('0x99')+_0x29e0ba+_0x891c('0xb6')+_0x151aaf+')/Microsoft.Dynamics.CRM.'+_0xbb90bc+_0x891c('0xbb'),'headers':{'Authorization':_0x891c('0x9a')+_0x342d0b,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x5241b9)[_0x891c('0xe')](function(_0x2aab50){var _0x134727={'id':_0x4ab95e+'_'+_0x2aab50[_0x891c('0x9e')],'name':_0x2aab50[_0x891c('0xb5')][_0x891c('0xb4')]?_0x2aab50['DisplayName'][_0x891c('0xb4')]['Label']:_0x2aab50['LogicalName'],'custom':![],'options':[]};_0x2332df['push'](_0x134727);return _0x2332df;});}
\ No newline at end of file