Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 143ae38..df9e8a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6dd1=['modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','overriddencreatedon','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidname','prioritycodename','productserialnumber','resolveby','resolvebykpiidname','responseby','responsiblecontactidyominame','slaname','statuscode','subjectidname','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','versionnumber','concat','username','password','remoteUri','tenantId','clientSecret','lastIndexOf','format','%s/api/data/v9.0/','POST','https://login.microsoftonline.com/','/oauth2/token','clientId','access_token','GET','Bearer\x20','4.0','value','MetadataId',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','remove','includes','LogicalName','forEach','@odata.type','substring','all','isNil','push','StringAttributeMetadata','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','statusCode','error','send','test',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','UserLocalizedLabel','Label','Value','DisplayName','EntityDefinitions(','TrueOption','FalseOption','false','?$select=DisplayName,LogicalName','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','destroy','then','stack','name','index','map','rawAttributes','type','key','query','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','Dynamics365Account','includeAll','include','catch','show','keys','find','body','params','getConfigurations','findOne','Dynamics365Configuration','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','create','Dynamics365Field','ticketType','incident','Incident','title','description','ownerid','caseorigincode','subject','phonenumber','directioncode','phonecall_activity_parties','actualserviceunits','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyyominame','customeridtype','emailaddress','entitlementidname','entityimage_timestamp','firstresponsebykpiidname','importsequencenumber','kbarticleidname','masteridname','modifiedbyyominame','modifiedonbehalfbyname'];(function(_0x23c58e,_0x1b6f60){var _0x319488=function(_0x195f06){while(--_0x195f06){_0x23c58e['push'](_0x23c58e['shift']());}};_0x319488(++_0x1b6f60);}(_0x6dd1,0x111));var _0x16dd=function(_0x32b169,_0x3a40ef){_0x32b169=_0x32b169-0x0;var _0x5cbea8=_0x6dd1[_0x32b169];return _0x5cbea8;};'use strict';var emlformat=require(_0x16dd('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x16dd('0x1'));var jsonpatch=require(_0x16dd('0x2'));var rp=require('request-promise');var moment=require(_0x16dd('0x3'));var BPromise=require(_0x16dd('0x4'));var Mustache=require(_0x16dd('0x5'));var util=require(_0x16dd('0x6'));var path=require(_0x16dd('0x7'));var sox=require(_0x16dd('0x8'));var csv=require(_0x16dd('0x9'));var ejs=require(_0x16dd('0xa'));var fs=require('fs');var fs_extra=require(_0x16dd('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x16dd('0xc'));var toCsv=require(_0x16dd('0x9'));var querystring=require(_0x16dd('0xd'));var Papa=require(_0x16dd('0xe'));var Redis=require('ioredis');var authService=require(_0x16dd('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x16dd('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x16dd('0x11'));var utils=require(_0x16dd('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0x16dd('0x13'));var db=require(_0x16dd('0x14'))['db'];var integrations=require(_0x16dd('0x15'));function respondWithStatusCode(_0x5e24c8,_0x204f9e){_0x204f9e=_0x204f9e||0xcc;return function(_0x3783fc){if(_0x3783fc){return _0x5e24c8[_0x16dd('0x16')](_0x204f9e);}return _0x5e24c8[_0x16dd('0x17')](_0x204f9e)[_0x16dd('0x18')]();};}function respondWithResult(_0x4d460c,_0x4f3646){_0x4f3646=_0x4f3646||0xc8;return function(_0xcfde1c){if(_0xcfde1c){return _0x4d460c['status'](_0x4f3646)[_0x16dd('0x19')](_0xcfde1c);}};}function respondWithFilteredResult(_0x167c44,_0x31a026){return function(_0x1719ba){if(_0x1719ba){var _0x3add51=typeof _0x31a026[_0x16dd('0x1a')]===_0x16dd('0x1b')&&typeof _0x31a026[_0x16dd('0x1c')]==='undefined';var _0x3d5bcb=_0x1719ba[_0x16dd('0x1d')];var _0x15b012=_0x3add51?0x0:_0x31a026[_0x16dd('0x1a')];var _0x3e9236=_0x3add51?_0x1719ba['count']:_0x31a026[_0x16dd('0x1a')]+_0x31a026[_0x16dd('0x1c')];var _0x3f36c0;if(_0x3e9236>=_0x3d5bcb){_0x3e9236=_0x3d5bcb;_0x3f36c0=0xc8;}else{_0x3f36c0=0xce;}_0x167c44[_0x16dd('0x17')](_0x3f36c0);return _0x167c44[_0x16dd('0x1e')](_0x16dd('0x1f'),_0x15b012+'-'+_0x3e9236+'/'+_0x3d5bcb)[_0x16dd('0x19')](_0x1719ba);}return null;};}function patchUpdates(_0x44464a){return function(_0x43a6ba){try{jsonpatch[_0x16dd('0x20')](_0x43a6ba,_0x44464a,!![]);}catch(_0x5e4468){return BPromise[_0x16dd('0x21')](_0x5e4468);}return _0x43a6ba[_0x16dd('0x22')]();};}function saveUpdates(_0x44f66b,_0x20a946){return function(_0x96ab00){if(_0x96ab00){return _0x96ab00['update'](_0x44f66b)['then'](function(_0x4445f8){return _0x4445f8;});}return null;};}function removeEntity(_0x239e59,_0x4d1f98){return function(_0x1276e6){if(_0x1276e6){return _0x1276e6[_0x16dd('0x23')]()[_0x16dd('0x24')](function(){_0x239e59['status'](0xcc)[_0x16dd('0x18')]();});}};}function handleEntityNotFound(_0x251be0,_0x33e57d){return function(_0x55b545){if(!_0x55b545){_0x251be0[_0x16dd('0x16')](0x194);}return _0x55b545;};}function handleError(_0x3625ec,_0x409b83){_0x409b83=_0x409b83||0x1f4;return function(_0x4a5dba){logger['error'](_0x4a5dba[_0x16dd('0x25')]);if(_0x4a5dba[_0x16dd('0x26')]){delete _0x4a5dba['name'];}_0x3625ec['status'](_0x409b83)['send'](_0x4a5dba);};}exports[_0x16dd('0x27')]=function(_0x20fc34,_0xf64a61){var _0x482cfb={},_0x455b1d={},_0xb5e868={'count':0x0,'rows':[]};var _0x33af6f=_[_0x16dd('0x28')](db['Dynamics365Account'][_0x16dd('0x29')],function(_0x2057e4){return{'name':_0x2057e4['fieldName'],'type':_0x2057e4[_0x16dd('0x2a')][_0x16dd('0x2b')]};});_0x455b1d['model']=_[_0x16dd('0x28')](_0x33af6f,'name');_0x455b1d[_0x16dd('0x2c')]=_['keys'](_0x20fc34[_0x16dd('0x2c')]);_0x455b1d[_0x16dd('0x2d')]=_[_0x16dd('0x2e')](_0x455b1d['model'],_0x455b1d[_0x16dd('0x2c')]);_0x482cfb[_0x16dd('0x2f')]=_['intersection'](_0x455b1d[_0x16dd('0x30')],qs[_0x16dd('0x31')](_0x20fc34[_0x16dd('0x2c')][_0x16dd('0x31')]));_0x482cfb['attributes']=_0x482cfb[_0x16dd('0x2f')][_0x16dd('0x32')]?_0x482cfb['attributes']:_0x455b1d[_0x16dd('0x30')];if(!_0x20fc34['query'][_0x16dd('0x33')](_0x16dd('0x34'))){_0x482cfb['limit']=qs['limit'](_0x20fc34[_0x16dd('0x2c')][_0x16dd('0x1c')]);_0x482cfb[_0x16dd('0x1a')]=qs[_0x16dd('0x1a')](_0x20fc34[_0x16dd('0x2c')][_0x16dd('0x1a')]);}_0x482cfb[_0x16dd('0x35')]=qs[_0x16dd('0x36')](_0x20fc34[_0x16dd('0x2c')]['sort']);_0x482cfb[_0x16dd('0x37')]=qs[_0x16dd('0x2d')](_[_0x16dd('0x38')](_0x20fc34['query'],_0x455b1d[_0x16dd('0x2d')]),_0x33af6f);if(_0x20fc34[_0x16dd('0x2c')][_0x16dd('0x39')]){_0x482cfb[_0x16dd('0x37')]=_['merge'](_0x482cfb['where'],{'$or':_['map'](_0x33af6f,function(_0x4c4788){if(_0x4c4788[_0x16dd('0x2a')]!=='VIRTUAL'){var _0x3cfe01={};_0x3cfe01[_0x4c4788['name']]={'$like':'%'+_0x20fc34[_0x16dd('0x2c')]['filter']+'%'};return _0x3cfe01;}})});}_0x482cfb=_[_0x16dd('0x3a')]({},_0x482cfb,_0x20fc34[_0x16dd('0x3b')]);var _0x2d92b5={'where':_0x482cfb[_0x16dd('0x37')]};return db[_0x16dd('0x3c')][_0x16dd('0x1d')](_0x2d92b5)['then'](function(_0x324fb9){_0xb5e868[_0x16dd('0x1d')]=_0x324fb9;if(_0x20fc34[_0x16dd('0x2c')][_0x16dd('0x3d')]){_0x482cfb[_0x16dd('0x3e')]=[{'all':!![]}];}return db[_0x16dd('0x3c')]['findAll'](_0x482cfb);})['then'](function(_0x1bdf5d){_0xb5e868['rows']=_0x1bdf5d;return _0xb5e868;})['then'](respondWithFilteredResult(_0xf64a61,_0x482cfb))[_0x16dd('0x3f')](handleError(_0xf64a61,null));};exports[_0x16dd('0x40')]=function(_0x1c0d79,_0x491bf0){var _0x24acb0={'raw':![],'where':{'id':_0x1c0d79['params']['id']}},_0x4c6e9e={};_0x4c6e9e[_0x16dd('0x30')]=_[_0x16dd('0x41')](db[_0x16dd('0x3c')][_0x16dd('0x29')]);_0x4c6e9e[_0x16dd('0x2c')]=_[_0x16dd('0x41')](_0x1c0d79[_0x16dd('0x2c')]);_0x4c6e9e[_0x16dd('0x2d')]=_[_0x16dd('0x2e')](_0x4c6e9e[_0x16dd('0x30')],_0x4c6e9e[_0x16dd('0x2c')]);_0x24acb0[_0x16dd('0x2f')]=_[_0x16dd('0x2e')](_0x4c6e9e['model'],qs['fields'](_0x1c0d79['query'][_0x16dd('0x31')]));_0x24acb0[_0x16dd('0x2f')]=_0x24acb0[_0x16dd('0x2f')][_0x16dd('0x32')]?_0x24acb0['attributes']:_0x4c6e9e[_0x16dd('0x30')];if(_0x1c0d79[_0x16dd('0x2c')][_0x16dd('0x3d')]){_0x24acb0[_0x16dd('0x3e')]=[{'all':!![]}];}_0x24acb0=_[_0x16dd('0x3a')]({},_0x24acb0,_0x1c0d79['options']);return db[_0x16dd('0x3c')][_0x16dd('0x42')](_0x24acb0)[_0x16dd('0x24')](handleEntityNotFound(_0x491bf0,null))[_0x16dd('0x24')](respondWithResult(_0x491bf0,null))[_0x16dd('0x3f')](handleError(_0x491bf0,null));};exports['create']=function(_0x53258b,_0x2e9fab){return db['Dynamics365Account']['create'](_0x53258b[_0x16dd('0x43')],{})[_0x16dd('0x24')](respondWithResult(_0x2e9fab,0xc9))[_0x16dd('0x3f')](handleError(_0x2e9fab,null));};exports['update']=function(_0x10db7c,_0x3b89f6){if(_0x10db7c[_0x16dd('0x43')]['id']){delete _0x10db7c[_0x16dd('0x43')]['id'];}return db[_0x16dd('0x3c')][_0x16dd('0x42')]({'where':{'id':_0x10db7c[_0x16dd('0x44')]['id']}})[_0x16dd('0x24')](handleEntityNotFound(_0x3b89f6,null))[_0x16dd('0x24')](saveUpdates(_0x10db7c[_0x16dd('0x43')],null))[_0x16dd('0x24')](respondWithResult(_0x3b89f6,null))[_0x16dd('0x3f')](handleError(_0x3b89f6,null));};exports[_0x16dd('0x23')]=function(_0x454aae,_0x541837){return db[_0x16dd('0x3c')]['find']({'where':{'id':_0x454aae['params']['id']}})[_0x16dd('0x24')](handleEntityNotFound(_0x541837,null))[_0x16dd('0x24')](removeEntity(_0x541837,null))[_0x16dd('0x3f')](handleError(_0x541837,null));};exports[_0x16dd('0x45')]=function(_0x479e4c,_0x2447c5,_0x400dc5){var _0x3ebbfc={};var _0x928af={};var _0x4a599d;var _0x2e4fbb;return db['Dynamics365Account'][_0x16dd('0x46')]({'where':{'id':_0x479e4c[_0x16dd('0x44')]['id']}})[_0x16dd('0x24')](handleEntityNotFound(_0x2447c5,null))[_0x16dd('0x24')](function(_0x5c5b36){if(_0x5c5b36){_0x4a599d=_0x5c5b36;_0x928af[_0x16dd('0x30')]=_[_0x16dd('0x41')](db[_0x16dd('0x47')]['rawAttributes']);_0x928af[_0x16dd('0x2c')]=_['keys'](_0x479e4c[_0x16dd('0x2c')]);_0x928af[_0x16dd('0x2d')]=_['intersection'](_0x928af[_0x16dd('0x30')],_0x928af[_0x16dd('0x2c')]);_0x3ebbfc[_0x16dd('0x2f')]=_[_0x16dd('0x2e')](_0x928af[_0x16dd('0x30')],qs[_0x16dd('0x31')](_0x479e4c['query'][_0x16dd('0x31')]));_0x3ebbfc[_0x16dd('0x2f')]=_0x3ebbfc['attributes'][_0x16dd('0x32')]?_0x3ebbfc['attributes']:_0x928af['model'];_0x3ebbfc[_0x16dd('0x35')]=qs[_0x16dd('0x36')](_0x479e4c[_0x16dd('0x2c')]['sort']);_0x3ebbfc[_0x16dd('0x37')]=qs[_0x16dd('0x2d')](_[_0x16dd('0x38')](_0x479e4c[_0x16dd('0x2c')],_0x928af[_0x16dd('0x2d')]));if(_0x479e4c['query'][_0x16dd('0x39')]){_0x3ebbfc['where']=_['merge'](_0x3ebbfc[_0x16dd('0x37')],{'$or':_[_0x16dd('0x28')](_0x3ebbfc[_0x16dd('0x2f')],function(_0xf6089f){var _0x29ecf9={};_0x29ecf9[_0xf6089f]={'$like':'%'+_0x479e4c[_0x16dd('0x2c')]['filter']+'%'};return _0x29ecf9;})});}_0x3ebbfc=_['merge']({},_0x3ebbfc,_0x479e4c['options']);return _0x4a599d[_0x16dd('0x45')](_0x3ebbfc);}})['then'](function(_0x3f4ab9){if(_0x3f4ab9){_0x2e4fbb=_0x3f4ab9['length'];if(!_0x479e4c[_0x16dd('0x2c')][_0x16dd('0x33')](_0x16dd('0x34'))){_0x3ebbfc[_0x16dd('0x1c')]=qs[_0x16dd('0x1c')](_0x479e4c['query']['limit']);_0x3ebbfc[_0x16dd('0x1a')]=qs[_0x16dd('0x1a')](_0x479e4c['query']['offset']);}return _0x4a599d[_0x16dd('0x45')](_0x3ebbfc);}})[_0x16dd('0x24')](function(_0x4379d3){if(_0x4379d3){return _0x4379d3?{'count':_0x2e4fbb,'rows':_0x4379d3}:null;}})[_0x16dd('0x24')](respondWithResult(_0x2447c5,null))[_0x16dd('0x3f')](handleError(_0x2447c5,null));};exports[_0x16dd('0x48')]=function(_0x26a35c,_0x84bfc0,_0x5b1fd9){if(_0x26a35c[_0x16dd('0x43')]['id']){delete _0x26a35c[_0x16dd('0x43')]['id'];}return db[_0x16dd('0x3c')][_0x16dd('0x46')]({'where':{'id':_0x26a35c[_0x16dd('0x44')]['id']}})[_0x16dd('0x24')](handleEntityNotFound(_0x84bfc0,null))[_0x16dd('0x24')](function(_0x47d0b6){if(_0x47d0b6){_0x26a35c[_0x16dd('0x43')][_0x16dd('0x49')]=_0x47d0b6['id'];_0x26a35c[_0x16dd('0x43')][_0x16dd('0x4a')]=integrations[_0x16dd('0x4b')](_0x26a35c[_0x16dd('0x43')][_0x16dd('0x4c')],_0x26a35c['body'][_0x16dd('0x2a')]);_0x26a35c[_0x16dd('0x43')][_0x16dd('0x4d')]=integrations['getDescriptions'](_0x26a35c[_0x16dd('0x43')][_0x16dd('0x4c')],_0x26a35c['body'][_0x16dd('0x2a')]);return db[_0x16dd('0x47')][_0x16dd('0x4e')](_0x26a35c[_0x16dd('0x43')],{'include':[{'model':db[_0x16dd('0x4f')],'as':_0x16dd('0x4a')},{'model':db[_0x16dd('0x4f')],'as':_0x16dd('0x4d')}]});}return null;})[_0x16dd('0x24')](respondWithResult(_0x84bfc0,null))[_0x16dd('0x3f')](handleError(_0x84bfc0,null));};exports['getFields']=function(_0x26bcf7,_0x31ad58,_0x53b8a5){var _0x3c4bce=_0x26bcf7[_0x16dd('0x2c')][_0x16dd('0x50')];var _0x177c6=_0x3c4bce===_0x16dd('0x51')?_0x16dd('0x52'):'PhoneCall';var _0x1a4c85='';var _0x3f7709='';var _0x329312='';var _0xa9d2e3='';var _0x40a812='';var _0x581e6b='';var _0x41e692='';var _0x3d9fd1='';var _0x2d1bbd=[_0x16dd('0x53'),_0x16dd('0x54'),'customerid',_0x16dd('0x55'),_0x16dd('0x56'),_0x16dd('0x57'),_0x16dd('0x58'),'regardingobjectid',_0x16dd('0x59'),_0x16dd('0x5a')];var _0x4ed2b3=['accountidname','accountidyominame',_0x16dd('0x5b'),'billedserviceunits','contactidname','contactidyominame','contractdetailidname',_0x16dd('0x5c'),_0x16dd('0x5d'),_0x16dd('0x5e'),_0x16dd('0x5f'),_0x16dd('0x60'),_0x16dd('0x61'),'createdonbehalfbyname',_0x16dd('0x62'),'customeridname',_0x16dd('0x63'),'customeridyominame',_0x16dd('0x64'),_0x16dd('0x65'),_0x16dd('0x66'),'entityimage_url','escalatedon','exchangerate',_0x16dd('0x67'),'followupby',_0x16dd('0x68'),'influencescore',_0x16dd('0x69'),'lastonholdtime',_0x16dd('0x6a'),'modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname',_0x16dd('0x6b'),'modifiedon',_0x16dd('0x6c'),_0x16dd('0x6d'),_0x16dd('0x6e'),_0x16dd('0x6f'),_0x16dd('0x70'),_0x16dd('0x71'),_0x16dd('0x72'),_0x16dd('0x73'),_0x16dd('0x74'),_0x16dd('0x75'),_0x16dd('0x76'),_0x16dd('0x77'),'primarycontactidyominame',_0x16dd('0x78'),'productidname',_0x16dd('0x79'),_0x16dd('0x7a'),_0x16dd('0x7b'),_0x16dd('0x7c'),'responsiblecontactidname',_0x16dd('0x7d'),'sentimentvalue','slainvokedidname',_0x16dd('0x7e'),'socialprofileidname','statecode',_0x16dd('0x7f'),_0x16dd('0x80'),'ticketnumber',_0x16dd('0x81'),_0x16dd('0x82'),_0x16dd('0x83'),'utcconversiontimezonecode',_0x16dd('0x84')];var _0x5a468e=_0x2d1bbd[_0x16dd('0x85')](_0x4ed2b3);return db[_0x16dd('0x3c')][_0x16dd('0x46')]({'where':{'id':_0x26bcf7[_0x16dd('0x44')]['id']},'attributes':['id',_0x16dd('0x86'),_0x16dd('0x87'),_0x16dd('0x88'),_0x16dd('0x89'),'clientId',_0x16dd('0x8a')]})[_0x16dd('0x24')](handleEntityNotFound(_0x31ad58,null))[_0x16dd('0x24')](function(_0x27a2a3){if(_0x27a2a3){_0x3d9fd1=_0x27a2a3['remoteUri'];var _0x58e2f1=_0x3d9fd1['slice'](-0x1);if(_0x58e2f1==='/'){_0x3d9fd1=_0x3d9fd1['substring'](0x0,_0x3d9fd1[_0x16dd('0x8b')](_0x58e2f1));}_0x41e692=util[_0x16dd('0x8c')](_0x16dd('0x8d'),_0x3d9fd1);var _0x1f0bc8={'method':_0x16dd('0x8e'),'uri':_0x16dd('0x8f')+_0x27a2a3['tenantId']+_0x16dd('0x90'),'form':{'client_id':_0x27a2a3[_0x16dd('0x91')],'resource':_0x3d9fd1,'username':_0x27a2a3[_0x16dd('0x86')],'password':_0x27a2a3['password'],'grant_type':'password','client_secret':_0x27a2a3['clientSecret']},'json':!![]};return rp(_0x1f0bc8);}})[_0x16dd('0x24')](function(_0x33e49d){_0x581e6b=_0x33e49d[_0x16dd('0x92')];var _0x280d44={'method':_0x16dd('0x93'),'uri':encodeURI(_0x41e692+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x177c6+'\x27'),'headers':{'Authorization':_0x16dd('0x94')+_0x581e6b,'If-None-Match':null,'OData-Version':_0x16dd('0x95')},'json':!![]};return rp(_0x280d44);})['then'](function(_0x1cb530){var _0x8c697e=_0x1cb530[_0x16dd('0x96')][0x0];var _0x29e5fe=_0x8c697e[_0x16dd('0x97')];var _0x47fcd3={'method':'GET','uri':_0x41e692+'EntityDefinitions('+_0x29e5fe+_0x16dd('0x98'),'headers':{'Authorization':_0x16dd('0x94')+_0x581e6b,'If-None-Match':null,'OData-Version':_0x16dd('0x95')},'json':!![]};return rp(_0x47fcd3);})[_0x16dd('0x24')](function(_0x4c6127){_0x1a4c85=_0x4c6127;_0x3f7709=_0x1a4c85[_0x16dd('0x99')];_0x3f7709=_[_0x16dd('0x9a')](_0x3f7709,function(_0x1e54d6){return!_0x5a468e[_0x16dd('0x9b')](_0x1e54d6[_0x16dd('0x9c')]);});var _0x17ee12=[];var _0x4fbdaa=[];_0x3f7709[_0x16dd('0x9d')](function(_0x273903){if(_0x273903[_0x16dd('0x9e')]){var _0x2dc670=_0x273903[_0x16dd('0x9e')][_0x16dd('0x9f')](_0x273903[_0x16dd('0x9e')][_0x16dd('0x8b')]('.')+0x1);if(_0x2dc670==='PicklistAttributeMetadata'){_0x17ee12['push'](getSelectList(_0x41e692,_0x3c4bce,_0x4fbdaa,_0x1a4c85['MetadataId'],_0x273903['MetadataId'],_0x581e6b));}}});return Promise[_0x16dd('0xa0')](_0x17ee12);})[_0x16dd('0x24')](function(_0x26c40f){_0x329312=_0x26c40f[0x0];var _0x302198=[];var _0x3338db=[];_0x3f7709[_0x16dd('0x9d')](function(_0x593468){if(!_[_0x16dd('0xa1')](_0x593468[_0x16dd('0x9e')])){var _0x4d6c32=_0x593468[_0x16dd('0x9e')][_0x16dd('0x9f')](_0x593468['@odata.type'][_0x16dd('0x8b')]('.')+0x1);if(_0x4d6c32==='BooleanAttributeMetadata'){_0x302198[_0x16dd('0xa2')](getBooleanList(_0x41e692,_0x3c4bce,_0x3338db,_0x1a4c85[_0x16dd('0x97')],_0x593468[_0x16dd('0x97')],_0x581e6b));}}});return Promise[_0x16dd('0xa0')](_0x302198);})[_0x16dd('0x24')](function(_0x5052f7){_0xa9d2e3=_0x5052f7[0x0];var _0x220785=[];var _0x6884bf=[];_0x3f7709[_0x16dd('0x9d')](function(_0x52d714){if(_0x52d714['@odata.type']){var _0x227b25=_0x52d714[_0x16dd('0x9e')][_0x16dd('0x9f')](_0x52d714[_0x16dd('0x9e')]['lastIndexOf']('.')+0x1);if(_0x227b25===_0x16dd('0xa3')||_0x227b25===_0x16dd('0xa4')||_0x227b25===_0x16dd('0xa5')||_0x227b25===_0x16dd('0xa6')||_0x227b25===_0x16dd('0xa7')||_0x227b25===_0x16dd('0xa8')||_0x227b25===_0x16dd('0xa9')||_0x227b25===_0x16dd('0xaa')||_0x227b25===_0x16dd('0xab')||_0x227b25===_0x16dd('0xac')){_0x220785[_0x16dd('0xa2')](getInputList(_0x41e692,_0x3c4bce,_0x227b25,_0x6884bf,_0x1a4c85[_0x16dd('0x97')],_0x52d714['MetadataId'],_0x581e6b));}}});return Promise[_0x16dd('0xa0')](_0x220785);})['then'](function(_0x578fe2){_0x40a812=_0x578fe2[0x0];var _0x499365=_0x329312['concat'](_0xa9d2e3)['concat'](_0x40a812);var _0x4fb44c={'count':_0x499365[_0x16dd('0x32')],'rows':_0x499365};return _0x4fb44c;})[_0x16dd('0x24')](respondWithResult(_0x31ad58,null))['catch'](function(_0x208d33){var _0x4d8cbf=_0x26bcf7[_0x16dd('0x2c')]['test']?0x1f4:_0x208d33[_0x16dd('0xad')]||0x1f4;logger[_0x16dd('0xae')](_0x208d33['stack']);delete _0x208d33[_0x16dd('0x26')];if(_0x4d8cbf===0x191){_0x4d8cbf=0x190;}_0x31ad58[_0x16dd('0x17')](_0x4d8cbf)[_0x16dd('0xaf')](_0x26bcf7['query'][_0x16dd('0xb0')]?{'message':'Wrong\x20credentials','statusCode':_0x208d33['statusCode']}:_0x208d33);});};function getSelectList(_0x2d431d,_0x5a27a9,_0x4ba9b4,_0x4a1c1c,_0x402250,_0x38190a){var _0x1e8540={'method':_0x16dd('0x93'),'uri':_0x2d431d+'EntityDefinitions('+_0x4a1c1c+_0x16dd('0xb1')+_0x402250+_0x16dd('0xb2')+_0x16dd('0xb3'),'headers':{'Authorization':_0x16dd('0x94')+_0x38190a,'If-None-Match':null,'OData-Version':_0x16dd('0x95')},'json':!![]};return rp(_0x1e8540)['then'](function(_0x5dedf3){var _0x207ba8=[];var _0x252c4c=_0x5dedf3[_0x16dd('0xb4')][_0x16dd('0xb5')];_0x252c4c['forEach'](function(_0x573ca3){_0x207ba8[_0x16dd('0xa2')]({'name':_0x573ca3['Label'][_0x16dd('0xb6')][_0x16dd('0xb7')],'value':String(_0x573ca3[_0x16dd('0xb8')])});});var _0x52091a={'id':_0x5a27a9+'_'+_0x5dedf3[_0x16dd('0x9c')],'name':_0x5dedf3[_0x16dd('0xb9')][_0x16dd('0xb6')][_0x16dd('0xb7')],'custom':![],'options':_0x207ba8};_0x4ba9b4[_0x16dd('0xa2')](_0x52091a);return _0x4ba9b4;});}function getBooleanList(_0x206852,_0x5ea073,_0x2cd653,_0x35f536,_0x2624d6,_0x3e9ab0){var _0x1fbc49={'method':_0x16dd('0x93'),'uri':_0x206852+_0x16dd('0xba')+_0x35f536+_0x16dd('0xb1')+_0x2624d6+')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','headers':{'Authorization':_0x16dd('0x94')+_0x3e9ab0,'If-None-Match':null,'OData-Version':_0x16dd('0x95')},'json':!![]};return rp(_0x1fbc49)[_0x16dd('0x24')](function(_0x49e9f1){var _0x357dc8=[];_0x357dc8[_0x16dd('0xa2')]({'name':_0x49e9f1[_0x16dd('0xb4')][_0x16dd('0xbb')][_0x16dd('0xb7')][_0x16dd('0xb6')][_0x16dd('0xb7')],'value':'true'},{'name':_0x49e9f1['OptionSet'][_0x16dd('0xbc')][_0x16dd('0xb7')][_0x16dd('0xb6')][_0x16dd('0xb7')],'value':_0x16dd('0xbd')});var _0x146978={'id':_0x5ea073+'_'+_0x49e9f1[_0x16dd('0x9c')],'name':_0x49e9f1[_0x16dd('0xb9')][_0x16dd('0xb6')][_0x16dd('0xb7')],'custom':![],'options':_0x357dc8};_0x2cd653[_0x16dd('0xa2')](_0x146978);return _0x2cd653;});}function getInputList(_0x348d24,_0x2402a2,_0x577082,_0x704b13,_0x2c5a67,_0x32274e,_0x295275){var _0xbfd56d={'method':_0x16dd('0x93'),'uri':_0x348d24+_0x16dd('0xba')+_0x2c5a67+')/Attributes('+_0x32274e+')/Microsoft.Dynamics.CRM.'+_0x577082+_0x16dd('0xbe'),'headers':{'Authorization':_0x16dd('0x94')+_0x295275,'If-None-Match':null,'OData-Version':_0x16dd('0x95')},'json':!![]};return rp(_0xbfd56d)[_0x16dd('0x24')](function(_0x4fd92a){var _0x4dfcef={'id':_0x2402a2+'_'+_0x4fd92a['LogicalName'],'name':_0x4fd92a[_0x16dd('0xb9')][_0x16dd('0xb6')]?_0x4fd92a[_0x16dd('0xb9')][_0x16dd('0xb6')]['Label']:_0x4fd92a[_0x16dd('0x9c')],'custom':![],'options':[]};_0x704b13[_0x16dd('0xa2')](_0x4dfcef);return _0x704b13;});}
\ 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