Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 7888702..df9e8a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe5b3=['subject','phonenumber','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contractdetailidname','contractidname','createdbyexternalpartyyominame','createdon','createdonbehalfbyname','customeridname','customeridtype','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','importsequencenumber','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyname','modifiedon','modifiedonbehalfbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','owneridtype','owneridyominame','primarycontactidname','primarycontactidyominame','prioritycodename','productserialnumber','resolveby','resolvebykpiidname','responsiblecontactidname','responsiblecontactidyominame','slainvokedidname','slaname','socialprofileidname','statuscode','subjectidname','ticketnumber','timezoneruleversionnumber','traversedpath','versionnumber','concat','username','remoteUri','tenantId','clientId','clientSecret','slice','substring','lastIndexOf','POST','https://login.microsoftonline.com/','/oauth2/token','password','access_token','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','Bearer\x20','4.0','value','MetadataId',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Attributes','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','all','isNil','push','DoubleAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode','error','Wrong\x20credentials','EntityDefinitions(',')/Attributes(','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','Options','Label','UserLocalizedLabel','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','true','OptionSet','FalseOption','false',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','limit','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','stack','name','send','index','map','Dynamics365Account','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','length','hasOwnProperty','order','sort','filters','filter','where','merge','options','count','includeAll','findAll','rows','catch','show','keys','find','create','body','params','getConfigurations','findOne','Dynamics365Configuration','pick','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','Dynamics365Field','getFields','ticketType','incident','Incident','PhoneCall','title','description','customerid','ownerid'];(function(_0x9f47cf,_0x2da62c){var _0xe0f94c=function(_0x1a4f2e){while(--_0x1a4f2e){_0x9f47cf['push'](_0x9f47cf['shift']());}};_0xe0f94c(++_0x2da62c);}(_0xe5b3,0x133));var _0x3e5b=function(_0x3512c3,_0x346843){_0x3512c3=_0x3512c3-0x0;var _0x3b2842=_0xe5b3[_0x3512c3];return _0x3b2842;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3e5b('0x0'));var zipdir=require(_0x3e5b('0x1'));var jsonpatch=require(_0x3e5b('0x2'));var rp=require(_0x3e5b('0x3'));var moment=require(_0x3e5b('0x4'));var BPromise=require(_0x3e5b('0x5'));var Mustache=require(_0x3e5b('0x6'));var util=require(_0x3e5b('0x7'));var path=require(_0x3e5b('0x8'));var sox=require(_0x3e5b('0x9'));var csv=require(_0x3e5b('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x3e5b('0xb'));var _=require(_0x3e5b('0xc'));var squel=require('squel');var crypto=require(_0x3e5b('0xd'));var jsforce=require(_0x3e5b('0xe'));var deskjs=require(_0x3e5b('0xf'));var toCsv=require(_0x3e5b('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x3e5b('0x10'));var authService=require(_0x3e5b('0x11'));var qs=require(_0x3e5b('0x12'));var as=require(_0x3e5b('0x13'));var hardwareService=require(_0x3e5b('0x14'));var logger=require('../../config/logger')(_0x3e5b('0x15'));var utils=require('../../config/utils');var config=require(_0x3e5b('0x16'));var licenseUtil=require(_0x3e5b('0x17'));var db=require(_0x3e5b('0x18'))['db'];var integrations=require(_0x3e5b('0x19'));function respondWithStatusCode(_0x20b97b,_0x3c4eb1){_0x3c4eb1=_0x3c4eb1||0xcc;return function(_0x405e70){if(_0x405e70){return _0x20b97b['sendStatus'](_0x3c4eb1);}return _0x20b97b[_0x3e5b('0x1a')](_0x3c4eb1)['end']();};}function respondWithResult(_0x51a188,_0x4d71a3){_0x4d71a3=_0x4d71a3||0xc8;return function(_0x3754e3){if(_0x3754e3){return _0x51a188[_0x3e5b('0x1a')](_0x4d71a3)[_0x3e5b('0x1b')](_0x3754e3);}};}function respondWithFilteredResult(_0x4fb471,_0x1f81a7){return function(_0x59ddc0){if(_0x59ddc0){var _0x56a453=typeof _0x1f81a7[_0x3e5b('0x1c')]===_0x3e5b('0x1d')&&typeof _0x1f81a7['limit']===_0x3e5b('0x1d');var _0x143040=_0x59ddc0['count'];var _0xc56a2a=_0x56a453?0x0:_0x1f81a7[_0x3e5b('0x1c')];var _0x52696c=_0x56a453?_0x59ddc0['count']:_0x1f81a7[_0x3e5b('0x1c')]+_0x1f81a7[_0x3e5b('0x1e')];var _0x20b549;if(_0x52696c>=_0x143040){_0x52696c=_0x143040;_0x20b549=0xc8;}else{_0x20b549=0xce;}_0x4fb471[_0x3e5b('0x1a')](_0x20b549);return _0x4fb471[_0x3e5b('0x1f')](_0x3e5b('0x20'),_0xc56a2a+'-'+_0x52696c+'/'+_0x143040)[_0x3e5b('0x1b')](_0x59ddc0);}return null;};}function patchUpdates(_0x21fc32){return function(_0x36c988){try{jsonpatch[_0x3e5b('0x21')](_0x36c988,_0x21fc32,!![]);}catch(_0x2b977c){return BPromise[_0x3e5b('0x22')](_0x2b977c);}return _0x36c988[_0x3e5b('0x23')]();};}function saveUpdates(_0x402873,_0x5b46d4){return function(_0x433f9c){if(_0x433f9c){return _0x433f9c[_0x3e5b('0x24')](_0x402873)[_0x3e5b('0x25')](function(_0x150674){return _0x150674;});}return null;};}function removeEntity(_0x50039b,_0x1eb80f){return function(_0x5b33bb){if(_0x5b33bb){return _0x5b33bb[_0x3e5b('0x26')]()[_0x3e5b('0x25')](function(){_0x50039b['status'](0xcc)[_0x3e5b('0x27')]();});}};}function handleEntityNotFound(_0x2f6368,_0x42d7e9){return function(_0x3c8965){if(!_0x3c8965){_0x2f6368[_0x3e5b('0x28')](0x194);}return _0x3c8965;};}function handleError(_0x26c7f2,_0x160e87){_0x160e87=_0x160e87||0x1f4;return function(_0x2ddf57){logger['error'](_0x2ddf57[_0x3e5b('0x29')]);if(_0x2ddf57['name']){delete _0x2ddf57[_0x3e5b('0x2a')];}_0x26c7f2['status'](_0x160e87)[_0x3e5b('0x2b')](_0x2ddf57);};}exports[_0x3e5b('0x2c')]=function(_0x1296ec,_0x475b39){var _0x10d2ed={},_0x3cfaf6={},_0x307091={'count':0x0,'rows':[]};var _0x9c2123=_[_0x3e5b('0x2d')](db[_0x3e5b('0x2e')][_0x3e5b('0x2f')],function(_0x489221){return{'name':_0x489221[_0x3e5b('0x30')],'type':_0x489221[_0x3e5b('0x31')][_0x3e5b('0x32')]};});_0x3cfaf6[_0x3e5b('0x33')]=_[_0x3e5b('0x2d')](_0x9c2123,_0x3e5b('0x2a'));_0x3cfaf6[_0x3e5b('0x34')]=_['keys'](_0x1296ec[_0x3e5b('0x34')]);_0x3cfaf6['filters']=_['intersection'](_0x3cfaf6[_0x3e5b('0x33')],_0x3cfaf6[_0x3e5b('0x34')]);_0x10d2ed['attributes']=_[_0x3e5b('0x35')](_0x3cfaf6[_0x3e5b('0x33')],qs[_0x3e5b('0x36')](_0x1296ec[_0x3e5b('0x34')][_0x3e5b('0x36')]));_0x10d2ed[_0x3e5b('0x37')]=_0x10d2ed[_0x3e5b('0x37')][_0x3e5b('0x38')]?_0x10d2ed[_0x3e5b('0x37')]:_0x3cfaf6[_0x3e5b('0x33')];if(!_0x1296ec[_0x3e5b('0x34')][_0x3e5b('0x39')]('nolimit')){_0x10d2ed[_0x3e5b('0x1e')]=qs[_0x3e5b('0x1e')](_0x1296ec['query']['limit']);_0x10d2ed[_0x3e5b('0x1c')]=qs['offset'](_0x1296ec[_0x3e5b('0x34')][_0x3e5b('0x1c')]);}_0x10d2ed[_0x3e5b('0x3a')]=qs[_0x3e5b('0x3b')](_0x1296ec['query'][_0x3e5b('0x3b')]);_0x10d2ed['where']=qs[_0x3e5b('0x3c')](_['pick'](_0x1296ec['query'],_0x3cfaf6['filters']),_0x9c2123);if(_0x1296ec[_0x3e5b('0x34')][_0x3e5b('0x3d')]){_0x10d2ed[_0x3e5b('0x3e')]=_[_0x3e5b('0x3f')](_0x10d2ed[_0x3e5b('0x3e')],{'$or':_[_0x3e5b('0x2d')](_0x9c2123,function(_0x5466ac){if(_0x5466ac['type']!=='VIRTUAL'){var _0x565319={};_0x565319[_0x5466ac['name']]={'$like':'%'+_0x1296ec['query']['filter']+'%'};return _0x565319;}})});}_0x10d2ed=_[_0x3e5b('0x3f')]({},_0x10d2ed,_0x1296ec[_0x3e5b('0x40')]);var _0x13a48d={'where':_0x10d2ed[_0x3e5b('0x3e')]};return db[_0x3e5b('0x2e')][_0x3e5b('0x41')](_0x13a48d)[_0x3e5b('0x25')](function(_0x423be2){_0x307091[_0x3e5b('0x41')]=_0x423be2;if(_0x1296ec[_0x3e5b('0x34')][_0x3e5b('0x42')]){_0x10d2ed['include']=[{'all':!![]}];}return db[_0x3e5b('0x2e')][_0x3e5b('0x43')](_0x10d2ed);})[_0x3e5b('0x25')](function(_0xae974f){_0x307091[_0x3e5b('0x44')]=_0xae974f;return _0x307091;})[_0x3e5b('0x25')](respondWithFilteredResult(_0x475b39,_0x10d2ed))[_0x3e5b('0x45')](handleError(_0x475b39,null));};exports[_0x3e5b('0x46')]=function(_0x351d5d,_0x39da3f){var _0x13c8d5={'raw':![],'where':{'id':_0x351d5d['params']['id']}},_0x559056={};_0x559056['model']=_['keys'](db[_0x3e5b('0x2e')][_0x3e5b('0x2f')]);_0x559056[_0x3e5b('0x34')]=_[_0x3e5b('0x47')](_0x351d5d[_0x3e5b('0x34')]);_0x559056[_0x3e5b('0x3c')]=_[_0x3e5b('0x35')](_0x559056[_0x3e5b('0x33')],_0x559056[_0x3e5b('0x34')]);_0x13c8d5[_0x3e5b('0x37')]=_['intersection'](_0x559056[_0x3e5b('0x33')],qs[_0x3e5b('0x36')](_0x351d5d[_0x3e5b('0x34')][_0x3e5b('0x36')]));_0x13c8d5[_0x3e5b('0x37')]=_0x13c8d5['attributes']['length']?_0x13c8d5['attributes']:_0x559056[_0x3e5b('0x33')];if(_0x351d5d[_0x3e5b('0x34')][_0x3e5b('0x42')]){_0x13c8d5['include']=[{'all':!![]}];}_0x13c8d5=_['merge']({},_0x13c8d5,_0x351d5d[_0x3e5b('0x40')]);return db[_0x3e5b('0x2e')][_0x3e5b('0x48')](_0x13c8d5)['then'](handleEntityNotFound(_0x39da3f,null))['then'](respondWithResult(_0x39da3f,null))[_0x3e5b('0x45')](handleError(_0x39da3f,null));};exports['create']=function(_0x14b62a,_0x3379a1){return db[_0x3e5b('0x2e')][_0x3e5b('0x49')](_0x14b62a[_0x3e5b('0x4a')],{})[_0x3e5b('0x25')](respondWithResult(_0x3379a1,0xc9))[_0x3e5b('0x45')](handleError(_0x3379a1,null));};exports[_0x3e5b('0x24')]=function(_0x339852,_0x4a2ae1){if(_0x339852[_0x3e5b('0x4a')]['id']){delete _0x339852['body']['id'];}return db[_0x3e5b('0x2e')][_0x3e5b('0x48')]({'where':{'id':_0x339852[_0x3e5b('0x4b')]['id']}})[_0x3e5b('0x25')](handleEntityNotFound(_0x4a2ae1,null))[_0x3e5b('0x25')](saveUpdates(_0x339852[_0x3e5b('0x4a')],null))[_0x3e5b('0x25')](respondWithResult(_0x4a2ae1,null))[_0x3e5b('0x45')](handleError(_0x4a2ae1,null));};exports[_0x3e5b('0x26')]=function(_0x371655,_0xf6ca5b){return db[_0x3e5b('0x2e')][_0x3e5b('0x48')]({'where':{'id':_0x371655['params']['id']}})[_0x3e5b('0x25')](handleEntityNotFound(_0xf6ca5b,null))[_0x3e5b('0x25')](removeEntity(_0xf6ca5b,null))[_0x3e5b('0x45')](handleError(_0xf6ca5b,null));};exports[_0x3e5b('0x4c')]=function(_0x16c9f9,_0x2cecd3,_0x55b46c){var _0x131af1={};var _0x1cbdf7={};var _0x25b166;var _0x314d42;return db[_0x3e5b('0x2e')][_0x3e5b('0x4d')]({'where':{'id':_0x16c9f9[_0x3e5b('0x4b')]['id']}})[_0x3e5b('0x25')](handleEntityNotFound(_0x2cecd3,null))['then'](function(_0x1e6403){if(_0x1e6403){_0x25b166=_0x1e6403;_0x1cbdf7['model']=_['keys'](db[_0x3e5b('0x4e')]['rawAttributes']);_0x1cbdf7[_0x3e5b('0x34')]=_[_0x3e5b('0x47')](_0x16c9f9[_0x3e5b('0x34')]);_0x1cbdf7[_0x3e5b('0x3c')]=_['intersection'](_0x1cbdf7['model'],_0x1cbdf7['query']);_0x131af1['attributes']=_[_0x3e5b('0x35')](_0x1cbdf7[_0x3e5b('0x33')],qs[_0x3e5b('0x36')](_0x16c9f9[_0x3e5b('0x34')][_0x3e5b('0x36')]));_0x131af1['attributes']=_0x131af1['attributes'][_0x3e5b('0x38')]?_0x131af1[_0x3e5b('0x37')]:_0x1cbdf7[_0x3e5b('0x33')];_0x131af1[_0x3e5b('0x3a')]=qs[_0x3e5b('0x3b')](_0x16c9f9['query']['sort']);_0x131af1['where']=qs['filters'](_[_0x3e5b('0x4f')](_0x16c9f9[_0x3e5b('0x34')],_0x1cbdf7[_0x3e5b('0x3c')]));if(_0x16c9f9[_0x3e5b('0x34')][_0x3e5b('0x3d')]){_0x131af1[_0x3e5b('0x3e')]=_[_0x3e5b('0x3f')](_0x131af1[_0x3e5b('0x3e')],{'$or':_['map'](_0x131af1[_0x3e5b('0x37')],function(_0x29897b){var _0x30d4b9={};_0x30d4b9[_0x29897b]={'$like':'%'+_0x16c9f9[_0x3e5b('0x34')][_0x3e5b('0x3d')]+'%'};return _0x30d4b9;})});}_0x131af1=_['merge']({},_0x131af1,_0x16c9f9[_0x3e5b('0x40')]);return _0x25b166['getConfigurations'](_0x131af1);}})[_0x3e5b('0x25')](function(_0x1fd40c){if(_0x1fd40c){_0x314d42=_0x1fd40c['length'];if(!_0x16c9f9['query']['hasOwnProperty'](_0x3e5b('0x50'))){_0x131af1['limit']=qs[_0x3e5b('0x1e')](_0x16c9f9[_0x3e5b('0x34')][_0x3e5b('0x1e')]);_0x131af1[_0x3e5b('0x1c')]=qs[_0x3e5b('0x1c')](_0x16c9f9['query']['offset']);}return _0x25b166[_0x3e5b('0x4c')](_0x131af1);}})[_0x3e5b('0x25')](function(_0x3f7f71){if(_0x3f7f71){return _0x3f7f71?{'count':_0x314d42,'rows':_0x3f7f71}:null;}})['then'](respondWithResult(_0x2cecd3,null))[_0x3e5b('0x45')](handleError(_0x2cecd3,null));};exports[_0x3e5b('0x51')]=function(_0x32a42f,_0x1c9526,_0x206bec){if(_0x32a42f[_0x3e5b('0x4a')]['id']){delete _0x32a42f[_0x3e5b('0x4a')]['id'];}return db[_0x3e5b('0x2e')][_0x3e5b('0x4d')]({'where':{'id':_0x32a42f[_0x3e5b('0x4b')]['id']}})[_0x3e5b('0x25')](handleEntityNotFound(_0x1c9526,null))[_0x3e5b('0x25')](function(_0x33bbb8){if(_0x33bbb8){_0x32a42f[_0x3e5b('0x4a')][_0x3e5b('0x52')]=_0x33bbb8['id'];_0x32a42f[_0x3e5b('0x4a')][_0x3e5b('0x53')]=integrations[_0x3e5b('0x54')](_0x32a42f['body'][_0x3e5b('0x55')],_0x32a42f[_0x3e5b('0x4a')]['type']);_0x32a42f[_0x3e5b('0x4a')][_0x3e5b('0x56')]=integrations['getDescriptions'](_0x32a42f['body']['channel'],_0x32a42f[_0x3e5b('0x4a')][_0x3e5b('0x31')]);return db['Dynamics365Configuration'][_0x3e5b('0x49')](_0x32a42f[_0x3e5b('0x4a')],{'include':[{'model':db['Dynamics365Field'],'as':_0x3e5b('0x53')},{'model':db[_0x3e5b('0x57')],'as':_0x3e5b('0x56')}]});}return null;})[_0x3e5b('0x25')](respondWithResult(_0x1c9526,null))[_0x3e5b('0x45')](handleError(_0x1c9526,null));};exports[_0x3e5b('0x58')]=function(_0x5891fe,_0x410c7a,_0x3f2c6c){var _0x589498=_0x5891fe[_0x3e5b('0x34')][_0x3e5b('0x59')];var _0x2d5685=_0x589498===_0x3e5b('0x5a')?_0x3e5b('0x5b'):_0x3e5b('0x5c');var _0x12c93d='';var _0x4efdbe='';var _0x590f0c='';var _0x1dd82b='';var _0x3ee33c='';var _0x4dd417='';var _0x404621='';var _0x6e1c5='';var _0x35e3ef=[_0x3e5b('0x5d'),_0x3e5b('0x5e'),_0x3e5b('0x5f'),_0x3e5b('0x60'),'caseorigincode',_0x3e5b('0x61'),_0x3e5b('0x62'),'regardingobjectid','directioncode','phonecall_activity_parties'];var _0x8d164e=[_0x3e5b('0x63'),_0x3e5b('0x64'),_0x3e5b('0x65'),_0x3e5b('0x66'),_0x3e5b('0x67'),'contactidyominame',_0x3e5b('0x68'),_0x3e5b('0x69'),'createdbyexternalpartyname',_0x3e5b('0x6a'),'createdbyname','createdbyyominame',_0x3e5b('0x6b'),_0x3e5b('0x6c'),'createdonbehalfbyyominame',_0x3e5b('0x6d'),_0x3e5b('0x6e'),'customeridyominame',_0x3e5b('0x6f'),_0x3e5b('0x70'),_0x3e5b('0x71'),_0x3e5b('0x72'),_0x3e5b('0x73'),_0x3e5b('0x74'),'firstresponsebykpiidname','followupby',_0x3e5b('0x75'),'influencescore','kbarticleidname',_0x3e5b('0x76'),_0x3e5b('0x77'),_0x3e5b('0x78'),'modifiedbyexternalpartyyominame',_0x3e5b('0x79'),'modifiedbyyominame',_0x3e5b('0x7a'),'modifiedonbehalfbyname',_0x3e5b('0x7b'),_0x3e5b('0x7c'),_0x3e5b('0x7d'),_0x3e5b('0x7e'),'onholdtime',_0x3e5b('0x7f'),'owneridname',_0x3e5b('0x80'),_0x3e5b('0x81'),'parentcaseidname',_0x3e5b('0x82'),_0x3e5b('0x83'),_0x3e5b('0x84'),'productidname',_0x3e5b('0x85'),_0x3e5b('0x86'),_0x3e5b('0x87'),'responseby',_0x3e5b('0x88'),_0x3e5b('0x89'),'sentimentvalue',_0x3e5b('0x8a'),_0x3e5b('0x8b'),_0x3e5b('0x8c'),'statecode',_0x3e5b('0x8d'),_0x3e5b('0x8e'),_0x3e5b('0x8f'),_0x3e5b('0x90'),'transactioncurrencyidname',_0x3e5b('0x91'),'utcconversiontimezonecode',_0x3e5b('0x92')];var _0x51b530=_0x35e3ef[_0x3e5b('0x93')](_0x8d164e);return db[_0x3e5b('0x2e')]['findOne']({'where':{'id':_0x5891fe[_0x3e5b('0x4b')]['id']},'attributes':['id',_0x3e5b('0x94'),'password',_0x3e5b('0x95'),_0x3e5b('0x96'),_0x3e5b('0x97'),_0x3e5b('0x98')]})['then'](handleEntityNotFound(_0x410c7a,null))['then'](function(_0xff0183){if(_0xff0183){_0x6e1c5=_0xff0183[_0x3e5b('0x95')];var _0x1ffb60=_0x6e1c5[_0x3e5b('0x99')](-0x1);if(_0x1ffb60==='/'){_0x6e1c5=_0x6e1c5[_0x3e5b('0x9a')](0x0,_0x6e1c5[_0x3e5b('0x9b')](_0x1ffb60));}_0x404621=util['format']('%s/api/data/v9.0/',_0x6e1c5);var _0x19e93f={'method':_0x3e5b('0x9c'),'uri':_0x3e5b('0x9d')+_0xff0183[_0x3e5b('0x96')]+_0x3e5b('0x9e'),'form':{'client_id':_0xff0183[_0x3e5b('0x97')],'resource':_0x6e1c5,'username':_0xff0183[_0x3e5b('0x94')],'password':_0xff0183[_0x3e5b('0x9f')],'grant_type':'password','client_secret':_0xff0183['clientSecret']},'json':!![]};return rp(_0x19e93f);}})[_0x3e5b('0x25')](function(_0x4d36b6){_0x4dd417=_0x4d36b6[_0x3e5b('0xa0')];var _0x44300d={'method':_0x3e5b('0xa1'),'uri':encodeURI(_0x404621+_0x3e5b('0xa2')+_0x2d5685+'\x27'),'headers':{'Authorization':_0x3e5b('0xa3')+_0x4dd417,'If-None-Match':null,'OData-Version':_0x3e5b('0xa4')},'json':!![]};return rp(_0x44300d);})[_0x3e5b('0x25')](function(_0x350bd7){var _0x2b5d74=_0x350bd7[_0x3e5b('0xa5')][0x0];var _0x1299ac=_0x2b5d74[_0x3e5b('0xa6')];var _0x1fe6a1={'method':'GET','uri':_0x404621+'EntityDefinitions('+_0x1299ac+_0x3e5b('0xa7'),'headers':{'Authorization':_0x3e5b('0xa3')+_0x4dd417,'If-None-Match':null,'OData-Version':_0x3e5b('0xa4')},'json':!![]};return rp(_0x1fe6a1);})[_0x3e5b('0x25')](function(_0x49b46c){_0x12c93d=_0x49b46c;_0x4efdbe=_0x12c93d[_0x3e5b('0xa8')];_0x4efdbe=_['remove'](_0x4efdbe,function(_0x215c43){return!_0x51b530['includes'](_0x215c43[_0x3e5b('0xa9')]);});var _0x3f28cc=[];var _0x2c22ef=[];_0x4efdbe[_0x3e5b('0xaa')](function(_0x121c8f){if(_0x121c8f[_0x3e5b('0xab')]){var _0xd93aed=_0x121c8f[_0x3e5b('0xab')][_0x3e5b('0x9a')](_0x121c8f['@odata.type'][_0x3e5b('0x9b')]('.')+0x1);if(_0xd93aed===_0x3e5b('0xac')){_0x3f28cc['push'](getSelectList(_0x404621,_0x589498,_0x2c22ef,_0x12c93d[_0x3e5b('0xa6')],_0x121c8f[_0x3e5b('0xa6')],_0x4dd417));}}});return Promise[_0x3e5b('0xad')](_0x3f28cc);})[_0x3e5b('0x25')](function(_0x41de83){_0x590f0c=_0x41de83[0x0];var _0x2df067=[];var _0x441890=[];_0x4efdbe[_0x3e5b('0xaa')](function(_0x2ddd9b){if(!_[_0x3e5b('0xae')](_0x2ddd9b[_0x3e5b('0xab')])){var _0x144019=_0x2ddd9b['@odata.type'][_0x3e5b('0x9a')](_0x2ddd9b[_0x3e5b('0xab')]['lastIndexOf']('.')+0x1);if(_0x144019==='BooleanAttributeMetadata'){_0x2df067[_0x3e5b('0xaf')](getBooleanList(_0x404621,_0x589498,_0x441890,_0x12c93d[_0x3e5b('0xa6')],_0x2ddd9b[_0x3e5b('0xa6')],_0x4dd417));}}});return Promise[_0x3e5b('0xad')](_0x2df067);})[_0x3e5b('0x25')](function(_0x4c66b7){_0x1dd82b=_0x4c66b7[0x0];var _0xc78d12=[];var _0x41f7c8=[];_0x4efdbe['forEach'](function(_0x53913d){if(_0x53913d[_0x3e5b('0xab')]){var _0x1d92f0=_0x53913d['@odata.type']['substring'](_0x53913d[_0x3e5b('0xab')][_0x3e5b('0x9b')]('.')+0x1);if(_0x1d92f0==='StringAttributeMetadata'||_0x1d92f0===_0x3e5b('0xb0')||_0x1d92f0===_0x3e5b('0xb1')||_0x1d92f0===_0x3e5b('0xb2')||_0x1d92f0===_0x3e5b('0xb3')||_0x1d92f0===_0x3e5b('0xb4')||_0x1d92f0==='StatusAttributeMetadata'||_0x1d92f0==='EntityNameAttributeMetadata'||_0x1d92f0===_0x3e5b('0xb5')||_0x1d92f0===_0x3e5b('0xb6')){_0xc78d12[_0x3e5b('0xaf')](getInputList(_0x404621,_0x589498,_0x1d92f0,_0x41f7c8,_0x12c93d[_0x3e5b('0xa6')],_0x53913d[_0x3e5b('0xa6')],_0x4dd417));}}});return Promise[_0x3e5b('0xad')](_0xc78d12);})[_0x3e5b('0x25')](function(_0x2c93f4){_0x3ee33c=_0x2c93f4[0x0];var _0x37f34c=_0x590f0c[_0x3e5b('0x93')](_0x1dd82b)[_0x3e5b('0x93')](_0x3ee33c);var _0x8efc1b={'count':_0x37f34c[_0x3e5b('0x38')],'rows':_0x37f34c};return _0x8efc1b;})[_0x3e5b('0x25')](respondWithResult(_0x410c7a,null))[_0x3e5b('0x45')](function(_0x3ca1fb){var _0x34edb6=_0x5891fe[_0x3e5b('0x34')][_0x3e5b('0xb7')]?0x1f4:_0x3ca1fb[_0x3e5b('0xb8')]||0x1f4;logger[_0x3e5b('0xb9')](_0x3ca1fb[_0x3e5b('0x29')]);delete _0x3ca1fb[_0x3e5b('0x2a')];if(_0x34edb6===0x191){_0x34edb6=0x190;}_0x410c7a[_0x3e5b('0x1a')](_0x34edb6)[_0x3e5b('0x2b')](_0x5891fe['query']['test']?{'message':_0x3e5b('0xba'),'statusCode':_0x3ca1fb[_0x3e5b('0xb8')]}:_0x3ca1fb);});};function getSelectList(_0x2f4c8f,_0xc015eb,_0x5b33a1,_0x17a736,_0x494adc,_0x1f1062){var _0x3ffc0f={'method':_0x3e5b('0xa1'),'uri':_0x2f4c8f+_0x3e5b('0xbb')+_0x17a736+_0x3e5b('0xbc')+_0x494adc+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+_0x3e5b('0xbd'),'headers':{'Authorization':_0x3e5b('0xa3')+_0x1f1062,'If-None-Match':null,'OData-Version':_0x3e5b('0xa4')},'json':!![]};return rp(_0x3ffc0f)[_0x3e5b('0x25')](function(_0xf51840){var _0x475b31=[];var _0x5db7b6=_0xf51840['OptionSet'][_0x3e5b('0xbe')];_0x5db7b6['forEach'](function(_0x54b166){_0x475b31[_0x3e5b('0xaf')]({'name':_0x54b166[_0x3e5b('0xbf')][_0x3e5b('0xc0')]['Label'],'value':String(_0x54b166['Value'])});});var _0x1968dd={'id':_0xc015eb+'_'+_0xf51840[_0x3e5b('0xa9')],'name':_0xf51840[_0x3e5b('0xc1')][_0x3e5b('0xc0')][_0x3e5b('0xbf')],'custom':![],'options':_0x475b31};_0x5b33a1[_0x3e5b('0xaf')](_0x1968dd);return _0x5b33a1;});}function getBooleanList(_0x4ef443,_0x4c6d02,_0x3c274b,_0x29a427,_0x38db0c,_0x1ac1ad){var _0x1d1b08={'method':_0x3e5b('0xa1'),'uri':_0x4ef443+_0x3e5b('0xbb')+_0x29a427+_0x3e5b('0xbc')+_0x38db0c+_0x3e5b('0xc2'),'headers':{'Authorization':_0x3e5b('0xa3')+_0x1ac1ad,'If-None-Match':null,'OData-Version':_0x3e5b('0xa4')},'json':!![]};return rp(_0x1d1b08)[_0x3e5b('0x25')](function(_0x283452){var _0x3585df=[];_0x3585df[_0x3e5b('0xaf')]({'name':_0x283452['OptionSet'][_0x3e5b('0xc3')][_0x3e5b('0xbf')][_0x3e5b('0xc0')][_0x3e5b('0xbf')],'value':_0x3e5b('0xc4')},{'name':_0x283452[_0x3e5b('0xc5')][_0x3e5b('0xc6')]['Label'][_0x3e5b('0xc0')][_0x3e5b('0xbf')],'value':_0x3e5b('0xc7')});var _0x3c72e1={'id':_0x4c6d02+'_'+_0x283452['LogicalName'],'name':_0x283452[_0x3e5b('0xc1')][_0x3e5b('0xc0')][_0x3e5b('0xbf')],'custom':![],'options':_0x3585df};_0x3c274b[_0x3e5b('0xaf')](_0x3c72e1);return _0x3c274b;});}function getInputList(_0xf8dba5,_0x1ce847,_0x325d92,_0x3acf47,_0x276caa,_0x5a988d,_0x163c14){var _0x157554={'method':'GET','uri':_0xf8dba5+_0x3e5b('0xbb')+_0x276caa+_0x3e5b('0xbc')+_0x5a988d+_0x3e5b('0xc8')+_0x325d92+_0x3e5b('0xc9'),'headers':{'Authorization':_0x3e5b('0xa3')+_0x163c14,'If-None-Match':null,'OData-Version':_0x3e5b('0xa4')},'json':!![]};return rp(_0x157554)[_0x3e5b('0x25')](function(_0x2fe546){var _0xc2aa59={'id':_0x1ce847+'_'+_0x2fe546['LogicalName'],'name':_0x2fe546['DisplayName'][_0x3e5b('0xc0')]?_0x2fe546[_0x3e5b('0xc1')][_0x3e5b('0xc0')]['Label']:_0x2fe546[_0x3e5b('0xa9')],'custom':![],'options':[]};_0x3acf47[_0x3e5b('0xaf')](_0xc2aa59);return _0x3acf47;});}
\ 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