Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 2346e55..b65a54b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf7f2=['FreshdeskAccount,\x20%s,\x20%s','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','end','status','offset','undefined','limit','count','set','Content-Range','json','reject','save','destroy','name','send','index','FreshdeskAccount','fieldName','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','includeAll','findAll','rows','show','rawAttributes','include','options','find','create','body','update','params','getConfigurations','findOne','FreshdeskConfiguration','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshdeskField','getFields','remoteUri','apiKey','slice','substring','lastIndexOf','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','%s:X','toString','base64','requester','subject','agent','priority','group','source','ticket_type','company','includes','custom_text','custom_dropdown','label','choices','capitalize','test','statusCode','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../components/integrations/configuration','jayson/promise','request','then','info'];(function(_0x52e68e,_0x309912){var _0x3211a4=function(_0x467c01){while(--_0x467c01){_0x52e68e['push'](_0x52e68e['shift']());}};_0x3211a4(++_0x309912);}(_0xf7f2,0x1da));var _0x2f7f=function(_0x2f7e15,_0x6e0949){_0x2f7e15=_0x2f7e15-0x0;var _0xbf1bf1=_0xf7f2[_0x2f7e15];return _0xbf1bf1;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x2f7f('0x0'));var zipdir=require(_0x2f7f('0x1'));var jsonpatch=require(_0x2f7f('0x2'));var rp=require(_0x2f7f('0x3'));var moment=require('moment');var BPromise=require(_0x2f7f('0x4'));var Mustache=require(_0x2f7f('0x5'));var util=require('util');var path=require(_0x2f7f('0x6'));var sox=require('sox');var csv=require(_0x2f7f('0x7'));var ejs=require(_0x2f7f('0x8'));var fs=require('fs');var fs_extra=require(_0x2f7f('0x9'));var _=require(_0x2f7f('0xa'));var squel=require(_0x2f7f('0xb'));var crypto=require(_0x2f7f('0xc'));var jsforce=require(_0x2f7f('0xd'));var deskjs=require(_0x2f7f('0xe'));var toCsv=require(_0x2f7f('0x7'));var querystring=require(_0x2f7f('0xf'));var Papa=require(_0x2f7f('0x10'));var Redis=require(_0x2f7f('0x11'));var authService=require(_0x2f7f('0x12'));var qs=require(_0x2f7f('0x13'));var as=require(_0x2f7f('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x2f7f('0x15'))(_0x2f7f('0x16'));var utils=require(_0x2f7f('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x2f7f('0x18'));var db=require('../../mysqldb')['db'];var integrations=require(_0x2f7f('0x19'));var jayson=require(_0x2f7f('0x1a'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1ba230,_0xc528d6,_0x39c4a1,_0x2174a5){return new BPromise(function(_0x3937dc,_0x4dc30f){var _0xe164a5=_0x2174a5||client;return _0xe164a5[_0x2f7f('0x1b')](_0x1ba230,_0x39c4a1)[_0x2f7f('0x1c')](function(_0x31e0a){logger[_0x2f7f('0x1d')](_0x2f7f('0x1e'),_0xc528d6,_0x2f7f('0x1f'));logger[_0x2f7f('0x20')](_0x2f7f('0x21'),_0xc528d6,_0x2f7f('0x1f'),JSON['stringify'](_0x31e0a));if(_0x31e0a[_0x2f7f('0x22')]){if(_0x31e0a[_0x2f7f('0x22')][_0x2f7f('0x23')]===0x1f4){logger['error'](_0x2f7f('0x1e'),_0xc528d6,_0x31e0a['error'][_0x2f7f('0x24')]);return _0x4dc30f(_0x31e0a[_0x2f7f('0x22')][_0x2f7f('0x24')]);}logger[_0x2f7f('0x22')](_0x2f7f('0x1e'),_0xc528d6,_0x31e0a[_0x2f7f('0x22')][_0x2f7f('0x24')]);return _0x3937dc(_0x31e0a[_0x2f7f('0x22')]['message']);}else{logger[_0x2f7f('0x1d')]('FreshdeskAccount,\x20%s,\x20%s',_0xc528d6,'request\x20sent');_0x3937dc(_0x31e0a['result'][_0x2f7f('0x24')]);}})[_0x2f7f('0x25')](function(_0x3bc9d8){logger[_0x2f7f('0x22')]('FreshdeskAccount,\x20%s,\x20%s',_0xc528d6,_0x3bc9d8);_0x4dc30f(_0x3bc9d8);});});}function respondWithStatusCode(_0x5398d0,_0x4b381e){_0x4b381e=_0x4b381e||0xcc;return function(_0x5a650c){if(_0x5a650c){return _0x5398d0['sendStatus'](_0x4b381e);}return _0x5398d0['status'](_0x4b381e)[_0x2f7f('0x26')]();};}function respondWithResult(_0x23c271,_0x31d0da){_0x31d0da=_0x31d0da||0xc8;return function(_0xbfa362){if(_0xbfa362){return _0x23c271[_0x2f7f('0x27')](_0x31d0da)['json'](_0xbfa362);}};}function respondWithFilteredResult(_0x4eb5c3,_0x1d8720){return function(_0x2271dc){if(_0x2271dc){var _0x488647=typeof _0x1d8720[_0x2f7f('0x28')]===_0x2f7f('0x29')&&typeof _0x1d8720[_0x2f7f('0x2a')]===_0x2f7f('0x29');var _0x4c94bf=_0x2271dc[_0x2f7f('0x2b')];var _0x4118e5=_0x488647?0x0:_0x1d8720[_0x2f7f('0x28')];var _0x58e186=_0x488647?_0x2271dc['count']:_0x1d8720[_0x2f7f('0x28')]+_0x1d8720[_0x2f7f('0x2a')];var _0x36ac50;if(_0x58e186>=_0x4c94bf){_0x58e186=_0x4c94bf;_0x36ac50=0xc8;}else{_0x36ac50=0xce;}_0x4eb5c3['status'](_0x36ac50);return _0x4eb5c3[_0x2f7f('0x2c')](_0x2f7f('0x2d'),_0x4118e5+'-'+_0x58e186+'/'+_0x4c94bf)[_0x2f7f('0x2e')](_0x2271dc);}return null;};}function patchUpdates(_0x3a4584){return function(_0x5a2cbf){try{jsonpatch['apply'](_0x5a2cbf,_0x3a4584,!![]);}catch(_0x2729b5){return BPromise[_0x2f7f('0x2f')](_0x2729b5);}return _0x5a2cbf[_0x2f7f('0x30')]();};}function saveUpdates(_0x12f903,_0x289364){return function(_0x4e717c){if(_0x4e717c){return _0x4e717c['update'](_0x12f903)[_0x2f7f('0x1c')](function(_0x7f0ebb){return _0x7f0ebb;});}return null;};}function removeEntity(_0x546a68,_0x3fe70a){return function(_0x50d1fd){if(_0x50d1fd){return _0x50d1fd[_0x2f7f('0x31')]()[_0x2f7f('0x1c')](function(){_0x546a68['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x404ece,_0x4679c8){return function(_0x8493b9){if(!_0x8493b9){_0x404ece['sendStatus'](0x194);}return _0x8493b9;};}function handleError(_0x3cafd3,_0x3b52a4){_0x3b52a4=_0x3b52a4||0x1f4;return function(_0x403cc8){logger[_0x2f7f('0x22')](_0x403cc8['stack']);if(_0x403cc8[_0x2f7f('0x32')]){delete _0x403cc8[_0x2f7f('0x32')];}_0x3cafd3[_0x2f7f('0x27')](_0x3b52a4)[_0x2f7f('0x33')](_0x403cc8);};}exports[_0x2f7f('0x34')]=function(_0x4ca311,_0x5418cd){var _0x485bc0={},_0x18ce60={},_0x5017a3={'count':0x0,'rows':[]};var _0x5607ae=_['map'](db[_0x2f7f('0x35')]['rawAttributes'],function(_0x4888da){return{'name':_0x4888da[_0x2f7f('0x36')],'type':_0x4888da['type'][_0x2f7f('0x37')]};});_0x18ce60[_0x2f7f('0x38')]=_[_0x2f7f('0x39')](_0x5607ae,'name');_0x18ce60[_0x2f7f('0x3a')]=_[_0x2f7f('0x3b')](_0x4ca311['query']);_0x18ce60[_0x2f7f('0x3c')]=_[_0x2f7f('0x3d')](_0x18ce60[_0x2f7f('0x38')],_0x18ce60[_0x2f7f('0x3a')]);_0x485bc0[_0x2f7f('0x3e')]=_[_0x2f7f('0x3d')](_0x18ce60[_0x2f7f('0x38')],qs[_0x2f7f('0x3f')](_0x4ca311[_0x2f7f('0x3a')][_0x2f7f('0x3f')]));_0x485bc0['attributes']=_0x485bc0['attributes'][_0x2f7f('0x40')]?_0x485bc0['attributes']:_0x18ce60[_0x2f7f('0x38')];if(!_0x4ca311['query'][_0x2f7f('0x41')](_0x2f7f('0x42'))){_0x485bc0[_0x2f7f('0x2a')]=qs[_0x2f7f('0x2a')](_0x4ca311[_0x2f7f('0x3a')][_0x2f7f('0x2a')]);_0x485bc0[_0x2f7f('0x28')]=qs[_0x2f7f('0x28')](_0x4ca311[_0x2f7f('0x3a')][_0x2f7f('0x28')]);}_0x485bc0[_0x2f7f('0x43')]=qs[_0x2f7f('0x44')](_0x4ca311[_0x2f7f('0x3a')][_0x2f7f('0x44')]);_0x485bc0['where']=qs[_0x2f7f('0x3c')](_[_0x2f7f('0x45')](_0x4ca311['query'],_0x18ce60['filters']),_0x5607ae);if(_0x4ca311['query'][_0x2f7f('0x46')]){_0x485bc0[_0x2f7f('0x47')]=_[_0x2f7f('0x48')](_0x485bc0[_0x2f7f('0x47')],{'$or':_[_0x2f7f('0x39')](_0x5607ae,function(_0x1a0886){if(_0x1a0886[_0x2f7f('0x49')]!=='VIRTUAL'){var _0x238bc6={};_0x238bc6[_0x1a0886[_0x2f7f('0x32')]]={'$like':'%'+_0x4ca311['query'][_0x2f7f('0x46')]+'%'};return _0x238bc6;}})});}_0x485bc0=_[_0x2f7f('0x48')]({},_0x485bc0,_0x4ca311['options']);var _0x19c28f={'where':_0x485bc0[_0x2f7f('0x47')]};return db[_0x2f7f('0x35')]['count'](_0x19c28f)[_0x2f7f('0x1c')](function(_0x490cf1){_0x5017a3['count']=_0x490cf1;if(_0x4ca311['query'][_0x2f7f('0x4a')]){_0x485bc0['include']=[{'all':!![]}];}return db[_0x2f7f('0x35')][_0x2f7f('0x4b')](_0x485bc0);})[_0x2f7f('0x1c')](function(_0x5223c5){_0x5017a3[_0x2f7f('0x4c')]=_0x5223c5;return _0x5017a3;})['then'](respondWithFilteredResult(_0x5418cd,_0x485bc0))[_0x2f7f('0x25')](handleError(_0x5418cd,null));};exports[_0x2f7f('0x4d')]=function(_0x215c76,_0x27a487){var _0x410705={'raw':![],'where':{'id':_0x215c76['params']['id']}},_0x1407c2={};_0x1407c2['model']=_[_0x2f7f('0x3b')](db[_0x2f7f('0x35')][_0x2f7f('0x4e')]);_0x1407c2['query']=_[_0x2f7f('0x3b')](_0x215c76[_0x2f7f('0x3a')]);_0x1407c2[_0x2f7f('0x3c')]=_['intersection'](_0x1407c2[_0x2f7f('0x38')],_0x1407c2[_0x2f7f('0x3a')]);_0x410705[_0x2f7f('0x3e')]=_[_0x2f7f('0x3d')](_0x1407c2[_0x2f7f('0x38')],qs['fields'](_0x215c76[_0x2f7f('0x3a')][_0x2f7f('0x3f')]));_0x410705[_0x2f7f('0x3e')]=_0x410705['attributes'][_0x2f7f('0x40')]?_0x410705['attributes']:_0x1407c2[_0x2f7f('0x38')];if(_0x215c76[_0x2f7f('0x3a')][_0x2f7f('0x4a')]){_0x410705[_0x2f7f('0x4f')]=[{'all':!![]}];}_0x410705=_['merge']({},_0x410705,_0x215c76[_0x2f7f('0x50')]);return db[_0x2f7f('0x35')][_0x2f7f('0x51')](_0x410705)[_0x2f7f('0x1c')](handleEntityNotFound(_0x27a487,null))[_0x2f7f('0x1c')](respondWithResult(_0x27a487,null))['catch'](handleError(_0x27a487,null));};exports[_0x2f7f('0x52')]=function(_0x192306,_0x17bc01){return db['FreshdeskAccount']['create'](_0x192306[_0x2f7f('0x53')],{})[_0x2f7f('0x1c')](respondWithResult(_0x17bc01,0xc9))[_0x2f7f('0x25')](handleError(_0x17bc01,null));};exports[_0x2f7f('0x54')]=function(_0x5a4084,_0x4e36b4){if(_0x5a4084[_0x2f7f('0x53')]['id']){delete _0x5a4084[_0x2f7f('0x53')]['id'];}return db[_0x2f7f('0x35')]['find']({'where':{'id':_0x5a4084[_0x2f7f('0x55')]['id']}})[_0x2f7f('0x1c')](handleEntityNotFound(_0x4e36b4,null))[_0x2f7f('0x1c')](saveUpdates(_0x5a4084[_0x2f7f('0x53')],null))[_0x2f7f('0x1c')](respondWithResult(_0x4e36b4,null))[_0x2f7f('0x25')](handleError(_0x4e36b4,null));};exports['destroy']=function(_0x59ce10,_0x263440){return db[_0x2f7f('0x35')][_0x2f7f('0x51')]({'where':{'id':_0x59ce10['params']['id']}})['then'](handleEntityNotFound(_0x263440,null))[_0x2f7f('0x1c')](removeEntity(_0x263440,null))[_0x2f7f('0x25')](handleError(_0x263440,null));};exports[_0x2f7f('0x56')]=function(_0x1080dc,_0xfa75ea,_0x37ffbe){var _0x3e6904={};var _0x994d59={};var _0x16d856;var _0x1c316b;return db['FreshdeskAccount'][_0x2f7f('0x57')]({'where':{'id':_0x1080dc[_0x2f7f('0x55')]['id']}})[_0x2f7f('0x1c')](handleEntityNotFound(_0xfa75ea,null))[_0x2f7f('0x1c')](function(_0x3bc501){if(_0x3bc501){_0x16d856=_0x3bc501;_0x994d59[_0x2f7f('0x38')]=_[_0x2f7f('0x3b')](db[_0x2f7f('0x58')][_0x2f7f('0x4e')]);_0x994d59[_0x2f7f('0x3a')]=_[_0x2f7f('0x3b')](_0x1080dc['query']);_0x994d59[_0x2f7f('0x3c')]=_[_0x2f7f('0x3d')](_0x994d59[_0x2f7f('0x38')],_0x994d59['query']);_0x3e6904[_0x2f7f('0x3e')]=_[_0x2f7f('0x3d')](_0x994d59[_0x2f7f('0x38')],qs['fields'](_0x1080dc['query']['fields']));_0x3e6904[_0x2f7f('0x3e')]=_0x3e6904[_0x2f7f('0x3e')][_0x2f7f('0x40')]?_0x3e6904[_0x2f7f('0x3e')]:_0x994d59[_0x2f7f('0x38')];_0x3e6904['order']=qs[_0x2f7f('0x44')](_0x1080dc[_0x2f7f('0x3a')][_0x2f7f('0x44')]);_0x3e6904[_0x2f7f('0x47')]=qs[_0x2f7f('0x3c')](_[_0x2f7f('0x45')](_0x1080dc[_0x2f7f('0x3a')],_0x994d59['filters']));if(_0x1080dc['query'][_0x2f7f('0x46')]){_0x3e6904['where']=_[_0x2f7f('0x48')](_0x3e6904[_0x2f7f('0x47')],{'$or':_[_0x2f7f('0x39')](_0x3e6904[_0x2f7f('0x3e')],function(_0x438f8b){var _0x507bad={};_0x507bad[_0x438f8b]={'$like':'%'+_0x1080dc[_0x2f7f('0x3a')][_0x2f7f('0x46')]+'%'};return _0x507bad;})});}_0x3e6904=_[_0x2f7f('0x48')]({},_0x3e6904,_0x1080dc[_0x2f7f('0x50')]);return _0x16d856['getConfigurations'](_0x3e6904);}})[_0x2f7f('0x1c')](function(_0x567162){if(_0x567162){_0x1c316b=_0x567162[_0x2f7f('0x40')];if(!_0x1080dc['query']['hasOwnProperty'](_0x2f7f('0x42'))){_0x3e6904[_0x2f7f('0x2a')]=qs[_0x2f7f('0x2a')](_0x1080dc[_0x2f7f('0x3a')][_0x2f7f('0x2a')]);_0x3e6904[_0x2f7f('0x28')]=qs['offset'](_0x1080dc[_0x2f7f('0x3a')][_0x2f7f('0x28')]);}return _0x16d856['getConfigurations'](_0x3e6904);}})['then'](function(_0x3c961a){if(_0x3c961a){return _0x3c961a?{'count':_0x1c316b,'rows':_0x3c961a}:null;}})[_0x2f7f('0x1c')](respondWithResult(_0xfa75ea,null))[_0x2f7f('0x25')](handleError(_0xfa75ea,null));};exports[_0x2f7f('0x59')]=function(_0x127840,_0x2f6aef,_0x4767bf){if(_0x127840[_0x2f7f('0x53')]['id']){delete _0x127840[_0x2f7f('0x53')]['id'];}return db[_0x2f7f('0x35')][_0x2f7f('0x57')]({'where':{'id':_0x127840[_0x2f7f('0x55')]['id']}})[_0x2f7f('0x1c')](handleEntityNotFound(_0x2f6aef,null))['then'](function(_0x585af4){if(_0x585af4){_0x127840[_0x2f7f('0x53')][_0x2f7f('0x5a')]=_0x585af4['id'];_0x127840[_0x2f7f('0x53')][_0x2f7f('0x5b')]=integrations[_0x2f7f('0x5c')](_0x127840['body'][_0x2f7f('0x5d')],_0x127840['body']['type']);_0x127840['body'][_0x2f7f('0x5e')]=integrations[_0x2f7f('0x5f')](_0x127840[_0x2f7f('0x53')]['channel'],_0x127840['body'][_0x2f7f('0x49')]);return db[_0x2f7f('0x58')][_0x2f7f('0x52')](_0x127840[_0x2f7f('0x53')],{'include':[{'model':db[_0x2f7f('0x60')],'as':_0x2f7f('0x5b')},{'model':db['FreshdeskField'],'as':_0x2f7f('0x5e')}]});}return null;})['then'](respondWithResult(_0x2f6aef,null))[_0x2f7f('0x25')](handleError(_0x2f6aef,null));};exports[_0x2f7f('0x61')]=function(_0x4e9e2e,_0x343284,_0x81a08c){var _0x45b162='';return db[_0x2f7f('0x35')][_0x2f7f('0x57')]({'where':{'id':_0x4e9e2e[_0x2f7f('0x55')]['id']},'attributes':['id',_0x2f7f('0x62'),_0x2f7f('0x63')]})[_0x2f7f('0x1c')](handleEntityNotFound(_0x343284,null))[_0x2f7f('0x1c')](function(_0x3046e9){if(_0x3046e9){_0x45b162=_0x3046e9[_0x2f7f('0x62')];var _0x48f20d=_0x45b162[_0x2f7f('0x64')](-0x1);if(_0x48f20d==='/'){_0x45b162=_0x45b162[_0x2f7f('0x65')](0x0,_0x45b162[_0x2f7f('0x66')](_0x48f20d));}return rp({'method':'GET','uri':util[_0x2f7f('0x67')](_0x2f7f('0x68'),_0x45b162,_0x2f7f('0x69')),'headers':{'Authorization':util[_0x2f7f('0x67')](_0x2f7f('0x6a'),new Buffer(util['format'](_0x2f7f('0x6b'),_0x3046e9['apiKey']))[_0x2f7f('0x6c')](_0x2f7f('0x6d')))},'json':!![]});}})['then'](function(_0x14d818){if(_0x14d818){var _0x2db91a=[_0x2f7f('0x6e'),_0x2f7f('0x6f'),_0x2f7f('0x70'),'description',_0x2f7f('0x27'),_0x2f7f('0x71'),_0x2f7f('0x72'),_0x2f7f('0x73'),_0x2f7f('0x74'),_0x2f7f('0x72'),_0x2f7f('0x75')];_['remove'](_0x14d818,function(_0x517baf){return _0x2db91a[_0x2f7f('0x76')](_0x517baf[_0x2f7f('0x32')])||!_0x517baf['default']&&_0x517baf[_0x2f7f('0x49')]!==_0x2f7f('0x77')&&_0x517baf[_0x2f7f('0x49')]!==_0x2f7f('0x78');});return{'count':_0x14d818['length'],'rows':_[_0x2f7f('0x39')](_0x14d818,function(_0x279e55){return{'id':_0x279e55[_0x2f7f('0x32')],'name':_0x279e55[_0x2f7f('0x79')],'custom':!_0x279e55['default'],'options':_0x279e55[_0x2f7f('0x7a')]?_['map'](_0x279e55[_0x2f7f('0x7a')],function(_0x34a769){return{'name':_[_0x2f7f('0x7b')](_0x34a769),'value':_0x34a769};}):[]};})};}})['then'](respondWithResult(_0x343284,null))['catch'](function(_0x1f83a4){var _0x36a72=_0x4e9e2e[_0x2f7f('0x3a')]['test']?0x1f4:_0x1f83a4['statusCode']||0x1f4;logger[_0x2f7f('0x22')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x36a72,JSON['stringify'](_0x1f83a4));delete _0x1f83a4[_0x2f7f('0x32')];if(_0x36a72===0x191){_0x36a72=0x190;}_0x343284['status'](_0x36a72)[_0x2f7f('0x33')](_0x4e9e2e['query'][_0x2f7f('0x7c')]?{'message':'Wrong\x20credentials','statusCode':_0x1f83a4[_0x2f7f('0x7d')]}:_0x1f83a4);});};
\ No newline at end of file
+var _0x8cfd=['to-csv','ejs','fs-extra','crypto','jsforce','desk.js','querystring','papaparse','../../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','status','end','offset','undefined','limit','count','set','Content-Range','json','reject','save','update','destroy','then','sendStatus','stack','name','send','index','map','FreshdeskAccount','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','nolimit','order','sort','where','filter','merge','type','VIRTUAL','includeAll','include','findAll','rows','show','options','find','catch','body','params','getConfigurations','findOne','rawAttributes','hasOwnProperty','Subjects','channel','Descriptions','getDescriptions','FreshdeskConfiguration','FreshdeskField','remoteUri','apiKey','slice','substring','GET','format','%s/%s','api/v2/ticket_fields','%s:X','base64','requester','subject','agent','description','group','source','ticket_type','company','remove','includes','default','label','choices','capitalize','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox'];(function(_0x56740a,_0x568894){var _0x257144=function(_0x2b8cc5){while(--_0x2b8cc5){_0x56740a['push'](_0x56740a['shift']());}};_0x257144(++_0x568894);}(_0x8cfd,0xe4));var _0xd8cf=function(_0x5235a6,_0x680b76){_0x5235a6=_0x5235a6-0x0;var _0x1cf37e=_0x8cfd[_0x5235a6];return _0x1cf37e;};'use strict';var emlformat=require(_0xd8cf('0x0'));var rimraf=require(_0xd8cf('0x1'));var zipdir=require(_0xd8cf('0x2'));var jsonpatch=require(_0xd8cf('0x3'));var rp=require(_0xd8cf('0x4'));var moment=require(_0xd8cf('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xd8cf('0x6'));var util=require(_0xd8cf('0x7'));var path=require(_0xd8cf('0x8'));var sox=require(_0xd8cf('0x9'));var csv=require(_0xd8cf('0xa'));var ejs=require(_0xd8cf('0xb'));var fs=require('fs');var fs_extra=require(_0xd8cf('0xc'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xd8cf('0xd'));var jsforce=require(_0xd8cf('0xe'));var deskjs=require(_0xd8cf('0xf'));var toCsv=require(_0xd8cf('0xa'));var querystring=require(_0xd8cf('0x10'));var Papa=require(_0xd8cf('0x11'));var Redis=require('ioredis');var authService=require(_0xd8cf('0x12'));var qs=require(_0xd8cf('0x13'));var as=require(_0xd8cf('0x14'));var hardwareService=require(_0xd8cf('0x15'));var logger=require(_0xd8cf('0x16'))(_0xd8cf('0x17'));var utils=require(_0xd8cf('0x18'));var config=require(_0xd8cf('0x19'));var licenseUtil=require(_0xd8cf('0x1a'));var db=require(_0xd8cf('0x1b'))['db'];var integrations=require(_0xd8cf('0x1c'));function respondWithStatusCode(_0x23c6e1,_0x599397){_0x599397=_0x599397||0xcc;return function(_0x8e55f2){if(_0x8e55f2){return _0x23c6e1['sendStatus'](_0x599397);}return _0x23c6e1[_0xd8cf('0x1d')](_0x599397)[_0xd8cf('0x1e')]();};}function respondWithResult(_0x4e6760,_0x3fdb82){_0x3fdb82=_0x3fdb82||0xc8;return function(_0x1ec11c){if(_0x1ec11c){return _0x4e6760[_0xd8cf('0x1d')](_0x3fdb82)['json'](_0x1ec11c);}};}function respondWithFilteredResult(_0x19cf6c,_0x5b9fb4){return function(_0xc39a9a){if(_0xc39a9a){var _0x24c78c=typeof _0x5b9fb4[_0xd8cf('0x1f')]===_0xd8cf('0x20')&&typeof _0x5b9fb4[_0xd8cf('0x21')]===_0xd8cf('0x20');var _0x5be3ac=_0xc39a9a[_0xd8cf('0x22')];var _0x73e7c3=_0x24c78c?0x0:_0x5b9fb4[_0xd8cf('0x1f')];var _0xf8732e=_0x24c78c?_0xc39a9a[_0xd8cf('0x22')]:_0x5b9fb4[_0xd8cf('0x1f')]+_0x5b9fb4[_0xd8cf('0x21')];var _0x1a8cee;if(_0xf8732e>=_0x5be3ac){_0xf8732e=_0x5be3ac;_0x1a8cee=0xc8;}else{_0x1a8cee=0xce;}_0x19cf6c[_0xd8cf('0x1d')](_0x1a8cee);return _0x19cf6c[_0xd8cf('0x23')](_0xd8cf('0x24'),_0x73e7c3+'-'+_0xf8732e+'/'+_0x5be3ac)[_0xd8cf('0x25')](_0xc39a9a);}return null;};}function patchUpdates(_0x3aa31c){return function(_0x1df141){try{jsonpatch['apply'](_0x1df141,_0x3aa31c,!![]);}catch(_0x10f979){return BPromise[_0xd8cf('0x26')](_0x10f979);}return _0x1df141[_0xd8cf('0x27')]();};}function saveUpdates(_0x182613,_0x454402){return function(_0x572871){if(_0x572871){return _0x572871[_0xd8cf('0x28')](_0x182613)['then'](function(_0x47b71d){return _0x47b71d;});}return null;};}function removeEntity(_0x4e7d83,_0x144083){return function(_0x5e193e){if(_0x5e193e){return _0x5e193e[_0xd8cf('0x29')]()[_0xd8cf('0x2a')](function(){_0x4e7d83[_0xd8cf('0x1d')](0xcc)[_0xd8cf('0x1e')]();});}};}function handleEntityNotFound(_0x4c8525,_0x1ac60d){return function(_0x2e1dd1){if(!_0x2e1dd1){_0x4c8525[_0xd8cf('0x2b')](0x194);}return _0x2e1dd1;};}function handleError(_0x31f1ec,_0x2f97b1){_0x2f97b1=_0x2f97b1||0x1f4;return function(_0x45a5b6){logger['error'](_0x45a5b6[_0xd8cf('0x2c')]);if(_0x45a5b6[_0xd8cf('0x2d')]){delete _0x45a5b6['name'];}_0x31f1ec[_0xd8cf('0x1d')](_0x2f97b1)[_0xd8cf('0x2e')](_0x45a5b6);};}exports[_0xd8cf('0x2f')]=function(_0x121025,_0x45127d){var _0x48013b={},_0x43fdf0={},_0x3ac9bc={'count':0x0,'rows':[]};var _0x33f969=_[_0xd8cf('0x30')](db[_0xd8cf('0x31')]['rawAttributes'],function(_0x114658){return{'name':_0x114658[_0xd8cf('0x32')],'type':_0x114658['type'][_0xd8cf('0x33')]};});_0x43fdf0[_0xd8cf('0x34')]=_['map'](_0x33f969,_0xd8cf('0x2d'));_0x43fdf0[_0xd8cf('0x35')]=_[_0xd8cf('0x36')](_0x121025['query']);_0x43fdf0[_0xd8cf('0x37')]=_['intersection'](_0x43fdf0[_0xd8cf('0x34')],_0x43fdf0[_0xd8cf('0x35')]);_0x48013b[_0xd8cf('0x38')]=_[_0xd8cf('0x39')](_0x43fdf0[_0xd8cf('0x34')],qs[_0xd8cf('0x3a')](_0x121025[_0xd8cf('0x35')][_0xd8cf('0x3a')]));_0x48013b[_0xd8cf('0x38')]=_0x48013b[_0xd8cf('0x38')][_0xd8cf('0x3b')]?_0x48013b['attributes']:_0x43fdf0[_0xd8cf('0x34')];if(!_0x121025[_0xd8cf('0x35')]['hasOwnProperty'](_0xd8cf('0x3c'))){_0x48013b[_0xd8cf('0x21')]=qs['limit'](_0x121025[_0xd8cf('0x35')][_0xd8cf('0x21')]);_0x48013b[_0xd8cf('0x1f')]=qs[_0xd8cf('0x1f')](_0x121025[_0xd8cf('0x35')][_0xd8cf('0x1f')]);}_0x48013b[_0xd8cf('0x3d')]=qs[_0xd8cf('0x3e')](_0x121025['query'][_0xd8cf('0x3e')]);_0x48013b[_0xd8cf('0x3f')]=qs[_0xd8cf('0x37')](_['pick'](_0x121025[_0xd8cf('0x35')],_0x43fdf0[_0xd8cf('0x37')]),_0x33f969);if(_0x121025[_0xd8cf('0x35')][_0xd8cf('0x40')]){_0x48013b[_0xd8cf('0x3f')]=_[_0xd8cf('0x41')](_0x48013b[_0xd8cf('0x3f')],{'$or':_[_0xd8cf('0x30')](_0x33f969,function(_0x209b64){if(_0x209b64[_0xd8cf('0x42')]!==_0xd8cf('0x43')){var _0x5b887f={};_0x5b887f[_0x209b64['name']]={'$like':'%'+_0x121025['query'][_0xd8cf('0x40')]+'%'};return _0x5b887f;}})});}_0x48013b=_['merge']({},_0x48013b,_0x121025['options']);var _0x552823={'where':_0x48013b[_0xd8cf('0x3f')]};return db[_0xd8cf('0x31')][_0xd8cf('0x22')](_0x552823)[_0xd8cf('0x2a')](function(_0x16eee9){_0x3ac9bc[_0xd8cf('0x22')]=_0x16eee9;if(_0x121025['query'][_0xd8cf('0x44')]){_0x48013b[_0xd8cf('0x45')]=[{'all':!![]}];}return db[_0xd8cf('0x31')][_0xd8cf('0x46')](_0x48013b);})[_0xd8cf('0x2a')](function(_0x287556){_0x3ac9bc[_0xd8cf('0x47')]=_0x287556;return _0x3ac9bc;})[_0xd8cf('0x2a')](respondWithFilteredResult(_0x45127d,_0x48013b))['catch'](handleError(_0x45127d,null));};exports[_0xd8cf('0x48')]=function(_0x37a410,_0x3972aa){var _0x558fb0={'raw':![],'where':{'id':_0x37a410['params']['id']}},_0x1d9598={};_0x1d9598[_0xd8cf('0x34')]=_['keys'](db['FreshdeskAccount']['rawAttributes']);_0x1d9598['query']=_[_0xd8cf('0x36')](_0x37a410[_0xd8cf('0x35')]);_0x1d9598[_0xd8cf('0x37')]=_['intersection'](_0x1d9598['model'],_0x1d9598[_0xd8cf('0x35')]);_0x558fb0[_0xd8cf('0x38')]=_[_0xd8cf('0x39')](_0x1d9598[_0xd8cf('0x34')],qs['fields'](_0x37a410[_0xd8cf('0x35')][_0xd8cf('0x3a')]));_0x558fb0[_0xd8cf('0x38')]=_0x558fb0['attributes'][_0xd8cf('0x3b')]?_0x558fb0[_0xd8cf('0x38')]:_0x1d9598[_0xd8cf('0x34')];if(_0x37a410[_0xd8cf('0x35')][_0xd8cf('0x44')]){_0x558fb0[_0xd8cf('0x45')]=[{'all':!![]}];}_0x558fb0=_['merge']({},_0x558fb0,_0x37a410[_0xd8cf('0x49')]);return db[_0xd8cf('0x31')][_0xd8cf('0x4a')](_0x558fb0)[_0xd8cf('0x2a')](handleEntityNotFound(_0x3972aa,null))[_0xd8cf('0x2a')](respondWithResult(_0x3972aa,null))[_0xd8cf('0x4b')](handleError(_0x3972aa,null));};exports['create']=function(_0x3686ee,_0x35d8f9){return db[_0xd8cf('0x31')]['create'](_0x3686ee[_0xd8cf('0x4c')],{})[_0xd8cf('0x2a')](respondWithResult(_0x35d8f9,0xc9))[_0xd8cf('0x4b')](handleError(_0x35d8f9,null));};exports[_0xd8cf('0x28')]=function(_0x25d001,_0x1625d2){if(_0x25d001[_0xd8cf('0x4c')]['id']){delete _0x25d001[_0xd8cf('0x4c')]['id'];}return db['FreshdeskAccount'][_0xd8cf('0x4a')]({'where':{'id':_0x25d001[_0xd8cf('0x4d')]['id']}})[_0xd8cf('0x2a')](handleEntityNotFound(_0x1625d2,null))[_0xd8cf('0x2a')](saveUpdates(_0x25d001[_0xd8cf('0x4c')],null))[_0xd8cf('0x2a')](respondWithResult(_0x1625d2,null))[_0xd8cf('0x4b')](handleError(_0x1625d2,null));};exports[_0xd8cf('0x29')]=function(_0x2f1348,_0x3dea3b){return db[_0xd8cf('0x31')][_0xd8cf('0x4a')]({'where':{'id':_0x2f1348[_0xd8cf('0x4d')]['id']}})[_0xd8cf('0x2a')](handleEntityNotFound(_0x3dea3b,null))[_0xd8cf('0x2a')](removeEntity(_0x3dea3b,null))[_0xd8cf('0x4b')](handleError(_0x3dea3b,null));};exports[_0xd8cf('0x4e')]=function(_0xa42d0e,_0x8ffd88,_0x4739ef){var _0x4d7b4d={};var _0x256beb={};var _0x1f8c4e;var _0x3cbf36;return db['FreshdeskAccount'][_0xd8cf('0x4f')]({'where':{'id':_0xa42d0e[_0xd8cf('0x4d')]['id']}})[_0xd8cf('0x2a')](handleEntityNotFound(_0x8ffd88,null))[_0xd8cf('0x2a')](function(_0x6d1fc8){if(_0x6d1fc8){_0x1f8c4e=_0x6d1fc8;_0x256beb[_0xd8cf('0x34')]=_['keys'](db['FreshdeskConfiguration'][_0xd8cf('0x50')]);_0x256beb['query']=_[_0xd8cf('0x36')](_0xa42d0e[_0xd8cf('0x35')]);_0x256beb[_0xd8cf('0x37')]=_['intersection'](_0x256beb[_0xd8cf('0x34')],_0x256beb[_0xd8cf('0x35')]);_0x4d7b4d[_0xd8cf('0x38')]=_[_0xd8cf('0x39')](_0x256beb[_0xd8cf('0x34')],qs[_0xd8cf('0x3a')](_0xa42d0e[_0xd8cf('0x35')]['fields']));_0x4d7b4d[_0xd8cf('0x38')]=_0x4d7b4d[_0xd8cf('0x38')][_0xd8cf('0x3b')]?_0x4d7b4d['attributes']:_0x256beb[_0xd8cf('0x34')];_0x4d7b4d[_0xd8cf('0x3d')]=qs[_0xd8cf('0x3e')](_0xa42d0e[_0xd8cf('0x35')][_0xd8cf('0x3e')]);_0x4d7b4d[_0xd8cf('0x3f')]=qs[_0xd8cf('0x37')](_['pick'](_0xa42d0e[_0xd8cf('0x35')],_0x256beb[_0xd8cf('0x37')]));if(_0xa42d0e[_0xd8cf('0x35')]['filter']){_0x4d7b4d[_0xd8cf('0x3f')]=_['merge'](_0x4d7b4d[_0xd8cf('0x3f')],{'$or':_[_0xd8cf('0x30')](_0x4d7b4d['attributes'],function(_0x38ee26){var _0x43b9af={};_0x43b9af[_0x38ee26]={'$like':'%'+_0xa42d0e[_0xd8cf('0x35')]['filter']+'%'};return _0x43b9af;})});}_0x4d7b4d=_[_0xd8cf('0x41')]({},_0x4d7b4d,_0xa42d0e['options']);return _0x1f8c4e[_0xd8cf('0x4e')](_0x4d7b4d);}})[_0xd8cf('0x2a')](function(_0xf73f5d){if(_0xf73f5d){_0x3cbf36=_0xf73f5d['length'];if(!_0xa42d0e[_0xd8cf('0x35')][_0xd8cf('0x51')](_0xd8cf('0x3c'))){_0x4d7b4d[_0xd8cf('0x21')]=qs[_0xd8cf('0x21')](_0xa42d0e[_0xd8cf('0x35')][_0xd8cf('0x21')]);_0x4d7b4d[_0xd8cf('0x1f')]=qs[_0xd8cf('0x1f')](_0xa42d0e[_0xd8cf('0x35')][_0xd8cf('0x1f')]);}return _0x1f8c4e[_0xd8cf('0x4e')](_0x4d7b4d);}})[_0xd8cf('0x2a')](function(_0x2cf49b){if(_0x2cf49b){return _0x2cf49b?{'count':_0x3cbf36,'rows':_0x2cf49b}:null;}})[_0xd8cf('0x2a')](respondWithResult(_0x8ffd88,null))[_0xd8cf('0x4b')](handleError(_0x8ffd88,null));};exports['addConfiguration']=function(_0x2f9459,_0x4ecd21,_0x46e644){if(_0x2f9459[_0xd8cf('0x4c')]['id']){delete _0x2f9459[_0xd8cf('0x4c')]['id'];}return db[_0xd8cf('0x31')][_0xd8cf('0x4f')]({'where':{'id':_0x2f9459[_0xd8cf('0x4d')]['id']}})[_0xd8cf('0x2a')](handleEntityNotFound(_0x4ecd21,null))[_0xd8cf('0x2a')](function(_0x139f45){if(_0x139f45){_0x2f9459[_0xd8cf('0x4c')]['AccountId']=_0x139f45['id'];_0x2f9459[_0xd8cf('0x4c')][_0xd8cf('0x52')]=integrations['getSubjects'](_0x2f9459['body'][_0xd8cf('0x53')],_0x2f9459[_0xd8cf('0x4c')][_0xd8cf('0x42')]);_0x2f9459[_0xd8cf('0x4c')][_0xd8cf('0x54')]=integrations[_0xd8cf('0x55')](_0x2f9459[_0xd8cf('0x4c')][_0xd8cf('0x53')],_0x2f9459[_0xd8cf('0x4c')][_0xd8cf('0x42')]);return db[_0xd8cf('0x56')]['create'](_0x2f9459['body'],{'include':[{'model':db[_0xd8cf('0x57')],'as':_0xd8cf('0x52')},{'model':db[_0xd8cf('0x57')],'as':'Descriptions'}]});}return null;})[_0xd8cf('0x2a')](respondWithResult(_0x4ecd21,null))['catch'](handleError(_0x4ecd21,null));};exports['getFields']=function(_0x46b17e,_0x5910a4,_0x23fe99){var _0x41dd8b='';return db[_0xd8cf('0x31')][_0xd8cf('0x4f')]({'where':{'id':_0x46b17e['params']['id']},'attributes':['id',_0xd8cf('0x58'),_0xd8cf('0x59')]})[_0xd8cf('0x2a')](handleEntityNotFound(_0x5910a4,null))[_0xd8cf('0x2a')](function(_0x333073){if(_0x333073){_0x41dd8b=_0x333073[_0xd8cf('0x58')];var _0x14241c=_0x41dd8b[_0xd8cf('0x5a')](-0x1);if(_0x14241c==='/'){_0x41dd8b=_0x41dd8b[_0xd8cf('0x5b')](0x0,_0x41dd8b['lastIndexOf'](_0x14241c));}return rp({'method':_0xd8cf('0x5c'),'uri':util[_0xd8cf('0x5d')](_0xd8cf('0x5e'),_0x41dd8b,_0xd8cf('0x5f')),'headers':{'Authorization':util[_0xd8cf('0x5d')]('Basic\x20%s',new Buffer(util[_0xd8cf('0x5d')](_0xd8cf('0x60'),_0x333073[_0xd8cf('0x59')]))['toString'](_0xd8cf('0x61')))},'json':!![]});}})['then'](function(_0x3809f3){if(_0x3809f3){var _0xd955aa=[_0xd8cf('0x62'),_0xd8cf('0x63'),_0xd8cf('0x64'),_0xd8cf('0x65'),_0xd8cf('0x1d'),'priority',_0xd8cf('0x66'),_0xd8cf('0x67'),_0xd8cf('0x68'),_0xd8cf('0x66'),_0xd8cf('0x69')];_[_0xd8cf('0x6a')](_0x3809f3,function(_0x3f1048){return _0xd955aa[_0xd8cf('0x6b')](_0x3f1048['name'])||!_0x3f1048[_0xd8cf('0x6c')]&&_0x3f1048[_0xd8cf('0x42')]!=='custom_text'&&_0x3f1048[_0xd8cf('0x42')]!=='custom_dropdown';});return{'count':_0x3809f3['length'],'rows':_[_0xd8cf('0x30')](_0x3809f3,function(_0x1bbcaf){return{'id':_0x1bbcaf[_0xd8cf('0x2d')],'name':_0x1bbcaf[_0xd8cf('0x6d')],'custom':!_0x1bbcaf[_0xd8cf('0x6c')],'options':_0x1bbcaf['choices']?_[_0xd8cf('0x30')](_0x1bbcaf[_0xd8cf('0x6e')],function(_0x74736a){return{'name':_[_0xd8cf('0x6f')](_0x74736a),'value':_0x74736a};}):[]};})};}})['then'](respondWithResult(_0x5910a4,null))[_0xd8cf('0x4b')](function(_0x2c6e0b){var _0x31ac8f=_0x46b17e['query'][_0xd8cf('0x70')]?0x1f4:_0x2c6e0b[_0xd8cf('0x71')]||0x1f4;logger[_0xd8cf('0x72')](_0xd8cf('0x73'),_0xd8cf('0x74'),_0x31ac8f,JSON[_0xd8cf('0x75')](_0x2c6e0b));delete _0x2c6e0b[_0xd8cf('0x2d')];if(_0x31ac8f===0x191){_0x31ac8f=0x190;}_0x5910a4[_0xd8cf('0x1d')](_0x31ac8f)[_0xd8cf('0x2e')](_0x46b17e[_0xd8cf('0x35')][_0xd8cf('0x70')]?{'message':_0xd8cf('0x76'),'statusCode':_0x2c6e0b[_0xd8cf('0x71')]}:_0x2c6e0b);});};
\ No newline at end of file