Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 0d03fc3..eb87028 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf1c8=['DeskField','getFields','priority','remoteUri','password','consumerKey','consumerSecret','token','slice','substring','lastIndexOf','%s/custom_fields','application/json','authType','Authorization','format','%s:%s','username','toString','concat','_embedded','entries','active','label','test','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','to-csv','lodash','squel','crypto','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../components/integrations/configuration','sendStatus','status','end','offset','limit','count','set','Content-Range','save','update','then','error','name','send','index','map','DeskAccount','rawAttributes','fieldName','key','query','keys','intersection','model','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','fields','length','include','find','body','findOne','DeskConfiguration','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','create'];(function(_0x3e12fd,_0x3cb5fc){var _0x6c8a9c=function(_0x5139ab){while(--_0x5139ab){_0x3e12fd['push'](_0x3e12fd['shift']());}};_0x6c8a9c(++_0x3cb5fc);}(_0xf1c8,0x15d));var _0x8f1c=function(_0x5392e8,_0x1ca8b9){_0x5392e8=_0x5392e8-0x0;var _0x43fce6=_0xf1c8[_0x5392e8];return _0x43fce6;};'use strict';var emlformat=require(_0x8f1c('0x0'));var rimraf=require(_0x8f1c('0x1'));var zipdir=require(_0x8f1c('0x2'));var jsonpatch=require(_0x8f1c('0x3'));var rp=require(_0x8f1c('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x8f1c('0x5'));var util=require(_0x8f1c('0x6'));var path=require(_0x8f1c('0x7'));var sox=require('sox');var csv=require(_0x8f1c('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8f1c('0x9'));var squel=require(_0x8f1c('0xa'));var crypto=require(_0x8f1c('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x8f1c('0x8'));var querystring=require(_0x8f1c('0xc'));var Papa=require('papaparse');var Redis=require(_0x8f1c('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x8f1c('0xe'));var as=require(_0x8f1c('0xf'));var hardwareService=require(_0x8f1c('0x10'));var logger=require('../../config/logger')(_0x8f1c('0x11'));var utils=require(_0x8f1c('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0x8f1c('0x13'));function respondWithStatusCode(_0x30bb13,_0x49885a){_0x49885a=_0x49885a||0xcc;return function(_0x506153){if(_0x506153){return _0x30bb13[_0x8f1c('0x14')](_0x49885a);}return _0x30bb13[_0x8f1c('0x15')](_0x49885a)[_0x8f1c('0x16')]();};}function respondWithResult(_0x2973c2,_0x5cf16d){_0x5cf16d=_0x5cf16d||0xc8;return function(_0xe8313e){if(_0xe8313e){return _0x2973c2['status'](_0x5cf16d)['json'](_0xe8313e);}};}function respondWithFilteredResult(_0x10fe4a,_0x2d24f7){return function(_0x97c312){if(_0x97c312){var _0x469e96=typeof _0x2d24f7[_0x8f1c('0x17')]==='undefined'&&typeof _0x2d24f7[_0x8f1c('0x18')]==='undefined';var _0x5d04f0=_0x97c312[_0x8f1c('0x19')];var _0x30cea2=_0x469e96?0x0:_0x2d24f7['offset'];var _0x4fae42=_0x469e96?_0x97c312[_0x8f1c('0x19')]:_0x2d24f7[_0x8f1c('0x17')]+_0x2d24f7[_0x8f1c('0x18')];var _0x1be8d6;if(_0x4fae42>=_0x5d04f0){_0x4fae42=_0x5d04f0;_0x1be8d6=0xc8;}else{_0x1be8d6=0xce;}_0x10fe4a['status'](_0x1be8d6);return _0x10fe4a[_0x8f1c('0x1a')](_0x8f1c('0x1b'),_0x30cea2+'-'+_0x4fae42+'/'+_0x5d04f0)['json'](_0x97c312);}return null;};}function patchUpdates(_0x119736){return function(_0x46e757){try{jsonpatch['apply'](_0x46e757,_0x119736,!![]);}catch(_0x111140){return BPromise['reject'](_0x111140);}return _0x46e757[_0x8f1c('0x1c')]();};}function saveUpdates(_0x1be26b,_0x24d42e){return function(_0x2c7695){if(_0x2c7695){return _0x2c7695[_0x8f1c('0x1d')](_0x1be26b)[_0x8f1c('0x1e')](function(_0x255f9a){return _0x255f9a;});}return null;};}function removeEntity(_0x4a7ec5,_0x509e1f){return function(_0x9cffd5){if(_0x9cffd5){return _0x9cffd5['destroy']()[_0x8f1c('0x1e')](function(){_0x4a7ec5[_0x8f1c('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x87aabe,_0x9e684d){return function(_0xc3deb4){if(!_0xc3deb4){_0x87aabe[_0x8f1c('0x14')](0x194);}return _0xc3deb4;};}function handleError(_0x3501bf,_0x19c037){_0x19c037=_0x19c037||0x1f4;return function(_0x455f66){logger[_0x8f1c('0x1f')](_0x455f66['stack']);if(_0x455f66[_0x8f1c('0x20')]){delete _0x455f66[_0x8f1c('0x20')];}_0x3501bf['status'](_0x19c037)[_0x8f1c('0x21')](_0x455f66);};}exports[_0x8f1c('0x22')]=function(_0x47530b,_0x4eed99){var _0x2b54b2={},_0x5a1a8f={},_0x1b9bb2={'count':0x0,'rows':[]};var _0x7ff259=_[_0x8f1c('0x23')](db[_0x8f1c('0x24')][_0x8f1c('0x25')],function(_0xfec2da){return{'name':_0xfec2da[_0x8f1c('0x26')],'type':_0xfec2da['type'][_0x8f1c('0x27')]};});_0x5a1a8f['model']=_[_0x8f1c('0x23')](_0x7ff259,_0x8f1c('0x20'));_0x5a1a8f[_0x8f1c('0x28')]=_[_0x8f1c('0x29')](_0x47530b[_0x8f1c('0x28')]);_0x5a1a8f['filters']=_[_0x8f1c('0x2a')](_0x5a1a8f[_0x8f1c('0x2b')],_0x5a1a8f[_0x8f1c('0x28')]);_0x2b54b2[_0x8f1c('0x2c')]=_[_0x8f1c('0x2a')](_0x5a1a8f[_0x8f1c('0x2b')],qs['fields'](_0x47530b['query']['fields']));_0x2b54b2[_0x8f1c('0x2c')]=_0x2b54b2[_0x8f1c('0x2c')]['length']?_0x2b54b2[_0x8f1c('0x2c')]:_0x5a1a8f[_0x8f1c('0x2b')];if(!_0x47530b['query'][_0x8f1c('0x2d')](_0x8f1c('0x2e'))){_0x2b54b2[_0x8f1c('0x18')]=qs[_0x8f1c('0x18')](_0x47530b[_0x8f1c('0x28')][_0x8f1c('0x18')]);_0x2b54b2[_0x8f1c('0x17')]=qs['offset'](_0x47530b[_0x8f1c('0x28')][_0x8f1c('0x17')]);}_0x2b54b2[_0x8f1c('0x2f')]=qs[_0x8f1c('0x30')](_0x47530b[_0x8f1c('0x28')][_0x8f1c('0x30')]);_0x2b54b2[_0x8f1c('0x31')]=qs['filters'](_[_0x8f1c('0x32')](_0x47530b['query'],_0x5a1a8f[_0x8f1c('0x33')]),_0x7ff259);if(_0x47530b[_0x8f1c('0x28')][_0x8f1c('0x34')]){_0x2b54b2[_0x8f1c('0x31')]=_[_0x8f1c('0x35')](_0x2b54b2[_0x8f1c('0x31')],{'$or':_['map'](_0x7ff259,function(_0x2a5f4e){if(_0x2a5f4e[_0x8f1c('0x36')]!==_0x8f1c('0x37')){var _0x39742a={};_0x39742a[_0x2a5f4e[_0x8f1c('0x20')]]={'$like':'%'+_0x47530b[_0x8f1c('0x28')]['filter']+'%'};return _0x39742a;}})});}_0x2b54b2=_['merge']({},_0x2b54b2,_0x47530b[_0x8f1c('0x38')]);var _0x36c823={'where':_0x2b54b2[_0x8f1c('0x31')]};return db['DeskAccount'][_0x8f1c('0x19')](_0x36c823)[_0x8f1c('0x1e')](function(_0x3d433b){_0x1b9bb2[_0x8f1c('0x19')]=_0x3d433b;if(_0x47530b['query'][_0x8f1c('0x39')]){_0x2b54b2['include']=[{'all':!![]}];}return db[_0x8f1c('0x24')][_0x8f1c('0x3a')](_0x2b54b2);})[_0x8f1c('0x1e')](function(_0x5b1713){_0x1b9bb2[_0x8f1c('0x3b')]=_0x5b1713;return _0x1b9bb2;})[_0x8f1c('0x1e')](respondWithFilteredResult(_0x4eed99,_0x2b54b2))[_0x8f1c('0x3c')](handleError(_0x4eed99,null));};exports[_0x8f1c('0x3d')]=function(_0x116536,_0x2f03c5){var _0x3e551a={'raw':![],'where':{'id':_0x116536[_0x8f1c('0x3e')]['id']}},_0x13f833={};_0x13f833['model']=_[_0x8f1c('0x29')](db[_0x8f1c('0x24')][_0x8f1c('0x25')]);_0x13f833[_0x8f1c('0x28')]=_[_0x8f1c('0x29')](_0x116536[_0x8f1c('0x28')]);_0x13f833[_0x8f1c('0x33')]=_[_0x8f1c('0x2a')](_0x13f833[_0x8f1c('0x2b')],_0x13f833[_0x8f1c('0x28')]);_0x3e551a[_0x8f1c('0x2c')]=_[_0x8f1c('0x2a')](_0x13f833[_0x8f1c('0x2b')],qs[_0x8f1c('0x3f')](_0x116536[_0x8f1c('0x28')][_0x8f1c('0x3f')]));_0x3e551a[_0x8f1c('0x2c')]=_0x3e551a['attributes'][_0x8f1c('0x40')]?_0x3e551a[_0x8f1c('0x2c')]:_0x13f833[_0x8f1c('0x2b')];if(_0x116536[_0x8f1c('0x28')][_0x8f1c('0x39')]){_0x3e551a[_0x8f1c('0x41')]=[{'all':!![]}];}_0x3e551a=_[_0x8f1c('0x35')]({},_0x3e551a,_0x116536[_0x8f1c('0x38')]);return db[_0x8f1c('0x24')][_0x8f1c('0x42')](_0x3e551a)[_0x8f1c('0x1e')](handleEntityNotFound(_0x2f03c5,null))[_0x8f1c('0x1e')](respondWithResult(_0x2f03c5,null))[_0x8f1c('0x3c')](handleError(_0x2f03c5,null));};exports['create']=function(_0x25a929,_0x263aaa){return db['DeskAccount']['create'](_0x25a929['body'],{})[_0x8f1c('0x1e')](respondWithResult(_0x263aaa,0xc9))[_0x8f1c('0x3c')](handleError(_0x263aaa,null));};exports[_0x8f1c('0x1d')]=function(_0x5c19b8,_0x46d4c3){if(_0x5c19b8['body']['id']){delete _0x5c19b8[_0x8f1c('0x43')]['id'];}return db[_0x8f1c('0x24')][_0x8f1c('0x42')]({'where':{'id':_0x5c19b8[_0x8f1c('0x3e')]['id']}})['then'](handleEntityNotFound(_0x46d4c3,null))[_0x8f1c('0x1e')](saveUpdates(_0x5c19b8[_0x8f1c('0x43')],null))[_0x8f1c('0x1e')](respondWithResult(_0x46d4c3,null))[_0x8f1c('0x3c')](handleError(_0x46d4c3,null));};exports['destroy']=function(_0x33ed5a,_0x29832c){return db[_0x8f1c('0x24')]['find']({'where':{'id':_0x33ed5a[_0x8f1c('0x3e')]['id']}})['then'](handleEntityNotFound(_0x29832c,null))[_0x8f1c('0x1e')](removeEntity(_0x29832c,null))[_0x8f1c('0x3c')](handleError(_0x29832c,null));};exports['getConfigurations']=function(_0x2eb9d3,_0x2593a1,_0x57b36a){var _0x442dad={};var _0x448f14={};var _0x552171;var _0x315cff;return db[_0x8f1c('0x24')][_0x8f1c('0x44')]({'where':{'id':_0x2eb9d3['params']['id']}})[_0x8f1c('0x1e')](handleEntityNotFound(_0x2593a1,null))['then'](function(_0xe793ee){if(_0xe793ee){_0x552171=_0xe793ee;_0x448f14['model']=_[_0x8f1c('0x29')](db[_0x8f1c('0x45')][_0x8f1c('0x25')]);_0x448f14[_0x8f1c('0x28')]=_[_0x8f1c('0x29')](_0x2eb9d3['query']);_0x448f14[_0x8f1c('0x33')]=_[_0x8f1c('0x2a')](_0x448f14[_0x8f1c('0x2b')],_0x448f14[_0x8f1c('0x28')]);_0x442dad[_0x8f1c('0x2c')]=_['intersection'](_0x448f14[_0x8f1c('0x2b')],qs[_0x8f1c('0x3f')](_0x2eb9d3[_0x8f1c('0x28')][_0x8f1c('0x3f')]));_0x442dad[_0x8f1c('0x2c')]=_0x442dad[_0x8f1c('0x2c')][_0x8f1c('0x40')]?_0x442dad[_0x8f1c('0x2c')]:_0x448f14[_0x8f1c('0x2b')];_0x442dad[_0x8f1c('0x2f')]=qs[_0x8f1c('0x30')](_0x2eb9d3[_0x8f1c('0x28')]['sort']);_0x442dad[_0x8f1c('0x31')]=qs[_0x8f1c('0x33')](_[_0x8f1c('0x32')](_0x2eb9d3['query'],_0x448f14['filters']));if(_0x2eb9d3[_0x8f1c('0x28')][_0x8f1c('0x34')]){_0x442dad[_0x8f1c('0x31')]=_[_0x8f1c('0x35')](_0x442dad['where'],{'$or':_[_0x8f1c('0x23')](_0x442dad['attributes'],function(_0x3be888){var _0x90aab6={};_0x90aab6[_0x3be888]={'$like':'%'+_0x2eb9d3[_0x8f1c('0x28')][_0x8f1c('0x34')]+'%'};return _0x90aab6;})});}_0x442dad=_[_0x8f1c('0x35')]({},_0x442dad,_0x2eb9d3['options']);return _0x552171[_0x8f1c('0x46')](_0x442dad);}})[_0x8f1c('0x1e')](function(_0x1b4b8d){if(_0x1b4b8d){_0x315cff=_0x1b4b8d[_0x8f1c('0x40')];if(!_0x2eb9d3[_0x8f1c('0x28')][_0x8f1c('0x2d')]('nolimit')){_0x442dad[_0x8f1c('0x18')]=qs[_0x8f1c('0x18')](_0x2eb9d3['query']['limit']);_0x442dad[_0x8f1c('0x17')]=qs[_0x8f1c('0x17')](_0x2eb9d3[_0x8f1c('0x28')][_0x8f1c('0x17')]);}return _0x552171['getConfigurations'](_0x442dad);}})['then'](function(_0xd7af9a){if(_0xd7af9a){return _0xd7af9a?{'count':_0x315cff,'rows':_0xd7af9a}:null;}})[_0x8f1c('0x1e')](respondWithResult(_0x2593a1,null))[_0x8f1c('0x3c')](handleError(_0x2593a1,null));};exports[_0x8f1c('0x47')]=function(_0x1e0db0,_0x3db501,_0x4c24b7){if(_0x1e0db0[_0x8f1c('0x43')]['id']){delete _0x1e0db0[_0x8f1c('0x43')]['id'];}return db[_0x8f1c('0x24')][_0x8f1c('0x44')]({'where':{'id':_0x1e0db0[_0x8f1c('0x3e')]['id']}})[_0x8f1c('0x1e')](handleEntityNotFound(_0x3db501,null))[_0x8f1c('0x1e')](function(_0x4a9b5b){if(_0x4a9b5b){_0x1e0db0[_0x8f1c('0x43')][_0x8f1c('0x48')]=_0x4a9b5b['id'];_0x1e0db0[_0x8f1c('0x43')][_0x8f1c('0x49')]=integrations[_0x8f1c('0x4a')](_0x1e0db0[_0x8f1c('0x43')][_0x8f1c('0x4b')],_0x1e0db0[_0x8f1c('0x43')]['type']);_0x1e0db0[_0x8f1c('0x43')][_0x8f1c('0x4c')]=integrations[_0x8f1c('0x4d')](_0x1e0db0[_0x8f1c('0x43')]['channel'],_0x1e0db0[_0x8f1c('0x43')]['type']);return db[_0x8f1c('0x45')][_0x8f1c('0x4e')](_0x1e0db0[_0x8f1c('0x43')],{'include':[{'model':db[_0x8f1c('0x4f')],'as':_0x8f1c('0x49')},{'model':db[_0x8f1c('0x4f')],'as':_0x8f1c('0x4c')}]});}return null;})[_0x8f1c('0x1e')](respondWithResult(_0x3db501,null))[_0x8f1c('0x3c')](handleError(_0x3db501,null));};exports[_0x8f1c('0x50')]=function(_0x8f7dd9,_0x147ebb,_0x4a4488){var _0x2e44a2=[{'name':'priority','label':_0x8f1c('0x51'),'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 _0x52530b='';return db[_0x8f1c('0x24')][_0x8f1c('0x44')]({'where':{'id':_0x8f7dd9[_0x8f1c('0x3e')]['id']},'attributes':['id',_0x8f1c('0x52'),'authType','username',_0x8f1c('0x53'),_0x8f1c('0x54'),_0x8f1c('0x55'),_0x8f1c('0x56'),'tokenSecret']})['then'](handleEntityNotFound(_0x147ebb,null))[_0x8f1c('0x1e')](function(_0x1ea03b){if(_0x1ea03b){_0x52530b=_0x1ea03b[_0x8f1c('0x52')];var _0x3aecc6=_0x52530b[_0x8f1c('0x57')](-0x1);if(_0x3aecc6==='/'){_0x52530b=_0x52530b[_0x8f1c('0x58')](0x0,_0x52530b[_0x8f1c('0x59')](_0x3aecc6));}var _0x575d9e={'method':'GET','uri':util['format'](_0x8f1c('0x5a'),_0x52530b),'headers':{'Content-Type':_0x8f1c('0x5b'),'Accept':_0x8f1c('0x5b')},'json':!![]};if(_0x1ea03b[_0x8f1c('0x5c')]==='basic'){_0x575d9e['headers'][_0x8f1c('0x5d')]=util[_0x8f1c('0x5e')]('Basic\x20%s',new Buffer(util['format'](_0x8f1c('0x5f'),_0x1ea03b[_0x8f1c('0x60')],_0x1ea03b['password']))[_0x8f1c('0x61')]('base64'));}return rp(_0x575d9e)[_0x8f1c('0x1e')](function(_0x32a937){return _0x2e44a2[_0x8f1c('0x62')](_['map'](_0x32a937[_0x8f1c('0x63')][_0x8f1c('0x64')],function(_0x1efdaa){return{'id':_0x1efdaa[_0x8f1c('0x20')],'name':_0x1efdaa[_0x8f1c('0x20')],'type':_0x1efdaa[_0x8f1c('0x36')],'active':_0x1efdaa[_0x8f1c('0x65')],'label':_0x1efdaa[_0x8f1c('0x66')],'custom':!![]};}));});}})['then'](function(_0x4768d9){return{'count':_0x4768d9['length'],'rows':_0x4768d9};})[_0x8f1c('0x1e')](respondWithResult(_0x147ebb,null))[_0x8f1c('0x3c')](function(_0x332ecc){var _0xb7b418=_0x8f7dd9[_0x8f1c('0x28')][_0x8f1c('0x67')]?0x1f4:_0x332ecc['statusCode']||0x1f4;logger[_0x8f1c('0x1f')](_0x8f1c('0x68'),_0x8f1c('0x50'),_0xb7b418,JSON['stringify'](_0x332ecc));delete _0x332ecc[_0x8f1c('0x20')];if(_0xb7b418===0x191){_0xb7b418=0x190;}_0x147ebb[_0x8f1c('0x15')](_0xb7b418)[_0x8f1c('0x21')](_0x8f7dd9[_0x8f1c('0x28')][_0x8f1c('0x67')]?{'message':_0x8f1c('0x69'),'statusCode':_0x332ecc[_0x8f1c('0x6a')]}:_0x332ecc);});};
\ No newline at end of file
+var _0xaa8e=['filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','create','body','getConfigurations','findOne','length','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','DeskConfiguration','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','slice','substring','lastIndexOf','GET','format','%s/custom_fields','basic','headers','toString','base64','concat','_embedded','entries','active','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','error','stack','name','index','map','DeskAccount','rawAttributes','type','model','query','keys'];(function(_0x22f53f,_0x14ef66){var _0x57bc67=function(_0x375f18){while(--_0x375f18){_0x22f53f['push'](_0x22f53f['shift']());}};_0x57bc67(++_0x14ef66);}(_0xaa8e,0x126));var _0xeaa8=function(_0x391fc3,_0x2aa361){_0x391fc3=_0x391fc3-0x0;var _0x684b49=_0xaa8e[_0x391fc3];return _0x684b49;};'use strict';var emlformat=require(_0xeaa8('0x0'));var rimraf=require(_0xeaa8('0x1'));var zipdir=require(_0xeaa8('0x2'));var jsonpatch=require(_0xeaa8('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xeaa8('0x4'));var Mustache=require('mustache');var util=require(_0xeaa8('0x5'));var path=require(_0xeaa8('0x6'));var sox=require(_0xeaa8('0x7'));var csv=require(_0xeaa8('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xeaa8('0x9'));var _=require(_0xeaa8('0xa'));var squel=require(_0xeaa8('0xb'));var crypto=require(_0xeaa8('0xc'));var jsforce=require(_0xeaa8('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xeaa8('0x8'));var querystring=require(_0xeaa8('0xe'));var Papa=require('papaparse');var Redis=require(_0xeaa8('0xf'));var authService=require(_0xeaa8('0x10'));var qs=require(_0xeaa8('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeaa8('0x12'));var logger=require(_0xeaa8('0x13'))(_0xeaa8('0x14'));var utils=require(_0xeaa8('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xeaa8('0x16'));var db=require(_0xeaa8('0x17'))['db'];var integrations=require(_0xeaa8('0x18'));function respondWithStatusCode(_0x427efe,_0x83795d){_0x83795d=_0x83795d||0xcc;return function(_0x55857a){if(_0x55857a){return _0x427efe[_0xeaa8('0x19')](_0x83795d);}return _0x427efe['status'](_0x83795d)[_0xeaa8('0x1a')]();};}function respondWithResult(_0x20e6a6,_0x6585b){_0x6585b=_0x6585b||0xc8;return function(_0xd8fb19){if(_0xd8fb19){return _0x20e6a6[_0xeaa8('0x1b')](_0x6585b)[_0xeaa8('0x1c')](_0xd8fb19);}};}function respondWithFilteredResult(_0x37f52b,_0x531e37){return function(_0x3923e2){if(_0x3923e2){var _0x109f5f=typeof _0x531e37['offset']===_0xeaa8('0x1d')&&typeof _0x531e37[_0xeaa8('0x1e')]===_0xeaa8('0x1d');var _0x1d9388=_0x3923e2[_0xeaa8('0x1f')];var _0xa6e8d2=_0x109f5f?0x0:_0x531e37[_0xeaa8('0x20')];var _0x2d2ed3=_0x109f5f?_0x3923e2[_0xeaa8('0x1f')]:_0x531e37[_0xeaa8('0x20')]+_0x531e37[_0xeaa8('0x1e')];var _0x4924ee;if(_0x2d2ed3>=_0x1d9388){_0x2d2ed3=_0x1d9388;_0x4924ee=0xc8;}else{_0x4924ee=0xce;}_0x37f52b[_0xeaa8('0x1b')](_0x4924ee);return _0x37f52b[_0xeaa8('0x21')](_0xeaa8('0x22'),_0xa6e8d2+'-'+_0x2d2ed3+'/'+_0x1d9388)[_0xeaa8('0x1c')](_0x3923e2);}return null;};}function patchUpdates(_0x56033e){return function(_0x4f5450){try{jsonpatch[_0xeaa8('0x23')](_0x4f5450,_0x56033e,!![]);}catch(_0x55883a){return BPromise[_0xeaa8('0x24')](_0x55883a);}return _0x4f5450[_0xeaa8('0x25')]();};}function saveUpdates(_0x209f04,_0x777a8b){return function(_0x551ecb){if(_0x551ecb){return _0x551ecb[_0xeaa8('0x26')](_0x209f04)[_0xeaa8('0x27')](function(_0x5441f9){return _0x5441f9;});}return null;};}function removeEntity(_0x1f0139,_0x543cd8){return function(_0x596271){if(_0x596271){return _0x596271['destroy']()[_0xeaa8('0x27')](function(){_0x1f0139[_0xeaa8('0x1b')](0xcc)[_0xeaa8('0x1a')]();});}};}function handleEntityNotFound(_0x4eb633,_0x15d1ee){return function(_0x49a8cb){if(!_0x49a8cb){_0x4eb633[_0xeaa8('0x19')](0x194);}return _0x49a8cb;};}function handleError(_0x2a7a0a,_0x43f053){_0x43f053=_0x43f053||0x1f4;return function(_0x24eb40){logger[_0xeaa8('0x28')](_0x24eb40[_0xeaa8('0x29')]);if(_0x24eb40[_0xeaa8('0x2a')]){delete _0x24eb40[_0xeaa8('0x2a')];}_0x2a7a0a['status'](_0x43f053)['send'](_0x24eb40);};}exports[_0xeaa8('0x2b')]=function(_0x5d8650,_0x60b6e4){var _0x425271={},_0x41ece8={},_0x1950ae={'count':0x0,'rows':[]};var _0x3d5c82=_[_0xeaa8('0x2c')](db[_0xeaa8('0x2d')][_0xeaa8('0x2e')],function(_0x5471c5){return{'name':_0x5471c5['fieldName'],'type':_0x5471c5[_0xeaa8('0x2f')]['key']};});_0x41ece8[_0xeaa8('0x30')]=_['map'](_0x3d5c82,_0xeaa8('0x2a'));_0x41ece8[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x5d8650['query']);_0x41ece8[_0xeaa8('0x33')]=_[_0xeaa8('0x34')](_0x41ece8[_0xeaa8('0x30')],_0x41ece8[_0xeaa8('0x31')]);_0x425271['attributes']=_['intersection'](_0x41ece8[_0xeaa8('0x30')],qs[_0xeaa8('0x35')](_0x5d8650['query'][_0xeaa8('0x35')]));_0x425271[_0xeaa8('0x36')]=_0x425271[_0xeaa8('0x36')]['length']?_0x425271[_0xeaa8('0x36')]:_0x41ece8[_0xeaa8('0x30')];if(!_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x37')](_0xeaa8('0x38'))){_0x425271[_0xeaa8('0x1e')]=qs[_0xeaa8('0x1e')](_0x5d8650[_0xeaa8('0x31')]['limit']);_0x425271['offset']=qs['offset'](_0x5d8650['query'][_0xeaa8('0x20')]);}_0x425271[_0xeaa8('0x39')]=qs[_0xeaa8('0x3a')](_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x3a')]);_0x425271[_0xeaa8('0x3b')]=qs[_0xeaa8('0x33')](_[_0xeaa8('0x3c')](_0x5d8650['query'],_0x41ece8[_0xeaa8('0x33')]),_0x3d5c82);if(_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x3d')]){_0x425271[_0xeaa8('0x3b')]=_[_0xeaa8('0x3e')](_0x425271[_0xeaa8('0x3b')],{'$or':_['map'](_0x3d5c82,function(_0x3c17f3){if(_0x3c17f3[_0xeaa8('0x2f')]!=='VIRTUAL'){var _0x4ea3a4={};_0x4ea3a4[_0x3c17f3[_0xeaa8('0x2a')]]={'$like':'%'+_0x5d8650[_0xeaa8('0x31')]['filter']+'%'};return _0x4ea3a4;}})});}_0x425271=_[_0xeaa8('0x3e')]({},_0x425271,_0x5d8650[_0xeaa8('0x3f')]);var _0x5b0a5f={'where':_0x425271['where']};return db[_0xeaa8('0x2d')][_0xeaa8('0x1f')](_0x5b0a5f)[_0xeaa8('0x27')](function(_0xfb43e4){_0x1950ae['count']=_0xfb43e4;if(_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x40')]){_0x425271[_0xeaa8('0x41')]=[{'all':!![]}];}return db[_0xeaa8('0x2d')]['findAll'](_0x425271);})[_0xeaa8('0x27')](function(_0x2b3bd5){_0x1950ae[_0xeaa8('0x42')]=_0x2b3bd5;return _0x1950ae;})[_0xeaa8('0x27')](respondWithFilteredResult(_0x60b6e4,_0x425271))[_0xeaa8('0x43')](handleError(_0x60b6e4,null));};exports[_0xeaa8('0x44')]=function(_0x1581aa,_0x3f63b7){var _0x1b4447={'raw':![],'where':{'id':_0x1581aa[_0xeaa8('0x45')]['id']}},_0x283b04={};_0x283b04[_0xeaa8('0x30')]=_[_0xeaa8('0x32')](db['DeskAccount']['rawAttributes']);_0x283b04[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x1581aa['query']);_0x283b04['filters']=_[_0xeaa8('0x34')](_0x283b04[_0xeaa8('0x30')],_0x283b04[_0xeaa8('0x31')]);_0x1b4447[_0xeaa8('0x36')]=_[_0xeaa8('0x34')](_0x283b04[_0xeaa8('0x30')],qs['fields'](_0x1581aa['query'][_0xeaa8('0x35')]));_0x1b4447[_0xeaa8('0x36')]=_0x1b4447[_0xeaa8('0x36')]['length']?_0x1b4447[_0xeaa8('0x36')]:_0x283b04[_0xeaa8('0x30')];if(_0x1581aa['query'][_0xeaa8('0x40')]){_0x1b4447['include']=[{'all':!![]}];}_0x1b4447=_['merge']({},_0x1b4447,_0x1581aa[_0xeaa8('0x3f')]);return db[_0xeaa8('0x2d')][_0xeaa8('0x46')](_0x1b4447)[_0xeaa8('0x27')](handleEntityNotFound(_0x3f63b7,null))[_0xeaa8('0x27')](respondWithResult(_0x3f63b7,null))[_0xeaa8('0x43')](handleError(_0x3f63b7,null));};exports['create']=function(_0x4f8a1c,_0x1ac592){return db['DeskAccount'][_0xeaa8('0x47')](_0x4f8a1c[_0xeaa8('0x48')],{})[_0xeaa8('0x27')](respondWithResult(_0x1ac592,0xc9))[_0xeaa8('0x43')](handleError(_0x1ac592,null));};exports['update']=function(_0x51a5d9,_0x1f4e8e){if(_0x51a5d9[_0xeaa8('0x48')]['id']){delete _0x51a5d9[_0xeaa8('0x48')]['id'];}return db[_0xeaa8('0x2d')][_0xeaa8('0x46')]({'where':{'id':_0x51a5d9[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0x1f4e8e,null))[_0xeaa8('0x27')](saveUpdates(_0x51a5d9[_0xeaa8('0x48')],null))[_0xeaa8('0x27')](respondWithResult(_0x1f4e8e,null))[_0xeaa8('0x43')](handleError(_0x1f4e8e,null));};exports['destroy']=function(_0x4e6489,_0x25dfa0){return db[_0xeaa8('0x2d')][_0xeaa8('0x46')]({'where':{'id':_0x4e6489[_0xeaa8('0x45')]['id']}})['then'](handleEntityNotFound(_0x25dfa0,null))[_0xeaa8('0x27')](removeEntity(_0x25dfa0,null))[_0xeaa8('0x43')](handleError(_0x25dfa0,null));};exports[_0xeaa8('0x49')]=function(_0x57f40d,_0xf7578,_0x54f0e0){var _0x1619f3={};var _0x1ad662={};var _0x3e303d;var _0x18c0f9;return db[_0xeaa8('0x2d')][_0xeaa8('0x4a')]({'where':{'id':_0x57f40d[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0xf7578,null))['then'](function(_0x4bda2a){if(_0x4bda2a){_0x3e303d=_0x4bda2a;_0x1ad662[_0xeaa8('0x30')]=_[_0xeaa8('0x32')](db['DeskConfiguration'][_0xeaa8('0x2e')]);_0x1ad662[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x57f40d[_0xeaa8('0x31')]);_0x1ad662[_0xeaa8('0x33')]=_[_0xeaa8('0x34')](_0x1ad662[_0xeaa8('0x30')],_0x1ad662[_0xeaa8('0x31')]);_0x1619f3[_0xeaa8('0x36')]=_[_0xeaa8('0x34')](_0x1ad662['model'],qs[_0xeaa8('0x35')](_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x35')]));_0x1619f3[_0xeaa8('0x36')]=_0x1619f3[_0xeaa8('0x36')][_0xeaa8('0x4b')]?_0x1619f3[_0xeaa8('0x36')]:_0x1ad662['model'];_0x1619f3[_0xeaa8('0x39')]=qs[_0xeaa8('0x3a')](_0x57f40d['query']['sort']);_0x1619f3[_0xeaa8('0x3b')]=qs['filters'](_[_0xeaa8('0x3c')](_0x57f40d[_0xeaa8('0x31')],_0x1ad662[_0xeaa8('0x33')]));if(_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x3d')]){_0x1619f3[_0xeaa8('0x3b')]=_[_0xeaa8('0x3e')](_0x1619f3['where'],{'$or':_['map'](_0x1619f3[_0xeaa8('0x36')],function(_0x30b632){var _0x53a49a={};_0x53a49a[_0x30b632]={'$like':'%'+_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x3d')]+'%'};return _0x53a49a;})});}_0x1619f3=_[_0xeaa8('0x3e')]({},_0x1619f3,_0x57f40d[_0xeaa8('0x3f')]);return _0x3e303d[_0xeaa8('0x49')](_0x1619f3);}})[_0xeaa8('0x27')](function(_0x2bb5be){if(_0x2bb5be){_0x18c0f9=_0x2bb5be['length'];if(!_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x37')](_0xeaa8('0x38'))){_0x1619f3['limit']=qs[_0xeaa8('0x1e')](_0x57f40d[_0xeaa8('0x31')]['limit']);_0x1619f3['offset']=qs['offset'](_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x20')]);}return _0x3e303d[_0xeaa8('0x49')](_0x1619f3);}})[_0xeaa8('0x27')](function(_0x1eafdd){if(_0x1eafdd){return _0x1eafdd?{'count':_0x18c0f9,'rows':_0x1eafdd}:null;}})[_0xeaa8('0x27')](respondWithResult(_0xf7578,null))[_0xeaa8('0x43')](handleError(_0xf7578,null));};exports[_0xeaa8('0x4c')]=function(_0xb5f8f9,_0x1ef259,_0x15defd){if(_0xb5f8f9[_0xeaa8('0x48')]['id']){delete _0xb5f8f9[_0xeaa8('0x48')]['id'];}return db[_0xeaa8('0x2d')][_0xeaa8('0x4a')]({'where':{'id':_0xb5f8f9[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0x1ef259,null))[_0xeaa8('0x27')](function(_0x1e4af4){if(_0x1e4af4){_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4d')]=_0x1e4af4['id'];_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4e')]=integrations['getSubjects'](_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4f')],_0xb5f8f9[_0xeaa8('0x48')]['type']);_0xb5f8f9['body'][_0xeaa8('0x50')]=integrations[_0xeaa8('0x51')](_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4f')],_0xb5f8f9[_0xeaa8('0x48')]['type']);return db[_0xeaa8('0x52')][_0xeaa8('0x47')](_0xb5f8f9['body'],{'include':[{'model':db[_0xeaa8('0x53')],'as':_0xeaa8('0x4e')},{'model':db['DeskField'],'as':_0xeaa8('0x50')}]});}return null;})[_0xeaa8('0x27')](respondWithResult(_0x1ef259,null))[_0xeaa8('0x43')](handleError(_0x1ef259,null));};exports[_0xeaa8('0x54')]=function(_0x3d3a09,_0x33afef,_0x474bd9){var _0x2836b4=[{'name':_0xeaa8('0x55'),'label':_0xeaa8('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 _0x330660='';return db['DeskAccount'][_0xeaa8('0x4a')]({'where':{'id':_0x3d3a09[_0xeaa8('0x45')]['id']},'attributes':['id',_0xeaa8('0x56'),_0xeaa8('0x57'),_0xeaa8('0x58'),_0xeaa8('0x59'),_0xeaa8('0x5a'),_0xeaa8('0x5b'),_0xeaa8('0x5c'),_0xeaa8('0x5d')]})[_0xeaa8('0x27')](handleEntityNotFound(_0x33afef,null))['then'](function(_0x3d22fe){if(_0x3d22fe){_0x330660=_0x3d22fe[_0xeaa8('0x56')];var _0x2726c0=_0x330660[_0xeaa8('0x5e')](-0x1);if(_0x2726c0==='/'){_0x330660=_0x330660[_0xeaa8('0x5f')](0x0,_0x330660[_0xeaa8('0x60')](_0x2726c0));}var _0x4c70f4={'method':_0xeaa8('0x61'),'uri':util[_0xeaa8('0x62')](_0xeaa8('0x63'),_0x330660),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x3d22fe[_0xeaa8('0x57')]===_0xeaa8('0x64')){_0x4c70f4[_0xeaa8('0x65')]['Authorization']=util[_0xeaa8('0x62')]('Basic\x20%s',new Buffer(util['format']('%s:%s',_0x3d22fe[_0xeaa8('0x58')],_0x3d22fe['password']))[_0xeaa8('0x66')](_0xeaa8('0x67')));}return rp(_0x4c70f4)[_0xeaa8('0x27')](function(_0x58bb05){return _0x2836b4[_0xeaa8('0x68')](_[_0xeaa8('0x2c')](_0x58bb05[_0xeaa8('0x69')][_0xeaa8('0x6a')],function(_0x53fb6c){return{'id':_0x53fb6c[_0xeaa8('0x2a')],'name':_0x53fb6c['name'],'type':_0x53fb6c['type'],'active':_0x53fb6c[_0xeaa8('0x6b')],'label':_0x53fb6c[_0xeaa8('0x6c')],'custom':!![]};}));});}})[_0xeaa8('0x27')](function(_0x3f3ef9){return{'count':_0x3f3ef9['length'],'rows':_0x3f3ef9};})[_0xeaa8('0x27')](respondWithResult(_0x33afef,null))[_0xeaa8('0x43')](function(_0x514c0e){var _0x13e4e3=_0x3d3a09[_0xeaa8('0x31')]['test']?0x1f4:_0x514c0e[_0xeaa8('0x6d')]||0x1f4;logger[_0xeaa8('0x28')](_0xeaa8('0x6e'),_0xeaa8('0x54'),_0x13e4e3,JSON[_0xeaa8('0x6f')](_0x514c0e));delete _0x514c0e[_0xeaa8('0x2a')];if(_0x13e4e3===0x191){_0x13e4e3=0x190;}_0x33afef[_0xeaa8('0x1b')](_0x13e4e3)[_0xeaa8('0x70')](_0x3d3a09[_0xeaa8('0x31')][_0xeaa8('0x71')]?{'message':_0xeaa8('0x72'),'statusCode':_0x514c0e['statusCode']}:_0x514c0e);});};
\ No newline at end of file