Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 1f7bc3d..90b1a92 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6c29=['escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','masteridname','modifiedbyexternalpartyname','modifiedbyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','owneridname','owneridtype','parentcaseidname','primarycontactidname','prioritycodename','productserialnumber','resolveby','resolvebykpiidname','responseby','responsiblecontactidyominame','slainvokedidname','socialprofileidname','statecode','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','versionnumber','username','password','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data5','data7','access_token','https://login.microsoftonline.com/','GET','Bearer\x20','4.0','MetadataId','EntityDefinitions(','Attributes','remove','includes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','push','all','isNil','StringAttributeMetadata','DoubleAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','concat','test','statusCode',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','Options','UserLocalizedLabel','Label','TrueOption','true','OptionSet','FalseOption','false','DisplayName',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','api','status','json','offset','undefined','limit','count','set','Content-Range','update','then','sendStatus','error','stack','name','send','index','map','rawAttributes','fieldName','type','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','Dynamics365Account','includeAll','include','catch','show','params','find','body','destroy','getConfigurations','findOne','Dynamics365Configuration','options','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','create','Dynamics365Field','slice','substring','lastIndexOf','%s/api/data/v9.0/','incident','PhoneCall','description','customerid','ownerid','caseorigincode','subject','regardingobjectid','directioncode','phonecall_activity_parties','accountidyominame','billedserviceunits','contactidname','contactidyominame','contractidname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','entitlementidname','entityimage_timestamp'];(function(_0x2edb29,_0x369171){var _0x3fdef3=function(_0x2396f1){while(--_0x2396f1){_0x2edb29['push'](_0x2edb29['shift']());}};_0x3fdef3(++_0x369171);}(_0x6c29,0x1c1));var _0x96c2=function(_0x168127,_0x59cea1){_0x168127=_0x168127-0x0;var _0x4c99ad=_0x6c29[_0x168127];return _0x4c99ad;};'use strict';var rp=require(_0x96c2('0x0'));var util=require(_0x96c2('0x1'));var _=require(_0x96c2('0x2'));var qs=require(_0x96c2('0x3'));var logger=require(_0x96c2('0x4'))(_0x96c2('0x5'));var db=require('../../mysqldb')['db'];var integrations=require('../../components/integrations/configuration');function respondWithResult(_0x20ac16,_0x1ba8ad){_0x1ba8ad=_0x1ba8ad||0xc8;return function(_0x5c84c4){if(_0x5c84c4){return _0x20ac16[_0x96c2('0x6')](_0x1ba8ad)[_0x96c2('0x7')](_0x5c84c4);}};}function respondWithFilteredResult(_0x2ee7c6,_0x2f9b84){return function(_0x4e15bd){if(_0x4e15bd){var _0x3dbbc2=typeof _0x2f9b84[_0x96c2('0x8')]===_0x96c2('0x9')&&typeof _0x2f9b84[_0x96c2('0xa')]===_0x96c2('0x9');var _0x51ac69=_0x4e15bd[_0x96c2('0xb')];var _0x3438f1=_0x3dbbc2?0x0:_0x2f9b84[_0x96c2('0x8')];var _0x4f2134=_0x3dbbc2?_0x4e15bd['count']:_0x2f9b84[_0x96c2('0x8')]+_0x2f9b84[_0x96c2('0xa')];var _0x3ac4e2;if(_0x4f2134>=_0x51ac69){_0x4f2134=_0x51ac69;_0x3ac4e2=0xc8;}else{_0x3ac4e2=0xce;}_0x2ee7c6['status'](_0x3ac4e2);return _0x2ee7c6[_0x96c2('0xc')](_0x96c2('0xd'),_0x3438f1+'-'+_0x4f2134+'/'+_0x51ac69)[_0x96c2('0x7')](_0x4e15bd);}return null;};}function saveUpdates(_0x605573){return function(_0xa933c3){if(_0xa933c3){return _0xa933c3[_0x96c2('0xe')](_0x605573)[_0x96c2('0xf')](function(_0x294a1f){return _0x294a1f;});}return null;};}function removeEntity(_0x160433){return function(_0x38f87e){if(_0x38f87e){return _0x38f87e['destroy']()[_0x96c2('0xf')](function(){_0x160433['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x420400){return function(_0x4bd8f9){if(!_0x4bd8f9){_0x420400[_0x96c2('0x10')](0x194);}return _0x4bd8f9;};}function handleError(_0x382707,_0x5472e5){_0x5472e5=_0x5472e5||0x1f4;return function(_0x3d4300){logger[_0x96c2('0x11')](_0x3d4300[_0x96c2('0x12')]);if(_0x3d4300[_0x96c2('0x13')]){delete _0x3d4300[_0x96c2('0x13')];}_0x382707['status'](_0x5472e5)[_0x96c2('0x14')](_0x3d4300);};}exports[_0x96c2('0x15')]=function(_0x161c32,_0xf4d354){var _0x4e1f88={},_0x32bfaa={},_0x47a875={'count':0x0,'rows':[]};var _0x5a296f=_[_0x96c2('0x16')](db['Dynamics365Account'][_0x96c2('0x17')],function(_0x1964af){return{'name':_0x1964af[_0x96c2('0x18')],'type':_0x1964af[_0x96c2('0x19')]['key']};});_0x32bfaa[_0x96c2('0x1a')]=_['map'](_0x5a296f,_0x96c2('0x13'));_0x32bfaa['query']=_[_0x96c2('0x1b')](_0x161c32[_0x96c2('0x1c')]);_0x32bfaa[_0x96c2('0x1d')]=_[_0x96c2('0x1e')](_0x32bfaa[_0x96c2('0x1a')],_0x32bfaa[_0x96c2('0x1c')]);_0x4e1f88['attributes']=_[_0x96c2('0x1e')](_0x32bfaa[_0x96c2('0x1a')],qs[_0x96c2('0x1f')](_0x161c32[_0x96c2('0x1c')][_0x96c2('0x1f')]));_0x4e1f88[_0x96c2('0x20')]=_0x4e1f88[_0x96c2('0x20')][_0x96c2('0x21')]?_0x4e1f88[_0x96c2('0x20')]:_0x32bfaa['model'];if(!_0x161c32[_0x96c2('0x1c')][_0x96c2('0x22')](_0x96c2('0x23'))){_0x4e1f88['limit']=qs[_0x96c2('0xa')](_0x161c32[_0x96c2('0x1c')][_0x96c2('0xa')]);_0x4e1f88['offset']=qs[_0x96c2('0x8')](_0x161c32[_0x96c2('0x1c')][_0x96c2('0x8')]);}_0x4e1f88[_0x96c2('0x24')]=qs[_0x96c2('0x25')](_0x161c32[_0x96c2('0x1c')]['sort']);_0x4e1f88[_0x96c2('0x26')]=qs['filters'](_[_0x96c2('0x27')](_0x161c32['query'],_0x32bfaa['filters']),_0x5a296f);if(_0x161c32[_0x96c2('0x1c')][_0x96c2('0x28')]){_0x4e1f88[_0x96c2('0x26')]=_['merge'](_0x4e1f88[_0x96c2('0x26')],{'$or':_[_0x96c2('0x16')](_0x5a296f,function(_0x277c09){if(_0x277c09[_0x96c2('0x19')]!==_0x96c2('0x29')){var _0x4eb7e9={};_0x4eb7e9[_0x277c09[_0x96c2('0x13')]]={'$like':'%'+_0x161c32[_0x96c2('0x1c')][_0x96c2('0x28')]+'%'};return _0x4eb7e9;}})});}_0x4e1f88=_[_0x96c2('0x2a')]({},_0x4e1f88,_0x161c32['options']);var _0xf65435={'where':_0x4e1f88[_0x96c2('0x26')]};return db[_0x96c2('0x2b')][_0x96c2('0xb')](_0xf65435)['then'](function(_0x3c6790){_0x47a875['count']=_0x3c6790;if(_0x161c32[_0x96c2('0x1c')][_0x96c2('0x2c')]){_0x4e1f88[_0x96c2('0x2d')]=[{'all':!![]}];}return db[_0x96c2('0x2b')]['findAll'](_0x4e1f88);})[_0x96c2('0xf')](function(_0x18c0bf){_0x47a875['rows']=_0x18c0bf;return _0x47a875;})[_0x96c2('0xf')](respondWithFilteredResult(_0xf4d354,_0x4e1f88))[_0x96c2('0x2e')](handleError(_0xf4d354,null));};exports[_0x96c2('0x2f')]=function(_0x3034fb,_0x81e447){var _0x4b6d6a={'raw':![],'where':{'id':_0x3034fb[_0x96c2('0x30')]['id']}},_0x34e753={};_0x34e753[_0x96c2('0x1a')]=_[_0x96c2('0x1b')](db[_0x96c2('0x2b')]['rawAttributes']);_0x34e753[_0x96c2('0x1c')]=_['keys'](_0x3034fb[_0x96c2('0x1c')]);_0x34e753[_0x96c2('0x1d')]=_[_0x96c2('0x1e')](_0x34e753['model'],_0x34e753['query']);_0x4b6d6a[_0x96c2('0x20')]=_[_0x96c2('0x1e')](_0x34e753['model'],qs[_0x96c2('0x1f')](_0x3034fb['query'][_0x96c2('0x1f')]));_0x4b6d6a[_0x96c2('0x20')]=_0x4b6d6a[_0x96c2('0x20')][_0x96c2('0x21')]?_0x4b6d6a[_0x96c2('0x20')]:_0x34e753['model'];if(_0x3034fb['query'][_0x96c2('0x2c')]){_0x4b6d6a[_0x96c2('0x2d')]=[{'all':!![]}];}_0x4b6d6a=_[_0x96c2('0x2a')]({},_0x4b6d6a,_0x3034fb['options']);return db[_0x96c2('0x2b')][_0x96c2('0x31')](_0x4b6d6a)['then'](handleEntityNotFound(_0x81e447,null))[_0x96c2('0xf')](respondWithResult(_0x81e447,null))[_0x96c2('0x2e')](handleError(_0x81e447,null));};exports['create']=function(_0x3323d4,_0xd1d6df){return db[_0x96c2('0x2b')]['create'](_0x3323d4[_0x96c2('0x32')],{})['then'](respondWithResult(_0xd1d6df,0xc9))[_0x96c2('0x2e')](handleError(_0xd1d6df,null));};exports[_0x96c2('0xe')]=function(_0x212c60,_0x4cce7b){if(_0x212c60[_0x96c2('0x32')]['id']){delete _0x212c60[_0x96c2('0x32')]['id'];}return db['Dynamics365Account'][_0x96c2('0x31')]({'where':{'id':_0x212c60[_0x96c2('0x30')]['id']}})[_0x96c2('0xf')](handleEntityNotFound(_0x4cce7b,null))[_0x96c2('0xf')](saveUpdates(_0x212c60['body'],null))[_0x96c2('0xf')](respondWithResult(_0x4cce7b,null))[_0x96c2('0x2e')](handleError(_0x4cce7b,null));};exports[_0x96c2('0x33')]=function(_0x4d6b02,_0x2ac67e){return db[_0x96c2('0x2b')][_0x96c2('0x31')]({'where':{'id':_0x4d6b02[_0x96c2('0x30')]['id']}})['then'](handleEntityNotFound(_0x2ac67e,null))[_0x96c2('0xf')](removeEntity(_0x2ac67e,null))[_0x96c2('0x2e')](handleError(_0x2ac67e,null));};exports[_0x96c2('0x34')]=function(_0x2aae23,_0x1a5a7a){var _0xa78d42={};var _0x369fd3={};var _0x168ad6;var _0x3b5ab2;return db[_0x96c2('0x2b')][_0x96c2('0x35')]({'where':{'id':_0x2aae23[_0x96c2('0x30')]['id']}})[_0x96c2('0xf')](handleEntityNotFound(_0x1a5a7a,null))[_0x96c2('0xf')](function(_0x1f994e){if(_0x1f994e){_0x168ad6=_0x1f994e;_0x369fd3[_0x96c2('0x1a')]=_[_0x96c2('0x1b')](db[_0x96c2('0x36')][_0x96c2('0x17')]);_0x369fd3[_0x96c2('0x1c')]=_[_0x96c2('0x1b')](_0x2aae23['query']);_0x369fd3[_0x96c2('0x1d')]=_[_0x96c2('0x1e')](_0x369fd3[_0x96c2('0x1a')],_0x369fd3[_0x96c2('0x1c')]);_0xa78d42[_0x96c2('0x20')]=_[_0x96c2('0x1e')](_0x369fd3[_0x96c2('0x1a')],qs[_0x96c2('0x1f')](_0x2aae23[_0x96c2('0x1c')][_0x96c2('0x1f')]));_0xa78d42[_0x96c2('0x20')]=_0xa78d42[_0x96c2('0x20')][_0x96c2('0x21')]?_0xa78d42[_0x96c2('0x20')]:_0x369fd3[_0x96c2('0x1a')];_0xa78d42['order']=qs[_0x96c2('0x25')](_0x2aae23[_0x96c2('0x1c')][_0x96c2('0x25')]);_0xa78d42[_0x96c2('0x26')]=qs[_0x96c2('0x1d')](_[_0x96c2('0x27')](_0x2aae23[_0x96c2('0x1c')],_0x369fd3[_0x96c2('0x1d')]));if(_0x2aae23[_0x96c2('0x1c')][_0x96c2('0x28')]){_0xa78d42['where']=_[_0x96c2('0x2a')](_0xa78d42[_0x96c2('0x26')],{'$or':_['map'](_0xa78d42[_0x96c2('0x20')],function(_0x468ed4){var _0x132ac6={};_0x132ac6[_0x468ed4]={'$like':'%'+_0x2aae23[_0x96c2('0x1c')][_0x96c2('0x28')]+'%'};return _0x132ac6;})});}_0xa78d42=_[_0x96c2('0x2a')]({},_0xa78d42,_0x2aae23[_0x96c2('0x37')]);return _0x168ad6[_0x96c2('0x34')](_0xa78d42);}})[_0x96c2('0xf')](function(_0xf65833){if(_0xf65833){_0x3b5ab2=_0xf65833['length'];if(!_0x2aae23[_0x96c2('0x1c')][_0x96c2('0x22')](_0x96c2('0x23'))){_0xa78d42['limit']=qs[_0x96c2('0xa')](_0x2aae23[_0x96c2('0x1c')][_0x96c2('0xa')]);_0xa78d42['offset']=qs[_0x96c2('0x8')](_0x2aae23['query'][_0x96c2('0x8')]);}return _0x168ad6[_0x96c2('0x34')](_0xa78d42);}})[_0x96c2('0xf')](function(_0x44305b){if(_0x44305b){return _0x44305b?{'count':_0x3b5ab2,'rows':_0x44305b}:null;}})[_0x96c2('0xf')](respondWithResult(_0x1a5a7a,null))[_0x96c2('0x2e')](handleError(_0x1a5a7a,null));};exports[_0x96c2('0x38')]=function(_0x180c8b,_0x9a1340){if(_0x180c8b[_0x96c2('0x32')]['id']){delete _0x180c8b[_0x96c2('0x32')]['id'];}return db[_0x96c2('0x2b')][_0x96c2('0x35')]({'where':{'id':_0x180c8b['params']['id']}})[_0x96c2('0xf')](handleEntityNotFound(_0x9a1340,null))[_0x96c2('0xf')](function(_0x263e07){if(_0x263e07){_0x180c8b[_0x96c2('0x32')][_0x96c2('0x39')]=_0x263e07['id'];_0x180c8b[_0x96c2('0x32')][_0x96c2('0x3a')]=integrations[_0x96c2('0x3b')](_0x180c8b[_0x96c2('0x32')][_0x96c2('0x3c')],_0x180c8b['body'][_0x96c2('0x19')]);_0x180c8b[_0x96c2('0x32')][_0x96c2('0x3d')]=integrations['getDescriptions'](_0x180c8b[_0x96c2('0x32')][_0x96c2('0x3c')],_0x180c8b[_0x96c2('0x32')]['type']);return db[_0x96c2('0x36')][_0x96c2('0x3e')](_0x180c8b[_0x96c2('0x32')],{'include':[{'model':db[_0x96c2('0x3f')],'as':_0x96c2('0x3a')},{'model':db[_0x96c2('0x3f')],'as':_0x96c2('0x3d')}]});}return null;})['then'](respondWithResult(_0x9a1340,null))[_0x96c2('0x2e')](handleError(_0x9a1340,null));};function sanitizeRemoteUri(_0x4db348){var _0x182366=_0x4db348[_0x96c2('0x40')](-0x1);if(_0x182366==='/')return _0x4db348[_0x96c2('0x41')](0x0,_0x4db348[_0x96c2('0x42')](_0x182366));return _0x4db348;}function getWebApiUrl(_0x5f3e61){return util['format'](_0x96c2('0x43'),_0x5f3e61);}exports['getFields']=function(_0x4673fa,_0x436bfb){var _0x161f86=_0x4673fa['query']['ticketType'];var _0x54acfa=_0x161f86===_0x96c2('0x44')?'Incident':_0x96c2('0x45');var _0x156b41='';var _0x10b465='';var _0x549cf1='';var _0x33d9ad='';var _0x37a0cb='';var _0x5f1577='';var _0x4557c4='';var _0x496635='';var _0x386953=['title',_0x96c2('0x46'),_0x96c2('0x47'),_0x96c2('0x48'),_0x96c2('0x49'),_0x96c2('0x4a'),'phonenumber',_0x96c2('0x4b'),_0x96c2('0x4c'),_0x96c2('0x4d')];var _0xb22357=['accountidname',_0x96c2('0x4e'),'actualserviceunits',_0x96c2('0x4f'),_0x96c2('0x50'),_0x96c2('0x51'),'contractdetailidname',_0x96c2('0x52'),'createdbyexternalpartyname',_0x96c2('0x53'),_0x96c2('0x54'),_0x96c2('0x55'),_0x96c2('0x56'),_0x96c2('0x57'),_0x96c2('0x58'),_0x96c2('0x59'),_0x96c2('0x5a'),_0x96c2('0x5b'),'emailaddress',_0x96c2('0x5c'),_0x96c2('0x5d'),'entityimage_url',_0x96c2('0x5e'),_0x96c2('0x5f'),_0x96c2('0x60'),_0x96c2('0x61'),_0x96c2('0x62'),_0x96c2('0x63'),'kbarticleidname','lastonholdtime',_0x96c2('0x64'),_0x96c2('0x65'),'modifiedbyexternalpartyyominame',_0x96c2('0x66'),_0x96c2('0x67'),_0x96c2('0x68'),_0x96c2('0x69'),_0x96c2('0x6a'),_0x96c2('0x6b'),_0x96c2('0x6c'),_0x96c2('0x6d'),'onholdtime',_0x96c2('0x6e'),_0x96c2('0x6f'),_0x96c2('0x70'),'owneridyominame',_0x96c2('0x71'),_0x96c2('0x72'),'primarycontactidyominame',_0x96c2('0x73'),'productidname',_0x96c2('0x74'),_0x96c2('0x75'),_0x96c2('0x76'),_0x96c2('0x77'),'responsiblecontactidname',_0x96c2('0x78'),'sentimentvalue',_0x96c2('0x79'),'slaname',_0x96c2('0x7a'),_0x96c2('0x7b'),_0x96c2('0x7c'),_0x96c2('0x7d'),_0x96c2('0x7e'),_0x96c2('0x7f'),_0x96c2('0x80'),_0x96c2('0x81'),'utcconversiontimezonecode',_0x96c2('0x82')];var _0x154ddf=_0x386953['concat'](_0xb22357);return db[_0x96c2('0x2b')]['findOne']({'where':{'id':_0x4673fa['params']['id']},'attributes':['id',_0x96c2('0x83'),_0x96c2('0x84'),'remoteUri',_0x96c2('0x85'),_0x96c2('0x86'),_0x96c2('0x87'),_0x96c2('0x88')],'include':[{'model':db[_0x96c2('0x89')],'as':_0x96c2('0x89'),'attributes':['id',_0x96c2('0x8a'),_0x96c2('0x8b')]}]})[_0x96c2('0xf')](handleEntityNotFound(_0x436bfb,null))[_0x96c2('0xf')](function(_0x5502bb){if(_0x5502bb){if(_0x5502bb[_0x96c2('0x88')]){_0x5502bb[_0x96c2('0x8c')]=_0x5502bb[_0x96c2('0x89')][_0x96c2('0x8a')];_0x496635=sanitizeRemoteUri(_0x5502bb['CloudProvider'][_0x96c2('0x8b')]);_0x4557c4=getWebApiUrl(_0x496635);return _0x5502bb;}_0x496635=sanitizeRemoteUri(_0x5502bb['remoteUri']);_0x4557c4=getWebApiUrl(_0x496635);var _0x4ec3e1={'method':'POST','uri':_0x96c2('0x8d')+_0x5502bb[_0x96c2('0x85')]+'/oauth2/token','form':{'client_id':_0x5502bb[_0x96c2('0x86')],'resource':_0x496635,'username':_0x5502bb[_0x96c2('0x83')],'password':_0x5502bb[_0x96c2('0x84')],'grant_type':_0x96c2('0x84'),'client_secret':_0x5502bb[_0x96c2('0x87')]},'json':!![]};return rp(_0x4ec3e1);}})[_0x96c2('0xf')](function(_0x1aa246){_0x5f1577=_0x1aa246[_0x96c2('0x8c')];var _0xe563={'method':_0x96c2('0x8e'),'uri':encodeURI(_0x4557c4+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x54acfa+'\x27'),'headers':{'Authorization':_0x96c2('0x8f')+_0x5f1577,'If-None-Match':null,'OData-Version':_0x96c2('0x90')},'json':!![]};return rp(_0xe563);})[_0x96c2('0xf')](function(_0x51510a){var _0x344db4=_0x51510a['value'][0x0];var _0x2414cb=_0x344db4[_0x96c2('0x91')];var _0x461b0d={'method':_0x96c2('0x8e'),'uri':_0x4557c4+_0x96c2('0x92')+_0x2414cb+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0x96c2('0x8f')+_0x5f1577,'If-None-Match':null,'OData-Version':_0x96c2('0x90')},'json':!![]};return rp(_0x461b0d);})[_0x96c2('0xf')](function(_0x5013f1){_0x156b41=_0x5013f1;_0x10b465=_0x156b41[_0x96c2('0x93')];_0x10b465=_[_0x96c2('0x94')](_0x10b465,function(_0x525b4b){return!_0x154ddf[_0x96c2('0x95')](_0x525b4b[_0x96c2('0x96')]);});var _0xc3a907=[];var _0x37d80b=[];_0x10b465[_0x96c2('0x97')](function(_0x32b828){if(_0x32b828[_0x96c2('0x98')]){var _0x336c1c=_0x32b828['@odata.type'][_0x96c2('0x41')](_0x32b828['@odata.type'][_0x96c2('0x42')]('.')+0x1);if(_0x336c1c===_0x96c2('0x99')){_0xc3a907[_0x96c2('0x9a')](getSelectList(_0x4557c4,_0x161f86,_0x37d80b,_0x156b41['MetadataId'],_0x32b828[_0x96c2('0x91')],_0x5f1577));}}});return Promise[_0x96c2('0x9b')](_0xc3a907);})['then'](function(_0x116fff){_0x549cf1=_0x116fff[0x0];var _0x564af8=[];var _0xfa6483=[];_0x10b465[_0x96c2('0x97')](function(_0x59d063){if(!_[_0x96c2('0x9c')](_0x59d063[_0x96c2('0x98')])){var _0x49d185=_0x59d063['@odata.type']['substring'](_0x59d063[_0x96c2('0x98')][_0x96c2('0x42')]('.')+0x1);if(_0x49d185==='BooleanAttributeMetadata'){_0x564af8[_0x96c2('0x9a')](getBooleanList(_0x4557c4,_0x161f86,_0xfa6483,_0x156b41[_0x96c2('0x91')],_0x59d063['MetadataId'],_0x5f1577));}}});return Promise[_0x96c2('0x9b')](_0x564af8);})[_0x96c2('0xf')](function(_0x4872e6){_0x33d9ad=_0x4872e6[0x0];var _0x4822ef=[];var _0x4a8ea7=[];_0x10b465[_0x96c2('0x97')](function(_0x339498){if(_0x339498[_0x96c2('0x98')]){var _0x585495=_0x339498[_0x96c2('0x98')][_0x96c2('0x41')](_0x339498[_0x96c2('0x98')][_0x96c2('0x42')]('.')+0x1);if(_0x585495===_0x96c2('0x9d')||_0x585495===_0x96c2('0x9e')||_0x585495==='BigIntAttributeMetadata'||_0x585495===_0x96c2('0x9f')||_0x585495===_0x96c2('0xa0')||_0x585495===_0x96c2('0xa1')||_0x585495==='StatusAttributeMetadata'||_0x585495===_0x96c2('0xa2')||_0x585495===_0x96c2('0xa3')||_0x585495===_0x96c2('0xa4')){_0x4822ef[_0x96c2('0x9a')](getInputList(_0x4557c4,_0x161f86,_0x585495,_0x4a8ea7,_0x156b41[_0x96c2('0x91')],_0x339498['MetadataId'],_0x5f1577));}}});return Promise[_0x96c2('0x9b')](_0x4822ef);})[_0x96c2('0xf')](function(_0x4117fc){_0x37a0cb=_0x4117fc[0x0];var _0x2914ec=_0x549cf1['concat'](_0x33d9ad)[_0x96c2('0xa5')](_0x37a0cb);var _0x4e1250={'count':_0x2914ec[_0x96c2('0x21')],'rows':_0x2914ec};return _0x4e1250;})['then'](respondWithResult(_0x436bfb,null))[_0x96c2('0x2e')](function(_0x22c7d2){var _0xd99e74=_0x4673fa[_0x96c2('0x1c')][_0x96c2('0xa6')]?0x1f4:_0x22c7d2[_0x96c2('0xa7')]||0x1f4;logger[_0x96c2('0x11')](_0x22c7d2[_0x96c2('0x12')]);delete _0x22c7d2[_0x96c2('0x13')];if(_0xd99e74===0x191){_0xd99e74=0x190;}_0x436bfb[_0x96c2('0x6')](_0xd99e74)[_0x96c2('0x14')](_0x4673fa[_0x96c2('0x1c')][_0x96c2('0xa6')]?{'message':'Wrong\x20credentials','statusCode':_0x22c7d2[_0x96c2('0xa7')]}:_0x22c7d2);});};function getSelectList(_0x71bffa,_0x4b7e7a,_0xe40981,_0x159966,_0x562eda,_0x4b9390){var _0xc2e7f3={'method':_0x96c2('0x8e'),'uri':_0x71bffa+_0x96c2('0x92')+_0x159966+_0x96c2('0xa8')+_0x562eda+_0x96c2('0xa9')+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0x96c2('0x8f')+_0x4b9390,'If-None-Match':null,'OData-Version':_0x96c2('0x90')},'json':!![]};return rp(_0xc2e7f3)['then'](function(_0x1d5dcc){var _0x593351=[];var _0x252237=_0x1d5dcc['OptionSet'][_0x96c2('0xaa')];_0x252237[_0x96c2('0x97')](function(_0x2e3bc0){_0x593351[_0x96c2('0x9a')]({'name':_0x2e3bc0['Label'][_0x96c2('0xab')]['Label'],'value':String(_0x2e3bc0['Value'])});});var _0x2a93b4={'id':_0x4b7e7a+'_'+_0x1d5dcc[_0x96c2('0x96')],'name':_0x1d5dcc['DisplayName']['UserLocalizedLabel'][_0x96c2('0xac')],'custom':![],'options':_0x593351};_0xe40981[_0x96c2('0x9a')](_0x2a93b4);return _0xe40981;});}function getBooleanList(_0x2925e4,_0x54d6b5,_0x461152,_0x76d1c9,_0x12679b,_0x44dcce){var _0x278f44={'method':_0x96c2('0x8e'),'uri':_0x2925e4+'EntityDefinitions('+_0x76d1c9+_0x96c2('0xa8')+_0x12679b+')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','headers':{'Authorization':'Bearer\x20'+_0x44dcce,'If-None-Match':null,'OData-Version':_0x96c2('0x90')},'json':!![]};return rp(_0x278f44)[_0x96c2('0xf')](function(_0x413e9f){var _0x620238=[];_0x620238[_0x96c2('0x9a')]({'name':_0x413e9f['OptionSet'][_0x96c2('0xad')][_0x96c2('0xac')][_0x96c2('0xab')][_0x96c2('0xac')],'value':_0x96c2('0xae')},{'name':_0x413e9f[_0x96c2('0xaf')][_0x96c2('0xb0')]['Label'][_0x96c2('0xab')][_0x96c2('0xac')],'value':_0x96c2('0xb1')});var _0x1dc512={'id':_0x54d6b5+'_'+_0x413e9f[_0x96c2('0x96')],'name':_0x413e9f[_0x96c2('0xb2')][_0x96c2('0xab')][_0x96c2('0xac')],'custom':![],'options':_0x620238};_0x461152['push'](_0x1dc512);return _0x461152;});}function getInputList(_0x5aa258,_0x5ad773,_0x18c151,_0x44f8a1,_0x1b5706,_0x2061f4,_0x47e7e6){var _0x1dd153={'method':_0x96c2('0x8e'),'uri':_0x5aa258+_0x96c2('0x92')+_0x1b5706+_0x96c2('0xa8')+_0x2061f4+_0x96c2('0xb3')+_0x18c151+_0x96c2('0xb4'),'headers':{'Authorization':_0x96c2('0x8f')+_0x47e7e6,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x1dd153)[_0x96c2('0xf')](function(_0x323af6){var _0x57b14a={'id':_0x5ad773+'_'+_0x323af6[_0x96c2('0x96')],'name':_0x323af6['DisplayName'][_0x96c2('0xab')]?_0x323af6[_0x96c2('0xb2')][_0x96c2('0xab')][_0x96c2('0xac')]:_0x323af6['LogicalName'],'custom':![],'options':[]};_0x44f8a1[_0x96c2('0x9a')](_0x57b14a);return _0x44f8a1;});}
\ No newline at end of file
+var _0xa9b2=['findAll','rows','catch','keys','options','find','create','body','params','getConfigurations','findOne','Dynamics365Configuration','AccountId','Descriptions','getDescriptions','channel','Dynamics365Field','lastIndexOf','format','%s/api/data/v9.0/','getFields','incident','Incident','title','customerid','caseorigincode','subject','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyname','createdon','createdonbehalfbyname','customeridname','customeridtype','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','kbarticleidname','masteridname','modifiedbyname','modifiedon','msdyn_incidenttypename','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidname','primarycontactidyominame','responseby','responsiblecontactidname','slainvokedidname','slaname','socialprofileidname','statuscode','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','versionnumber','concat','username','password','remoteUri','tenantId','clientId','clientSecret','CloudProvider','modernAuthentication','access_token','data7','POST','/oauth2/token','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','GET','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','includes','LogicalName','forEach','@odata.type','substring','PicklistAttributeMetadata','MetadataId','all','isNil','push','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','EntityNameAttributeMetadata','test','statusCode','Wrong\x20credentials',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label','UserLocalizedLabel','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','true','false',')/Microsoft.Dynamics.CRM.','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','api','../../components/integrations/configuration','status','json','undefined','limit','offset','count','set','Content-Range','update','destroy','then','end','error','stack','name','send','map','Dynamics365Account','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','includeAll','include'];(function(_0x5d6456,_0x58ecc7){var _0x4d66c1=function(_0x4335e3){while(--_0x4335e3){_0x5d6456['push'](_0x5d6456['shift']());}};_0x4d66c1(++_0x58ecc7);}(_0xa9b2,0x1e5));var _0x2a9b=function(_0x2bafde,_0x39326c){_0x2bafde=_0x2bafde-0x0;var _0x5733dc=_0xa9b2[_0x2bafde];return _0x5733dc;};'use strict';var rp=require(_0x2a9b('0x0'));var util=require(_0x2a9b('0x1'));var _=require(_0x2a9b('0x2'));var qs=require(_0x2a9b('0x3'));var logger=require(_0x2a9b('0x4'))(_0x2a9b('0x5'));var db=require('../../mysqldb')['db'];var integrations=require(_0x2a9b('0x6'));function respondWithResult(_0x4a1fd6,_0x26bb70){_0x26bb70=_0x26bb70||0xc8;return function(_0x17ca79){if(_0x17ca79){return _0x4a1fd6[_0x2a9b('0x7')](_0x26bb70)[_0x2a9b('0x8')](_0x17ca79);}};}function respondWithFilteredResult(_0x8a4bdd,_0x2dafb4){return function(_0x20b12c){if(_0x20b12c){var _0x53c156=typeof _0x2dafb4['offset']===_0x2a9b('0x9')&&typeof _0x2dafb4[_0x2a9b('0xa')]==='undefined';var _0x4891d2=_0x20b12c['count'];var _0x233f77=_0x53c156?0x0:_0x2dafb4[_0x2a9b('0xb')];var _0x40f9f6=_0x53c156?_0x20b12c[_0x2a9b('0xc')]:_0x2dafb4[_0x2a9b('0xb')]+_0x2dafb4[_0x2a9b('0xa')];var _0x4bc334;if(_0x40f9f6>=_0x4891d2){_0x40f9f6=_0x4891d2;_0x4bc334=0xc8;}else{_0x4bc334=0xce;}_0x8a4bdd[_0x2a9b('0x7')](_0x4bc334);return _0x8a4bdd[_0x2a9b('0xd')](_0x2a9b('0xe'),_0x233f77+'-'+_0x40f9f6+'/'+_0x4891d2)[_0x2a9b('0x8')](_0x20b12c);}return null;};}function saveUpdates(_0x12b6d6){return function(_0x57464a){if(_0x57464a){return _0x57464a[_0x2a9b('0xf')](_0x12b6d6)['then'](function(_0x11e538){return _0x11e538;});}return null;};}function removeEntity(_0x2f0402){return function(_0x38b1b2){if(_0x38b1b2){return _0x38b1b2[_0x2a9b('0x10')]()[_0x2a9b('0x11')](function(){_0x2f0402[_0x2a9b('0x7')](0xcc)[_0x2a9b('0x12')]();});}};}function handleEntityNotFound(_0xf7c011){return function(_0x2ee711){if(!_0x2ee711){_0xf7c011['sendStatus'](0x194);}return _0x2ee711;};}function handleError(_0x1ac1c0,_0x2d3ed1){_0x2d3ed1=_0x2d3ed1||0x1f4;return function(_0x53ce4b){logger[_0x2a9b('0x13')](_0x53ce4b[_0x2a9b('0x14')]);if(_0x53ce4b[_0x2a9b('0x15')]){delete _0x53ce4b[_0x2a9b('0x15')];}_0x1ac1c0[_0x2a9b('0x7')](_0x2d3ed1)[_0x2a9b('0x16')](_0x53ce4b);};}exports['index']=function(_0x248408,_0x5bbe9d){var _0x123213={},_0x1d053a={},_0x1d2049={'count':0x0,'rows':[]};var _0x12b53d=_[_0x2a9b('0x17')](db[_0x2a9b('0x18')][_0x2a9b('0x19')],function(_0x4abd2e){return{'name':_0x4abd2e[_0x2a9b('0x1a')],'type':_0x4abd2e[_0x2a9b('0x1b')]['key']};});_0x1d053a[_0x2a9b('0x1c')]=_[_0x2a9b('0x17')](_0x12b53d,_0x2a9b('0x15'));_0x1d053a[_0x2a9b('0x1d')]=_['keys'](_0x248408[_0x2a9b('0x1d')]);_0x1d053a[_0x2a9b('0x1e')]=_[_0x2a9b('0x1f')](_0x1d053a[_0x2a9b('0x1c')],_0x1d053a[_0x2a9b('0x1d')]);_0x123213[_0x2a9b('0x20')]=_[_0x2a9b('0x1f')](_0x1d053a[_0x2a9b('0x1c')],qs[_0x2a9b('0x21')](_0x248408[_0x2a9b('0x1d')][_0x2a9b('0x21')]));_0x123213['attributes']=_0x123213['attributes'][_0x2a9b('0x22')]?_0x123213[_0x2a9b('0x20')]:_0x1d053a[_0x2a9b('0x1c')];if(!_0x248408['query'][_0x2a9b('0x23')](_0x2a9b('0x24'))){_0x123213['limit']=qs['limit'](_0x248408[_0x2a9b('0x1d')][_0x2a9b('0xa')]);_0x123213[_0x2a9b('0xb')]=qs[_0x2a9b('0xb')](_0x248408[_0x2a9b('0x1d')][_0x2a9b('0xb')]);}_0x123213[_0x2a9b('0x25')]=qs[_0x2a9b('0x26')](_0x248408[_0x2a9b('0x1d')][_0x2a9b('0x26')]);_0x123213[_0x2a9b('0x27')]=qs[_0x2a9b('0x1e')](_[_0x2a9b('0x28')](_0x248408[_0x2a9b('0x1d')],_0x1d053a['filters']),_0x12b53d);if(_0x248408[_0x2a9b('0x1d')][_0x2a9b('0x29')]){_0x123213['where']=_['merge'](_0x123213[_0x2a9b('0x27')],{'$or':_['map'](_0x12b53d,function(_0x2bdd91){if(_0x2bdd91['type']!==_0x2a9b('0x2a')){var _0x217aa7={};_0x217aa7[_0x2bdd91[_0x2a9b('0x15')]]={'$like':'%'+_0x248408['query'][_0x2a9b('0x29')]+'%'};return _0x217aa7;}})});}_0x123213=_[_0x2a9b('0x2b')]({},_0x123213,_0x248408['options']);var _0x270e75={'where':_0x123213[_0x2a9b('0x27')]};return db[_0x2a9b('0x18')][_0x2a9b('0xc')](_0x270e75)[_0x2a9b('0x11')](function(_0x15eee2){_0x1d2049[_0x2a9b('0xc')]=_0x15eee2;if(_0x248408['query'][_0x2a9b('0x2c')]){_0x123213[_0x2a9b('0x2d')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x2a9b('0x2e')](_0x123213);})[_0x2a9b('0x11')](function(_0x28b0e0){_0x1d2049[_0x2a9b('0x2f')]=_0x28b0e0;return _0x1d2049;})[_0x2a9b('0x11')](respondWithFilteredResult(_0x5bbe9d,_0x123213))[_0x2a9b('0x30')](handleError(_0x5bbe9d,null));};exports['show']=function(_0x1fdd24,_0x381173){var _0x4d07e9={'raw':![],'where':{'id':_0x1fdd24['params']['id']}},_0x34c3f4={};_0x34c3f4[_0x2a9b('0x1c')]=_[_0x2a9b('0x31')](db[_0x2a9b('0x18')][_0x2a9b('0x19')]);_0x34c3f4[_0x2a9b('0x1d')]=_[_0x2a9b('0x31')](_0x1fdd24['query']);_0x34c3f4[_0x2a9b('0x1e')]=_[_0x2a9b('0x1f')](_0x34c3f4[_0x2a9b('0x1c')],_0x34c3f4[_0x2a9b('0x1d')]);_0x4d07e9[_0x2a9b('0x20')]=_[_0x2a9b('0x1f')](_0x34c3f4[_0x2a9b('0x1c')],qs[_0x2a9b('0x21')](_0x1fdd24[_0x2a9b('0x1d')][_0x2a9b('0x21')]));_0x4d07e9['attributes']=_0x4d07e9[_0x2a9b('0x20')][_0x2a9b('0x22')]?_0x4d07e9[_0x2a9b('0x20')]:_0x34c3f4[_0x2a9b('0x1c')];if(_0x1fdd24[_0x2a9b('0x1d')][_0x2a9b('0x2c')]){_0x4d07e9[_0x2a9b('0x2d')]=[{'all':!![]}];}_0x4d07e9=_[_0x2a9b('0x2b')]({},_0x4d07e9,_0x1fdd24[_0x2a9b('0x32')]);return db[_0x2a9b('0x18')][_0x2a9b('0x33')](_0x4d07e9)[_0x2a9b('0x11')](handleEntityNotFound(_0x381173,null))[_0x2a9b('0x11')](respondWithResult(_0x381173,null))[_0x2a9b('0x30')](handleError(_0x381173,null));};exports[_0x2a9b('0x34')]=function(_0x420ac0,_0x49cb3e){return db[_0x2a9b('0x18')][_0x2a9b('0x34')](_0x420ac0[_0x2a9b('0x35')],{})['then'](respondWithResult(_0x49cb3e,0xc9))['catch'](handleError(_0x49cb3e,null));};exports[_0x2a9b('0xf')]=function(_0x4bb715,_0x189bff){if(_0x4bb715['body']['id']){delete _0x4bb715[_0x2a9b('0x35')]['id'];}return db[_0x2a9b('0x18')][_0x2a9b('0x33')]({'where':{'id':_0x4bb715[_0x2a9b('0x36')]['id']}})[_0x2a9b('0x11')](handleEntityNotFound(_0x189bff,null))['then'](saveUpdates(_0x4bb715[_0x2a9b('0x35')],null))[_0x2a9b('0x11')](respondWithResult(_0x189bff,null))[_0x2a9b('0x30')](handleError(_0x189bff,null));};exports[_0x2a9b('0x10')]=function(_0x5ec9e7,_0x14cb7a){return db['Dynamics365Account'][_0x2a9b('0x33')]({'where':{'id':_0x5ec9e7[_0x2a9b('0x36')]['id']}})[_0x2a9b('0x11')](handleEntityNotFound(_0x14cb7a,null))[_0x2a9b('0x11')](removeEntity(_0x14cb7a,null))['catch'](handleError(_0x14cb7a,null));};exports[_0x2a9b('0x37')]=function(_0x318cca,_0x583d49){var _0xf0f575={};var _0x543c2f={};var _0x3f03a7;var _0x38cf11;return db[_0x2a9b('0x18')][_0x2a9b('0x38')]({'where':{'id':_0x318cca[_0x2a9b('0x36')]['id']}})[_0x2a9b('0x11')](handleEntityNotFound(_0x583d49,null))['then'](function(_0x2136f0){if(_0x2136f0){_0x3f03a7=_0x2136f0;_0x543c2f['model']=_[_0x2a9b('0x31')](db[_0x2a9b('0x39')]['rawAttributes']);_0x543c2f[_0x2a9b('0x1d')]=_[_0x2a9b('0x31')](_0x318cca[_0x2a9b('0x1d')]);_0x543c2f[_0x2a9b('0x1e')]=_[_0x2a9b('0x1f')](_0x543c2f[_0x2a9b('0x1c')],_0x543c2f[_0x2a9b('0x1d')]);_0xf0f575[_0x2a9b('0x20')]=_['intersection'](_0x543c2f[_0x2a9b('0x1c')],qs['fields'](_0x318cca[_0x2a9b('0x1d')][_0x2a9b('0x21')]));_0xf0f575['attributes']=_0xf0f575[_0x2a9b('0x20')][_0x2a9b('0x22')]?_0xf0f575[_0x2a9b('0x20')]:_0x543c2f[_0x2a9b('0x1c')];_0xf0f575[_0x2a9b('0x25')]=qs[_0x2a9b('0x26')](_0x318cca[_0x2a9b('0x1d')][_0x2a9b('0x26')]);_0xf0f575[_0x2a9b('0x27')]=qs[_0x2a9b('0x1e')](_['pick'](_0x318cca[_0x2a9b('0x1d')],_0x543c2f[_0x2a9b('0x1e')]));if(_0x318cca[_0x2a9b('0x1d')][_0x2a9b('0x29')]){_0xf0f575[_0x2a9b('0x27')]=_[_0x2a9b('0x2b')](_0xf0f575[_0x2a9b('0x27')],{'$or':_[_0x2a9b('0x17')](_0xf0f575[_0x2a9b('0x20')],function(_0x22200f){var _0x47e7eb={};_0x47e7eb[_0x22200f]={'$like':'%'+_0x318cca[_0x2a9b('0x1d')]['filter']+'%'};return _0x47e7eb;})});}_0xf0f575=_[_0x2a9b('0x2b')]({},_0xf0f575,_0x318cca[_0x2a9b('0x32')]);return _0x3f03a7[_0x2a9b('0x37')](_0xf0f575);}})[_0x2a9b('0x11')](function(_0x43f06b){if(_0x43f06b){_0x38cf11=_0x43f06b[_0x2a9b('0x22')];if(!_0x318cca[_0x2a9b('0x1d')][_0x2a9b('0x23')](_0x2a9b('0x24'))){_0xf0f575['limit']=qs[_0x2a9b('0xa')](_0x318cca['query']['limit']);_0xf0f575[_0x2a9b('0xb')]=qs['offset'](_0x318cca['query'][_0x2a9b('0xb')]);}return _0x3f03a7[_0x2a9b('0x37')](_0xf0f575);}})[_0x2a9b('0x11')](function(_0x116d02){if(_0x116d02){return _0x116d02?{'count':_0x38cf11,'rows':_0x116d02}:null;}})[_0x2a9b('0x11')](respondWithResult(_0x583d49,null))[_0x2a9b('0x30')](handleError(_0x583d49,null));};exports['addConfiguration']=function(_0x291c88,_0x18b450){if(_0x291c88[_0x2a9b('0x35')]['id']){delete _0x291c88['body']['id'];}return db[_0x2a9b('0x18')][_0x2a9b('0x38')]({'where':{'id':_0x291c88['params']['id']}})[_0x2a9b('0x11')](handleEntityNotFound(_0x18b450,null))[_0x2a9b('0x11')](function(_0x463ec3){if(_0x463ec3){_0x291c88[_0x2a9b('0x35')][_0x2a9b('0x3a')]=_0x463ec3['id'];_0x291c88[_0x2a9b('0x35')]['Subjects']=integrations['getSubjects'](_0x291c88[_0x2a9b('0x35')]['channel'],_0x291c88[_0x2a9b('0x35')][_0x2a9b('0x1b')]);_0x291c88[_0x2a9b('0x35')][_0x2a9b('0x3b')]=integrations[_0x2a9b('0x3c')](_0x291c88[_0x2a9b('0x35')][_0x2a9b('0x3d')],_0x291c88['body'][_0x2a9b('0x1b')]);return db['Dynamics365Configuration'][_0x2a9b('0x34')](_0x291c88['body'],{'include':[{'model':db[_0x2a9b('0x3e')],'as':'Subjects'},{'model':db['Dynamics365Field'],'as':_0x2a9b('0x3b')}]});}return null;})[_0x2a9b('0x11')](respondWithResult(_0x18b450,null))['catch'](handleError(_0x18b450,null));};function sanitizeRemoteUri(_0x539e2c){var _0x44ceef=_0x539e2c['slice'](-0x1);if(_0x44ceef==='/')return _0x539e2c['substring'](0x0,_0x539e2c[_0x2a9b('0x3f')](_0x44ceef));return _0x539e2c;}function getWebApiUrl(_0xa96c3){return util[_0x2a9b('0x40')](_0x2a9b('0x41'),_0xa96c3);}exports[_0x2a9b('0x42')]=function(_0x2f41b2,_0x353c25){var _0x484e35=_0x2f41b2[_0x2a9b('0x1d')]['ticketType'];var _0x321c24=_0x484e35===_0x2a9b('0x43')?_0x2a9b('0x44'):'PhoneCall';var _0x430281='';var _0x569600='';var _0x5255f2='';var _0x199d0b='';var _0x131d34='';var _0x3c76bb='';var _0x2a6318='';var _0x5d9283='';var _0x3612a0=[_0x2a9b('0x45'),'description',_0x2a9b('0x46'),'ownerid',_0x2a9b('0x47'),_0x2a9b('0x48'),'phonenumber',_0x2a9b('0x49'),_0x2a9b('0x4a'),_0x2a9b('0x4b')];var _0x38529f=[_0x2a9b('0x4c'),_0x2a9b('0x4d'),_0x2a9b('0x4e'),_0x2a9b('0x4f'),_0x2a9b('0x50'),_0x2a9b('0x51'),_0x2a9b('0x52'),_0x2a9b('0x53'),_0x2a9b('0x54'),'createdbyexternalpartyyominame',_0x2a9b('0x55'),'createdbyyominame',_0x2a9b('0x56'),_0x2a9b('0x57'),'createdonbehalfbyyominame',_0x2a9b('0x58'),_0x2a9b('0x59'),_0x2a9b('0x5a'),_0x2a9b('0x5b'),_0x2a9b('0x5c'),_0x2a9b('0x5d'),_0x2a9b('0x5e'),'escalatedon',_0x2a9b('0x5f'),_0x2a9b('0x60'),_0x2a9b('0x61'),_0x2a9b('0x62'),_0x2a9b('0x63'),_0x2a9b('0x64'),'lastonholdtime',_0x2a9b('0x65'),'modifiedbyexternalpartyname','modifiedbyexternalpartyyominame',_0x2a9b('0x66'),'modifiedbyyominame',_0x2a9b('0x67'),'modifiedonbehalfbyname','modifiedonbehalfbyyominame',_0x2a9b('0x68'),'msdyn_iotalertname',_0x2a9b('0x69'),_0x2a9b('0x6a'),_0x2a9b('0x6b'),_0x2a9b('0x6c'),_0x2a9b('0x6d'),_0x2a9b('0x6e'),_0x2a9b('0x6f'),_0x2a9b('0x70'),_0x2a9b('0x71'),'prioritycodename','productidname','productserialnumber','resolveby','resolvebykpiidname',_0x2a9b('0x72'),_0x2a9b('0x73'),'responsiblecontactidyominame','sentimentvalue',_0x2a9b('0x74'),_0x2a9b('0x75'),_0x2a9b('0x76'),'statecode',_0x2a9b('0x77'),'subjectidname',_0x2a9b('0x78'),_0x2a9b('0x79'),_0x2a9b('0x7a'),_0x2a9b('0x7b'),'utcconversiontimezonecode',_0x2a9b('0x7c')];var _0x2d2d5f=_0x3612a0[_0x2a9b('0x7d')](_0x38529f);return db[_0x2a9b('0x18')][_0x2a9b('0x38')]({'where':{'id':_0x2f41b2[_0x2a9b('0x36')]['id']},'attributes':['id',_0x2a9b('0x7e'),_0x2a9b('0x7f'),_0x2a9b('0x80'),_0x2a9b('0x81'),_0x2a9b('0x82'),_0x2a9b('0x83'),'modernAuthentication'],'include':[{'model':db[_0x2a9b('0x84')],'as':'CloudProvider','attributes':['id','data5','data7']}]})['then'](handleEntityNotFound(_0x353c25,null))[_0x2a9b('0x11')](function(_0x19b275){if(_0x19b275){if(_0x19b275[_0x2a9b('0x85')]){_0x19b275[_0x2a9b('0x86')]=_0x19b275['CloudProvider']['data5'];_0x5d9283=sanitizeRemoteUri(_0x19b275[_0x2a9b('0x84')][_0x2a9b('0x87')]);_0x2a6318=getWebApiUrl(_0x5d9283);return _0x19b275;}_0x5d9283=sanitizeRemoteUri(_0x19b275[_0x2a9b('0x80')]);_0x2a6318=getWebApiUrl(_0x5d9283);var _0x2f7e86={'method':_0x2a9b('0x88'),'uri':'https://login.microsoftonline.com/'+_0x19b275[_0x2a9b('0x81')]+_0x2a9b('0x89'),'form':{'client_id':_0x19b275[_0x2a9b('0x82')],'resource':_0x5d9283,'username':_0x19b275[_0x2a9b('0x7e')],'password':_0x19b275['password'],'grant_type':'password','client_secret':_0x19b275[_0x2a9b('0x83')]},'json':!![]};return rp(_0x2f7e86);}})[_0x2a9b('0x11')](function(_0x2aff7b){_0x3c76bb=_0x2aff7b[_0x2a9b('0x86')];var _0x2fd180={'method':'GET','uri':encodeURI(_0x2a6318+_0x2a9b('0x8a')+_0x321c24+'\x27'),'headers':{'Authorization':_0x2a9b('0x8b')+_0x3c76bb,'If-None-Match':null,'OData-Version':_0x2a9b('0x8c')},'json':!![]};return rp(_0x2fd180);})[_0x2a9b('0x11')](function(_0x155ce9){var _0xc08ece=_0x155ce9['value'][0x0];var _0x17db3e=_0xc08ece['MetadataId'];var _0x5e953b={'method':_0x2a9b('0x8d'),'uri':_0x2a6318+_0x2a9b('0x8e')+_0x17db3e+_0x2a9b('0x8f'),'headers':{'Authorization':_0x2a9b('0x8b')+_0x3c76bb,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x5e953b);})[_0x2a9b('0x11')](function(_0x338141){_0x430281=_0x338141;_0x569600=_0x430281[_0x2a9b('0x90')];_0x569600=_['remove'](_0x569600,function(_0x3d031b){return!_0x2d2d5f[_0x2a9b('0x91')](_0x3d031b[_0x2a9b('0x92')]);});var _0x5a4eb9=[];var _0x25b26f=[];_0x569600[_0x2a9b('0x93')](function(_0x4cd1bd){if(_0x4cd1bd[_0x2a9b('0x94')]){var _0x4cdfac=_0x4cd1bd[_0x2a9b('0x94')][_0x2a9b('0x95')](_0x4cd1bd['@odata.type'][_0x2a9b('0x3f')]('.')+0x1);if(_0x4cdfac===_0x2a9b('0x96')){_0x5a4eb9['push'](getSelectList(_0x2a6318,_0x484e35,_0x25b26f,_0x430281[_0x2a9b('0x97')],_0x4cd1bd['MetadataId'],_0x3c76bb));}}});return Promise[_0x2a9b('0x98')](_0x5a4eb9);})[_0x2a9b('0x11')](function(_0xe190af){_0x5255f2=_0xe190af[0x0];var _0x3e2683=[];var _0x317745=[];_0x569600[_0x2a9b('0x93')](function(_0x23bdf3){if(!_[_0x2a9b('0x99')](_0x23bdf3[_0x2a9b('0x94')])){var _0x971cbc=_0x23bdf3['@odata.type'][_0x2a9b('0x95')](_0x23bdf3[_0x2a9b('0x94')]['lastIndexOf']('.')+0x1);if(_0x971cbc==='BooleanAttributeMetadata'){_0x3e2683[_0x2a9b('0x9a')](getBooleanList(_0x2a6318,_0x484e35,_0x317745,_0x430281['MetadataId'],_0x23bdf3['MetadataId'],_0x3c76bb));}}});return Promise[_0x2a9b('0x98')](_0x3e2683);})[_0x2a9b('0x11')](function(_0x2c6711){_0x199d0b=_0x2c6711[0x0];var _0x1c1260=[];var _0x2781bb=[];_0x569600[_0x2a9b('0x93')](function(_0x11a610){if(_0x11a610[_0x2a9b('0x94')]){var _0x2d19a3=_0x11a610[_0x2a9b('0x94')][_0x2a9b('0x95')](_0x11a610[_0x2a9b('0x94')][_0x2a9b('0x3f')]('.')+0x1);if(_0x2d19a3===_0x2a9b('0x9b')||_0x2d19a3==='DoubleAttributeMetadata'||_0x2d19a3===_0x2a9b('0x9c')||_0x2d19a3===_0x2a9b('0x9d')||_0x2d19a3===_0x2a9b('0x9e')||_0x2d19a3===_0x2a9b('0x9f')||_0x2d19a3==='StatusAttributeMetadata'||_0x2d19a3===_0x2a9b('0xa0')||_0x2d19a3==='StateAttributeMetadata'||_0x2d19a3==='DecimalAttributeMetadata'){_0x1c1260[_0x2a9b('0x9a')](getInputList(_0x2a6318,_0x484e35,_0x2d19a3,_0x2781bb,_0x430281[_0x2a9b('0x97')],_0x11a610[_0x2a9b('0x97')],_0x3c76bb));}}});return Promise[_0x2a9b('0x98')](_0x1c1260);})[_0x2a9b('0x11')](function(_0x272b75){_0x131d34=_0x272b75[0x0];var _0x446fb6=_0x5255f2[_0x2a9b('0x7d')](_0x199d0b)[_0x2a9b('0x7d')](_0x131d34);var _0x49c4ab={'count':_0x446fb6[_0x2a9b('0x22')],'rows':_0x446fb6};return _0x49c4ab;})[_0x2a9b('0x11')](respondWithResult(_0x353c25,null))[_0x2a9b('0x30')](function(_0x359ffc){var _0x10f0dd=_0x2f41b2[_0x2a9b('0x1d')][_0x2a9b('0xa1')]?0x1f4:_0x359ffc[_0x2a9b('0xa2')]||0x1f4;logger[_0x2a9b('0x13')](_0x359ffc[_0x2a9b('0x14')]);delete _0x359ffc[_0x2a9b('0x15')];if(_0x10f0dd===0x191){_0x10f0dd=0x190;}_0x353c25['status'](_0x10f0dd)[_0x2a9b('0x16')](_0x2f41b2['query']['test']?{'message':_0x2a9b('0xa3'),'statusCode':_0x359ffc[_0x2a9b('0xa2')]}:_0x359ffc);});};function getSelectList(_0x399162,_0x51d6c9,_0x4c36b0,_0xe72528,_0x3ee9e5,_0x2d82f9){var _0x35453c={'method':'GET','uri':_0x399162+_0x2a9b('0x8e')+_0xe72528+_0x2a9b('0xa4')+_0x3ee9e5+_0x2a9b('0xa5')+_0x2a9b('0xa6'),'headers':{'Authorization':_0x2a9b('0x8b')+_0x2d82f9,'If-None-Match':null,'OData-Version':_0x2a9b('0x8c')},'json':!![]};return rp(_0x35453c)[_0x2a9b('0x11')](function(_0x2573f3){var _0x48e65c=[];var _0x27af1e=_0x2573f3[_0x2a9b('0xa7')][_0x2a9b('0xa8')];_0x27af1e[_0x2a9b('0x93')](function(_0x5c263f){_0x48e65c['push']({'name':_0x5c263f[_0x2a9b('0xa9')][_0x2a9b('0xaa')][_0x2a9b('0xa9')],'value':String(_0x5c263f['Value'])});});var _0x4bbedf={'id':_0x51d6c9+'_'+_0x2573f3[_0x2a9b('0x92')],'name':_0x2573f3[_0x2a9b('0xab')][_0x2a9b('0xaa')][_0x2a9b('0xa9')],'custom':![],'options':_0x48e65c};_0x4c36b0[_0x2a9b('0x9a')](_0x4bbedf);return _0x4c36b0;});}function getBooleanList(_0xe4d3d1,_0x5d459f,_0x33855a,_0x4a13d1,_0x32e2d3,_0x3572f6){var _0x30de34={'method':_0x2a9b('0x8d'),'uri':_0xe4d3d1+'EntityDefinitions('+_0x4a13d1+_0x2a9b('0xa4')+_0x32e2d3+_0x2a9b('0xac'),'headers':{'Authorization':'Bearer\x20'+_0x3572f6,'If-None-Match':null,'OData-Version':_0x2a9b('0x8c')},'json':!![]};return rp(_0x30de34)[_0x2a9b('0x11')](function(_0x3424ff){var _0xd89bdd=[];_0xd89bdd[_0x2a9b('0x9a')]({'name':_0x3424ff[_0x2a9b('0xa7')][_0x2a9b('0xad')]['Label']['UserLocalizedLabel']['Label'],'value':_0x2a9b('0xae')},{'name':_0x3424ff['OptionSet']['FalseOption'][_0x2a9b('0xa9')][_0x2a9b('0xaa')][_0x2a9b('0xa9')],'value':_0x2a9b('0xaf')});var _0x56d6b1={'id':_0x5d459f+'_'+_0x3424ff['LogicalName'],'name':_0x3424ff['DisplayName'][_0x2a9b('0xaa')]['Label'],'custom':![],'options':_0xd89bdd};_0x33855a['push'](_0x56d6b1);return _0x33855a;});}function getInputList(_0x29d319,_0x564e60,_0x30a2d9,_0x2d210c,_0x3b9678,_0x1ef648,_0x4f3e0b){var _0x520369={'method':'GET','uri':_0x29d319+'EntityDefinitions('+_0x3b9678+')/Attributes('+_0x1ef648+_0x2a9b('0xb0')+_0x30a2d9+'?$select=DisplayName,LogicalName','headers':{'Authorization':_0x2a9b('0x8b')+_0x4f3e0b,'If-None-Match':null,'OData-Version':_0x2a9b('0x8c')},'json':!![]};return rp(_0x520369)[_0x2a9b('0x11')](function(_0x2c7964){var _0x591cb4={'id':_0x564e60+'_'+_0x2c7964['LogicalName'],'name':_0x2c7964[_0x2a9b('0xab')]['UserLocalizedLabel']?_0x2c7964[_0x2a9b('0xab')][_0x2a9b('0xaa')][_0x2a9b('0xa9')]:_0x2c7964['LogicalName'],'custom':![],'options':[]};_0x2d210c[_0x2a9b('0x9a')](_0x591cb4);return _0x2d210c;});}
\ No newline at end of file