Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 3a65db1..ee792ca 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2f81=['apply','save','then','error','stack','name','send','map','fieldName','type','key','model','query','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','DeskAccount','include','rows','show','params','rawAttributes','keys','length','includeAll','find','catch','create','body','getConfigurations','findOne','DeskConfiguration','hasOwnProperty','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','DeskField','getFields','priority','password','consumerKey','token','tokenSecret','remoteUri','slice','lastIndexOf','GET','format','%s/custom_fields','application/json','authType','basic','headers','Authorization','Basic\x20%s','%s:%s','username','toString','active','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','offset','limit','undefined','count','set'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x2f81,0xba));var _0x12f8=function(_0x2425ed,_0x3a6637){_0x2425ed=_0x2425ed-0x0;var _0x8ce321=_0x2f81[_0x2425ed];return _0x8ce321;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x12f8('0x0'));var jsonpatch=require(_0x12f8('0x1'));var rp=require(_0x12f8('0x2'));var moment=require('moment');var BPromise=require(_0x12f8('0x3'));var Mustache=require(_0x12f8('0x4'));var util=require('util');var path=require(_0x12f8('0x5'));var sox=require(_0x12f8('0x6'));var csv=require(_0x12f8('0x7'));var ejs=require(_0x12f8('0x8'));var fs=require('fs');var fs_extra=require(_0x12f8('0x9'));var _=require(_0x12f8('0xa'));var squel=require(_0x12f8('0xb'));var crypto=require(_0x12f8('0xc'));var jsforce=require(_0x12f8('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x12f8('0xe'));var Papa=require(_0x12f8('0xf'));var Redis=require(_0x12f8('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x12f8('0x11'));var as=require(_0x12f8('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x12f8('0x13'))(_0x12f8('0x14'));var utils=require('../../config/utils');var config=require(_0x12f8('0x15'));var licenseUtil=require(_0x12f8('0x16'));var db=require(_0x12f8('0x17'))['db'];var integrations=require(_0x12f8('0x18'));function respondWithStatusCode(_0x3eea66,_0x41ab56){_0x41ab56=_0x41ab56||0xcc;return function(_0x1ead1f){if(_0x1ead1f){return _0x3eea66[_0x12f8('0x19')](_0x41ab56);}return _0x3eea66['status'](_0x41ab56)[_0x12f8('0x1a')]();};}function respondWithResult(_0x43639c,_0x1c6894){_0x1c6894=_0x1c6894||0xc8;return function(_0x47abd6){if(_0x47abd6){return _0x43639c[_0x12f8('0x1b')](_0x1c6894)[_0x12f8('0x1c')](_0x47abd6);}};}function respondWithFilteredResult(_0x10e396,_0x23b1af){return function(_0x5ad244){if(_0x5ad244){var _0x3d801b=typeof _0x23b1af[_0x12f8('0x1d')]==='undefined'&&typeof _0x23b1af[_0x12f8('0x1e')]===_0x12f8('0x1f');var _0x27e492=_0x5ad244[_0x12f8('0x20')];var _0x4eff35=_0x3d801b?0x0:_0x23b1af['offset'];var _0x504f4e=_0x3d801b?_0x5ad244[_0x12f8('0x20')]:_0x23b1af[_0x12f8('0x1d')]+_0x23b1af['limit'];var _0x2c050a;if(_0x504f4e>=_0x27e492){_0x504f4e=_0x27e492;_0x2c050a=0xc8;}else{_0x2c050a=0xce;}_0x10e396[_0x12f8('0x1b')](_0x2c050a);return _0x10e396[_0x12f8('0x21')]('Content-Range',_0x4eff35+'-'+_0x504f4e+'/'+_0x27e492)[_0x12f8('0x1c')](_0x5ad244);}return null;};}function patchUpdates(_0x244612){return function(_0xba086a){try{jsonpatch[_0x12f8('0x22')](_0xba086a,_0x244612,!![]);}catch(_0x4ca53a){return BPromise['reject'](_0x4ca53a);}return _0xba086a[_0x12f8('0x23')]();};}function saveUpdates(_0x4f8f43,_0x19f10e){return function(_0x44099b){if(_0x44099b){return _0x44099b['update'](_0x4f8f43)[_0x12f8('0x24')](function(_0x29e904){return _0x29e904;});}return null;};}function removeEntity(_0x3ba59c,_0x2370f5){return function(_0x3bd9e4){if(_0x3bd9e4){return _0x3bd9e4['destroy']()['then'](function(){_0x3ba59c[_0x12f8('0x1b')](0xcc)[_0x12f8('0x1a')]();});}};}function handleEntityNotFound(_0x3f4588,_0x55bd5f){return function(_0x2f7759){if(!_0x2f7759){_0x3f4588[_0x12f8('0x19')](0x194);}return _0x2f7759;};}function handleError(_0x2b6efc,_0x35f6d1){_0x35f6d1=_0x35f6d1||0x1f4;return function(_0x3064da){logger[_0x12f8('0x25')](_0x3064da[_0x12f8('0x26')]);if(_0x3064da[_0x12f8('0x27')]){delete _0x3064da['name'];}_0x2b6efc['status'](_0x35f6d1)[_0x12f8('0x28')](_0x3064da);};}exports['index']=function(_0x2aba67,_0xf540f2){var _0x2a4262={},_0x37a4f4={},_0x2a7f18={'count':0x0,'rows':[]};var _0x27a066=_[_0x12f8('0x29')](db['DeskAccount']['rawAttributes'],function(_0xffec8b){return{'name':_0xffec8b[_0x12f8('0x2a')],'type':_0xffec8b[_0x12f8('0x2b')][_0x12f8('0x2c')]};});_0x37a4f4[_0x12f8('0x2d')]=_[_0x12f8('0x29')](_0x27a066,'name');_0x37a4f4[_0x12f8('0x2e')]=_['keys'](_0x2aba67['query']);_0x37a4f4[_0x12f8('0x2f')]=_[_0x12f8('0x30')](_0x37a4f4['model'],_0x37a4f4[_0x12f8('0x2e')]);_0x2a4262['attributes']=_[_0x12f8('0x30')](_0x37a4f4[_0x12f8('0x2d')],qs[_0x12f8('0x31')](_0x2aba67[_0x12f8('0x2e')][_0x12f8('0x31')]));_0x2a4262[_0x12f8('0x32')]=_0x2a4262['attributes']['length']?_0x2a4262[_0x12f8('0x32')]:_0x37a4f4[_0x12f8('0x2d')];if(!_0x2aba67[_0x12f8('0x2e')]['hasOwnProperty'](_0x12f8('0x33'))){_0x2a4262[_0x12f8('0x1e')]=qs[_0x12f8('0x1e')](_0x2aba67['query'][_0x12f8('0x1e')]);_0x2a4262[_0x12f8('0x1d')]=qs[_0x12f8('0x1d')](_0x2aba67[_0x12f8('0x2e')]['offset']);}_0x2a4262[_0x12f8('0x34')]=qs[_0x12f8('0x35')](_0x2aba67[_0x12f8('0x2e')][_0x12f8('0x35')]);_0x2a4262[_0x12f8('0x36')]=qs[_0x12f8('0x2f')](_[_0x12f8('0x37')](_0x2aba67[_0x12f8('0x2e')],_0x37a4f4[_0x12f8('0x2f')]),_0x27a066);if(_0x2aba67['query'][_0x12f8('0x38')]){_0x2a4262['where']=_[_0x12f8('0x39')](_0x2a4262[_0x12f8('0x36')],{'$or':_[_0x12f8('0x29')](_0x27a066,function(_0xf5641e){if(_0xf5641e[_0x12f8('0x2b')]!==_0x12f8('0x3a')){var _0x4dc155={};_0x4dc155[_0xf5641e[_0x12f8('0x27')]]={'$like':'%'+_0x2aba67[_0x12f8('0x2e')]['filter']+'%'};return _0x4dc155;}})});}_0x2a4262=_['merge']({},_0x2a4262,_0x2aba67[_0x12f8('0x3b')]);var _0x50e3c0={'where':_0x2a4262[_0x12f8('0x36')]};return db[_0x12f8('0x3c')][_0x12f8('0x20')](_0x50e3c0)[_0x12f8('0x24')](function(_0x35c668){_0x2a7f18['count']=_0x35c668;if(_0x2aba67[_0x12f8('0x2e')]['includeAll']){_0x2a4262[_0x12f8('0x3d')]=[{'all':!![]}];}return db['DeskAccount']['findAll'](_0x2a4262);})[_0x12f8('0x24')](function(_0x5884fa){_0x2a7f18[_0x12f8('0x3e')]=_0x5884fa;return _0x2a7f18;})[_0x12f8('0x24')](respondWithFilteredResult(_0xf540f2,_0x2a4262))['catch'](handleError(_0xf540f2,null));};exports[_0x12f8('0x3f')]=function(_0xde1c50,_0xde993d){var _0x961a31={'raw':![],'where':{'id':_0xde1c50[_0x12f8('0x40')]['id']}},_0x2eef98={};_0x2eef98['model']=_['keys'](db[_0x12f8('0x3c')][_0x12f8('0x41')]);_0x2eef98['query']=_[_0x12f8('0x42')](_0xde1c50['query']);_0x2eef98['filters']=_['intersection'](_0x2eef98[_0x12f8('0x2d')],_0x2eef98['query']);_0x961a31[_0x12f8('0x32')]=_[_0x12f8('0x30')](_0x2eef98[_0x12f8('0x2d')],qs[_0x12f8('0x31')](_0xde1c50[_0x12f8('0x2e')][_0x12f8('0x31')]));_0x961a31[_0x12f8('0x32')]=_0x961a31['attributes'][_0x12f8('0x43')]?_0x961a31[_0x12f8('0x32')]:_0x2eef98[_0x12f8('0x2d')];if(_0xde1c50[_0x12f8('0x2e')][_0x12f8('0x44')]){_0x961a31[_0x12f8('0x3d')]=[{'all':!![]}];}_0x961a31=_[_0x12f8('0x39')]({},_0x961a31,_0xde1c50['options']);return db[_0x12f8('0x3c')][_0x12f8('0x45')](_0x961a31)['then'](handleEntityNotFound(_0xde993d,null))[_0x12f8('0x24')](respondWithResult(_0xde993d,null))[_0x12f8('0x46')](handleError(_0xde993d,null));};exports[_0x12f8('0x47')]=function(_0x5b914e,_0x13794c){return db[_0x12f8('0x3c')][_0x12f8('0x47')](_0x5b914e[_0x12f8('0x48')],{})[_0x12f8('0x24')](respondWithResult(_0x13794c,0xc9))['catch'](handleError(_0x13794c,null));};exports['update']=function(_0x488fb0,_0x2ecabc){if(_0x488fb0[_0x12f8('0x48')]['id']){delete _0x488fb0['body']['id'];}return db['DeskAccount']['find']({'where':{'id':_0x488fb0['params']['id']}})[_0x12f8('0x24')](handleEntityNotFound(_0x2ecabc,null))[_0x12f8('0x24')](saveUpdates(_0x488fb0[_0x12f8('0x48')],null))[_0x12f8('0x24')](respondWithResult(_0x2ecabc,null))['catch'](handleError(_0x2ecabc,null));};exports['destroy']=function(_0x42f06d,_0x4459ce){return db['DeskAccount'][_0x12f8('0x45')]({'where':{'id':_0x42f06d[_0x12f8('0x40')]['id']}})['then'](handleEntityNotFound(_0x4459ce,null))[_0x12f8('0x24')](removeEntity(_0x4459ce,null))[_0x12f8('0x46')](handleError(_0x4459ce,null));};exports[_0x12f8('0x49')]=function(_0x147295,_0x136a21,_0x4235a9){var _0x1f850d={};var _0x5d97b8={};var _0x477e03;var _0x4231ec;return db[_0x12f8('0x3c')][_0x12f8('0x4a')]({'where':{'id':_0x147295[_0x12f8('0x40')]['id']}})['then'](handleEntityNotFound(_0x136a21,null))['then'](function(_0x50c60d){if(_0x50c60d){_0x477e03=_0x50c60d;_0x5d97b8[_0x12f8('0x2d')]=_[_0x12f8('0x42')](db[_0x12f8('0x4b')][_0x12f8('0x41')]);_0x5d97b8[_0x12f8('0x2e')]=_[_0x12f8('0x42')](_0x147295[_0x12f8('0x2e')]);_0x5d97b8[_0x12f8('0x2f')]=_['intersection'](_0x5d97b8[_0x12f8('0x2d')],_0x5d97b8[_0x12f8('0x2e')]);_0x1f850d[_0x12f8('0x32')]=_[_0x12f8('0x30')](_0x5d97b8[_0x12f8('0x2d')],qs[_0x12f8('0x31')](_0x147295['query']['fields']));_0x1f850d['attributes']=_0x1f850d[_0x12f8('0x32')][_0x12f8('0x43')]?_0x1f850d['attributes']:_0x5d97b8['model'];_0x1f850d[_0x12f8('0x34')]=qs['sort'](_0x147295[_0x12f8('0x2e')]['sort']);_0x1f850d[_0x12f8('0x36')]=qs[_0x12f8('0x2f')](_[_0x12f8('0x37')](_0x147295[_0x12f8('0x2e')],_0x5d97b8[_0x12f8('0x2f')]));if(_0x147295[_0x12f8('0x2e')]['filter']){_0x1f850d[_0x12f8('0x36')]=_[_0x12f8('0x39')](_0x1f850d[_0x12f8('0x36')],{'$or':_['map'](_0x1f850d['attributes'],function(_0x1bb713){var _0x5e1e5b={};_0x5e1e5b[_0x1bb713]={'$like':'%'+_0x147295[_0x12f8('0x2e')][_0x12f8('0x38')]+'%'};return _0x5e1e5b;})});}_0x1f850d=_[_0x12f8('0x39')]({},_0x1f850d,_0x147295[_0x12f8('0x3b')]);return _0x477e03[_0x12f8('0x49')](_0x1f850d);}})[_0x12f8('0x24')](function(_0x18eddb){if(_0x18eddb){_0x4231ec=_0x18eddb['length'];if(!_0x147295[_0x12f8('0x2e')][_0x12f8('0x4c')]('nolimit')){_0x1f850d[_0x12f8('0x1e')]=qs[_0x12f8('0x1e')](_0x147295['query'][_0x12f8('0x1e')]);_0x1f850d['offset']=qs[_0x12f8('0x1d')](_0x147295['query'][_0x12f8('0x1d')]);}return _0x477e03[_0x12f8('0x49')](_0x1f850d);}})['then'](function(_0x1aec80){if(_0x1aec80){return _0x1aec80?{'count':_0x4231ec,'rows':_0x1aec80}:null;}})[_0x12f8('0x24')](respondWithResult(_0x136a21,null))[_0x12f8('0x46')](handleError(_0x136a21,null));};exports[_0x12f8('0x4d')]=function(_0x1c079e,_0x599e07,_0x3b1638){if(_0x1c079e[_0x12f8('0x48')]['id']){delete _0x1c079e['body']['id'];}return db['DeskAccount'][_0x12f8('0x4a')]({'where':{'id':_0x1c079e[_0x12f8('0x40')]['id']}})[_0x12f8('0x24')](handleEntityNotFound(_0x599e07,null))['then'](function(_0x15c58b){if(_0x15c58b){_0x1c079e[_0x12f8('0x48')][_0x12f8('0x4e')]=_0x15c58b['id'];_0x1c079e[_0x12f8('0x48')][_0x12f8('0x4f')]=integrations['getSubjects'](_0x1c079e[_0x12f8('0x48')][_0x12f8('0x50')],_0x1c079e[_0x12f8('0x48')]['type']);_0x1c079e[_0x12f8('0x48')][_0x12f8('0x51')]=integrations[_0x12f8('0x52')](_0x1c079e[_0x12f8('0x48')]['channel'],_0x1c079e[_0x12f8('0x48')][_0x12f8('0x2b')]);return db[_0x12f8('0x4b')][_0x12f8('0x47')](_0x1c079e[_0x12f8('0x48')],{'include':[{'model':db['DeskField'],'as':_0x12f8('0x4f')},{'model':db[_0x12f8('0x53')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x599e07,null))[_0x12f8('0x46')](handleError(_0x599e07,null));};exports[_0x12f8('0x54')]=function(_0x37a8e5,_0x46ff44,_0x1cc633){var _0x2de021=[{'name':_0x12f8('0x55'),'label':_0x12f8('0x55'),'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 _0x592f84='';return db['DeskAccount'][_0x12f8('0x4a')]({'where':{'id':_0x37a8e5['params']['id']},'attributes':['id','remoteUri','authType','username',_0x12f8('0x56'),_0x12f8('0x57'),'consumerSecret',_0x12f8('0x58'),_0x12f8('0x59')]})[_0x12f8('0x24')](handleEntityNotFound(_0x46ff44,null))[_0x12f8('0x24')](function(_0x4ddae9){if(_0x4ddae9){_0x592f84=_0x4ddae9[_0x12f8('0x5a')];var _0x377a7d=_0x592f84[_0x12f8('0x5b')](-0x1);if(_0x377a7d==='/'){_0x592f84=_0x592f84['substring'](0x0,_0x592f84[_0x12f8('0x5c')](_0x377a7d));}var _0x400f31={'method':_0x12f8('0x5d'),'uri':util[_0x12f8('0x5e')](_0x12f8('0x5f'),_0x592f84),'headers':{'Content-Type':'application/json','Accept':_0x12f8('0x60')},'json':!![]};if(_0x4ddae9[_0x12f8('0x61')]===_0x12f8('0x62')){_0x400f31[_0x12f8('0x63')][_0x12f8('0x64')]=util[_0x12f8('0x5e')](_0x12f8('0x65'),new Buffer(util[_0x12f8('0x5e')](_0x12f8('0x66'),_0x4ddae9[_0x12f8('0x67')],_0x4ddae9[_0x12f8('0x56')]))[_0x12f8('0x68')]('base64'));}return rp(_0x400f31)['then'](function(_0x51013){return _0x2de021['concat'](_['map'](_0x51013['_embedded']['entries'],function(_0x3e3442){return{'id':_0x3e3442[_0x12f8('0x27')],'name':_0x3e3442['name'],'type':_0x3e3442['type'],'active':_0x3e3442[_0x12f8('0x69')],'label':_0x3e3442['label'],'custom':!![]};}));});}})[_0x12f8('0x24')](function(_0x4c5dc3){return{'count':_0x4c5dc3[_0x12f8('0x43')],'rows':_0x4c5dc3};})['then'](respondWithResult(_0x46ff44,null))[_0x12f8('0x46')](function(_0x54afc2){var _0x45bc8f=_0x37a8e5[_0x12f8('0x2e')][_0x12f8('0x6a')]?0x1f4:_0x54afc2[_0x12f8('0x6b')]||0x1f4;logger[_0x12f8('0x25')](_0x12f8('0x6c'),'getFields',_0x45bc8f,JSON['stringify'](_0x54afc2));delete _0x54afc2[_0x12f8('0x27')];if(_0x45bc8f===0x191){_0x45bc8f=0x190;}_0x46ff44[_0x12f8('0x1b')](_0x45bc8f)['send'](_0x37a8e5[_0x12f8('0x2e')][_0x12f8('0x6a')]?{'message':_0x12f8('0x6d'),'statusCode':_0x54afc2[_0x12f8('0x6b')]}:_0x54afc2);});};
\ No newline at end of file
+var _0x554c=['DeskAccount','rawAttributes','type','key','keys','query','filters','intersection','fields','attributes','length','model','sort','merge','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','getConfigurations','findOne','DeskConfiguration','order','where','pick','hasOwnProperty','nolimit','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','DeskField','getFields','priority','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','substring','lastIndexOf','GET','format','basic','headers','Authorization','toString','concat','_embedded','entries','active','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then','error','name','send','map'];(function(_0x3743e5,_0x4b6bb9){var _0x370603=function(_0x1d8df1){while(--_0x1d8df1){_0x3743e5['push'](_0x3743e5['shift']());}};_0x370603(++_0x4b6bb9);}(_0x554c,0x127));var _0xc554=function(_0x2dbae6,_0x424afb){_0x2dbae6=_0x2dbae6-0x0;var _0x37f9ae=_0x554c[_0x2dbae6];return _0x37f9ae;};'use strict';var emlformat=require(_0xc554('0x0'));var rimraf=require(_0xc554('0x1'));var zipdir=require(_0xc554('0x2'));var jsonpatch=require(_0xc554('0x3'));var rp=require('request-promise');var moment=require(_0xc554('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xc554('0x5'));var util=require(_0xc554('0x6'));var path=require(_0xc554('0x7'));var sox=require('sox');var csv=require(_0xc554('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc554('0x9'));var squel=require(_0xc554('0xa'));var crypto=require(_0xc554('0xb'));var jsforce=require(_0xc554('0xc'));var deskjs=require(_0xc554('0xd'));var toCsv=require(_0xc554('0x8'));var querystring=require(_0xc554('0xe'));var Papa=require(_0xc554('0xf'));var Redis=require(_0xc554('0x10'));var authService=require(_0xc554('0x11'));var qs=require(_0xc554('0x12'));var as=require(_0xc554('0x13'));var hardwareService=require(_0xc554('0x14'));var logger=require(_0xc554('0x15'))(_0xc554('0x16'));var utils=require(_0xc554('0x17'));var config=require(_0xc554('0x18'));var licenseUtil=require(_0xc554('0x19'));var db=require(_0xc554('0x1a'))['db'];var integrations=require(_0xc554('0x1b'));function respondWithStatusCode(_0x11ac26,_0x7ff077){_0x7ff077=_0x7ff077||0xcc;return function(_0x493c68){if(_0x493c68){return _0x11ac26[_0xc554('0x1c')](_0x7ff077);}return _0x11ac26[_0xc554('0x1d')](_0x7ff077)[_0xc554('0x1e')]();};}function respondWithResult(_0x1fc61c,_0x44df8){_0x44df8=_0x44df8||0xc8;return function(_0x4937bb){if(_0x4937bb){return _0x1fc61c[_0xc554('0x1d')](_0x44df8)[_0xc554('0x1f')](_0x4937bb);}};}function respondWithFilteredResult(_0x173f63,_0x2e99c5){return function(_0x54a34b){if(_0x54a34b){var _0x5b98d6=typeof _0x2e99c5[_0xc554('0x20')]===_0xc554('0x21')&&typeof _0x2e99c5[_0xc554('0x22')]===_0xc554('0x21');var _0x51c89b=_0x54a34b['count'];var _0x5009df=_0x5b98d6?0x0:_0x2e99c5[_0xc554('0x20')];var _0x6b2cf5=_0x5b98d6?_0x54a34b[_0xc554('0x23')]:_0x2e99c5[_0xc554('0x20')]+_0x2e99c5[_0xc554('0x22')];var _0x35bf8a;if(_0x6b2cf5>=_0x51c89b){_0x6b2cf5=_0x51c89b;_0x35bf8a=0xc8;}else{_0x35bf8a=0xce;}_0x173f63[_0xc554('0x1d')](_0x35bf8a);return _0x173f63[_0xc554('0x24')](_0xc554('0x25'),_0x5009df+'-'+_0x6b2cf5+'/'+_0x51c89b)[_0xc554('0x1f')](_0x54a34b);}return null;};}function patchUpdates(_0x3197e3){return function(_0x351f54){try{jsonpatch[_0xc554('0x26')](_0x351f54,_0x3197e3,!![]);}catch(_0x5633e1){return BPromise[_0xc554('0x27')](_0x5633e1);}return _0x351f54['save']();};}function saveUpdates(_0x1506ef,_0x4c9b3b){return function(_0x45624b){if(_0x45624b){return _0x45624b[_0xc554('0x28')](_0x1506ef)['then'](function(_0x433e9b){return _0x433e9b;});}return null;};}function removeEntity(_0x32a1fd,_0x1c80fb){return function(_0xb171bb){if(_0xb171bb){return _0xb171bb[_0xc554('0x29')]()[_0xc554('0x2a')](function(){_0x32a1fd[_0xc554('0x1d')](0xcc)[_0xc554('0x1e')]();});}};}function handleEntityNotFound(_0x4a6384,_0x176efe){return function(_0x53edcc){if(!_0x53edcc){_0x4a6384[_0xc554('0x1c')](0x194);}return _0x53edcc;};}function handleError(_0x5e636d,_0x7ed7ca){_0x7ed7ca=_0x7ed7ca||0x1f4;return function(_0x7f1ebc){logger[_0xc554('0x2b')](_0x7f1ebc['stack']);if(_0x7f1ebc[_0xc554('0x2c')]){delete _0x7f1ebc[_0xc554('0x2c')];}_0x5e636d[_0xc554('0x1d')](_0x7ed7ca)[_0xc554('0x2d')](_0x7f1ebc);};}exports['index']=function(_0x1287f4,_0x58cde9){var _0x6fef5a={},_0x4fc458={},_0x22fd71={'count':0x0,'rows':[]};var _0x50d3f3=_[_0xc554('0x2e')](db[_0xc554('0x2f')][_0xc554('0x30')],function(_0xe05459){return{'name':_0xe05459['fieldName'],'type':_0xe05459[_0xc554('0x31')][_0xc554('0x32')]};});_0x4fc458['model']=_['map'](_0x50d3f3,_0xc554('0x2c'));_0x4fc458['query']=_[_0xc554('0x33')](_0x1287f4[_0xc554('0x34')]);_0x4fc458[_0xc554('0x35')]=_[_0xc554('0x36')](_0x4fc458['model'],_0x4fc458['query']);_0x6fef5a['attributes']=_[_0xc554('0x36')](_0x4fc458['model'],qs['fields'](_0x1287f4[_0xc554('0x34')][_0xc554('0x37')]));_0x6fef5a[_0xc554('0x38')]=_0x6fef5a[_0xc554('0x38')][_0xc554('0x39')]?_0x6fef5a[_0xc554('0x38')]:_0x4fc458[_0xc554('0x3a')];if(!_0x1287f4[_0xc554('0x34')]['hasOwnProperty']('nolimit')){_0x6fef5a[_0xc554('0x22')]=qs[_0xc554('0x22')](_0x1287f4[_0xc554('0x34')][_0xc554('0x22')]);_0x6fef5a[_0xc554('0x20')]=qs[_0xc554('0x20')](_0x1287f4[_0xc554('0x34')]['offset']);}_0x6fef5a['order']=qs[_0xc554('0x3b')](_0x1287f4[_0xc554('0x34')][_0xc554('0x3b')]);_0x6fef5a['where']=qs[_0xc554('0x35')](_['pick'](_0x1287f4[_0xc554('0x34')],_0x4fc458[_0xc554('0x35')]),_0x50d3f3);if(_0x1287f4[_0xc554('0x34')]['filter']){_0x6fef5a['where']=_[_0xc554('0x3c')](_0x6fef5a['where'],{'$or':_[_0xc554('0x2e')](_0x50d3f3,function(_0x2cdcb0){if(_0x2cdcb0['type']!=='VIRTUAL'){var _0x3902fb={};_0x3902fb[_0x2cdcb0[_0xc554('0x2c')]]={'$like':'%'+_0x1287f4[_0xc554('0x34')]['filter']+'%'};return _0x3902fb;}})});}_0x6fef5a=_[_0xc554('0x3c')]({},_0x6fef5a,_0x1287f4[_0xc554('0x3d')]);var _0x4e26c4={'where':_0x6fef5a['where']};return db[_0xc554('0x2f')][_0xc554('0x23')](_0x4e26c4)[_0xc554('0x2a')](function(_0x5c33ea){_0x22fd71[_0xc554('0x23')]=_0x5c33ea;if(_0x1287f4[_0xc554('0x34')][_0xc554('0x3e')]){_0x6fef5a['include']=[{'all':!![]}];}return db[_0xc554('0x2f')][_0xc554('0x3f')](_0x6fef5a);})['then'](function(_0x5c2b57){_0x22fd71[_0xc554('0x40')]=_0x5c2b57;return _0x22fd71;})[_0xc554('0x2a')](respondWithFilteredResult(_0x58cde9,_0x6fef5a))[_0xc554('0x41')](handleError(_0x58cde9,null));};exports[_0xc554('0x42')]=function(_0x5168e5,_0x3d49fd){var _0x23e5f3={'raw':![],'where':{'id':_0x5168e5[_0xc554('0x43')]['id']}},_0x53bdff={};_0x53bdff[_0xc554('0x3a')]=_[_0xc554('0x33')](db[_0xc554('0x2f')][_0xc554('0x30')]);_0x53bdff['query']=_['keys'](_0x5168e5[_0xc554('0x34')]);_0x53bdff[_0xc554('0x35')]=_[_0xc554('0x36')](_0x53bdff[_0xc554('0x3a')],_0x53bdff[_0xc554('0x34')]);_0x23e5f3[_0xc554('0x38')]=_[_0xc554('0x36')](_0x53bdff['model'],qs[_0xc554('0x37')](_0x5168e5[_0xc554('0x34')][_0xc554('0x37')]));_0x23e5f3['attributes']=_0x23e5f3['attributes'][_0xc554('0x39')]?_0x23e5f3[_0xc554('0x38')]:_0x53bdff[_0xc554('0x3a')];if(_0x5168e5['query']['includeAll']){_0x23e5f3[_0xc554('0x44')]=[{'all':!![]}];}_0x23e5f3=_['merge']({},_0x23e5f3,_0x5168e5[_0xc554('0x3d')]);return db[_0xc554('0x2f')][_0xc554('0x45')](_0x23e5f3)[_0xc554('0x2a')](handleEntityNotFound(_0x3d49fd,null))[_0xc554('0x2a')](respondWithResult(_0x3d49fd,null))[_0xc554('0x41')](handleError(_0x3d49fd,null));};exports[_0xc554('0x46')]=function(_0x3173b8,_0x241f68){return db[_0xc554('0x2f')]['create'](_0x3173b8[_0xc554('0x47')],{})[_0xc554('0x2a')](respondWithResult(_0x241f68,0xc9))[_0xc554('0x41')](handleError(_0x241f68,null));};exports['update']=function(_0x3592aa,_0x130126){if(_0x3592aa[_0xc554('0x47')]['id']){delete _0x3592aa[_0xc554('0x47')]['id'];}return db[_0xc554('0x2f')][_0xc554('0x45')]({'where':{'id':_0x3592aa['params']['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x130126,null))[_0xc554('0x2a')](saveUpdates(_0x3592aa[_0xc554('0x47')],null))[_0xc554('0x2a')](respondWithResult(_0x130126,null))[_0xc554('0x41')](handleError(_0x130126,null));};exports['destroy']=function(_0x4c2b14,_0x4c7603){return db['DeskAccount'][_0xc554('0x45')]({'where':{'id':_0x4c2b14[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x4c7603,null))[_0xc554('0x2a')](removeEntity(_0x4c7603,null))[_0xc554('0x41')](handleError(_0x4c7603,null));};exports[_0xc554('0x48')]=function(_0x276161,_0x4e77aa,_0x31cc47){var _0x1214d6={};var _0x1f1309={};var _0xb95fb1;var _0x2595aa;return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x276161[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x4e77aa,null))[_0xc554('0x2a')](function(_0xc33439){if(_0xc33439){_0xb95fb1=_0xc33439;_0x1f1309[_0xc554('0x3a')]=_[_0xc554('0x33')](db[_0xc554('0x4a')]['rawAttributes']);_0x1f1309[_0xc554('0x34')]=_[_0xc554('0x33')](_0x276161['query']);_0x1f1309[_0xc554('0x35')]=_[_0xc554('0x36')](_0x1f1309[_0xc554('0x3a')],_0x1f1309['query']);_0x1214d6['attributes']=_[_0xc554('0x36')](_0x1f1309[_0xc554('0x3a')],qs[_0xc554('0x37')](_0x276161[_0xc554('0x34')][_0xc554('0x37')]));_0x1214d6[_0xc554('0x38')]=_0x1214d6[_0xc554('0x38')][_0xc554('0x39')]?_0x1214d6[_0xc554('0x38')]:_0x1f1309[_0xc554('0x3a')];_0x1214d6[_0xc554('0x4b')]=qs[_0xc554('0x3b')](_0x276161[_0xc554('0x34')][_0xc554('0x3b')]);_0x1214d6[_0xc554('0x4c')]=qs[_0xc554('0x35')](_[_0xc554('0x4d')](_0x276161[_0xc554('0x34')],_0x1f1309[_0xc554('0x35')]));if(_0x276161[_0xc554('0x34')]['filter']){_0x1214d6[_0xc554('0x4c')]=_[_0xc554('0x3c')](_0x1214d6['where'],{'$or':_[_0xc554('0x2e')](_0x1214d6[_0xc554('0x38')],function(_0x60abe9){var _0xfbf9fd={};_0xfbf9fd[_0x60abe9]={'$like':'%'+_0x276161[_0xc554('0x34')]['filter']+'%'};return _0xfbf9fd;})});}_0x1214d6=_[_0xc554('0x3c')]({},_0x1214d6,_0x276161['options']);return _0xb95fb1['getConfigurations'](_0x1214d6);}})[_0xc554('0x2a')](function(_0x363ca0){if(_0x363ca0){_0x2595aa=_0x363ca0[_0xc554('0x39')];if(!_0x276161['query'][_0xc554('0x4e')](_0xc554('0x4f'))){_0x1214d6[_0xc554('0x22')]=qs[_0xc554('0x22')](_0x276161[_0xc554('0x34')][_0xc554('0x22')]);_0x1214d6[_0xc554('0x20')]=qs[_0xc554('0x20')](_0x276161[_0xc554('0x34')][_0xc554('0x20')]);}return _0xb95fb1[_0xc554('0x48')](_0x1214d6);}})[_0xc554('0x2a')](function(_0x5c27b0){if(_0x5c27b0){return _0x5c27b0?{'count':_0x2595aa,'rows':_0x5c27b0}:null;}})[_0xc554('0x2a')](respondWithResult(_0x4e77aa,null))[_0xc554('0x41')](handleError(_0x4e77aa,null));};exports[_0xc554('0x50')]=function(_0x2e5a49,_0x35e61c,_0x3904b3){if(_0x2e5a49[_0xc554('0x47')]['id']){delete _0x2e5a49['body']['id'];}return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x2e5a49[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x35e61c,null))[_0xc554('0x2a')](function(_0x52d12c){if(_0x52d12c){_0x2e5a49[_0xc554('0x47')][_0xc554('0x51')]=_0x52d12c['id'];_0x2e5a49[_0xc554('0x47')][_0xc554('0x52')]=integrations['getSubjects'](_0x2e5a49[_0xc554('0x47')][_0xc554('0x53')],_0x2e5a49[_0xc554('0x47')][_0xc554('0x31')]);_0x2e5a49[_0xc554('0x47')][_0xc554('0x54')]=integrations[_0xc554('0x55')](_0x2e5a49['body'][_0xc554('0x53')],_0x2e5a49['body'][_0xc554('0x31')]);return db[_0xc554('0x4a')][_0xc554('0x46')](_0x2e5a49[_0xc554('0x47')],{'include':[{'model':db['DeskField'],'as':_0xc554('0x52')},{'model':db[_0xc554('0x56')],'as':_0xc554('0x54')}]});}return null;})[_0xc554('0x2a')](respondWithResult(_0x35e61c,null))[_0xc554('0x41')](handleError(_0x35e61c,null));};exports[_0xc554('0x57')]=function(_0x2ea0d5,_0x3f4cfb,_0x293da1){var _0x2af638=[{'name':_0xc554('0x58'),'label':_0xc554('0x58'),'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 _0x301584='';return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x2ea0d5[_0xc554('0x43')]['id']},'attributes':['id','remoteUri',_0xc554('0x59'),_0xc554('0x5a'),_0xc554('0x5b'),_0xc554('0x5c'),_0xc554('0x5d'),_0xc554('0x5e'),_0xc554('0x5f')]})['then'](handleEntityNotFound(_0x3f4cfb,null))[_0xc554('0x2a')](function(_0x479575){if(_0x479575){_0x301584=_0x479575['remoteUri'];var _0xf23b3f=_0x301584['slice'](-0x1);if(_0xf23b3f==='/'){_0x301584=_0x301584[_0xc554('0x60')](0x0,_0x301584[_0xc554('0x61')](_0xf23b3f));}var _0x14c837={'method':_0xc554('0x62'),'uri':util[_0xc554('0x63')]('%s/custom_fields',_0x301584),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x479575['authType']===_0xc554('0x64')){_0x14c837[_0xc554('0x65')][_0xc554('0x66')]=util[_0xc554('0x63')]('Basic\x20%s',new Buffer(util[_0xc554('0x63')]('%s:%s',_0x479575[_0xc554('0x5a')],_0x479575[_0xc554('0x5b')]))[_0xc554('0x67')]('base64'));}return rp(_0x14c837)[_0xc554('0x2a')](function(_0x1d6bf4){return _0x2af638[_0xc554('0x68')](_[_0xc554('0x2e')](_0x1d6bf4[_0xc554('0x69')][_0xc554('0x6a')],function(_0x1ffd01){return{'id':_0x1ffd01['name'],'name':_0x1ffd01[_0xc554('0x2c')],'type':_0x1ffd01[_0xc554('0x31')],'active':_0x1ffd01[_0xc554('0x6b')],'label':_0x1ffd01[_0xc554('0x6c')],'custom':!![]};}));});}})[_0xc554('0x2a')](function(_0x4ea1d5){return{'count':_0x4ea1d5[_0xc554('0x39')],'rows':_0x4ea1d5};})[_0xc554('0x2a')](respondWithResult(_0x3f4cfb,null))[_0xc554('0x41')](function(_0x22f1da){var _0x5285ba=_0x2ea0d5[_0xc554('0x34')]['test']?0x1f4:_0x22f1da[_0xc554('0x6d')]||0x1f4;logger[_0xc554('0x2b')](_0xc554('0x6e'),_0xc554('0x57'),_0x5285ba,JSON[_0xc554('0x6f')](_0x22f1da));delete _0x22f1da['name'];if(_0x5285ba===0x191){_0x5285ba=0x190;}_0x3f4cfb['status'](_0x5285ba)[_0xc554('0x2d')](_0x2ea0d5[_0xc554('0x34')][_0xc554('0x70')]?{'message':_0xc554('0x71'),'statusCode':_0x22f1da[_0xc554('0x6d')]}:_0x22f1da);});};
\ No newline at end of file