Built motion from commit a61a4a20.|2.5.46
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 4bf8471..775733b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd372=['rawAttributes','create','body','update','destroy','find','DeskConfiguration','nolimit','getConfigurations','findOne','getSubjects','channel','Descriptions','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','slice','substring','format','%s/custom_fields','application/json','basic','Authorization','base64','concat','entries','active','label','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','then','end','stack','name','send','index','DeskAccount','fieldName','type','model','map','filters','intersection','attributes','fields','query','length','hasOwnProperty','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','rows','catch','show','params','keys'];(function(_0x40ac5e,_0x2de228){var _0x2839d6=function(_0x123d47){while(--_0x123d47){_0x40ac5e['push'](_0x40ac5e['shift']());}};_0x2839d6(++_0x2de228);}(_0xd372,0x15f));var _0x2d37=function(_0x453f3a,_0x478fc9){_0x453f3a=_0x453f3a-0x0;var _0x493272=_0xd372[_0x453f3a];return _0x493272;};'use strict';var emlformat=require(_0x2d37('0x0'));var rimraf=require(_0x2d37('0x1'));var zipdir=require(_0x2d37('0x2'));var jsonpatch=require(_0x2d37('0x3'));var rp=require(_0x2d37('0x4'));var moment=require(_0x2d37('0x5'));var BPromise=require(_0x2d37('0x6'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x2d37('0x7'));var csv=require(_0x2d37('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x2d37('0x9'));var _=require(_0x2d37('0xa'));var squel=require(_0x2d37('0xb'));var crypto=require(_0x2d37('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x2d37('0xd'));var toCsv=require('to-csv');var querystring=require(_0x2d37('0xe'));var Papa=require(_0x2d37('0xf'));var Redis=require('ioredis');var authService=require(_0x2d37('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x2d37('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0x2d37('0x12'));var db=require(_0x2d37('0x13'))['db'];var integrations=require(_0x2d37('0x14'));function respondWithStatusCode(_0x1d374b,_0x4f5a04){_0x4f5a04=_0x4f5a04||0xcc;return function(_0xc750f7){if(_0xc750f7){return _0x1d374b[_0x2d37('0x15')](_0x4f5a04);}return _0x1d374b[_0x2d37('0x16')](_0x4f5a04)['end']();};}function respondWithResult(_0x220a69,_0x3f7f3d){_0x3f7f3d=_0x3f7f3d||0xc8;return function(_0x33c904){if(_0x33c904){return _0x220a69[_0x2d37('0x16')](_0x3f7f3d)['json'](_0x33c904);}};}function respondWithFilteredResult(_0xc89943,_0x551b90){return function(_0x41ddd1){if(_0x41ddd1){var _0x4ea993=typeof _0x551b90[_0x2d37('0x17')]===_0x2d37('0x18')&&typeof _0x551b90[_0x2d37('0x19')]==='undefined';var _0x393df6=_0x41ddd1[_0x2d37('0x1a')];var _0x419ab3=_0x4ea993?0x0:_0x551b90[_0x2d37('0x17')];var _0x45f7b7=_0x4ea993?_0x41ddd1[_0x2d37('0x1a')]:_0x551b90[_0x2d37('0x17')]+_0x551b90['limit'];var _0x1739db;if(_0x45f7b7>=_0x393df6){_0x45f7b7=_0x393df6;_0x1739db=0xc8;}else{_0x1739db=0xce;}_0xc89943['status'](_0x1739db);return _0xc89943[_0x2d37('0x1b')](_0x2d37('0x1c'),_0x419ab3+'-'+_0x45f7b7+'/'+_0x393df6)[_0x2d37('0x1d')](_0x41ddd1);}return null;};}function patchUpdates(_0x4aa228){return function(_0xc42a56){try{jsonpatch[_0x2d37('0x1e')](_0xc42a56,_0x4aa228,!![]);}catch(_0x2ea6ce){return BPromise[_0x2d37('0x1f')](_0x2ea6ce);}return _0xc42a56[_0x2d37('0x20')]();};}function saveUpdates(_0x4880a5,_0x336e79){return function(_0xcf61f2){if(_0xcf61f2){return _0xcf61f2['update'](_0x4880a5)[_0x2d37('0x21')](function(_0x1c2d41){return _0x1c2d41;});}return null;};}function removeEntity(_0x279a9a,_0x1a9678){return function(_0x472bcf){if(_0x472bcf){return _0x472bcf['destroy']()[_0x2d37('0x21')](function(){_0x279a9a[_0x2d37('0x16')](0xcc)[_0x2d37('0x22')]();});}};}function handleEntityNotFound(_0x43f210,_0x58a046){return function(_0x334152){if(!_0x334152){_0x43f210['sendStatus'](0x194);}return _0x334152;};}function handleError(_0x5e71d0,_0x44766d){_0x44766d=_0x44766d||0x1f4;return function(_0x2092ca){logger['error'](_0x2092ca[_0x2d37('0x23')]);if(_0x2092ca['name']){delete _0x2092ca[_0x2d37('0x24')];}_0x5e71d0[_0x2d37('0x16')](_0x44766d)[_0x2d37('0x25')](_0x2092ca);};}exports[_0x2d37('0x26')]=function(_0x11f27a,_0x33c7b1){var _0x4362db={},_0x20663a={},_0x4e2f66={'count':0x0,'rows':[]};var _0x2dd650=_['map'](db[_0x2d37('0x27')]['rawAttributes'],function(_0x189461){return{'name':_0x189461[_0x2d37('0x28')],'type':_0x189461[_0x2d37('0x29')]['key']};});_0x20663a[_0x2d37('0x2a')]=_[_0x2d37('0x2b')](_0x2dd650,_0x2d37('0x24'));_0x20663a['query']=_['keys'](_0x11f27a['query']);_0x20663a[_0x2d37('0x2c')]=_[_0x2d37('0x2d')](_0x20663a['model'],_0x20663a['query']);_0x4362db[_0x2d37('0x2e')]=_['intersection'](_0x20663a[_0x2d37('0x2a')],qs[_0x2d37('0x2f')](_0x11f27a[_0x2d37('0x30')][_0x2d37('0x2f')]));_0x4362db[_0x2d37('0x2e')]=_0x4362db[_0x2d37('0x2e')][_0x2d37('0x31')]?_0x4362db['attributes']:_0x20663a['model'];if(!_0x11f27a[_0x2d37('0x30')][_0x2d37('0x32')]('nolimit')){_0x4362db[_0x2d37('0x19')]=qs['limit'](_0x11f27a[_0x2d37('0x30')][_0x2d37('0x19')]);_0x4362db[_0x2d37('0x17')]=qs['offset'](_0x11f27a[_0x2d37('0x30')][_0x2d37('0x17')]);}_0x4362db[_0x2d37('0x33')]=qs[_0x2d37('0x34')](_0x11f27a[_0x2d37('0x30')][_0x2d37('0x34')]);_0x4362db['where']=qs[_0x2d37('0x2c')](_[_0x2d37('0x35')](_0x11f27a[_0x2d37('0x30')],_0x20663a[_0x2d37('0x2c')]),_0x2dd650);if(_0x11f27a['query'][_0x2d37('0x36')]){_0x4362db[_0x2d37('0x37')]=_[_0x2d37('0x38')](_0x4362db[_0x2d37('0x37')],{'$or':_['map'](_0x2dd650,function(_0x5322ed){if(_0x5322ed[_0x2d37('0x29')]!==_0x2d37('0x39')){var _0x5acf8b={};_0x5acf8b[_0x5322ed[_0x2d37('0x24')]]={'$like':'%'+_0x11f27a[_0x2d37('0x30')]['filter']+'%'};return _0x5acf8b;}})});}_0x4362db=_[_0x2d37('0x38')]({},_0x4362db,_0x11f27a[_0x2d37('0x3a')]);var _0x11d7ed={'where':_0x4362db[_0x2d37('0x37')]};return db[_0x2d37('0x27')]['count'](_0x11d7ed)[_0x2d37('0x21')](function(_0x4f5d81){_0x4e2f66[_0x2d37('0x1a')]=_0x4f5d81;if(_0x11f27a[_0x2d37('0x30')][_0x2d37('0x3b')]){_0x4362db['include']=[{'all':!![]}];}return db[_0x2d37('0x27')]['findAll'](_0x4362db);})['then'](function(_0x3b5abb){_0x4e2f66[_0x2d37('0x3c')]=_0x3b5abb;return _0x4e2f66;})['then'](respondWithFilteredResult(_0x33c7b1,_0x4362db))[_0x2d37('0x3d')](handleError(_0x33c7b1,null));};exports[_0x2d37('0x3e')]=function(_0x340161,_0x27be6f){var _0x4d3b4e={'raw':![],'where':{'id':_0x340161[_0x2d37('0x3f')]['id']}},_0x7aa08d={};_0x7aa08d[_0x2d37('0x2a')]=_[_0x2d37('0x40')](db[_0x2d37('0x27')][_0x2d37('0x41')]);_0x7aa08d['query']=_['keys'](_0x340161[_0x2d37('0x30')]);_0x7aa08d[_0x2d37('0x2c')]=_['intersection'](_0x7aa08d[_0x2d37('0x2a')],_0x7aa08d[_0x2d37('0x30')]);_0x4d3b4e[_0x2d37('0x2e')]=_[_0x2d37('0x2d')](_0x7aa08d['model'],qs[_0x2d37('0x2f')](_0x340161[_0x2d37('0x30')][_0x2d37('0x2f')]));_0x4d3b4e['attributes']=_0x4d3b4e[_0x2d37('0x2e')][_0x2d37('0x31')]?_0x4d3b4e[_0x2d37('0x2e')]:_0x7aa08d[_0x2d37('0x2a')];if(_0x340161[_0x2d37('0x30')][_0x2d37('0x3b')]){_0x4d3b4e['include']=[{'all':!![]}];}_0x4d3b4e=_['merge']({},_0x4d3b4e,_0x340161['options']);return db[_0x2d37('0x27')]['find'](_0x4d3b4e)[_0x2d37('0x21')](handleEntityNotFound(_0x27be6f,null))[_0x2d37('0x21')](respondWithResult(_0x27be6f,null))[_0x2d37('0x3d')](handleError(_0x27be6f,null));};exports[_0x2d37('0x42')]=function(_0x543c07,_0x14b405){return db[_0x2d37('0x27')][_0x2d37('0x42')](_0x543c07[_0x2d37('0x43')],{})[_0x2d37('0x21')](respondWithResult(_0x14b405,0xc9))['catch'](handleError(_0x14b405,null));};exports[_0x2d37('0x44')]=function(_0x1b7067,_0x569d62){if(_0x1b7067[_0x2d37('0x43')]['id']){delete _0x1b7067['body']['id'];}return db[_0x2d37('0x27')]['find']({'where':{'id':_0x1b7067[_0x2d37('0x3f')]['id']}})[_0x2d37('0x21')](handleEntityNotFound(_0x569d62,null))[_0x2d37('0x21')](saveUpdates(_0x1b7067[_0x2d37('0x43')],null))['then'](respondWithResult(_0x569d62,null))[_0x2d37('0x3d')](handleError(_0x569d62,null));};exports[_0x2d37('0x45')]=function(_0x45e048,_0x58805f){return db[_0x2d37('0x27')][_0x2d37('0x46')]({'where':{'id':_0x45e048[_0x2d37('0x3f')]['id']}})[_0x2d37('0x21')](handleEntityNotFound(_0x58805f,null))[_0x2d37('0x21')](removeEntity(_0x58805f,null))[_0x2d37('0x3d')](handleError(_0x58805f,null));};exports['getConfigurations']=function(_0xf61201,_0x5c1746,_0x3a56b1){var _0x317150={};var _0x24e0c4={};var _0x6301eb;var _0x2f8d89;return db['DeskAccount']['findOne']({'where':{'id':_0xf61201['params']['id']}})['then'](handleEntityNotFound(_0x5c1746,null))[_0x2d37('0x21')](function(_0x5bd7b1){if(_0x5bd7b1){_0x6301eb=_0x5bd7b1;_0x24e0c4[_0x2d37('0x2a')]=_[_0x2d37('0x40')](db[_0x2d37('0x47')][_0x2d37('0x41')]);_0x24e0c4[_0x2d37('0x30')]=_['keys'](_0xf61201[_0x2d37('0x30')]);_0x24e0c4[_0x2d37('0x2c')]=_[_0x2d37('0x2d')](_0x24e0c4[_0x2d37('0x2a')],_0x24e0c4[_0x2d37('0x30')]);_0x317150['attributes']=_[_0x2d37('0x2d')](_0x24e0c4[_0x2d37('0x2a')],qs[_0x2d37('0x2f')](_0xf61201[_0x2d37('0x30')][_0x2d37('0x2f')]));_0x317150[_0x2d37('0x2e')]=_0x317150[_0x2d37('0x2e')][_0x2d37('0x31')]?_0x317150[_0x2d37('0x2e')]:_0x24e0c4[_0x2d37('0x2a')];_0x317150[_0x2d37('0x33')]=qs[_0x2d37('0x34')](_0xf61201[_0x2d37('0x30')][_0x2d37('0x34')]);_0x317150[_0x2d37('0x37')]=qs['filters'](_[_0x2d37('0x35')](_0xf61201[_0x2d37('0x30')],_0x24e0c4[_0x2d37('0x2c')]));if(_0xf61201[_0x2d37('0x30')][_0x2d37('0x36')]){_0x317150['where']=_[_0x2d37('0x38')](_0x317150[_0x2d37('0x37')],{'$or':_[_0x2d37('0x2b')](_0x317150[_0x2d37('0x2e')],function(_0x1d64fe){var _0x5f00ab={};_0x5f00ab[_0x1d64fe]={'$like':'%'+_0xf61201[_0x2d37('0x30')][_0x2d37('0x36')]+'%'};return _0x5f00ab;})});}_0x317150=_[_0x2d37('0x38')]({},_0x317150,_0xf61201[_0x2d37('0x3a')]);return _0x6301eb['getConfigurations'](_0x317150);}})['then'](function(_0x2e7b79){if(_0x2e7b79){_0x2f8d89=_0x2e7b79[_0x2d37('0x31')];if(!_0xf61201['query'][_0x2d37('0x32')](_0x2d37('0x48'))){_0x317150[_0x2d37('0x19')]=qs[_0x2d37('0x19')](_0xf61201[_0x2d37('0x30')][_0x2d37('0x19')]);_0x317150[_0x2d37('0x17')]=qs[_0x2d37('0x17')](_0xf61201[_0x2d37('0x30')][_0x2d37('0x17')]);}return _0x6301eb[_0x2d37('0x49')](_0x317150);}})[_0x2d37('0x21')](function(_0x3367f1){if(_0x3367f1){return _0x3367f1?{'count':_0x2f8d89,'rows':_0x3367f1}:null;}})[_0x2d37('0x21')](respondWithResult(_0x5c1746,null))[_0x2d37('0x3d')](handleError(_0x5c1746,null));};exports['addConfiguration']=function(_0x2693b5,_0x439852,_0x32ee3e){if(_0x2693b5[_0x2d37('0x43')]['id']){delete _0x2693b5[_0x2d37('0x43')]['id'];}return db[_0x2d37('0x27')][_0x2d37('0x4a')]({'where':{'id':_0x2693b5[_0x2d37('0x3f')]['id']}})[_0x2d37('0x21')](handleEntityNotFound(_0x439852,null))[_0x2d37('0x21')](function(_0x2473a4){if(_0x2473a4){_0x2693b5['body']['AccountId']=_0x2473a4['id'];_0x2693b5[_0x2d37('0x43')]['Subjects']=integrations[_0x2d37('0x4b')](_0x2693b5[_0x2d37('0x43')][_0x2d37('0x4c')],_0x2693b5[_0x2d37('0x43')][_0x2d37('0x29')]);_0x2693b5['body'][_0x2d37('0x4d')]=integrations['getDescriptions'](_0x2693b5[_0x2d37('0x43')][_0x2d37('0x4c')],_0x2693b5[_0x2d37('0x43')][_0x2d37('0x29')]);return db[_0x2d37('0x47')]['create'](_0x2693b5[_0x2d37('0x43')],{'include':[{'model':db[_0x2d37('0x4e')],'as':'Subjects'},{'model':db[_0x2d37('0x4e')],'as':_0x2d37('0x4d')}]});}return null;})[_0x2d37('0x21')](respondWithResult(_0x439852,null))[_0x2d37('0x3d')](handleError(_0x439852,null));};exports[_0x2d37('0x4f')]=function(_0x128c36,_0x3fbf77,_0x4fc084){var _0x14fee2=[{'name':_0x2d37('0x50'),'label':_0x2d37('0x50'),'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 _0x12b2ed='';return db[_0x2d37('0x27')][_0x2d37('0x4a')]({'where':{'id':_0x128c36['params']['id']},'attributes':['id',_0x2d37('0x51'),_0x2d37('0x52'),_0x2d37('0x53'),_0x2d37('0x54'),_0x2d37('0x55'),_0x2d37('0x56'),_0x2d37('0x57'),'tokenSecret']})[_0x2d37('0x21')](handleEntityNotFound(_0x3fbf77,null))['then'](function(_0x352117){if(_0x352117){_0x12b2ed=_0x352117[_0x2d37('0x51')];var _0x54a398=_0x12b2ed[_0x2d37('0x58')](-0x1);if(_0x54a398==='/'){_0x12b2ed=_0x12b2ed[_0x2d37('0x59')](0x0,_0x12b2ed['lastIndexOf'](_0x54a398));}var _0x3b9f34={'method':'GET','uri':util[_0x2d37('0x5a')](_0x2d37('0x5b'),_0x12b2ed),'headers':{'Content-Type':_0x2d37('0x5c'),'Accept':'application/json'},'json':!![]};if(_0x352117[_0x2d37('0x52')]===_0x2d37('0x5d')){_0x3b9f34['headers'][_0x2d37('0x5e')]=util['format']('Basic\x20%s',new Buffer(util[_0x2d37('0x5a')]('%s:%s',_0x352117[_0x2d37('0x53')],_0x352117[_0x2d37('0x54')]))['toString'](_0x2d37('0x5f')));}return rp(_0x3b9f34)['then'](function(_0x2b2b1b){return _0x14fee2[_0x2d37('0x60')](_['map'](_0x2b2b1b['_embedded'][_0x2d37('0x61')],function(_0x3e8825){return{'id':_0x3e8825[_0x2d37('0x24')],'name':_0x3e8825[_0x2d37('0x24')],'type':_0x3e8825[_0x2d37('0x29')],'active':_0x3e8825[_0x2d37('0x62')],'label':_0x3e8825[_0x2d37('0x63')],'custom':!![]};}));});}})[_0x2d37('0x21')](function(_0x35a8cc){return{'count':_0x35a8cc[_0x2d37('0x31')],'rows':_0x35a8cc};})[_0x2d37('0x21')](respondWithResult(_0x3fbf77,null))[_0x2d37('0x3d')](function(_0x3fa083){var _0x24c779=_0x128c36[_0x2d37('0x30')][_0x2d37('0x64')]?0x1f4:_0x3fa083[_0x2d37('0x65')]||0x1f4;logger['error'](_0x2d37('0x66'),'getFields',_0x24c779,JSON[_0x2d37('0x67')](_0x3fa083));delete _0x3fa083[_0x2d37('0x24')];if(_0x24c779===0x191){_0x24c779=0x190;}_0x3fbf77['status'](_0x24c779)[_0x2d37('0x25')](_0x128c36[_0x2d37('0x30')][_0x2d37('0x64')]?{'message':'Wrong\x20credentials','statusCode':_0x3fa083[_0x2d37('0x65')]}:_0x3fa083);});};
\ No newline at end of file
+var _0x13c9=['key','model','map','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','DeskAccount','includeAll','include','findAll','catch','show','params','keys','find','create','body','getConfigurations','findOne','DeskConfiguration','addConfiguration','AccountId','Subjects','channel','getDescriptions','DeskField','Descriptions','priority','authType','username','consumerSecret','tokenSecret','remoteUri','substring','lastIndexOf','GET','format','%s/custom_fields','application/json','basic','headers','%s:%s','password','toString','base64','concat','_embedded','entries','active','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','send','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','status','json','offset','undefined','count','limit','Content-Range','save','update','then','destroy','end','sendStatus','error','name','index','rawAttributes','fieldName','type'];(function(_0x1419be,_0x2003f2){var _0x5136bd=function(_0x49c834){while(--_0x49c834){_0x1419be['push'](_0x1419be['shift']());}};_0x5136bd(++_0x2003f2);}(_0x13c9,0x11e));var _0x913c=function(_0x1653ba,_0x272a5a){_0x1653ba=_0x1653ba-0x0;var _0x2d5912=_0x13c9[_0x1653ba];return _0x2d5912;};'use strict';var emlformat=require(_0x913c('0x0'));var rimraf=require(_0x913c('0x1'));var zipdir=require(_0x913c('0x2'));var jsonpatch=require(_0x913c('0x3'));var rp=require(_0x913c('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x913c('0x5'));var path=require(_0x913c('0x6'));var sox=require(_0x913c('0x7'));var csv=require(_0x913c('0x8'));var ejs=require(_0x913c('0x9'));var fs=require('fs');var fs_extra=require(_0x913c('0xa'));var _=require(_0x913c('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x913c('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x913c('0x8'));var querystring=require(_0x913c('0xd'));var Papa=require('papaparse');var Redis=require(_0x913c('0xe'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x913c('0xf'));var hardwareService=require(_0x913c('0x10'));var logger=require(_0x913c('0x11'))('api');var utils=require(_0x913c('0x12'));var config=require(_0x913c('0x13'));var licenseUtil=require(_0x913c('0x14'));var db=require('../../mysqldb')['db'];var integrations=require(_0x913c('0x15'));function respondWithStatusCode(_0x3b1d00,_0x2f8437){_0x2f8437=_0x2f8437||0xcc;return function(_0x4a9d18){if(_0x4a9d18){return _0x3b1d00['sendStatus'](_0x2f8437);}return _0x3b1d00['status'](_0x2f8437)['end']();};}function respondWithResult(_0x511924,_0x5f19f2){_0x5f19f2=_0x5f19f2||0xc8;return function(_0x1508b4){if(_0x1508b4){return _0x511924[_0x913c('0x16')](_0x5f19f2)[_0x913c('0x17')](_0x1508b4);}};}function respondWithFilteredResult(_0x3cb38b,_0x1071a4){return function(_0x4c5e57){if(_0x4c5e57){var _0x189179=typeof _0x1071a4[_0x913c('0x18')]===_0x913c('0x19')&&typeof _0x1071a4['limit']===_0x913c('0x19');var _0x34c848=_0x4c5e57[_0x913c('0x1a')];var _0x583633=_0x189179?0x0:_0x1071a4[_0x913c('0x18')];var _0x5bb42c=_0x189179?_0x4c5e57['count']:_0x1071a4['offset']+_0x1071a4[_0x913c('0x1b')];var _0x4f1030;if(_0x5bb42c>=_0x34c848){_0x5bb42c=_0x34c848;_0x4f1030=0xc8;}else{_0x4f1030=0xce;}_0x3cb38b[_0x913c('0x16')](_0x4f1030);return _0x3cb38b['set'](_0x913c('0x1c'),_0x583633+'-'+_0x5bb42c+'/'+_0x34c848)[_0x913c('0x17')](_0x4c5e57);}return null;};}function patchUpdates(_0x314786){return function(_0x3559df){try{jsonpatch['apply'](_0x3559df,_0x314786,!![]);}catch(_0x3106ce){return BPromise['reject'](_0x3106ce);}return _0x3559df[_0x913c('0x1d')]();};}function saveUpdates(_0x51f184,_0x3ef244){return function(_0x5bab5e){if(_0x5bab5e){return _0x5bab5e[_0x913c('0x1e')](_0x51f184)[_0x913c('0x1f')](function(_0x2f5bcd){return _0x2f5bcd;});}return null;};}function removeEntity(_0x5df151,_0x236bb2){return function(_0x4a3785){if(_0x4a3785){return _0x4a3785[_0x913c('0x20')]()[_0x913c('0x1f')](function(){_0x5df151[_0x913c('0x16')](0xcc)[_0x913c('0x21')]();});}};}function handleEntityNotFound(_0x2667f9,_0x219123){return function(_0x4bd65b){if(!_0x4bd65b){_0x2667f9[_0x913c('0x22')](0x194);}return _0x4bd65b;};}function handleError(_0x3b6d63,_0x2466f0){_0x2466f0=_0x2466f0||0x1f4;return function(_0x3aea82){logger[_0x913c('0x23')](_0x3aea82['stack']);if(_0x3aea82['name']){delete _0x3aea82[_0x913c('0x24')];}_0x3b6d63[_0x913c('0x16')](_0x2466f0)['send'](_0x3aea82);};}exports[_0x913c('0x25')]=function(_0x43bfdf,_0x3e6060){var _0x3b0b7f={},_0xdf04b1={},_0x243044={'count':0x0,'rows':[]};var _0x55d903=_['map'](db['DeskAccount'][_0x913c('0x26')],function(_0x28be9c){return{'name':_0x28be9c[_0x913c('0x27')],'type':_0x28be9c[_0x913c('0x28')][_0x913c('0x29')]};});_0xdf04b1[_0x913c('0x2a')]=_[_0x913c('0x2b')](_0x55d903,'name');_0xdf04b1['query']=_['keys'](_0x43bfdf[_0x913c('0x2c')]);_0xdf04b1[_0x913c('0x2d')]=_[_0x913c('0x2e')](_0xdf04b1[_0x913c('0x2a')],_0xdf04b1['query']);_0x3b0b7f[_0x913c('0x2f')]=_[_0x913c('0x2e')](_0xdf04b1[_0x913c('0x2a')],qs[_0x913c('0x30')](_0x43bfdf[_0x913c('0x2c')][_0x913c('0x30')]));_0x3b0b7f[_0x913c('0x2f')]=_0x3b0b7f[_0x913c('0x2f')][_0x913c('0x31')]?_0x3b0b7f[_0x913c('0x2f')]:_0xdf04b1[_0x913c('0x2a')];if(!_0x43bfdf[_0x913c('0x2c')]['hasOwnProperty'](_0x913c('0x32'))){_0x3b0b7f[_0x913c('0x1b')]=qs['limit'](_0x43bfdf['query'][_0x913c('0x1b')]);_0x3b0b7f['offset']=qs[_0x913c('0x18')](_0x43bfdf[_0x913c('0x2c')]['offset']);}_0x3b0b7f[_0x913c('0x33')]=qs[_0x913c('0x34')](_0x43bfdf[_0x913c('0x2c')][_0x913c('0x34')]);_0x3b0b7f[_0x913c('0x35')]=qs[_0x913c('0x2d')](_[_0x913c('0x36')](_0x43bfdf[_0x913c('0x2c')],_0xdf04b1[_0x913c('0x2d')]),_0x55d903);if(_0x43bfdf[_0x913c('0x2c')][_0x913c('0x37')]){_0x3b0b7f[_0x913c('0x35')]=_[_0x913c('0x38')](_0x3b0b7f[_0x913c('0x35')],{'$or':_[_0x913c('0x2b')](_0x55d903,function(_0x11ff6a){if(_0x11ff6a[_0x913c('0x28')]!==_0x913c('0x39')){var _0x3f695e={};_0x3f695e[_0x11ff6a[_0x913c('0x24')]]={'$like':'%'+_0x43bfdf[_0x913c('0x2c')][_0x913c('0x37')]+'%'};return _0x3f695e;}})});}_0x3b0b7f=_[_0x913c('0x38')]({},_0x3b0b7f,_0x43bfdf[_0x913c('0x3a')]);var _0x35f986={'where':_0x3b0b7f['where']};return db[_0x913c('0x3b')][_0x913c('0x1a')](_0x35f986)[_0x913c('0x1f')](function(_0x266e3b){_0x243044[_0x913c('0x1a')]=_0x266e3b;if(_0x43bfdf['query'][_0x913c('0x3c')]){_0x3b0b7f[_0x913c('0x3d')]=[{'all':!![]}];}return db[_0x913c('0x3b')][_0x913c('0x3e')](_0x3b0b7f);})[_0x913c('0x1f')](function(_0x18ce3f){_0x243044['rows']=_0x18ce3f;return _0x243044;})[_0x913c('0x1f')](respondWithFilteredResult(_0x3e6060,_0x3b0b7f))[_0x913c('0x3f')](handleError(_0x3e6060,null));};exports[_0x913c('0x40')]=function(_0x3362fe,_0x4127c2){var _0x3322ff={'raw':![],'where':{'id':_0x3362fe[_0x913c('0x41')]['id']}},_0x2906c2={};_0x2906c2[_0x913c('0x2a')]=_[_0x913c('0x42')](db[_0x913c('0x3b')][_0x913c('0x26')]);_0x2906c2[_0x913c('0x2c')]=_['keys'](_0x3362fe[_0x913c('0x2c')]);_0x2906c2[_0x913c('0x2d')]=_['intersection'](_0x2906c2['model'],_0x2906c2['query']);_0x3322ff[_0x913c('0x2f')]=_[_0x913c('0x2e')](_0x2906c2['model'],qs[_0x913c('0x30')](_0x3362fe[_0x913c('0x2c')][_0x913c('0x30')]));_0x3322ff[_0x913c('0x2f')]=_0x3322ff[_0x913c('0x2f')][_0x913c('0x31')]?_0x3322ff[_0x913c('0x2f')]:_0x2906c2[_0x913c('0x2a')];if(_0x3362fe[_0x913c('0x2c')][_0x913c('0x3c')]){_0x3322ff[_0x913c('0x3d')]=[{'all':!![]}];}_0x3322ff=_[_0x913c('0x38')]({},_0x3322ff,_0x3362fe[_0x913c('0x3a')]);return db[_0x913c('0x3b')][_0x913c('0x43')](_0x3322ff)[_0x913c('0x1f')](handleEntityNotFound(_0x4127c2,null))['then'](respondWithResult(_0x4127c2,null))['catch'](handleError(_0x4127c2,null));};exports[_0x913c('0x44')]=function(_0x31fd49,_0x557c04){return db[_0x913c('0x3b')]['create'](_0x31fd49[_0x913c('0x45')],{})['then'](respondWithResult(_0x557c04,0xc9))[_0x913c('0x3f')](handleError(_0x557c04,null));};exports[_0x913c('0x1e')]=function(_0x722178,_0xc27bc1){if(_0x722178[_0x913c('0x45')]['id']){delete _0x722178[_0x913c('0x45')]['id'];}return db[_0x913c('0x3b')][_0x913c('0x43')]({'where':{'id':_0x722178[_0x913c('0x41')]['id']}})[_0x913c('0x1f')](handleEntityNotFound(_0xc27bc1,null))[_0x913c('0x1f')](saveUpdates(_0x722178['body'],null))[_0x913c('0x1f')](respondWithResult(_0xc27bc1,null))[_0x913c('0x3f')](handleError(_0xc27bc1,null));};exports['destroy']=function(_0x27e2be,_0x366e16){return db['DeskAccount'][_0x913c('0x43')]({'where':{'id':_0x27e2be[_0x913c('0x41')]['id']}})['then'](handleEntityNotFound(_0x366e16,null))[_0x913c('0x1f')](removeEntity(_0x366e16,null))[_0x913c('0x3f')](handleError(_0x366e16,null));};exports[_0x913c('0x46')]=function(_0xd441e4,_0x46edde,_0x54a5ff){var _0x2dd4bc={};var _0x5632f2={};var _0x40daea;var _0x40fdab;return db['DeskAccount'][_0x913c('0x47')]({'where':{'id':_0xd441e4[_0x913c('0x41')]['id']}})[_0x913c('0x1f')](handleEntityNotFound(_0x46edde,null))['then'](function(_0x29d293){if(_0x29d293){_0x40daea=_0x29d293;_0x5632f2[_0x913c('0x2a')]=_[_0x913c('0x42')](db[_0x913c('0x48')]['rawAttributes']);_0x5632f2['query']=_[_0x913c('0x42')](_0xd441e4[_0x913c('0x2c')]);_0x5632f2[_0x913c('0x2d')]=_[_0x913c('0x2e')](_0x5632f2[_0x913c('0x2a')],_0x5632f2[_0x913c('0x2c')]);_0x2dd4bc['attributes']=_[_0x913c('0x2e')](_0x5632f2[_0x913c('0x2a')],qs[_0x913c('0x30')](_0xd441e4[_0x913c('0x2c')][_0x913c('0x30')]));_0x2dd4bc['attributes']=_0x2dd4bc[_0x913c('0x2f')]['length']?_0x2dd4bc[_0x913c('0x2f')]:_0x5632f2['model'];_0x2dd4bc[_0x913c('0x33')]=qs[_0x913c('0x34')](_0xd441e4['query'][_0x913c('0x34')]);_0x2dd4bc[_0x913c('0x35')]=qs[_0x913c('0x2d')](_[_0x913c('0x36')](_0xd441e4[_0x913c('0x2c')],_0x5632f2['filters']));if(_0xd441e4[_0x913c('0x2c')][_0x913c('0x37')]){_0x2dd4bc[_0x913c('0x35')]=_[_0x913c('0x38')](_0x2dd4bc['where'],{'$or':_['map'](_0x2dd4bc[_0x913c('0x2f')],function(_0x2fc6dc){var _0x594104={};_0x594104[_0x2fc6dc]={'$like':'%'+_0xd441e4[_0x913c('0x2c')][_0x913c('0x37')]+'%'};return _0x594104;})});}_0x2dd4bc=_['merge']({},_0x2dd4bc,_0xd441e4['options']);return _0x40daea[_0x913c('0x46')](_0x2dd4bc);}})[_0x913c('0x1f')](function(_0x130937){if(_0x130937){_0x40fdab=_0x130937['length'];if(!_0xd441e4[_0x913c('0x2c')]['hasOwnProperty'](_0x913c('0x32'))){_0x2dd4bc[_0x913c('0x1b')]=qs[_0x913c('0x1b')](_0xd441e4[_0x913c('0x2c')][_0x913c('0x1b')]);_0x2dd4bc[_0x913c('0x18')]=qs[_0x913c('0x18')](_0xd441e4[_0x913c('0x2c')][_0x913c('0x18')]);}return _0x40daea[_0x913c('0x46')](_0x2dd4bc);}})['then'](function(_0x59dc25){if(_0x59dc25){return _0x59dc25?{'count':_0x40fdab,'rows':_0x59dc25}:null;}})[_0x913c('0x1f')](respondWithResult(_0x46edde,null))[_0x913c('0x3f')](handleError(_0x46edde,null));};exports[_0x913c('0x49')]=function(_0x4448c7,_0x53e544,_0x20188f){if(_0x4448c7[_0x913c('0x45')]['id']){delete _0x4448c7[_0x913c('0x45')]['id'];}return db['DeskAccount'][_0x913c('0x47')]({'where':{'id':_0x4448c7[_0x913c('0x41')]['id']}})[_0x913c('0x1f')](handleEntityNotFound(_0x53e544,null))[_0x913c('0x1f')](function(_0x4ca96d){if(_0x4ca96d){_0x4448c7[_0x913c('0x45')][_0x913c('0x4a')]=_0x4ca96d['id'];_0x4448c7['body'][_0x913c('0x4b')]=integrations['getSubjects'](_0x4448c7[_0x913c('0x45')][_0x913c('0x4c')],_0x4448c7[_0x913c('0x45')]['type']);_0x4448c7[_0x913c('0x45')]['Descriptions']=integrations[_0x913c('0x4d')](_0x4448c7[_0x913c('0x45')][_0x913c('0x4c')],_0x4448c7[_0x913c('0x45')][_0x913c('0x28')]);return db[_0x913c('0x48')][_0x913c('0x44')](_0x4448c7[_0x913c('0x45')],{'include':[{'model':db[_0x913c('0x4e')],'as':'Subjects'},{'model':db[_0x913c('0x4e')],'as':_0x913c('0x4f')}]});}return null;})['then'](respondWithResult(_0x53e544,null))[_0x913c('0x3f')](handleError(_0x53e544,null));};exports['getFields']=function(_0x16049b,_0x11ba02,_0x29c82d){var _0x2e23bf=[{'name':_0x913c('0x50'),'label':_0x913c('0x50'),'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 _0xd64381='';return db[_0x913c('0x3b')]['findOne']({'where':{'id':_0x16049b[_0x913c('0x41')]['id']},'attributes':['id','remoteUri',_0x913c('0x51'),_0x913c('0x52'),'password','consumerKey',_0x913c('0x53'),'token',_0x913c('0x54')]})[_0x913c('0x1f')](handleEntityNotFound(_0x11ba02,null))[_0x913c('0x1f')](function(_0x3489ff){if(_0x3489ff){_0xd64381=_0x3489ff[_0x913c('0x55')];var _0x42e83a=_0xd64381['slice'](-0x1);if(_0x42e83a==='/'){_0xd64381=_0xd64381[_0x913c('0x56')](0x0,_0xd64381[_0x913c('0x57')](_0x42e83a));}var _0xf69fa7={'method':_0x913c('0x58'),'uri':util[_0x913c('0x59')](_0x913c('0x5a'),_0xd64381),'headers':{'Content-Type':_0x913c('0x5b'),'Accept':_0x913c('0x5b')},'json':!![]};if(_0x3489ff['authType']===_0x913c('0x5c')){_0xf69fa7[_0x913c('0x5d')]['Authorization']=util[_0x913c('0x59')]('Basic\x20%s',new Buffer(util[_0x913c('0x59')](_0x913c('0x5e'),_0x3489ff[_0x913c('0x52')],_0x3489ff[_0x913c('0x5f')]))[_0x913c('0x60')](_0x913c('0x61')));}return rp(_0xf69fa7)[_0x913c('0x1f')](function(_0x16b1cf){return _0x2e23bf[_0x913c('0x62')](_[_0x913c('0x2b')](_0x16b1cf[_0x913c('0x63')][_0x913c('0x64')],function(_0x486b9c){return{'id':_0x486b9c[_0x913c('0x24')],'name':_0x486b9c[_0x913c('0x24')],'type':_0x486b9c[_0x913c('0x28')],'active':_0x486b9c[_0x913c('0x65')],'label':_0x486b9c['label'],'custom':!![]};}));});}})['then'](function(_0x224de7){return{'count':_0x224de7[_0x913c('0x31')],'rows':_0x224de7};})['then'](respondWithResult(_0x11ba02,null))[_0x913c('0x3f')](function(_0x26db76){var _0x2d1a09=_0x16049b[_0x913c('0x2c')]['test']?0x1f4:_0x26db76[_0x913c('0x66')]||0x1f4;logger[_0x913c('0x23')](_0x913c('0x67'),_0x913c('0x68'),_0x2d1a09,JSON[_0x913c('0x69')](_0x26db76));delete _0x26db76[_0x913c('0x24')];if(_0x2d1a09===0x191){_0x2d1a09=0x190;}_0x11ba02[_0x913c('0x16')](_0x2d1a09)[_0x913c('0x6a')](_0x16049b[_0x913c('0x2c')][_0x913c('0x6b')]?{'message':_0x913c('0x6c'),'statusCode':_0x26db76['statusCode']}:_0x26db76);});};
\ No newline at end of file