Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
index 3f12ca1..24f9632 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf482=['remoteUri','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data5','data7','POST','https://login.microsoftonline.com/','/oauth2/token','access_token','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','4.0','value','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Bearer\x20','Attributes','remove','LogicalName','forEach','@odata.type','PicklistAttributeMetadata','MetadataId','all','isNil','push','StringAttributeMetadata','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test',')/Attributes(','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options','Label',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','UserLocalizedLabel','FalseOption','false','DisplayName','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','api','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','limit','Content-Range','update','then','end','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','length','nolimit','order','sort','where','VIRTUAL','merge','options','Dynamics365Account','count','includeAll','include','findAll','catch','show','params','fields','find','create','body','destroy','pick','filter','getConfigurations','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','Incident','PhoneCall','description','ownerid','caseorigincode','subject','phonecall_activity_parties','accountidname','accountidyominame','billedserviceunits','contactidname','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyyominame','createdon','createdonbehalfbyname','customeridyominame','emailaddress','entitlementidname','entityimage_timestamp','entityimage_url','firstresponsebykpiidname','importsequencenumber','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','onholdtime','owneridname','owneridtype','owneridyominame','primarycontactidyominame','productidname','productserialnumber','resolveby','responseby','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statecode','statuscode','ticketnumber','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','findOne','username','password'];(function(_0x5f3f88,_0x562baf){var _0xd08119=function(_0x42dbf7){while(--_0x42dbf7){_0x5f3f88['push'](_0x5f3f88['shift']());}};_0xd08119(++_0x562baf);}(_0xf482,0xe4));var _0x2f48=function(_0x3f0228,_0x102e3f){_0x3f0228=_0x3f0228-0x0;var _0x848b65=_0xf482[_0x3f0228];return _0x848b65;};'use strict';var rp=require(_0x2f48('0x0'));var util=require(_0x2f48('0x1'));var _=require(_0x2f48('0x2'));var qs=require(_0x2f48('0x3'));var logger=require(_0x2f48('0x4'))(_0x2f48('0x5'));var db=require(_0x2f48('0x6'))['db'];var integrations=require(_0x2f48('0x7'));function respondWithResult(_0x975618,_0x52973f){_0x52973f=_0x52973f||0xc8;return function(_0xdcbbdb){if(_0xdcbbdb){return _0x975618[_0x2f48('0x8')](_0x52973f)[_0x2f48('0x9')](_0xdcbbdb);}};}function respondWithFilteredResult(_0x4dd869,_0x44bd3b){return function(_0x4f72ce){if(_0x4f72ce){var _0x34cb0a=typeof _0x44bd3b[_0x2f48('0xa')]===_0x2f48('0xb')&&typeof _0x44bd3b[_0x2f48('0xc')]===_0x2f48('0xb');var _0x1dce31=_0x4f72ce['count'];var _0x2c725a=_0x34cb0a?0x0:_0x44bd3b[_0x2f48('0xa')];var _0x154c78=_0x34cb0a?_0x4f72ce['count']:_0x44bd3b[_0x2f48('0xa')]+_0x44bd3b['limit'];var _0x396078;if(_0x154c78>=_0x1dce31){_0x154c78=_0x1dce31;_0x396078=0xc8;}else{_0x396078=0xce;}_0x4dd869[_0x2f48('0x8')](_0x396078);return _0x4dd869['set'](_0x2f48('0xd'),_0x2c725a+'-'+_0x154c78+'/'+_0x1dce31)[_0x2f48('0x9')](_0x4f72ce);}return null;};}function saveUpdates(_0x51b141){return function(_0x155482){if(_0x155482){return _0x155482[_0x2f48('0xe')](_0x51b141)[_0x2f48('0xf')](function(_0x160fb8){return _0x160fb8;});}return null;};}function removeEntity(_0x3c2ba9){return function(_0x40649b){if(_0x40649b){return _0x40649b['destroy']()[_0x2f48('0xf')](function(){_0x3c2ba9[_0x2f48('0x8')](0xcc)[_0x2f48('0x10')]();});}};}function handleEntityNotFound(_0x4c2f15){return function(_0x4b11cf){if(!_0x4b11cf){_0x4c2f15['sendStatus'](0x194);}return _0x4b11cf;};}function handleError(_0x13a511,_0x3adca1){_0x3adca1=_0x3adca1||0x1f4;return function(_0x42b69b){logger[_0x2f48('0x11')](_0x42b69b[_0x2f48('0x12')]);if(_0x42b69b[_0x2f48('0x13')]){delete _0x42b69b[_0x2f48('0x13')];}_0x13a511['status'](_0x3adca1)[_0x2f48('0x14')](_0x42b69b);};}exports['index']=function(_0x3386ae,_0x2f424c){var _0x48b068={},_0x1601be={},_0x40f4c7={'count':0x0,'rows':[]};var _0x52b1e0=_[_0x2f48('0x15')](db['Dynamics365Account'][_0x2f48('0x16')],function(_0x331a40){return{'name':_0x331a40[_0x2f48('0x17')],'type':_0x331a40[_0x2f48('0x18')][_0x2f48('0x19')]};});_0x1601be[_0x2f48('0x1a')]=_[_0x2f48('0x15')](_0x52b1e0,_0x2f48('0x13'));_0x1601be[_0x2f48('0x1b')]=_[_0x2f48('0x1c')](_0x3386ae[_0x2f48('0x1b')]);_0x1601be[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x1601be[_0x2f48('0x1a')],_0x1601be[_0x2f48('0x1b')]);_0x48b068[_0x2f48('0x1f')]=_[_0x2f48('0x1e')](_0x1601be[_0x2f48('0x1a')],qs['fields'](_0x3386ae[_0x2f48('0x1b')]['fields']));_0x48b068['attributes']=_0x48b068['attributes'][_0x2f48('0x20')]?_0x48b068[_0x2f48('0x1f')]:_0x1601be[_0x2f48('0x1a')];if(!_0x3386ae[_0x2f48('0x1b')]['hasOwnProperty'](_0x2f48('0x21'))){_0x48b068['limit']=qs[_0x2f48('0xc')](_0x3386ae['query'][_0x2f48('0xc')]);_0x48b068[_0x2f48('0xa')]=qs[_0x2f48('0xa')](_0x3386ae[_0x2f48('0x1b')][_0x2f48('0xa')]);}_0x48b068[_0x2f48('0x22')]=qs[_0x2f48('0x23')](_0x3386ae[_0x2f48('0x1b')][_0x2f48('0x23')]);_0x48b068[_0x2f48('0x24')]=qs[_0x2f48('0x1d')](_['pick'](_0x3386ae[_0x2f48('0x1b')],_0x1601be[_0x2f48('0x1d')]),_0x52b1e0);if(_0x3386ae['query']['filter']){_0x48b068[_0x2f48('0x24')]=_['merge'](_0x48b068[_0x2f48('0x24')],{'$or':_['map'](_0x52b1e0,function(_0x2071cb){if(_0x2071cb[_0x2f48('0x18')]!==_0x2f48('0x25')){var _0x53c7da={};_0x53c7da[_0x2071cb[_0x2f48('0x13')]]={'$like':'%'+_0x3386ae[_0x2f48('0x1b')]['filter']+'%'};return _0x53c7da;}})});}_0x48b068=_[_0x2f48('0x26')]({},_0x48b068,_0x3386ae[_0x2f48('0x27')]);var _0x3cd7e8={'where':_0x48b068[_0x2f48('0x24')]};return db[_0x2f48('0x28')][_0x2f48('0x29')](_0x3cd7e8)[_0x2f48('0xf')](function(_0x32d299){_0x40f4c7[_0x2f48('0x29')]=_0x32d299;if(_0x3386ae[_0x2f48('0x1b')][_0x2f48('0x2a')]){_0x48b068[_0x2f48('0x2b')]=[{'all':!![]}];}return db['Dynamics365Account'][_0x2f48('0x2c')](_0x48b068);})[_0x2f48('0xf')](function(_0x257818){_0x40f4c7['rows']=_0x257818;return _0x40f4c7;})[_0x2f48('0xf')](respondWithFilteredResult(_0x2f424c,_0x48b068))[_0x2f48('0x2d')](handleError(_0x2f424c,null));};exports[_0x2f48('0x2e')]=function(_0x84818c,_0x5b98c9){var _0x35cadd={'raw':![],'where':{'id':_0x84818c[_0x2f48('0x2f')]['id']}},_0x52669b={};_0x52669b[_0x2f48('0x1a')]=_[_0x2f48('0x1c')](db['Dynamics365Account'][_0x2f48('0x16')]);_0x52669b['query']=_[_0x2f48('0x1c')](_0x84818c[_0x2f48('0x1b')]);_0x52669b[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x52669b[_0x2f48('0x1a')],_0x52669b[_0x2f48('0x1b')]);_0x35cadd[_0x2f48('0x1f')]=_[_0x2f48('0x1e')](_0x52669b[_0x2f48('0x1a')],qs[_0x2f48('0x30')](_0x84818c[_0x2f48('0x1b')][_0x2f48('0x30')]));_0x35cadd[_0x2f48('0x1f')]=_0x35cadd[_0x2f48('0x1f')]['length']?_0x35cadd[_0x2f48('0x1f')]:_0x52669b[_0x2f48('0x1a')];if(_0x84818c['query']['includeAll']){_0x35cadd[_0x2f48('0x2b')]=[{'all':!![]}];}_0x35cadd=_[_0x2f48('0x26')]({},_0x35cadd,_0x84818c[_0x2f48('0x27')]);return db[_0x2f48('0x28')][_0x2f48('0x31')](_0x35cadd)[_0x2f48('0xf')](handleEntityNotFound(_0x5b98c9,null))[_0x2f48('0xf')](respondWithResult(_0x5b98c9,null))['catch'](handleError(_0x5b98c9,null));};exports[_0x2f48('0x32')]=function(_0x151421,_0x10c7b8){return db[_0x2f48('0x28')][_0x2f48('0x32')](_0x151421['body'],{})[_0x2f48('0xf')](respondWithResult(_0x10c7b8,0xc9))[_0x2f48('0x2d')](handleError(_0x10c7b8,null));};exports[_0x2f48('0xe')]=function(_0x24becd,_0x3bca45){if(_0x24becd[_0x2f48('0x33')]['id']){delete _0x24becd[_0x2f48('0x33')]['id'];}return db[_0x2f48('0x28')][_0x2f48('0x31')]({'where':{'id':_0x24becd['params']['id']}})[_0x2f48('0xf')](handleEntityNotFound(_0x3bca45,null))[_0x2f48('0xf')](saveUpdates(_0x24becd[_0x2f48('0x33')],null))[_0x2f48('0xf')](respondWithResult(_0x3bca45,null))[_0x2f48('0x2d')](handleError(_0x3bca45,null));};exports[_0x2f48('0x34')]=function(_0x2aed38,_0x12d49a){return db[_0x2f48('0x28')][_0x2f48('0x31')]({'where':{'id':_0x2aed38[_0x2f48('0x2f')]['id']}})[_0x2f48('0xf')](handleEntityNotFound(_0x12d49a,null))[_0x2f48('0xf')](removeEntity(_0x12d49a,null))[_0x2f48('0x2d')](handleError(_0x12d49a,null));};exports['getConfigurations']=function(_0x5571aa,_0x1df93c){var _0x23b4ab={};var _0x4fe8e0={};var _0xcac0eb;var _0x32d0ab;return db['Dynamics365Account']['findOne']({'where':{'id':_0x5571aa['params']['id']}})['then'](handleEntityNotFound(_0x1df93c,null))[_0x2f48('0xf')](function(_0x442013){if(_0x442013){_0xcac0eb=_0x442013;_0x4fe8e0[_0x2f48('0x1a')]=_[_0x2f48('0x1c')](db['Dynamics365Configuration'][_0x2f48('0x16')]);_0x4fe8e0[_0x2f48('0x1b')]=_[_0x2f48('0x1c')](_0x5571aa['query']);_0x4fe8e0[_0x2f48('0x1d')]=_[_0x2f48('0x1e')](_0x4fe8e0[_0x2f48('0x1a')],_0x4fe8e0[_0x2f48('0x1b')]);_0x23b4ab['attributes']=_[_0x2f48('0x1e')](_0x4fe8e0[_0x2f48('0x1a')],qs[_0x2f48('0x30')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x30')]));_0x23b4ab[_0x2f48('0x1f')]=_0x23b4ab['attributes']['length']?_0x23b4ab[_0x2f48('0x1f')]:_0x4fe8e0[_0x2f48('0x1a')];_0x23b4ab[_0x2f48('0x22')]=qs[_0x2f48('0x23')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x23')]);_0x23b4ab[_0x2f48('0x24')]=qs[_0x2f48('0x1d')](_[_0x2f48('0x35')](_0x5571aa[_0x2f48('0x1b')],_0x4fe8e0[_0x2f48('0x1d')]));if(_0x5571aa[_0x2f48('0x1b')][_0x2f48('0x36')]){_0x23b4ab['where']=_[_0x2f48('0x26')](_0x23b4ab['where'],{'$or':_[_0x2f48('0x15')](_0x23b4ab['attributes'],function(_0x10412){var _0x1ad537={};_0x1ad537[_0x10412]={'$like':'%'+_0x5571aa['query'][_0x2f48('0x36')]+'%'};return _0x1ad537;})});}_0x23b4ab=_[_0x2f48('0x26')]({},_0x23b4ab,_0x5571aa['options']);return _0xcac0eb[_0x2f48('0x37')](_0x23b4ab);}})['then'](function(_0x25c4d1){if(_0x25c4d1){_0x32d0ab=_0x25c4d1['length'];if(!_0x5571aa['query'][_0x2f48('0x38')](_0x2f48('0x21'))){_0x23b4ab[_0x2f48('0xc')]=qs[_0x2f48('0xc')](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0xc')]);_0x23b4ab[_0x2f48('0xa')]=qs['offset'](_0x5571aa[_0x2f48('0x1b')][_0x2f48('0xa')]);}return _0xcac0eb[_0x2f48('0x37')](_0x23b4ab);}})['then'](function(_0x15606e){if(_0x15606e){return _0x15606e?{'count':_0x32d0ab,'rows':_0x15606e}:null;}})[_0x2f48('0xf')](respondWithResult(_0x1df93c,null))[_0x2f48('0x2d')](handleError(_0x1df93c,null));};exports[_0x2f48('0x39')]=function(_0x509a66,_0x1eb32e){if(_0x509a66['body']['id']){delete _0x509a66['body']['id'];}return db[_0x2f48('0x28')]['findOne']({'where':{'id':_0x509a66['params']['id']}})['then'](handleEntityNotFound(_0x1eb32e,null))[_0x2f48('0xf')](function(_0x39fcd8){if(_0x39fcd8){_0x509a66[_0x2f48('0x33')][_0x2f48('0x3a')]=_0x39fcd8['id'];_0x509a66[_0x2f48('0x33')][_0x2f48('0x3b')]=integrations[_0x2f48('0x3c')](_0x509a66[_0x2f48('0x33')][_0x2f48('0x3d')],_0x509a66['body'][_0x2f48('0x18')]);_0x509a66[_0x2f48('0x33')]['Descriptions']=integrations[_0x2f48('0x3e')](_0x509a66[_0x2f48('0x33')][_0x2f48('0x3d')],_0x509a66[_0x2f48('0x33')][_0x2f48('0x18')]);return db['Dynamics365Configuration'][_0x2f48('0x32')](_0x509a66['body'],{'include':[{'model':db[_0x2f48('0x3f')],'as':_0x2f48('0x3b')},{'model':db[_0x2f48('0x3f')],'as':_0x2f48('0x40')}]});}return null;})[_0x2f48('0xf')](respondWithResult(_0x1eb32e,null))[_0x2f48('0x2d')](handleError(_0x1eb32e,null));};function sanitizeRemoteUri(_0x4c924a){var _0x350e1f=_0x4c924a[_0x2f48('0x41')](-0x1);if(_0x350e1f==='/')return _0x4c924a[_0x2f48('0x42')](0x0,_0x4c924a[_0x2f48('0x43')](_0x350e1f));return _0x4c924a;}function getWebApiUrl(_0x207dbd){return util[_0x2f48('0x44')](_0x2f48('0x45'),_0x207dbd);}exports[_0x2f48('0x46')]=function(_0x11d1d2,_0x4bb1ec){var _0x480b4f=_0x11d1d2['query'][_0x2f48('0x47')];var _0x47628e=_0x480b4f==='incident'?_0x2f48('0x48'):_0x2f48('0x49');var _0x557d26='';var _0x55ca59='';var _0x5629d6='';var _0x1abdf2='';var _0xcba5b6='';var _0x251dfa='';var _0x31b255='';var _0x51bc32='';var _0x457cd4=['title',_0x2f48('0x4a'),'customerid',_0x2f48('0x4b'),_0x2f48('0x4c'),_0x2f48('0x4d'),'phonenumber','regardingobjectid','directioncode',_0x2f48('0x4e')];var _0x3880bc=[_0x2f48('0x4f'),_0x2f48('0x50'),'actualserviceunits',_0x2f48('0x51'),_0x2f48('0x52'),'contactidyominame',_0x2f48('0x53'),_0x2f48('0x54'),_0x2f48('0x55'),_0x2f48('0x56'),'createdbyname',_0x2f48('0x57'),_0x2f48('0x58'),_0x2f48('0x59'),'createdonbehalfbyyominame','customeridname','customeridtype',_0x2f48('0x5a'),_0x2f48('0x5b'),_0x2f48('0x5c'),_0x2f48('0x5d'),_0x2f48('0x5e'),'escalatedon','exchangerate',_0x2f48('0x5f'),'followupby',_0x2f48('0x60'),'influencescore','kbarticleidname',_0x2f48('0x61'),_0x2f48('0x62'),_0x2f48('0x63'),_0x2f48('0x64'),_0x2f48('0x65'),_0x2f48('0x66'),'modifiedon','modifiedonbehalfbyname','modifiedonbehalfbyyominame',_0x2f48('0x67'),_0x2f48('0x68'),_0x2f48('0x69'),_0x2f48('0x6a'),'overriddencreatedon',_0x2f48('0x6b'),_0x2f48('0x6c'),_0x2f48('0x6d'),'parentcaseidname','primarycontactidname',_0x2f48('0x6e'),'prioritycodename',_0x2f48('0x6f'),_0x2f48('0x70'),_0x2f48('0x71'),'resolvebykpiidname',_0x2f48('0x72'),'responsiblecontactidname',_0x2f48('0x73'),_0x2f48('0x74'),_0x2f48('0x75'),_0x2f48('0x76'),_0x2f48('0x77'),_0x2f48('0x78'),_0x2f48('0x79'),'subjectidname',_0x2f48('0x7a'),_0x2f48('0x7b'),_0x2f48('0x7c'),_0x2f48('0x7d'),_0x2f48('0x7e'),_0x2f48('0x7f')];var _0x154e45=_0x457cd4[_0x2f48('0x80')](_0x3880bc);return db[_0x2f48('0x28')][_0x2f48('0x81')]({'where':{'id':_0x11d1d2[_0x2f48('0x2f')]['id']},'attributes':['id',_0x2f48('0x82'),_0x2f48('0x83'),_0x2f48('0x84'),_0x2f48('0x85'),_0x2f48('0x86'),_0x2f48('0x87'),_0x2f48('0x88')],'include':[{'model':db[_0x2f48('0x89')],'as':_0x2f48('0x89'),'attributes':['id',_0x2f48('0x8a'),_0x2f48('0x8b')]}]})[_0x2f48('0xf')](handleEntityNotFound(_0x4bb1ec,null))[_0x2f48('0xf')](function(_0x36b781){if(_0x36b781){if(_0x36b781[_0x2f48('0x88')]){_0x36b781['access_token']=_0x36b781[_0x2f48('0x89')][_0x2f48('0x8a')];_0x51bc32=sanitizeRemoteUri(_0x36b781[_0x2f48('0x89')][_0x2f48('0x8b')]);_0x31b255=getWebApiUrl(_0x51bc32);return _0x36b781;}_0x51bc32=sanitizeRemoteUri(_0x36b781['remoteUri']);_0x31b255=getWebApiUrl(_0x51bc32);var _0x357957={'method':_0x2f48('0x8c'),'uri':_0x2f48('0x8d')+_0x36b781[_0x2f48('0x85')]+_0x2f48('0x8e'),'form':{'client_id':_0x36b781['clientId'],'resource':_0x51bc32,'username':_0x36b781[_0x2f48('0x82')],'password':_0x36b781[_0x2f48('0x83')],'grant_type':_0x2f48('0x83'),'client_secret':_0x36b781[_0x2f48('0x87')]},'json':!![]};return rp(_0x357957);}})[_0x2f48('0xf')](function(_0x183698){_0x251dfa=_0x183698[_0x2f48('0x8f')];var _0x42def7={'method':_0x2f48('0x90'),'uri':encodeURI(_0x31b255+_0x2f48('0x91')+_0x47628e+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x251dfa,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0x42def7);})[_0x2f48('0xf')](function(_0x411294){var _0x4b90a8=_0x411294[_0x2f48('0x93')][0x0];var _0x4f2fce=_0x4b90a8['MetadataId'];var _0xdde592={'method':_0x2f48('0x90'),'uri':_0x31b255+_0x2f48('0x94')+_0x4f2fce+_0x2f48('0x95'),'headers':{'Authorization':_0x2f48('0x96')+_0x251dfa,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0xdde592);})[_0x2f48('0xf')](function(_0x20dd57){_0x557d26=_0x20dd57;_0x55ca59=_0x557d26[_0x2f48('0x97')];_0x55ca59=_[_0x2f48('0x98')](_0x55ca59,function(_0x3a23d9){return!_0x154e45['includes'](_0x3a23d9[_0x2f48('0x99')]);});var _0x1e3272=[];var _0x439c12=[];_0x55ca59[_0x2f48('0x9a')](function(_0x3a49f2){if(_0x3a49f2['@odata.type']){var _0x58f239=_0x3a49f2[_0x2f48('0x9b')][_0x2f48('0x42')](_0x3a49f2['@odata.type'][_0x2f48('0x43')]('.')+0x1);if(_0x58f239===_0x2f48('0x9c')){_0x1e3272['push'](getSelectList(_0x31b255,_0x480b4f,_0x439c12,_0x557d26[_0x2f48('0x9d')],_0x3a49f2['MetadataId'],_0x251dfa));}}});return Promise[_0x2f48('0x9e')](_0x1e3272);})[_0x2f48('0xf')](function(_0x5b1c11){_0x5629d6=_0x5b1c11[0x0];var _0x1d2b7c=[];var _0x55079a=[];_0x55ca59['forEach'](function(_0x35ab5e){if(!_[_0x2f48('0x9f')](_0x35ab5e['@odata.type'])){var _0x1f6ff3=_0x35ab5e['@odata.type']['substring'](_0x35ab5e['@odata.type'][_0x2f48('0x43')]('.')+0x1);if(_0x1f6ff3==='BooleanAttributeMetadata'){_0x1d2b7c[_0x2f48('0xa0')](getBooleanList(_0x31b255,_0x480b4f,_0x55079a,_0x557d26[_0x2f48('0x9d')],_0x35ab5e[_0x2f48('0x9d')],_0x251dfa));}}});return Promise['all'](_0x1d2b7c);})['then'](function(_0x574b1c){_0x1abdf2=_0x574b1c[0x0];var _0x58f517=[];var _0x58726a=[];_0x55ca59[_0x2f48('0x9a')](function(_0x1b02e4){if(_0x1b02e4[_0x2f48('0x9b')]){var _0x84c0a2=_0x1b02e4['@odata.type'][_0x2f48('0x42')](_0x1b02e4[_0x2f48('0x9b')]['lastIndexOf']('.')+0x1);if(_0x84c0a2===_0x2f48('0xa1')||_0x84c0a2==='DoubleAttributeMetadata'||_0x84c0a2===_0x2f48('0xa2')||_0x84c0a2===_0x2f48('0xa3')||_0x84c0a2===_0x2f48('0xa4')||_0x84c0a2==='DateTimeAttributeMetadata'||_0x84c0a2==='StatusAttributeMetadata'||_0x84c0a2===_0x2f48('0xa5')||_0x84c0a2===_0x2f48('0xa6')||_0x84c0a2===_0x2f48('0xa7')){_0x58f517['push'](getInputList(_0x31b255,_0x480b4f,_0x84c0a2,_0x58726a,_0x557d26[_0x2f48('0x9d')],_0x1b02e4[_0x2f48('0x9d')],_0x251dfa));}}});return Promise[_0x2f48('0x9e')](_0x58f517);})[_0x2f48('0xf')](function(_0x397d05){_0xcba5b6=_0x397d05[0x0];var _0x31d275=_0x5629d6[_0x2f48('0x80')](_0x1abdf2)[_0x2f48('0x80')](_0xcba5b6);var _0x73491a={'count':_0x31d275['length'],'rows':_0x31d275};return _0x73491a;})[_0x2f48('0xf')](respondWithResult(_0x4bb1ec,null))[_0x2f48('0x2d')](function(_0x248d46){var _0x58eb88=_0x11d1d2[_0x2f48('0x1b')][_0x2f48('0xa8')]?0x1f4:_0x248d46['statusCode']||0x1f4;logger[_0x2f48('0x11')](_0x248d46['stack']);delete _0x248d46['name'];if(_0x58eb88===0x191){_0x58eb88=0x190;}_0x4bb1ec[_0x2f48('0x8')](_0x58eb88)[_0x2f48('0x14')](_0x11d1d2['query'][_0x2f48('0xa8')]?{'message':'Wrong\x20credentials','statusCode':_0x248d46['statusCode']}:_0x248d46);});};function getSelectList(_0x5cf04a,_0x21adf9,_0x16c71b,_0x3ea445,_0x5bc483,_0x4dfbb6){var _0x5a1c54={'method':_0x2f48('0x90'),'uri':_0x5cf04a+_0x2f48('0x94')+_0x3ea445+_0x2f48('0xa9')+_0x5bc483+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+_0x2f48('0xaa'),'headers':{'Authorization':'Bearer\x20'+_0x4dfbb6,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x5a1c54)[_0x2f48('0xf')](function(_0x35bc4c){var _0x152491=[];var _0x53c9fc=_0x35bc4c[_0x2f48('0xab')][_0x2f48('0xac')];_0x53c9fc['forEach'](function(_0x21b6b3){_0x152491[_0x2f48('0xa0')]({'name':_0x21b6b3[_0x2f48('0xad')]['UserLocalizedLabel']['Label'],'value':String(_0x21b6b3['Value'])});});var _0x3f817e={'id':_0x21adf9+'_'+_0x35bc4c[_0x2f48('0x99')],'name':_0x35bc4c['DisplayName']['UserLocalizedLabel'][_0x2f48('0xad')],'custom':![],'options':_0x152491};_0x16c71b[_0x2f48('0xa0')](_0x3f817e);return _0x16c71b;});}function getBooleanList(_0x52a33a,_0x30ff0d,_0x1b4c15,_0x3cf15f,_0x488a8b,_0x4497b2){var _0x4371dd={'method':'GET','uri':_0x52a33a+_0x2f48('0x94')+_0x3cf15f+_0x2f48('0xa9')+_0x488a8b+_0x2f48('0xae'),'headers':{'Authorization':_0x2f48('0x96')+_0x4497b2,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x4371dd)[_0x2f48('0xf')](function(_0x216b05){var _0x7456ab=[];_0x7456ab[_0x2f48('0xa0')]({'name':_0x216b05[_0x2f48('0xab')]['TrueOption'][_0x2f48('0xad')][_0x2f48('0xaf')][_0x2f48('0xad')],'value':'true'},{'name':_0x216b05[_0x2f48('0xab')][_0x2f48('0xb0')][_0x2f48('0xad')][_0x2f48('0xaf')][_0x2f48('0xad')],'value':_0x2f48('0xb1')});var _0xa3860b={'id':_0x30ff0d+'_'+_0x216b05[_0x2f48('0x99')],'name':_0x216b05[_0x2f48('0xb2')][_0x2f48('0xaf')][_0x2f48('0xad')],'custom':![],'options':_0x7456ab};_0x1b4c15[_0x2f48('0xa0')](_0xa3860b);return _0x1b4c15;});}function getInputList(_0x12a84c,_0x2dc675,_0x48b8b4,_0x107209,_0x580466,_0x4d1f92,_0x537685){var _0x284b46={'method':_0x2f48('0x90'),'uri':_0x12a84c+_0x2f48('0x94')+_0x580466+_0x2f48('0xa9')+_0x4d1f92+')/Microsoft.Dynamics.CRM.'+_0x48b8b4+_0x2f48('0xb3'),'headers':{'Authorization':_0x2f48('0x96')+_0x537685,'If-None-Match':null,'OData-Version':_0x2f48('0x92')},'json':!![]};return rp(_0x284b46)[_0x2f48('0xf')](function(_0xa7d8da){var _0x4fa45={'id':_0x2dc675+'_'+_0xa7d8da[_0x2f48('0x99')],'name':_0xa7d8da['DisplayName'][_0x2f48('0xaf')]?_0xa7d8da[_0x2f48('0xb2')][_0x2f48('0xaf')][_0x2f48('0xad')]:_0xa7d8da[_0x2f48('0x99')],'custom':![],'options':[]};_0x107209['push'](_0x4fa45);return _0x107209;});}
\ No newline at end of file
+var _0x116c=[')/Attributes(','OptionSet','Options','Label','UserLocalizedLabel','DisplayName',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','TrueOption','true','FalseOption','LogicalName',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../components/parsers/qs','../../config/logger','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','end','stack','name','send','index','map','Dynamics365Account','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','findAll','rows','catch','params','includeAll','include','create','body','find','findOne','Dynamics365Configuration','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','format','%s/api/data/v9.0/','getFields','ticketType','incident','Incident','PhoneCall','customerid','ownerid','caseorigincode','subject','phonenumber','regardingobjectid','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contractdetailidname','contractidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdonbehalfbyname','createdonbehalfbyyominame','customeridname','customeridtype','entitlementidname','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','followupby','importsequencenumber','influencescore','lastonholdtime','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedonbehalfbyname','msdyn_incidenttypename','msdyn_iotalertname','numberofchildincidents','overriddencreatedon','owneridtype','parentcaseidname','primarycontactidname','primarycontactidyominame','prioritycodename','productidname','resolveby','resolvebykpiidname','responseby','responsiblecontactidname','responsiblecontactidyominame','sentimentvalue','slainvokedidname','slaname','socialprofileidname','statuscode','subjectidname','timezoneruleversionnumber','transactioncurrencyidname','utcconversiontimezonecode','versionnumber','concat','username','password','remoteUri','tenantId','clientId','clientSecret','CloudProvider','data5','data7','modernAuthentication','https://login.microsoftonline.com/','/oauth2/token','access_token','GET','EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27','value','MetadataId','EntityDefinitions(',')?$select=LogicalName&$expand=Attributes($select=LogicalName)','Bearer\x20','4.0','includes','@odata.type','substring','lastIndexOf','push','all','forEach','isNil','BooleanAttributeMetadata','StringAttributeMetadata','DoubleAttributeMetadata','BigIntAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','test','statusCode'];(function(_0x2c8ab9,_0x496b5b){var _0x5c1675=function(_0xe6c13a){while(--_0xe6c13a){_0x2c8ab9['push'](_0x2c8ab9['shift']());}};_0x5c1675(++_0x496b5b);}(_0x116c,0xca));var _0xc116=function(_0x3c0776,_0x14ac3b){_0x3c0776=_0x3c0776-0x0;var _0x2ab1e0=_0x116c[_0x3c0776];return _0x2ab1e0;};'use strict';var rp=require(_0xc116('0x0'));var util=require(_0xc116('0x1'));var _=require(_0xc116('0x2'));var qs=require(_0xc116('0x3'));var logger=require(_0xc116('0x4'))('api');var db=require(_0xc116('0x5'))['db'];var integrations=require(_0xc116('0x6'));function respondWithResult(_0x4c0496,_0x6e40c2){_0x6e40c2=_0x6e40c2||0xc8;return function(_0x290b61){if(_0x290b61){return _0x4c0496[_0xc116('0x7')](_0x6e40c2)[_0xc116('0x8')](_0x290b61);}};}function respondWithFilteredResult(_0x5950a1,_0x45ab9f){return function(_0x157cbc){if(_0x157cbc){var _0x5ab26f=typeof _0x45ab9f[_0xc116('0x9')]===_0xc116('0xa')&&typeof _0x45ab9f[_0xc116('0xb')]===_0xc116('0xa');var _0x23ad9d=_0x157cbc[_0xc116('0xc')];var _0x551e2e=_0x5ab26f?0x0:_0x45ab9f[_0xc116('0x9')];var _0x2520ca=_0x5ab26f?_0x157cbc[_0xc116('0xc')]:_0x45ab9f[_0xc116('0x9')]+_0x45ab9f['limit'];var _0x3e3e39;if(_0x2520ca>=_0x23ad9d){_0x2520ca=_0x23ad9d;_0x3e3e39=0xc8;}else{_0x3e3e39=0xce;}_0x5950a1[_0xc116('0x7')](_0x3e3e39);return _0x5950a1[_0xc116('0xd')](_0xc116('0xe'),_0x551e2e+'-'+_0x2520ca+'/'+_0x23ad9d)[_0xc116('0x8')](_0x157cbc);}return null;};}function saveUpdates(_0x2fc414){return function(_0x5e6ed7){if(_0x5e6ed7){return _0x5e6ed7[_0xc116('0xf')](_0x2fc414)[_0xc116('0x10')](function(_0xd0e7fa){return _0xd0e7fa;});}return null;};}function removeEntity(_0x2fa664){return function(_0x5a8ba7){if(_0x5a8ba7){return _0x5a8ba7[_0xc116('0x11')]()[_0xc116('0x10')](function(){_0x2fa664[_0xc116('0x7')](0xcc)[_0xc116('0x12')]();});}};}function handleEntityNotFound(_0x4a4928){return function(_0x99396d){if(!_0x99396d){_0x4a4928['sendStatus'](0x194);}return _0x99396d;};}function handleError(_0x4fc377,_0x5cdca8){_0x5cdca8=_0x5cdca8||0x1f4;return function(_0x3ded70){logger['error'](_0x3ded70[_0xc116('0x13')]);if(_0x3ded70[_0xc116('0x14')]){delete _0x3ded70[_0xc116('0x14')];}_0x4fc377['status'](_0x5cdca8)[_0xc116('0x15')](_0x3ded70);};}exports[_0xc116('0x16')]=function(_0x5309c5,_0x3c384a){var _0x5092c1={},_0x18a241={},_0x1fe055={'count':0x0,'rows':[]};var _0x3a9d32=_[_0xc116('0x17')](db[_0xc116('0x18')][_0xc116('0x19')],function(_0x520c8a){return{'name':_0x520c8a['fieldName'],'type':_0x520c8a[_0xc116('0x1a')][_0xc116('0x1b')]};});_0x18a241[_0xc116('0x1c')]=_[_0xc116('0x17')](_0x3a9d32,'name');_0x18a241[_0xc116('0x1d')]=_[_0xc116('0x1e')](_0x5309c5[_0xc116('0x1d')]);_0x18a241[_0xc116('0x1f')]=_[_0xc116('0x20')](_0x18a241[_0xc116('0x1c')],_0x18a241[_0xc116('0x1d')]);_0x5092c1[_0xc116('0x21')]=_[_0xc116('0x20')](_0x18a241[_0xc116('0x1c')],qs[_0xc116('0x22')](_0x5309c5[_0xc116('0x1d')][_0xc116('0x22')]));_0x5092c1[_0xc116('0x21')]=_0x5092c1[_0xc116('0x21')][_0xc116('0x23')]?_0x5092c1[_0xc116('0x21')]:_0x18a241['model'];if(!_0x5309c5[_0xc116('0x1d')][_0xc116('0x24')](_0xc116('0x25'))){_0x5092c1[_0xc116('0xb')]=qs[_0xc116('0xb')](_0x5309c5[_0xc116('0x1d')][_0xc116('0xb')]);_0x5092c1[_0xc116('0x9')]=qs[_0xc116('0x9')](_0x5309c5[_0xc116('0x1d')][_0xc116('0x9')]);}_0x5092c1[_0xc116('0x26')]=qs['sort'](_0x5309c5[_0xc116('0x1d')][_0xc116('0x27')]);_0x5092c1[_0xc116('0x28')]=qs[_0xc116('0x1f')](_[_0xc116('0x29')](_0x5309c5[_0xc116('0x1d')],_0x18a241[_0xc116('0x1f')]),_0x3a9d32);if(_0x5309c5[_0xc116('0x1d')]['filter']){_0x5092c1[_0xc116('0x28')]=_[_0xc116('0x2a')](_0x5092c1[_0xc116('0x28')],{'$or':_['map'](_0x3a9d32,function(_0x40db2e){if(_0x40db2e[_0xc116('0x1a')]!==_0xc116('0x2b')){var _0x2cc4c0={};_0x2cc4c0[_0x40db2e[_0xc116('0x14')]]={'$like':'%'+_0x5309c5[_0xc116('0x1d')][_0xc116('0x2c')]+'%'};return _0x2cc4c0;}})});}_0x5092c1=_[_0xc116('0x2a')]({},_0x5092c1,_0x5309c5[_0xc116('0x2d')]);var _0x57f1d6={'where':_0x5092c1[_0xc116('0x28')]};return db[_0xc116('0x18')]['count'](_0x57f1d6)[_0xc116('0x10')](function(_0x2f7f2a){_0x1fe055['count']=_0x2f7f2a;if(_0x5309c5[_0xc116('0x1d')]['includeAll']){_0x5092c1['include']=[{'all':!![]}];}return db[_0xc116('0x18')][_0xc116('0x2e')](_0x5092c1);})[_0xc116('0x10')](function(_0x349b11){_0x1fe055[_0xc116('0x2f')]=_0x349b11;return _0x1fe055;})[_0xc116('0x10')](respondWithFilteredResult(_0x3c384a,_0x5092c1))[_0xc116('0x30')](handleError(_0x3c384a,null));};exports['show']=function(_0x3a45aa,_0x56b1f){var _0x104437={'raw':![],'where':{'id':_0x3a45aa[_0xc116('0x31')]['id']}},_0x1ed267={};_0x1ed267['model']=_['keys'](db[_0xc116('0x18')][_0xc116('0x19')]);_0x1ed267[_0xc116('0x1d')]=_[_0xc116('0x1e')](_0x3a45aa[_0xc116('0x1d')]);_0x1ed267[_0xc116('0x1f')]=_[_0xc116('0x20')](_0x1ed267[_0xc116('0x1c')],_0x1ed267[_0xc116('0x1d')]);_0x104437[_0xc116('0x21')]=_[_0xc116('0x20')](_0x1ed267[_0xc116('0x1c')],qs['fields'](_0x3a45aa[_0xc116('0x1d')][_0xc116('0x22')]));_0x104437[_0xc116('0x21')]=_0x104437[_0xc116('0x21')][_0xc116('0x23')]?_0x104437[_0xc116('0x21')]:_0x1ed267[_0xc116('0x1c')];if(_0x3a45aa[_0xc116('0x1d')][_0xc116('0x32')]){_0x104437[_0xc116('0x33')]=[{'all':!![]}];}_0x104437=_['merge']({},_0x104437,_0x3a45aa[_0xc116('0x2d')]);return db[_0xc116('0x18')]['find'](_0x104437)[_0xc116('0x10')](handleEntityNotFound(_0x56b1f,null))[_0xc116('0x10')](respondWithResult(_0x56b1f,null))[_0xc116('0x30')](handleError(_0x56b1f,null));};exports[_0xc116('0x34')]=function(_0x514c75,_0x1c0bcf){return db[_0xc116('0x18')][_0xc116('0x34')](_0x514c75[_0xc116('0x35')],{})[_0xc116('0x10')](respondWithResult(_0x1c0bcf,0xc9))[_0xc116('0x30')](handleError(_0x1c0bcf,null));};exports['update']=function(_0x2edb59,_0x1d6565){if(_0x2edb59[_0xc116('0x35')]['id']){delete _0x2edb59[_0xc116('0x35')]['id'];}return db['Dynamics365Account'][_0xc116('0x36')]({'where':{'id':_0x2edb59[_0xc116('0x31')]['id']}})[_0xc116('0x10')](handleEntityNotFound(_0x1d6565,null))[_0xc116('0x10')](saveUpdates(_0x2edb59[_0xc116('0x35')],null))[_0xc116('0x10')](respondWithResult(_0x1d6565,null))['catch'](handleError(_0x1d6565,null));};exports[_0xc116('0x11')]=function(_0x7f3fd5,_0x23e077){return db['Dynamics365Account'][_0xc116('0x36')]({'where':{'id':_0x7f3fd5[_0xc116('0x31')]['id']}})[_0xc116('0x10')](handleEntityNotFound(_0x23e077,null))[_0xc116('0x10')](removeEntity(_0x23e077,null))[_0xc116('0x30')](handleError(_0x23e077,null));};exports['getConfigurations']=function(_0x1ce820,_0x1b4d31){var _0x3ae0d6={};var _0x502706={};var _0x1b2275;var _0x4a0ecb;return db[_0xc116('0x18')][_0xc116('0x37')]({'where':{'id':_0x1ce820[_0xc116('0x31')]['id']}})[_0xc116('0x10')](handleEntityNotFound(_0x1b4d31,null))[_0xc116('0x10')](function(_0x1d85c5){if(_0x1d85c5){_0x1b2275=_0x1d85c5;_0x502706['model']=_[_0xc116('0x1e')](db[_0xc116('0x38')][_0xc116('0x19')]);_0x502706['query']=_[_0xc116('0x1e')](_0x1ce820['query']);_0x502706[_0xc116('0x1f')]=_[_0xc116('0x20')](_0x502706[_0xc116('0x1c')],_0x502706['query']);_0x3ae0d6[_0xc116('0x21')]=_[_0xc116('0x20')](_0x502706[_0xc116('0x1c')],qs[_0xc116('0x22')](_0x1ce820[_0xc116('0x1d')]['fields']));_0x3ae0d6[_0xc116('0x21')]=_0x3ae0d6[_0xc116('0x21')][_0xc116('0x23')]?_0x3ae0d6[_0xc116('0x21')]:_0x502706[_0xc116('0x1c')];_0x3ae0d6[_0xc116('0x26')]=qs[_0xc116('0x27')](_0x1ce820[_0xc116('0x1d')]['sort']);_0x3ae0d6[_0xc116('0x28')]=qs[_0xc116('0x1f')](_[_0xc116('0x29')](_0x1ce820[_0xc116('0x1d')],_0x502706[_0xc116('0x1f')]));if(_0x1ce820[_0xc116('0x1d')][_0xc116('0x2c')]){_0x3ae0d6['where']=_[_0xc116('0x2a')](_0x3ae0d6[_0xc116('0x28')],{'$or':_[_0xc116('0x17')](_0x3ae0d6[_0xc116('0x21')],function(_0x36fa77){var _0x43783f={};_0x43783f[_0x36fa77]={'$like':'%'+_0x1ce820[_0xc116('0x1d')][_0xc116('0x2c')]+'%'};return _0x43783f;})});}_0x3ae0d6=_['merge']({},_0x3ae0d6,_0x1ce820[_0xc116('0x2d')]);return _0x1b2275[_0xc116('0x39')](_0x3ae0d6);}})[_0xc116('0x10')](function(_0x5226da){if(_0x5226da){_0x4a0ecb=_0x5226da['length'];if(!_0x1ce820[_0xc116('0x1d')][_0xc116('0x24')](_0xc116('0x25'))){_0x3ae0d6[_0xc116('0xb')]=qs[_0xc116('0xb')](_0x1ce820[_0xc116('0x1d')][_0xc116('0xb')]);_0x3ae0d6[_0xc116('0x9')]=qs['offset'](_0x1ce820['query'][_0xc116('0x9')]);}return _0x1b2275['getConfigurations'](_0x3ae0d6);}})[_0xc116('0x10')](function(_0x183508){if(_0x183508){return _0x183508?{'count':_0x4a0ecb,'rows':_0x183508}:null;}})[_0xc116('0x10')](respondWithResult(_0x1b4d31,null))[_0xc116('0x30')](handleError(_0x1b4d31,null));};exports[_0xc116('0x3a')]=function(_0x376774,_0x482ad7){if(_0x376774['body']['id']){delete _0x376774[_0xc116('0x35')]['id'];}return db[_0xc116('0x18')]['findOne']({'where':{'id':_0x376774['params']['id']}})[_0xc116('0x10')](handleEntityNotFound(_0x482ad7,null))['then'](function(_0x5078df){if(_0x5078df){_0x376774[_0xc116('0x35')][_0xc116('0x3b')]=_0x5078df['id'];_0x376774[_0xc116('0x35')][_0xc116('0x3c')]=integrations[_0xc116('0x3d')](_0x376774[_0xc116('0x35')][_0xc116('0x3e')],_0x376774[_0xc116('0x35')][_0xc116('0x1a')]);_0x376774[_0xc116('0x35')]['Descriptions']=integrations[_0xc116('0x3f')](_0x376774[_0xc116('0x35')][_0xc116('0x3e')],_0x376774[_0xc116('0x35')][_0xc116('0x1a')]);return db[_0xc116('0x38')][_0xc116('0x34')](_0x376774[_0xc116('0x35')],{'include':[{'model':db[_0xc116('0x40')],'as':'Subjects'},{'model':db['Dynamics365Field'],'as':_0xc116('0x41')}]});}return null;})[_0xc116('0x10')](respondWithResult(_0x482ad7,null))['catch'](handleError(_0x482ad7,null));};function sanitizeRemoteUri(_0x2fb15c){var _0x5d75f7=_0x2fb15c[_0xc116('0x42')](-0x1);if(_0x5d75f7==='/')return _0x2fb15c['substring'](0x0,_0x2fb15c['lastIndexOf'](_0x5d75f7));return _0x2fb15c;}function getWebApiUrl(_0x1b6ab9){return util[_0xc116('0x43')](_0xc116('0x44'),_0x1b6ab9);}exports[_0xc116('0x45')]=function(_0x58259b,_0x3c4f12){var _0x3c9d5b=_0x58259b[_0xc116('0x1d')][_0xc116('0x46')];var _0x321d40=_0x3c9d5b===_0xc116('0x47')?_0xc116('0x48'):_0xc116('0x49');var _0xdb1546='';var _0x335e76='';var _0x51fb2c='';var _0x3729f7='';var _0x2e24d7='';var _0x46f72e='';var _0xa07abf='';var _0x424cbc='';var _0xd2a6b6=['title','description',_0xc116('0x4a'),_0xc116('0x4b'),_0xc116('0x4c'),_0xc116('0x4d'),_0xc116('0x4e'),_0xc116('0x4f'),_0xc116('0x50'),_0xc116('0x51')];var _0x3c4dee=[_0xc116('0x52'),_0xc116('0x53'),_0xc116('0x54'),_0xc116('0x55'),_0xc116('0x56'),'contactidyominame',_0xc116('0x57'),_0xc116('0x58'),_0xc116('0x59'),_0xc116('0x5a'),_0xc116('0x5b'),_0xc116('0x5c'),'createdon',_0xc116('0x5d'),_0xc116('0x5e'),_0xc116('0x5f'),_0xc116('0x60'),'customeridyominame','emailaddress',_0xc116('0x61'),_0xc116('0x62'),_0xc116('0x63'),_0xc116('0x64'),_0xc116('0x65'),_0xc116('0x66'),_0xc116('0x67'),_0xc116('0x68'),_0xc116('0x69'),'kbarticleidname',_0xc116('0x6a'),'masteridname',_0xc116('0x6b'),_0xc116('0x6c'),_0xc116('0x6d'),'modifiedbyyominame','modifiedon',_0xc116('0x6e'),'modifiedonbehalfbyyominame',_0xc116('0x6f'),_0xc116('0x70'),_0xc116('0x71'),'onholdtime',_0xc116('0x72'),'owneridname',_0xc116('0x73'),'owneridyominame',_0xc116('0x74'),_0xc116('0x75'),_0xc116('0x76'),_0xc116('0x77'),_0xc116('0x78'),'productserialnumber',_0xc116('0x79'),_0xc116('0x7a'),_0xc116('0x7b'),_0xc116('0x7c'),_0xc116('0x7d'),_0xc116('0x7e'),_0xc116('0x7f'),_0xc116('0x80'),_0xc116('0x81'),'statecode',_0xc116('0x82'),_0xc116('0x83'),'ticketnumber',_0xc116('0x84'),_0xc116('0x85'),'traversedpath',_0xc116('0x86'),_0xc116('0x87')];var _0x4c58b4=_0xd2a6b6[_0xc116('0x88')](_0x3c4dee);return db[_0xc116('0x18')]['findOne']({'where':{'id':_0x58259b['params']['id']},'attributes':['id',_0xc116('0x89'),_0xc116('0x8a'),_0xc116('0x8b'),_0xc116('0x8c'),_0xc116('0x8d'),_0xc116('0x8e'),'modernAuthentication'],'include':[{'model':db[_0xc116('0x8f')],'as':_0xc116('0x8f'),'attributes':['id',_0xc116('0x90'),_0xc116('0x91')]}]})[_0xc116('0x10')](handleEntityNotFound(_0x3c4f12,null))[_0xc116('0x10')](function(_0x2cdc7f){if(_0x2cdc7f){if(_0x2cdc7f[_0xc116('0x92')]){_0x2cdc7f['access_token']=_0x2cdc7f[_0xc116('0x8f')][_0xc116('0x90')];_0x424cbc=sanitizeRemoteUri(_0x2cdc7f[_0xc116('0x8f')][_0xc116('0x91')]);_0xa07abf=getWebApiUrl(_0x424cbc);return _0x2cdc7f;}_0x424cbc=sanitizeRemoteUri(_0x2cdc7f[_0xc116('0x8b')]);_0xa07abf=getWebApiUrl(_0x424cbc);var _0x51b9a8={'method':'POST','uri':_0xc116('0x93')+_0x2cdc7f['tenantId']+_0xc116('0x94'),'form':{'client_id':_0x2cdc7f['clientId'],'resource':_0x424cbc,'username':_0x2cdc7f['username'],'password':_0x2cdc7f[_0xc116('0x8a')],'grant_type':_0xc116('0x8a'),'client_secret':_0x2cdc7f['clientSecret']},'json':!![]};return rp(_0x51b9a8);}})[_0xc116('0x10')](function(_0x2b9864){_0x46f72e=_0x2b9864[_0xc116('0x95')];var _0x3937e6={'method':_0xc116('0x96'),'uri':encodeURI(_0xa07abf+_0xc116('0x97')+_0x321d40+'\x27'),'headers':{'Authorization':'Bearer\x20'+_0x46f72e,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x3937e6);})[_0xc116('0x10')](function(_0x2cb121){var _0xe2a946=_0x2cb121[_0xc116('0x98')][0x0];var _0x3b0986=_0xe2a946[_0xc116('0x99')];var _0x52d7cd={'method':'GET','uri':_0xa07abf+_0xc116('0x9a')+_0x3b0986+_0xc116('0x9b'),'headers':{'Authorization':_0xc116('0x9c')+_0x46f72e,'If-None-Match':null,'OData-Version':_0xc116('0x9d')},'json':!![]};return rp(_0x52d7cd);})['then'](function(_0xeb91d6){_0xdb1546=_0xeb91d6;_0x335e76=_0xdb1546['Attributes'];_0x335e76=_['remove'](_0x335e76,function(_0x17f54c){return!_0x4c58b4[_0xc116('0x9e')](_0x17f54c['LogicalName']);});var _0x54c0cd=[];var _0x20117f=[];_0x335e76['forEach'](function(_0x418589){if(_0x418589[_0xc116('0x9f')]){var _0x3e5e7e=_0x418589[_0xc116('0x9f')][_0xc116('0xa0')](_0x418589[_0xc116('0x9f')][_0xc116('0xa1')]('.')+0x1);if(_0x3e5e7e==='PicklistAttributeMetadata'){_0x54c0cd[_0xc116('0xa2')](getSelectList(_0xa07abf,_0x3c9d5b,_0x20117f,_0xdb1546[_0xc116('0x99')],_0x418589[_0xc116('0x99')],_0x46f72e));}}});return Promise[_0xc116('0xa3')](_0x54c0cd);})['then'](function(_0x583485){_0x51fb2c=_0x583485[0x0];var _0x1633e8=[];var _0x466d1c=[];_0x335e76[_0xc116('0xa4')](function(_0x42fda1){if(!_[_0xc116('0xa5')](_0x42fda1[_0xc116('0x9f')])){var _0x48565b=_0x42fda1[_0xc116('0x9f')]['substring'](_0x42fda1[_0xc116('0x9f')]['lastIndexOf']('.')+0x1);if(_0x48565b===_0xc116('0xa6')){_0x1633e8[_0xc116('0xa2')](getBooleanList(_0xa07abf,_0x3c9d5b,_0x466d1c,_0xdb1546[_0xc116('0x99')],_0x42fda1[_0xc116('0x99')],_0x46f72e));}}});return Promise[_0xc116('0xa3')](_0x1633e8);})['then'](function(_0x517d7c){_0x3729f7=_0x517d7c[0x0];var _0x58572f=[];var _0x166af7=[];_0x335e76[_0xc116('0xa4')](function(_0x5e717e){if(_0x5e717e[_0xc116('0x9f')]){var _0x301963=_0x5e717e[_0xc116('0x9f')][_0xc116('0xa0')](_0x5e717e[_0xc116('0x9f')]['lastIndexOf']('.')+0x1);if(_0x301963===_0xc116('0xa7')||_0x301963===_0xc116('0xa8')||_0x301963===_0xc116('0xa9')||_0x301963==='IntegerAttributeMetadata'||_0x301963===_0xc116('0xaa')||_0x301963===_0xc116('0xab')||_0x301963==='StatusAttributeMetadata'||_0x301963===_0xc116('0xac')||_0x301963===_0xc116('0xad')||_0x301963==='DecimalAttributeMetadata'){_0x58572f[_0xc116('0xa2')](getInputList(_0xa07abf,_0x3c9d5b,_0x301963,_0x166af7,_0xdb1546['MetadataId'],_0x5e717e[_0xc116('0x99')],_0x46f72e));}}});return Promise['all'](_0x58572f);})[_0xc116('0x10')](function(_0x2f855d){_0x2e24d7=_0x2f855d[0x0];var _0x35fcff=_0x51fb2c[_0xc116('0x88')](_0x3729f7)['concat'](_0x2e24d7);var _0x30269e={'count':_0x35fcff['length'],'rows':_0x35fcff};return _0x30269e;})[_0xc116('0x10')](respondWithResult(_0x3c4f12,null))[_0xc116('0x30')](function(_0x10c61d){var _0x1ba24a=_0x58259b[_0xc116('0x1d')][_0xc116('0xae')]?0x1f4:_0x10c61d['statusCode']||0x1f4;logger['error'](_0x10c61d[_0xc116('0x13')]);delete _0x10c61d[_0xc116('0x14')];if(_0x1ba24a===0x191){_0x1ba24a=0x190;}_0x3c4f12[_0xc116('0x7')](_0x1ba24a)[_0xc116('0x15')](_0x58259b['query'][_0xc116('0xae')]?{'message':'Wrong\x20credentials','statusCode':_0x10c61d[_0xc116('0xaf')]}:_0x10c61d);});};function getSelectList(_0xc927ad,_0x234ca9,_0x541383,_0x502699,_0x291e0b,_0x25ad8f){var _0x657177={'method':_0xc116('0x96'),'uri':_0xc927ad+'EntityDefinitions('+_0x502699+_0xc116('0xb0')+_0x291e0b+')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?'+'$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','headers':{'Authorization':_0xc116('0x9c')+_0x25ad8f,'If-None-Match':null,'OData-Version':_0xc116('0x9d')},'json':!![]};return rp(_0x657177)['then'](function(_0x18925d){var _0x402ba3=[];var _0x4410e5=_0x18925d[_0xc116('0xb1')][_0xc116('0xb2')];_0x4410e5[_0xc116('0xa4')](function(_0x349d4f){_0x402ba3[_0xc116('0xa2')]({'name':_0x349d4f[_0xc116('0xb3')][_0xc116('0xb4')]['Label'],'value':String(_0x349d4f['Value'])});});var _0x2a9be9={'id':_0x234ca9+'_'+_0x18925d['LogicalName'],'name':_0x18925d[_0xc116('0xb5')]['UserLocalizedLabel'][_0xc116('0xb3')],'custom':![],'options':_0x402ba3};_0x541383[_0xc116('0xa2')](_0x2a9be9);return _0x541383;});}function getBooleanList(_0x5f1ef8,_0x3a8526,_0x4c0825,_0x299c7c,_0x384e1e,_0x23d606){var _0x49c5b0={'method':_0xc116('0x96'),'uri':_0x5f1ef8+_0xc116('0x9a')+_0x299c7c+')/Attributes('+_0x384e1e+_0xc116('0xb6'),'headers':{'Authorization':_0xc116('0x9c')+_0x23d606,'If-None-Match':null,'OData-Version':_0xc116('0x9d')},'json':!![]};return rp(_0x49c5b0)[_0xc116('0x10')](function(_0x41f4bd){var _0x473846=[];_0x473846[_0xc116('0xa2')]({'name':_0x41f4bd['OptionSet'][_0xc116('0xb7')]['Label'][_0xc116('0xb4')][_0xc116('0xb3')],'value':_0xc116('0xb8')},{'name':_0x41f4bd['OptionSet'][_0xc116('0xb9')]['Label'][_0xc116('0xb4')][_0xc116('0xb3')],'value':'false'});var _0x3c3273={'id':_0x3a8526+'_'+_0x41f4bd[_0xc116('0xba')],'name':_0x41f4bd['DisplayName'][_0xc116('0xb4')][_0xc116('0xb3')],'custom':![],'options':_0x473846};_0x4c0825[_0xc116('0xa2')](_0x3c3273);return _0x4c0825;});}function getInputList(_0x2b5b0a,_0xe3187c,_0x38eeb7,_0x2a489c,_0x36f9a5,_0x1b4db4,_0x4f5d49){var _0x2a1e43={'method':_0xc116('0x96'),'uri':_0x2b5b0a+_0xc116('0x9a')+_0x36f9a5+_0xc116('0xb0')+_0x1b4db4+_0xc116('0xbb')+_0x38eeb7+_0xc116('0xbc'),'headers':{'Authorization':_0xc116('0x9c')+_0x4f5d49,'If-None-Match':null,'OData-Version':_0xc116('0x9d')},'json':!![]};return rp(_0x2a1e43)['then'](function(_0x113772){var _0x52b314={'id':_0xe3187c+'_'+_0x113772[_0xc116('0xba')],'name':_0x113772[_0xc116('0xb5')][_0xc116('0xb4')]?_0x113772['DisplayName'][_0xc116('0xb4')][_0xc116('0xb3')]:_0x113772[_0xc116('0xba')],'custom':![],'options':[]};_0x2a489c['push'](_0x52b314);return _0x2a489c;});}
\ No newline at end of file