Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 0ba3600..8dc5cfa 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1f92=['channel','Descriptions','DeskConfiguration','DeskField','Subjects','getFields','priority','remoteUri','authType','username','password','consumerSecret','token','slice','substring','lastIndexOf','GET','format','application/json','basic','headers','Authorization','Basic\x20%s','%s:%s','concat','active','label','test','stringify','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','offset','undefined','limit','set','Content-Range','json','save','update','then','destroy','error','stack','name','send','index','DeskAccount','rawAttributes','fieldName','type','map','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','count','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','findOne','getConfigurations','addConfiguration','AccountId','getSubjects'];(function(_0x47e7cb,_0x4c1b8d){var _0x2a8874=function(_0x36498f){while(--_0x36498f){_0x47e7cb['push'](_0x47e7cb['shift']());}};_0x2a8874(++_0x4c1b8d);}(_0x1f92,0xfb));var _0x21f9=function(_0x17401f,_0x37d9f9){_0x17401f=_0x17401f-0x0;var _0x502dfa=_0x1f92[_0x17401f];return _0x502dfa;};'use strict';var emlformat=require(_0x21f9('0x0'));var rimraf=require(_0x21f9('0x1'));var zipdir=require(_0x21f9('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x21f9('0x3'));var moment=require(_0x21f9('0x4'));var BPromise=require(_0x21f9('0x5'));var Mustache=require(_0x21f9('0x6'));var util=require('util');var path=require(_0x21f9('0x7'));var sox=require(_0x21f9('0x8'));var csv=require(_0x21f9('0x9'));var ejs=require(_0x21f9('0xa'));var fs=require('fs');var fs_extra=require(_0x21f9('0xb'));var _=require(_0x21f9('0xc'));var squel=require(_0x21f9('0xd'));var crypto=require(_0x21f9('0xe'));var jsforce=require(_0x21f9('0xf'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x21f9('0x10'));var Papa=require(_0x21f9('0x11'));var Redis=require('ioredis');var authService=require(_0x21f9('0x12'));var qs=require(_0x21f9('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x21f9('0x14'))('api');var utils=require(_0x21f9('0x15'));var config=require(_0x21f9('0x16'));var licenseUtil=require(_0x21f9('0x17'));var db=require('../../mysqldb')['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x119159,_0x1617a4){_0x1617a4=_0x1617a4||0xcc;return function(_0x1e1a40){if(_0x1e1a40){return _0x119159[_0x21f9('0x18')](_0x1617a4);}return _0x119159[_0x21f9('0x19')](_0x1617a4)['end']();};}function respondWithResult(_0x8ec031,_0xc84c98){_0xc84c98=_0xc84c98||0xc8;return function(_0x5d0138){if(_0x5d0138){return _0x8ec031[_0x21f9('0x19')](_0xc84c98)['json'](_0x5d0138);}};}function respondWithFilteredResult(_0x15d998,_0x159c78){return function(_0x202237){if(_0x202237){var _0x1ec357=typeof _0x159c78[_0x21f9('0x1a')]===_0x21f9('0x1b')&&typeof _0x159c78['limit']==='undefined';var _0x288db3=_0x202237['count'];var _0xd08d8=_0x1ec357?0x0:_0x159c78[_0x21f9('0x1a')];var _0x1e0606=_0x1ec357?_0x202237['count']:_0x159c78[_0x21f9('0x1a')]+_0x159c78[_0x21f9('0x1c')];var _0x978263;if(_0x1e0606>=_0x288db3){_0x1e0606=_0x288db3;_0x978263=0xc8;}else{_0x978263=0xce;}_0x15d998['status'](_0x978263);return _0x15d998[_0x21f9('0x1d')](_0x21f9('0x1e'),_0xd08d8+'-'+_0x1e0606+'/'+_0x288db3)[_0x21f9('0x1f')](_0x202237);}return null;};}function patchUpdates(_0x4e4ce8){return function(_0x34c0bb){try{jsonpatch['apply'](_0x34c0bb,_0x4e4ce8,!![]);}catch(_0x1b60c4){return BPromise['reject'](_0x1b60c4);}return _0x34c0bb[_0x21f9('0x20')]();};}function saveUpdates(_0x2a6119,_0x3e1e3a){return function(_0xfed1d2){if(_0xfed1d2){return _0xfed1d2[_0x21f9('0x21')](_0x2a6119)[_0x21f9('0x22')](function(_0x1043de){return _0x1043de;});}return null;};}function removeEntity(_0x2cba0e,_0x397e29){return function(_0x5a8c30){if(_0x5a8c30){return _0x5a8c30[_0x21f9('0x23')]()['then'](function(){_0x2cba0e[_0x21f9('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3cd4b8,_0x1032b1){return function(_0x497cac){if(!_0x497cac){_0x3cd4b8[_0x21f9('0x18')](0x194);}return _0x497cac;};}function handleError(_0x546828,_0x53822b){_0x53822b=_0x53822b||0x1f4;return function(_0x4f742c){logger[_0x21f9('0x24')](_0x4f742c[_0x21f9('0x25')]);if(_0x4f742c[_0x21f9('0x26')]){delete _0x4f742c[_0x21f9('0x26')];}_0x546828[_0x21f9('0x19')](_0x53822b)[_0x21f9('0x27')](_0x4f742c);};}exports[_0x21f9('0x28')]=function(_0x3c6e11,_0x279dc4){var _0xd6187c={},_0x5f0e83={},_0x4ac789={'count':0x0,'rows':[]};var _0x4857c2=_['map'](db[_0x21f9('0x29')][_0x21f9('0x2a')],function(_0x28aca8){return{'name':_0x28aca8[_0x21f9('0x2b')],'type':_0x28aca8[_0x21f9('0x2c')]['key']};});_0x5f0e83['model']=_[_0x21f9('0x2d')](_0x4857c2,_0x21f9('0x26'));_0x5f0e83[_0x21f9('0x2e')]=_[_0x21f9('0x2f')](_0x3c6e11['query']);_0x5f0e83[_0x21f9('0x30')]=_['intersection'](_0x5f0e83[_0x21f9('0x31')],_0x5f0e83['query']);_0xd6187c[_0x21f9('0x32')]=_[_0x21f9('0x33')](_0x5f0e83[_0x21f9('0x31')],qs[_0x21f9('0x34')](_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x34')]));_0xd6187c[_0x21f9('0x32')]=_0xd6187c[_0x21f9('0x32')][_0x21f9('0x35')]?_0xd6187c['attributes']:_0x5f0e83['model'];if(!_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x36')](_0x21f9('0x37'))){_0xd6187c['limit']=qs['limit'](_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x1c')]);_0xd6187c[_0x21f9('0x1a')]=qs[_0x21f9('0x1a')](_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x1a')]);}_0xd6187c[_0x21f9('0x38')]=qs['sort'](_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x39')]);_0xd6187c[_0x21f9('0x3a')]=qs[_0x21f9('0x30')](_[_0x21f9('0x3b')](_0x3c6e11[_0x21f9('0x2e')],_0x5f0e83[_0x21f9('0x30')]),_0x4857c2);if(_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x3c')]){_0xd6187c[_0x21f9('0x3a')]=_['merge'](_0xd6187c[_0x21f9('0x3a')],{'$or':_[_0x21f9('0x2d')](_0x4857c2,function(_0x40e701){if(_0x40e701[_0x21f9('0x2c')]!=='VIRTUAL'){var _0x3483b6={};_0x3483b6[_0x40e701[_0x21f9('0x26')]]={'$like':'%'+_0x3c6e11['query'][_0x21f9('0x3c')]+'%'};return _0x3483b6;}})});}_0xd6187c=_[_0x21f9('0x3d')]({},_0xd6187c,_0x3c6e11['options']);var _0x268fb7={'where':_0xd6187c[_0x21f9('0x3a')]};return db[_0x21f9('0x29')][_0x21f9('0x3e')](_0x268fb7)[_0x21f9('0x22')](function(_0xa8fff){_0x4ac789[_0x21f9('0x3e')]=_0xa8fff;if(_0x3c6e11[_0x21f9('0x2e')][_0x21f9('0x3f')]){_0xd6187c[_0x21f9('0x40')]=[{'all':!![]}];}return db[_0x21f9('0x29')][_0x21f9('0x41')](_0xd6187c);})[_0x21f9('0x22')](function(_0x2e650d){_0x4ac789[_0x21f9('0x42')]=_0x2e650d;return _0x4ac789;})[_0x21f9('0x22')](respondWithFilteredResult(_0x279dc4,_0xd6187c))[_0x21f9('0x43')](handleError(_0x279dc4,null));};exports[_0x21f9('0x44')]=function(_0x41ccfa,_0x32e71e){var _0x145c66={'raw':![],'where':{'id':_0x41ccfa[_0x21f9('0x45')]['id']}},_0x153527={};_0x153527[_0x21f9('0x31')]=_[_0x21f9('0x2f')](db[_0x21f9('0x29')][_0x21f9('0x2a')]);_0x153527[_0x21f9('0x2e')]=_[_0x21f9('0x2f')](_0x41ccfa[_0x21f9('0x2e')]);_0x153527['filters']=_['intersection'](_0x153527[_0x21f9('0x31')],_0x153527[_0x21f9('0x2e')]);_0x145c66[_0x21f9('0x32')]=_[_0x21f9('0x33')](_0x153527['model'],qs['fields'](_0x41ccfa[_0x21f9('0x2e')]['fields']));_0x145c66[_0x21f9('0x32')]=_0x145c66[_0x21f9('0x32')][_0x21f9('0x35')]?_0x145c66[_0x21f9('0x32')]:_0x153527[_0x21f9('0x31')];if(_0x41ccfa[_0x21f9('0x2e')][_0x21f9('0x3f')]){_0x145c66[_0x21f9('0x40')]=[{'all':!![]}];}_0x145c66=_[_0x21f9('0x3d')]({},_0x145c66,_0x41ccfa[_0x21f9('0x46')]);return db[_0x21f9('0x29')][_0x21f9('0x47')](_0x145c66)[_0x21f9('0x22')](handleEntityNotFound(_0x32e71e,null))[_0x21f9('0x22')](respondWithResult(_0x32e71e,null))[_0x21f9('0x43')](handleError(_0x32e71e,null));};exports[_0x21f9('0x48')]=function(_0x19c932,_0x4f7352){return db[_0x21f9('0x29')]['create'](_0x19c932[_0x21f9('0x49')],{})[_0x21f9('0x22')](respondWithResult(_0x4f7352,0xc9))[_0x21f9('0x43')](handleError(_0x4f7352,null));};exports[_0x21f9('0x21')]=function(_0xc23f3f,_0x319b57){if(_0xc23f3f[_0x21f9('0x49')]['id']){delete _0xc23f3f[_0x21f9('0x49')]['id'];}return db[_0x21f9('0x29')][_0x21f9('0x47')]({'where':{'id':_0xc23f3f[_0x21f9('0x45')]['id']}})['then'](handleEntityNotFound(_0x319b57,null))[_0x21f9('0x22')](saveUpdates(_0xc23f3f['body'],null))[_0x21f9('0x22')](respondWithResult(_0x319b57,null))[_0x21f9('0x43')](handleError(_0x319b57,null));};exports[_0x21f9('0x23')]=function(_0x131e69,_0x1aa211){return db[_0x21f9('0x29')][_0x21f9('0x47')]({'where':{'id':_0x131e69['params']['id']}})[_0x21f9('0x22')](handleEntityNotFound(_0x1aa211,null))[_0x21f9('0x22')](removeEntity(_0x1aa211,null))[_0x21f9('0x43')](handleError(_0x1aa211,null));};exports['getConfigurations']=function(_0x488909,_0x46f16c,_0x3244e2){var _0x4329a8={};var _0x3ffb4b={};var _0x9ac156;var _0x25207d;return db[_0x21f9('0x29')][_0x21f9('0x4a')]({'where':{'id':_0x488909[_0x21f9('0x45')]['id']}})['then'](handleEntityNotFound(_0x46f16c,null))[_0x21f9('0x22')](function(_0x373f68){if(_0x373f68){_0x9ac156=_0x373f68;_0x3ffb4b['model']=_['keys'](db['DeskConfiguration'][_0x21f9('0x2a')]);_0x3ffb4b[_0x21f9('0x2e')]=_[_0x21f9('0x2f')](_0x488909[_0x21f9('0x2e')]);_0x3ffb4b['filters']=_[_0x21f9('0x33')](_0x3ffb4b[_0x21f9('0x31')],_0x3ffb4b['query']);_0x4329a8[_0x21f9('0x32')]=_[_0x21f9('0x33')](_0x3ffb4b[_0x21f9('0x31')],qs['fields'](_0x488909[_0x21f9('0x2e')][_0x21f9('0x34')]));_0x4329a8[_0x21f9('0x32')]=_0x4329a8['attributes']['length']?_0x4329a8[_0x21f9('0x32')]:_0x3ffb4b[_0x21f9('0x31')];_0x4329a8[_0x21f9('0x38')]=qs['sort'](_0x488909[_0x21f9('0x2e')]['sort']);_0x4329a8['where']=qs[_0x21f9('0x30')](_[_0x21f9('0x3b')](_0x488909['query'],_0x3ffb4b['filters']));if(_0x488909[_0x21f9('0x2e')][_0x21f9('0x3c')]){_0x4329a8[_0x21f9('0x3a')]=_[_0x21f9('0x3d')](_0x4329a8[_0x21f9('0x3a')],{'$or':_['map'](_0x4329a8[_0x21f9('0x32')],function(_0x272c04){var _0x320379={};_0x320379[_0x272c04]={'$like':'%'+_0x488909[_0x21f9('0x2e')]['filter']+'%'};return _0x320379;})});}_0x4329a8=_['merge']({},_0x4329a8,_0x488909[_0x21f9('0x46')]);return _0x9ac156[_0x21f9('0x4b')](_0x4329a8);}})[_0x21f9('0x22')](function(_0x1cb697){if(_0x1cb697){_0x25207d=_0x1cb697[_0x21f9('0x35')];if(!_0x488909[_0x21f9('0x2e')][_0x21f9('0x36')](_0x21f9('0x37'))){_0x4329a8[_0x21f9('0x1c')]=qs[_0x21f9('0x1c')](_0x488909['query'][_0x21f9('0x1c')]);_0x4329a8[_0x21f9('0x1a')]=qs[_0x21f9('0x1a')](_0x488909[_0x21f9('0x2e')][_0x21f9('0x1a')]);}return _0x9ac156[_0x21f9('0x4b')](_0x4329a8);}})[_0x21f9('0x22')](function(_0x47ff5c){if(_0x47ff5c){return _0x47ff5c?{'count':_0x25207d,'rows':_0x47ff5c}:null;}})[_0x21f9('0x22')](respondWithResult(_0x46f16c,null))[_0x21f9('0x43')](handleError(_0x46f16c,null));};exports[_0x21f9('0x4c')]=function(_0x3773e0,_0xebd9f9,_0x5512f5){if(_0x3773e0[_0x21f9('0x49')]['id']){delete _0x3773e0[_0x21f9('0x49')]['id'];}return db[_0x21f9('0x29')][_0x21f9('0x4a')]({'where':{'id':_0x3773e0[_0x21f9('0x45')]['id']}})[_0x21f9('0x22')](handleEntityNotFound(_0xebd9f9,null))[_0x21f9('0x22')](function(_0x2d6312){if(_0x2d6312){_0x3773e0[_0x21f9('0x49')][_0x21f9('0x4d')]=_0x2d6312['id'];_0x3773e0[_0x21f9('0x49')]['Subjects']=integrations[_0x21f9('0x4e')](_0x3773e0[_0x21f9('0x49')][_0x21f9('0x4f')],_0x3773e0[_0x21f9('0x49')][_0x21f9('0x2c')]);_0x3773e0['body'][_0x21f9('0x50')]=integrations['getDescriptions'](_0x3773e0[_0x21f9('0x49')]['channel'],_0x3773e0[_0x21f9('0x49')][_0x21f9('0x2c')]);return db[_0x21f9('0x51')][_0x21f9('0x48')](_0x3773e0[_0x21f9('0x49')],{'include':[{'model':db[_0x21f9('0x52')],'as':_0x21f9('0x53')},{'model':db[_0x21f9('0x52')],'as':_0x21f9('0x50')}]});}return null;})[_0x21f9('0x22')](respondWithResult(_0xebd9f9,null))['catch'](handleError(_0xebd9f9,null));};exports[_0x21f9('0x54')]=function(_0x31723d,_0x4bcdd4,_0x5320c3){var _0x31e42d=[{'name':_0x21f9('0x55'),'label':'priority','custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x5097a9='';return db[_0x21f9('0x29')][_0x21f9('0x4a')]({'where':{'id':_0x31723d[_0x21f9('0x45')]['id']},'attributes':['id',_0x21f9('0x56'),_0x21f9('0x57'),_0x21f9('0x58'),_0x21f9('0x59'),'consumerKey',_0x21f9('0x5a'),_0x21f9('0x5b'),'tokenSecret']})['then'](handleEntityNotFound(_0x4bcdd4,null))[_0x21f9('0x22')](function(_0x3eba25){if(_0x3eba25){_0x5097a9=_0x3eba25[_0x21f9('0x56')];var _0x5ecec1=_0x5097a9[_0x21f9('0x5c')](-0x1);if(_0x5ecec1==='/'){_0x5097a9=_0x5097a9[_0x21f9('0x5d')](0x0,_0x5097a9[_0x21f9('0x5e')](_0x5ecec1));}var _0x12d3ba={'method':_0x21f9('0x5f'),'uri':util[_0x21f9('0x60')]('%s/custom_fields',_0x5097a9),'headers':{'Content-Type':_0x21f9('0x61'),'Accept':_0x21f9('0x61')},'json':!![]};if(_0x3eba25['authType']===_0x21f9('0x62')){_0x12d3ba[_0x21f9('0x63')][_0x21f9('0x64')]=util[_0x21f9('0x60')](_0x21f9('0x65'),new Buffer(util['format'](_0x21f9('0x66'),_0x3eba25['username'],_0x3eba25['password']))['toString']('base64'));}return rp(_0x12d3ba)[_0x21f9('0x22')](function(_0x51ee47){return _0x31e42d[_0x21f9('0x67')](_[_0x21f9('0x2d')](_0x51ee47['_embedded']['entries'],function(_0x544a9e){return{'id':_0x544a9e[_0x21f9('0x26')],'name':_0x544a9e[_0x21f9('0x26')],'type':_0x544a9e[_0x21f9('0x2c')],'active':_0x544a9e[_0x21f9('0x68')],'label':_0x544a9e[_0x21f9('0x69')],'custom':!![]};}));});}})[_0x21f9('0x22')](function(_0x41f30b){return{'count':_0x41f30b[_0x21f9('0x35')],'rows':_0x41f30b};})['then'](respondWithResult(_0x4bcdd4,null))[_0x21f9('0x43')](function(_0x1e63d5){var _0xd5544b=_0x31723d[_0x21f9('0x2e')][_0x21f9('0x6a')]?0x1f4:_0x1e63d5['statusCode']||0x1f4;logger[_0x21f9('0x24')]('getFields,\x20%s,\x20%s,\x20%s',_0x21f9('0x54'),_0xd5544b,JSON[_0x21f9('0x6b')](_0x1e63d5));delete _0x1e63d5[_0x21f9('0x26')];if(_0xd5544b===0x191){_0xd5544b=0x190;}_0x4bcdd4['status'](_0xd5544b)[_0x21f9('0x27')](_0x31723d['query'][_0x21f9('0x6a')]?{'message':_0x21f9('0x6c'),'statusCode':_0x1e63d5[_0x21f9('0x6d')]}:_0x1e63d5);});};
\ No newline at end of file
+var _0xa308=['../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','map','rawAttributes','fieldName','type','keys','filters','intersection','model','query','attributes','fields','length','nolimit','order','where','pick','filter','merge','VIRTUAL','options','include','DeskAccount','findAll','rows','catch','show','params','includeAll','find','create','body','getConfigurations','findOne','DeskConfiguration','sort','hasOwnProperty','Subjects','getSubjects','channel','DeskField','getFields','authType','username','password','consumerKey','consumerSecret','token','remoteUri','slice','substring','lastIndexOf','%s/custom_fields','application/json','headers','Authorization','format','%s:%s','toString','concat','_embedded','entries','active','label','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','rimraf','request-promise','moment','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis'];(function(_0x48de9e,_0x144e00){var _0x20e60f=function(_0x2f65a3){while(--_0x2f65a3){_0x48de9e['push'](_0x48de9e['shift']());}};_0x20e60f(++_0x144e00);}(_0xa308,0x1a2));var _0x8a30=function(_0xfb0281,_0x3ff38b){_0xfb0281=_0xfb0281-0x0;var _0x408dd3=_0xa308[_0xfb0281];return _0x408dd3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8a30('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x8a30('0x1'));var moment=require(_0x8a30('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x8a30('0x3'));var util=require('util');var path=require(_0x8a30('0x4'));var sox=require('sox');var csv=require(_0x8a30('0x5'));var ejs=require(_0x8a30('0x6'));var fs=require('fs');var fs_extra=require(_0x8a30('0x7'));var _=require(_0x8a30('0x8'));var squel=require(_0x8a30('0x9'));var crypto=require(_0x8a30('0xa'));var jsforce=require(_0x8a30('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x8a30('0xc'));var Papa=require('papaparse');var Redis=require(_0x8a30('0xd'));var authService=require(_0x8a30('0xe'));var qs=require(_0x8a30('0xf'));var as=require(_0x8a30('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8a30('0x11'))(_0x8a30('0x12'));var utils=require('../../config/utils');var config=require(_0x8a30('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x8a30('0x14'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x1d3f92,_0x136a01){_0x136a01=_0x136a01||0xcc;return function(_0x23a1f7){if(_0x23a1f7){return _0x1d3f92[_0x8a30('0x15')](_0x136a01);}return _0x1d3f92[_0x8a30('0x16')](_0x136a01)[_0x8a30('0x17')]();};}function respondWithResult(_0x5866ed,_0x3e6c8e){_0x3e6c8e=_0x3e6c8e||0xc8;return function(_0x52aa71){if(_0x52aa71){return _0x5866ed['status'](_0x3e6c8e)[_0x8a30('0x18')](_0x52aa71);}};}function respondWithFilteredResult(_0x20a221,_0x4bb01a){return function(_0x448257){if(_0x448257){var _0x5d4db9=typeof _0x4bb01a[_0x8a30('0x19')]===_0x8a30('0x1a')&&typeof _0x4bb01a[_0x8a30('0x1b')]===_0x8a30('0x1a');var _0x57371e=_0x448257[_0x8a30('0x1c')];var _0x48f30b=_0x5d4db9?0x0:_0x4bb01a[_0x8a30('0x19')];var _0x4c4ea4=_0x5d4db9?_0x448257['count']:_0x4bb01a[_0x8a30('0x19')]+_0x4bb01a[_0x8a30('0x1b')];var _0x740955;if(_0x4c4ea4>=_0x57371e){_0x4c4ea4=_0x57371e;_0x740955=0xc8;}else{_0x740955=0xce;}_0x20a221[_0x8a30('0x16')](_0x740955);return _0x20a221[_0x8a30('0x1d')](_0x8a30('0x1e'),_0x48f30b+'-'+_0x4c4ea4+'/'+_0x57371e)['json'](_0x448257);}return null;};}function patchUpdates(_0x15644e){return function(_0x3d5ff1){try{jsonpatch[_0x8a30('0x1f')](_0x3d5ff1,_0x15644e,!![]);}catch(_0x3a5305){return BPromise[_0x8a30('0x20')](_0x3a5305);}return _0x3d5ff1[_0x8a30('0x21')]();};}function saveUpdates(_0x16df91,_0x2b2baf){return function(_0x2c6372){if(_0x2c6372){return _0x2c6372[_0x8a30('0x22')](_0x16df91)[_0x8a30('0x23')](function(_0x4345bf){return _0x4345bf;});}return null;};}function removeEntity(_0x329a98,_0x48dffe){return function(_0x29959a){if(_0x29959a){return _0x29959a[_0x8a30('0x24')]()[_0x8a30('0x23')](function(){_0x329a98['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xd8afe5,_0x18daa3){return function(_0x1bc637){if(!_0x1bc637){_0xd8afe5[_0x8a30('0x15')](0x194);}return _0x1bc637;};}function handleError(_0x3ec125,_0x2564d6){_0x2564d6=_0x2564d6||0x1f4;return function(_0x2f1fb0){logger[_0x8a30('0x25')](_0x2f1fb0[_0x8a30('0x26')]);if(_0x2f1fb0[_0x8a30('0x27')]){delete _0x2f1fb0['name'];}_0x3ec125[_0x8a30('0x16')](_0x2564d6)[_0x8a30('0x28')](_0x2f1fb0);};}exports['index']=function(_0x8f4754,_0x57252c){var _0x397394={},_0x2cdcdc={},_0x3b5fc0={'count':0x0,'rows':[]};var _0x422f5f=_[_0x8a30('0x29')](db['DeskAccount'][_0x8a30('0x2a')],function(_0x213bab){return{'name':_0x213bab[_0x8a30('0x2b')],'type':_0x213bab[_0x8a30('0x2c')]['key']};});_0x2cdcdc['model']=_['map'](_0x422f5f,_0x8a30('0x27'));_0x2cdcdc['query']=_[_0x8a30('0x2d')](_0x8f4754['query']);_0x2cdcdc[_0x8a30('0x2e')]=_[_0x8a30('0x2f')](_0x2cdcdc[_0x8a30('0x30')],_0x2cdcdc[_0x8a30('0x31')]);_0x397394[_0x8a30('0x32')]=_[_0x8a30('0x2f')](_0x2cdcdc[_0x8a30('0x30')],qs['fields'](_0x8f4754[_0x8a30('0x31')][_0x8a30('0x33')]));_0x397394[_0x8a30('0x32')]=_0x397394[_0x8a30('0x32')][_0x8a30('0x34')]?_0x397394[_0x8a30('0x32')]:_0x2cdcdc[_0x8a30('0x30')];if(!_0x8f4754[_0x8a30('0x31')]['hasOwnProperty'](_0x8a30('0x35'))){_0x397394['limit']=qs[_0x8a30('0x1b')](_0x8f4754[_0x8a30('0x31')][_0x8a30('0x1b')]);_0x397394[_0x8a30('0x19')]=qs['offset'](_0x8f4754['query'][_0x8a30('0x19')]);}_0x397394[_0x8a30('0x36')]=qs['sort'](_0x8f4754[_0x8a30('0x31')]['sort']);_0x397394[_0x8a30('0x37')]=qs['filters'](_[_0x8a30('0x38')](_0x8f4754[_0x8a30('0x31')],_0x2cdcdc[_0x8a30('0x2e')]),_0x422f5f);if(_0x8f4754[_0x8a30('0x31')][_0x8a30('0x39')]){_0x397394[_0x8a30('0x37')]=_[_0x8a30('0x3a')](_0x397394[_0x8a30('0x37')],{'$or':_['map'](_0x422f5f,function(_0x2df84a){if(_0x2df84a[_0x8a30('0x2c')]!==_0x8a30('0x3b')){var _0x3fca6c={};_0x3fca6c[_0x2df84a['name']]={'$like':'%'+_0x8f4754[_0x8a30('0x31')][_0x8a30('0x39')]+'%'};return _0x3fca6c;}})});}_0x397394=_[_0x8a30('0x3a')]({},_0x397394,_0x8f4754[_0x8a30('0x3c')]);var _0x169995={'where':_0x397394[_0x8a30('0x37')]};return db['DeskAccount'][_0x8a30('0x1c')](_0x169995)['then'](function(_0x350cb7){_0x3b5fc0[_0x8a30('0x1c')]=_0x350cb7;if(_0x8f4754[_0x8a30('0x31')]['includeAll']){_0x397394[_0x8a30('0x3d')]=[{'all':!![]}];}return db[_0x8a30('0x3e')][_0x8a30('0x3f')](_0x397394);})[_0x8a30('0x23')](function(_0x8b60e2){_0x3b5fc0[_0x8a30('0x40')]=_0x8b60e2;return _0x3b5fc0;})['then'](respondWithFilteredResult(_0x57252c,_0x397394))[_0x8a30('0x41')](handleError(_0x57252c,null));};exports[_0x8a30('0x42')]=function(_0x177f30,_0x53567d){var _0x57ad6e={'raw':![],'where':{'id':_0x177f30[_0x8a30('0x43')]['id']}},_0x136fa6={};_0x136fa6['model']=_['keys'](db[_0x8a30('0x3e')]['rawAttributes']);_0x136fa6['query']=_[_0x8a30('0x2d')](_0x177f30[_0x8a30('0x31')]);_0x136fa6['filters']=_['intersection'](_0x136fa6['model'],_0x136fa6[_0x8a30('0x31')]);_0x57ad6e[_0x8a30('0x32')]=_[_0x8a30('0x2f')](_0x136fa6['model'],qs[_0x8a30('0x33')](_0x177f30[_0x8a30('0x31')][_0x8a30('0x33')]));_0x57ad6e[_0x8a30('0x32')]=_0x57ad6e['attributes'][_0x8a30('0x34')]?_0x57ad6e[_0x8a30('0x32')]:_0x136fa6[_0x8a30('0x30')];if(_0x177f30[_0x8a30('0x31')][_0x8a30('0x44')]){_0x57ad6e['include']=[{'all':!![]}];}_0x57ad6e=_[_0x8a30('0x3a')]({},_0x57ad6e,_0x177f30[_0x8a30('0x3c')]);return db[_0x8a30('0x3e')][_0x8a30('0x45')](_0x57ad6e)[_0x8a30('0x23')](handleEntityNotFound(_0x53567d,null))[_0x8a30('0x23')](respondWithResult(_0x53567d,null))[_0x8a30('0x41')](handleError(_0x53567d,null));};exports[_0x8a30('0x46')]=function(_0x5e5bb1,_0x12ea2d){return db[_0x8a30('0x3e')][_0x8a30('0x46')](_0x5e5bb1[_0x8a30('0x47')],{})[_0x8a30('0x23')](respondWithResult(_0x12ea2d,0xc9))[_0x8a30('0x41')](handleError(_0x12ea2d,null));};exports[_0x8a30('0x22')]=function(_0x1114ec,_0x2b5074){if(_0x1114ec[_0x8a30('0x47')]['id']){delete _0x1114ec[_0x8a30('0x47')]['id'];}return db['DeskAccount'][_0x8a30('0x45')]({'where':{'id':_0x1114ec['params']['id']}})[_0x8a30('0x23')](handleEntityNotFound(_0x2b5074,null))[_0x8a30('0x23')](saveUpdates(_0x1114ec[_0x8a30('0x47')],null))[_0x8a30('0x23')](respondWithResult(_0x2b5074,null))[_0x8a30('0x41')](handleError(_0x2b5074,null));};exports['destroy']=function(_0x2c9687,_0xa99621){return db[_0x8a30('0x3e')][_0x8a30('0x45')]({'where':{'id':_0x2c9687[_0x8a30('0x43')]['id']}})[_0x8a30('0x23')](handleEntityNotFound(_0xa99621,null))[_0x8a30('0x23')](removeEntity(_0xa99621,null))[_0x8a30('0x41')](handleError(_0xa99621,null));};exports[_0x8a30('0x48')]=function(_0x2d8cdf,_0x3ca055,_0x970239){var _0x517c7e={};var _0x7cea3={};var _0x1fd8ea;var _0x1b403e;return db[_0x8a30('0x3e')][_0x8a30('0x49')]({'where':{'id':_0x2d8cdf[_0x8a30('0x43')]['id']}})[_0x8a30('0x23')](handleEntityNotFound(_0x3ca055,null))[_0x8a30('0x23')](function(_0x5b6b3e){if(_0x5b6b3e){_0x1fd8ea=_0x5b6b3e;_0x7cea3[_0x8a30('0x30')]=_[_0x8a30('0x2d')](db[_0x8a30('0x4a')]['rawAttributes']);_0x7cea3[_0x8a30('0x31')]=_[_0x8a30('0x2d')](_0x2d8cdf[_0x8a30('0x31')]);_0x7cea3[_0x8a30('0x2e')]=_[_0x8a30('0x2f')](_0x7cea3[_0x8a30('0x30')],_0x7cea3[_0x8a30('0x31')]);_0x517c7e[_0x8a30('0x32')]=_[_0x8a30('0x2f')](_0x7cea3['model'],qs[_0x8a30('0x33')](_0x2d8cdf[_0x8a30('0x31')]['fields']));_0x517c7e['attributes']=_0x517c7e[_0x8a30('0x32')]['length']?_0x517c7e['attributes']:_0x7cea3[_0x8a30('0x30')];_0x517c7e[_0x8a30('0x36')]=qs['sort'](_0x2d8cdf[_0x8a30('0x31')][_0x8a30('0x4b')]);_0x517c7e['where']=qs[_0x8a30('0x2e')](_[_0x8a30('0x38')](_0x2d8cdf[_0x8a30('0x31')],_0x7cea3[_0x8a30('0x2e')]));if(_0x2d8cdf[_0x8a30('0x31')]['filter']){_0x517c7e['where']=_['merge'](_0x517c7e[_0x8a30('0x37')],{'$or':_[_0x8a30('0x29')](_0x517c7e[_0x8a30('0x32')],function(_0x5317d7){var _0x55c889={};_0x55c889[_0x5317d7]={'$like':'%'+_0x2d8cdf[_0x8a30('0x31')][_0x8a30('0x39')]+'%'};return _0x55c889;})});}_0x517c7e=_[_0x8a30('0x3a')]({},_0x517c7e,_0x2d8cdf[_0x8a30('0x3c')]);return _0x1fd8ea['getConfigurations'](_0x517c7e);}})[_0x8a30('0x23')](function(_0x505d24){if(_0x505d24){_0x1b403e=_0x505d24[_0x8a30('0x34')];if(!_0x2d8cdf[_0x8a30('0x31')][_0x8a30('0x4c')](_0x8a30('0x35'))){_0x517c7e['limit']=qs[_0x8a30('0x1b')](_0x2d8cdf[_0x8a30('0x31')][_0x8a30('0x1b')]);_0x517c7e[_0x8a30('0x19')]=qs[_0x8a30('0x19')](_0x2d8cdf[_0x8a30('0x31')][_0x8a30('0x19')]);}return _0x1fd8ea['getConfigurations'](_0x517c7e);}})['then'](function(_0x7065){if(_0x7065){return _0x7065?{'count':_0x1b403e,'rows':_0x7065}:null;}})[_0x8a30('0x23')](respondWithResult(_0x3ca055,null))[_0x8a30('0x41')](handleError(_0x3ca055,null));};exports['addConfiguration']=function(_0x5b4406,_0x391271,_0x381898){if(_0x5b4406[_0x8a30('0x47')]['id']){delete _0x5b4406[_0x8a30('0x47')]['id'];}return db[_0x8a30('0x3e')][_0x8a30('0x49')]({'where':{'id':_0x5b4406[_0x8a30('0x43')]['id']}})['then'](handleEntityNotFound(_0x391271,null))['then'](function(_0x150723){if(_0x150723){_0x5b4406[_0x8a30('0x47')]['AccountId']=_0x150723['id'];_0x5b4406[_0x8a30('0x47')][_0x8a30('0x4d')]=integrations[_0x8a30('0x4e')](_0x5b4406[_0x8a30('0x47')][_0x8a30('0x4f')],_0x5b4406[_0x8a30('0x47')][_0x8a30('0x2c')]);_0x5b4406[_0x8a30('0x47')]['Descriptions']=integrations['getDescriptions'](_0x5b4406[_0x8a30('0x47')][_0x8a30('0x4f')],_0x5b4406['body']['type']);return db['DeskConfiguration']['create'](_0x5b4406[_0x8a30('0x47')],{'include':[{'model':db[_0x8a30('0x50')],'as':_0x8a30('0x4d')},{'model':db[_0x8a30('0x50')],'as':'Descriptions'}]});}return null;})[_0x8a30('0x23')](respondWithResult(_0x391271,null))[_0x8a30('0x41')](handleError(_0x391271,null));};exports[_0x8a30('0x51')]=function(_0xb16213,_0x3ea664,_0x3b4530){var _0x562d2b=[{'name':'priority','label':'priority','custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x3b4529='';return db[_0x8a30('0x3e')][_0x8a30('0x49')]({'where':{'id':_0xb16213[_0x8a30('0x43')]['id']},'attributes':['id','remoteUri',_0x8a30('0x52'),_0x8a30('0x53'),_0x8a30('0x54'),_0x8a30('0x55'),_0x8a30('0x56'),_0x8a30('0x57'),'tokenSecret']})[_0x8a30('0x23')](handleEntityNotFound(_0x3ea664,null))[_0x8a30('0x23')](function(_0xa6fbd3){if(_0xa6fbd3){_0x3b4529=_0xa6fbd3[_0x8a30('0x58')];var _0x3b19ef=_0x3b4529[_0x8a30('0x59')](-0x1);if(_0x3b19ef==='/'){_0x3b4529=_0x3b4529[_0x8a30('0x5a')](0x0,_0x3b4529[_0x8a30('0x5b')](_0x3b19ef));}var _0xfb6e87={'method':'GET','uri':util['format'](_0x8a30('0x5c'),_0x3b4529),'headers':{'Content-Type':'application/json','Accept':_0x8a30('0x5d')},'json':!![]};if(_0xa6fbd3[_0x8a30('0x52')]==='basic'){_0xfb6e87[_0x8a30('0x5e')][_0x8a30('0x5f')]=util[_0x8a30('0x60')]('Basic\x20%s',new Buffer(util[_0x8a30('0x60')](_0x8a30('0x61'),_0xa6fbd3[_0x8a30('0x53')],_0xa6fbd3[_0x8a30('0x54')]))[_0x8a30('0x62')]('base64'));}return rp(_0xfb6e87)[_0x8a30('0x23')](function(_0x46dd22){return _0x562d2b[_0x8a30('0x63')](_[_0x8a30('0x29')](_0x46dd22[_0x8a30('0x64')][_0x8a30('0x65')],function(_0x139616){return{'id':_0x139616['name'],'name':_0x139616[_0x8a30('0x27')],'type':_0x139616['type'],'active':_0x139616[_0x8a30('0x66')],'label':_0x139616[_0x8a30('0x67')],'custom':!![]};}));});}})[_0x8a30('0x23')](function(_0x36c115){return{'count':_0x36c115[_0x8a30('0x34')],'rows':_0x36c115};})['then'](respondWithResult(_0x3ea664,null))[_0x8a30('0x41')](function(_0xc684ac){var _0x5c68ea=_0xb16213['query'][_0x8a30('0x68')]?0x1f4:_0xc684ac[_0x8a30('0x69')]||0x1f4;logger[_0x8a30('0x25')](_0x8a30('0x6a'),_0x8a30('0x51'),_0x5c68ea,JSON['stringify'](_0xc684ac));delete _0xc684ac[_0x8a30('0x27')];if(_0x5c68ea===0x191){_0x5c68ea=0x190;}_0x3ea664[_0x8a30('0x16')](_0x5c68ea)['send'](_0xb16213['query']['test']?{'message':_0x8a30('0x6b'),'statusCode':_0xc684ac[_0x8a30('0x69')]}:_0xc684ac);});};
\ No newline at end of file