Built motion from commit f7863d46.|2.5.41
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 2b6bdcb..8f0353b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f78=['index','map','FreshdeskAccount','rawAttributes','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','catch','show','params','create','body','update','find','getConfigurations','order','nolimit','addConfiguration','findOne','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshdeskField','remoteUri','apiKey','substring','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','%s:X','toString','requester','subject','agent','description','priority','group','source','ticket_type','company','includes','custom_text','label','default','choices','capitalize','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','send','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','then','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','status','end','json','count','offset','limit','Content-Range','apply','reject','destroy','sendStatus','stack','name'];(function(_0x5106c1,_0x13233a){var _0x5bcaac=function(_0x18c12e){while(--_0x18c12e){_0x5106c1['push'](_0x5106c1['shift']());}};_0x5bcaac(++_0x13233a);}(_0x8f78,0xc9));var _0x88f7=function(_0x422905,_0x3bce3a){_0x422905=_0x422905-0x0;var _0x33dc6c=_0x8f78[_0x422905];return _0x33dc6c;};'use strict';var pdf=require(_0x88f7('0x0'));var emlformat=require(_0x88f7('0x1'));var rimraf=require(_0x88f7('0x2'));var zipdir=require(_0x88f7('0x3'));var jsonpatch=require(_0x88f7('0x4'));var rp=require(_0x88f7('0x5'));var moment=require(_0x88f7('0x6'));var BPromise=require(_0x88f7('0x7'));var Mustache=require(_0x88f7('0x8'));var util=require(_0x88f7('0x9'));var path=require(_0x88f7('0xa'));var sox=require('sox');var csv=require(_0x88f7('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x88f7('0xc'));var jsforce=require(_0x88f7('0xd'));var deskjs=require(_0x88f7('0xe'));var toCsv=require(_0x88f7('0xb'));var querystring=require(_0x88f7('0xf'));var Papa=require(_0x88f7('0x10'));var Redis=require(_0x88f7('0x11'));var authService=require(_0x88f7('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x88f7('0x13'));var hardwareService=require(_0x88f7('0x14'));var logger=require('../../config/logger')(_0x88f7('0x15'));var utils=require('../../config/utils');var config=require(_0x88f7('0x16'));var db=require(_0x88f7('0x17'))['db'];var integrations=require(_0x88f7('0x18'));var jayson=require(_0x88f7('0x19'));var client=jayson[_0x88f7('0x1a')]['http']({'port':0x232a});function checkPasswordPattern(_0x1bb1d8,_0x12377b,_0x32de16){if(_0x32de16){var _0x4b23d1=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4b23d1[_0x88f7('0x1b')](_0x12377b)){return _0x1bb1d8;}else{throw new db[(_0x88f7('0x1c'))][(_0x88f7('0x1d'))](_0x88f7('0x1e'));}}else{return _0x1bb1d8;}}function respondWithRpcPromise(_0x3a1179,_0x329338,_0x502f7b,_0x445ce3){return new BPromise(function(_0x5bb752,_0x14e8ee){var _0x57caba=_0x445ce3||client;return _0x57caba['request'](_0x3a1179,_0x502f7b)[_0x88f7('0x1f')](function(_0x59b540){logger[_0x88f7('0x20')](_0x88f7('0x21'),_0x329338,_0x88f7('0x22'));logger['debug'](_0x88f7('0x23'),_0x329338,'request\x20sent',JSON[_0x88f7('0x24')](_0x59b540));if(_0x59b540[_0x88f7('0x25')]){if(_0x59b540['error']['code']===0x1f4){logger[_0x88f7('0x25')](_0x88f7('0x21'),_0x329338,_0x59b540['error'][_0x88f7('0x26')]);return _0x14e8ee(_0x59b540[_0x88f7('0x25')][_0x88f7('0x26')]);}logger[_0x88f7('0x25')](_0x88f7('0x21'),_0x329338,_0x59b540[_0x88f7('0x25')][_0x88f7('0x26')]);return _0x5bb752(_0x59b540['error']['message']);}else{logger[_0x88f7('0x20')](_0x88f7('0x21'),_0x329338,_0x88f7('0x22'));_0x5bb752(_0x59b540[_0x88f7('0x27')][_0x88f7('0x26')]);}})['catch'](function(_0x56c197){logger[_0x88f7('0x25')]('FreshdeskAccount,\x20%s,\x20%s',_0x329338,_0x56c197);_0x14e8ee(_0x56c197);});});}function respondWithStatusCode(_0x57d6da,_0x446933){_0x446933=_0x446933||0xcc;return function(_0x2ea65e){if(_0x2ea65e){return _0x57d6da['sendStatus'](_0x446933);}return _0x57d6da[_0x88f7('0x28')](_0x446933)[_0x88f7('0x29')]();};}function respondWithResult(_0x565c2b,_0x4576ab){_0x4576ab=_0x4576ab||0xc8;return function(_0x4c1d51){if(_0x4c1d51){return _0x565c2b[_0x88f7('0x28')](_0x4576ab)[_0x88f7('0x2a')](_0x4c1d51);}};}function respondWithFilteredResult(_0x3ec41d,_0x1f954f){return function(_0x1fc3bc){if(_0x1fc3bc){var _0x44da5a=_0x1fc3bc[_0x88f7('0x2b')],_0x29ca06=_0x1f954f[_0x88f7('0x2c')],_0x1cbdbb=_0x1f954f[_0x88f7('0x2c')]+_0x1f954f[_0x88f7('0x2d')],_0x3c7326;if(_0x1cbdbb>=_0x44da5a){_0x1cbdbb=_0x44da5a;_0x3c7326=0xc8;}else{_0x3c7326=0xce;}_0x3ec41d['status'](_0x3c7326);return _0x3ec41d['set'](_0x88f7('0x2e'),_0x29ca06+'-'+_0x1cbdbb+'/'+_0x44da5a)['json'](_0x1fc3bc);}return null;};}function patchUpdates(_0xf11da9){return function(_0x4c4bba){try{jsonpatch[_0x88f7('0x2f')](_0x4c4bba,_0xf11da9,!![]);}catch(_0x2641d5){return BPromise[_0x88f7('0x30')](_0x2641d5);}return _0x4c4bba['save']();};}function saveUpdates(_0x11e232,_0x17d100){return function(_0x2c0a4b){if(_0x2c0a4b){return _0x2c0a4b['update'](_0x11e232)[_0x88f7('0x1f')](function(_0x246857){return _0x246857;});}return null;};}function removeEntity(_0x1e2d36,_0x3a3591){return function(_0x2de780){if(_0x2de780){return _0x2de780[_0x88f7('0x31')]()[_0x88f7('0x1f')](function(){_0x1e2d36[_0x88f7('0x28')](0xcc)[_0x88f7('0x29')]();});}};}function handleEntityNotFound(_0xdc5483,_0x3069ad){return function(_0x3e23df){if(!_0x3e23df){_0xdc5483[_0x88f7('0x32')](0x194);}return _0x3e23df;};}function handleError(_0x5b9eae,_0x1c1617){_0x1c1617=_0x1c1617||0x1f4;return function(_0xc2b5ff){logger[_0x88f7('0x25')](_0xc2b5ff[_0x88f7('0x33')]);if(_0xc2b5ff[_0x88f7('0x34')]){delete _0xc2b5ff[_0x88f7('0x34')];}_0x5b9eae['status'](_0x1c1617)['send'](_0xc2b5ff);};}exports[_0x88f7('0x35')]=function(_0x28d0ed,_0x459e00){var _0x11a2a1={},_0x128468={},_0x4fb9c4={'count':0x0,'rows':[]};var _0x20707b=_[_0x88f7('0x36')](db[_0x88f7('0x37')][_0x88f7('0x38')],function(_0x4350cb){return{'name':_0x4350cb[_0x88f7('0x39')],'type':_0x4350cb[_0x88f7('0x3a')][_0x88f7('0x3b')]};});_0x128468[_0x88f7('0x3c')]=_['map'](_0x20707b,_0x88f7('0x34'));_0x128468['query']=_[_0x88f7('0x3d')](_0x28d0ed[_0x88f7('0x3e')]);_0x128468[_0x88f7('0x3f')]=_['intersection'](_0x128468[_0x88f7('0x3c')],_0x128468['query']);_0x11a2a1[_0x88f7('0x40')]=_[_0x88f7('0x41')](_0x128468[_0x88f7('0x3c')],qs[_0x88f7('0x42')](_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x42')]));_0x11a2a1[_0x88f7('0x40')]=_0x11a2a1[_0x88f7('0x40')][_0x88f7('0x43')]?_0x11a2a1[_0x88f7('0x40')]:_0x128468[_0x88f7('0x3c')];if(!_0x28d0ed['query'][_0x88f7('0x44')]('nolimit')){_0x11a2a1[_0x88f7('0x2d')]=qs[_0x88f7('0x2d')](_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x2d')]);_0x11a2a1['offset']=qs['offset'](_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x2c')]);}_0x11a2a1['order']=qs[_0x88f7('0x45')](_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x45')]);_0x11a2a1[_0x88f7('0x46')]=qs[_0x88f7('0x3f')](_['pick'](_0x28d0ed[_0x88f7('0x3e')],_0x128468[_0x88f7('0x3f')]));if(_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x47')]){_0x11a2a1[_0x88f7('0x46')]=_['merge'](_0x11a2a1['where'],{'$or':_[_0x88f7('0x36')](_0x20707b,function(_0xe65a32){if(_0xe65a32[_0x88f7('0x3a')]!==_0x88f7('0x48')){var _0x5f14c9={};_0x5f14c9[_0xe65a32['name']]={'$like':'%'+_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x47')]+'%'};return _0x5f14c9;}})});}_0x11a2a1=_[_0x88f7('0x49')]({},_0x11a2a1,_0x28d0ed[_0x88f7('0x4a')]);var _0x4f0c2f={'where':_0x11a2a1[_0x88f7('0x46')]};return db[_0x88f7('0x37')]['count'](_0x4f0c2f)[_0x88f7('0x1f')](function(_0x26f9f2){_0x4fb9c4[_0x88f7('0x2b')]=_0x26f9f2;if(_0x28d0ed[_0x88f7('0x3e')][_0x88f7('0x4b')]){_0x11a2a1[_0x88f7('0x4c')]=[{'all':!![]}];}return db[_0x88f7('0x37')][_0x88f7('0x4d')](_0x11a2a1);})[_0x88f7('0x1f')](function(_0x1a8220){_0x4fb9c4['rows']=_0x1a8220;return _0x4fb9c4;})[_0x88f7('0x1f')](respondWithFilteredResult(_0x459e00,_0x11a2a1))[_0x88f7('0x4e')](handleError(_0x459e00,null));};exports[_0x88f7('0x4f')]=function(_0x58f609,_0x7f9f8){var _0x17a967={'raw':![],'where':{'id':_0x58f609[_0x88f7('0x50')]['id']}},_0x5d7eb7={};_0x5d7eb7[_0x88f7('0x3c')]=_['keys'](db[_0x88f7('0x37')]['rawAttributes']);_0x5d7eb7[_0x88f7('0x3e')]=_[_0x88f7('0x3d')](_0x58f609[_0x88f7('0x3e')]);_0x5d7eb7[_0x88f7('0x3f')]=_[_0x88f7('0x41')](_0x5d7eb7['model'],_0x5d7eb7['query']);_0x17a967['attributes']=_['intersection'](_0x5d7eb7[_0x88f7('0x3c')],qs['fields'](_0x58f609[_0x88f7('0x3e')][_0x88f7('0x42')]));_0x17a967[_0x88f7('0x40')]=_0x17a967[_0x88f7('0x40')][_0x88f7('0x43')]?_0x17a967[_0x88f7('0x40')]:_0x5d7eb7[_0x88f7('0x3c')];if(_0x58f609[_0x88f7('0x3e')]['includeAll']){_0x17a967[_0x88f7('0x4c')]=[{'all':!![]}];}_0x17a967=_[_0x88f7('0x49')]({},_0x17a967,_0x58f609[_0x88f7('0x4a')]);return db['FreshdeskAccount']['find'](_0x17a967)[_0x88f7('0x1f')](handleEntityNotFound(_0x7f9f8,null))[_0x88f7('0x1f')](respondWithResult(_0x7f9f8,null))['catch'](handleError(_0x7f9f8,null));};exports[_0x88f7('0x51')]=function(_0x4142b5,_0x564979){return db['FreshdeskAccount'][_0x88f7('0x51')](_0x4142b5[_0x88f7('0x52')],{})[_0x88f7('0x1f')](respondWithResult(_0x564979,0xc9))[_0x88f7('0x4e')](handleError(_0x564979,null));};exports[_0x88f7('0x53')]=function(_0x44ddab,_0x28c0a5){if(_0x44ddab[_0x88f7('0x52')]['id']){delete _0x44ddab[_0x88f7('0x52')]['id'];}return db['FreshdeskAccount'][_0x88f7('0x54')]({'where':{'id':_0x44ddab['params']['id']}})[_0x88f7('0x1f')](handleEntityNotFound(_0x28c0a5,null))[_0x88f7('0x1f')](saveUpdates(_0x44ddab['body'],null))[_0x88f7('0x1f')](respondWithResult(_0x28c0a5,null))[_0x88f7('0x4e')](handleError(_0x28c0a5,null));};exports['destroy']=function(_0x45b61f,_0xd44015){return db[_0x88f7('0x37')][_0x88f7('0x54')]({'where':{'id':_0x45b61f[_0x88f7('0x50')]['id']}})[_0x88f7('0x1f')](handleEntityNotFound(_0xd44015,null))[_0x88f7('0x1f')](removeEntity(_0xd44015,null))['catch'](handleError(_0xd44015,null));};exports[_0x88f7('0x55')]=function(_0x29c395,_0x1163e1,_0x321884){var _0x184968={};var _0x4e46ba={};var _0x5114a9;var _0x11a5fb;return db['FreshdeskAccount']['findOne']({'where':{'id':_0x29c395[_0x88f7('0x50')]['id']}})[_0x88f7('0x1f')](handleEntityNotFound(_0x1163e1,null))[_0x88f7('0x1f')](function(_0x159290){if(_0x159290){_0x5114a9=_0x159290;_0x4e46ba[_0x88f7('0x3c')]=_[_0x88f7('0x3d')](db['FreshdeskConfiguration'][_0x88f7('0x38')]);_0x4e46ba[_0x88f7('0x3e')]=_[_0x88f7('0x3d')](_0x29c395['query']);_0x4e46ba[_0x88f7('0x3f')]=_[_0x88f7('0x41')](_0x4e46ba[_0x88f7('0x3c')],_0x4e46ba['query']);_0x184968['attributes']=_['intersection'](_0x4e46ba['model'],qs[_0x88f7('0x42')](_0x29c395['query'][_0x88f7('0x42')]));_0x184968['attributes']=_0x184968[_0x88f7('0x40')][_0x88f7('0x43')]?_0x184968['attributes']:_0x4e46ba['model'];_0x184968[_0x88f7('0x56')]=qs[_0x88f7('0x45')](_0x29c395['query'][_0x88f7('0x45')]);_0x184968[_0x88f7('0x46')]=qs[_0x88f7('0x3f')](_['pick'](_0x29c395[_0x88f7('0x3e')],_0x4e46ba[_0x88f7('0x3f')]));if(_0x29c395[_0x88f7('0x3e')][_0x88f7('0x47')]){_0x184968[_0x88f7('0x46')]=_['merge'](_0x184968['where'],{'$or':_[_0x88f7('0x36')](_0x184968['attributes'],function(_0x310882){var _0x8c844a={};_0x8c844a[_0x310882]={'$like':'%'+_0x29c395[_0x88f7('0x3e')][_0x88f7('0x47')]+'%'};return _0x8c844a;})});}_0x184968=_[_0x88f7('0x49')]({},_0x184968,_0x29c395[_0x88f7('0x4a')]);return _0x5114a9[_0x88f7('0x55')](_0x184968);}})[_0x88f7('0x1f')](function(_0x4ba0f9){if(_0x4ba0f9){_0x11a5fb=_0x4ba0f9['length'];if(!_0x29c395['query'][_0x88f7('0x44')](_0x88f7('0x57'))){_0x184968[_0x88f7('0x2d')]=qs[_0x88f7('0x2d')](_0x29c395[_0x88f7('0x3e')][_0x88f7('0x2d')]);_0x184968[_0x88f7('0x2c')]=qs[_0x88f7('0x2c')](_0x29c395[_0x88f7('0x3e')][_0x88f7('0x2c')]);}return _0x5114a9[_0x88f7('0x55')](_0x184968);}})[_0x88f7('0x1f')](function(_0x93a9d6){if(_0x93a9d6){return _0x93a9d6?{'count':_0x11a5fb,'rows':_0x93a9d6}:null;}})[_0x88f7('0x1f')](respondWithResult(_0x1163e1,null))[_0x88f7('0x4e')](handleError(_0x1163e1,null));};exports[_0x88f7('0x58')]=function(_0x154807,_0x128e88,_0x58cf8b){if(_0x154807[_0x88f7('0x52')]['id']){delete _0x154807['body']['id'];}return db[_0x88f7('0x37')][_0x88f7('0x59')]({'where':{'id':_0x154807[_0x88f7('0x50')]['id']}})['then'](handleEntityNotFound(_0x128e88,null))[_0x88f7('0x1f')](function(_0x3ef059){if(_0x3ef059){_0x154807[_0x88f7('0x52')]['AccountId']=_0x3ef059['id'];_0x154807['body'][_0x88f7('0x5a')]=integrations[_0x88f7('0x5b')](_0x154807['body'][_0x88f7('0x5c')],_0x154807[_0x88f7('0x52')][_0x88f7('0x3a')]);_0x154807[_0x88f7('0x52')][_0x88f7('0x5d')]=integrations[_0x88f7('0x5e')](_0x154807[_0x88f7('0x52')][_0x88f7('0x5c')],_0x154807[_0x88f7('0x52')][_0x88f7('0x3a')]);return db['FreshdeskConfiguration'][_0x88f7('0x51')](_0x154807[_0x88f7('0x52')],{'include':[{'model':db[_0x88f7('0x5f')],'as':_0x88f7('0x5a')},{'model':db[_0x88f7('0x5f')],'as':'Descriptions'}]});}return null;})[_0x88f7('0x1f')](respondWithResult(_0x128e88,null))[_0x88f7('0x4e')](handleError(_0x128e88,null));};exports['getFields']=function(_0x565a88,_0x4f5266,_0xf90a73){var _0x4fa87c='';return db[_0x88f7('0x37')][_0x88f7('0x59')]({'where':{'id':_0x565a88[_0x88f7('0x50')]['id']},'attributes':['id',_0x88f7('0x60'),_0x88f7('0x61')]})[_0x88f7('0x1f')](handleEntityNotFound(_0x4f5266,null))[_0x88f7('0x1f')](function(_0x29650b){if(_0x29650b){_0x4fa87c=_0x29650b['remoteUri'];var _0x3fd399=_0x4fa87c['slice'](-0x1);if(_0x3fd399==='/'){_0x4fa87c=_0x4fa87c[_0x88f7('0x62')](0x0,_0x4fa87c[_0x88f7('0x63')](_0x3fd399));}return rp({'method':_0x88f7('0x64'),'uri':util[_0x88f7('0x65')](_0x88f7('0x66'),_0x4fa87c,_0x88f7('0x67')),'headers':{'Authorization':util[_0x88f7('0x65')](_0x88f7('0x68'),new Buffer(util['format'](_0x88f7('0x69'),_0x29650b[_0x88f7('0x61')]))[_0x88f7('0x6a')]('base64'))},'json':!![]});}})[_0x88f7('0x1f')](function(_0x2b0a08){if(_0x2b0a08){var _0x842c20=[_0x88f7('0x6b'),_0x88f7('0x6c'),_0x88f7('0x6d'),_0x88f7('0x6e'),'status',_0x88f7('0x6f'),_0x88f7('0x70'),_0x88f7('0x71'),_0x88f7('0x72'),_0x88f7('0x70'),_0x88f7('0x73')];_['remove'](_0x2b0a08,function(_0x303a03){return _0x842c20[_0x88f7('0x74')](_0x303a03[_0x88f7('0x34')])||!_0x303a03['default']&&_0x303a03['type']!==_0x88f7('0x75')&&_0x303a03[_0x88f7('0x3a')]!=='custom_dropdown';});return{'count':_0x2b0a08[_0x88f7('0x43')],'rows':_[_0x88f7('0x36')](_0x2b0a08,function(_0x5126d7){return{'id':_0x5126d7[_0x88f7('0x34')],'name':_0x5126d7[_0x88f7('0x76')],'custom':!_0x5126d7[_0x88f7('0x77')],'options':_0x5126d7[_0x88f7('0x78')]?_[_0x88f7('0x36')](_0x5126d7[_0x88f7('0x78')],function(_0x318b95){return{'name':_[_0x88f7('0x79')](_0x318b95),'value':_0x318b95};}):[]};})};}})[_0x88f7('0x1f')](respondWithResult(_0x4f5266,null))[_0x88f7('0x4e')](function(_0x38b51c){var _0x2f5300=_0x565a88[_0x88f7('0x3e')]['test']?0x1f4:_0x38b51c[_0x88f7('0x7a')]||0x1f4;logger[_0x88f7('0x25')](_0x88f7('0x7b'),_0x88f7('0x7c'),_0x2f5300,JSON[_0x88f7('0x24')](_0x38b51c));delete _0x38b51c['name'];if(_0x2f5300===0x191){_0x2f5300=0x190;}_0x4f5266[_0x88f7('0x28')](_0x2f5300)[_0x88f7('0x7d')](_0x565a88[_0x88f7('0x3e')][_0x88f7('0x1b')]?{'message':_0x88f7('0x7e'),'statusCode':_0x38b51c[_0x88f7('0x7a')]}:_0x38b51c);});};
\ No newline at end of file
+var _0xd5b6=['bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','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','status','end','json','offset','count','set','Content-Range','apply','reject','save','update','then','sendStatus','error','stack','name','map','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','limit','order','sort','where','pick','merge','VIRTUAL','filter','options','FreshdeskAccount','includeAll','include','findAll','rows','catch','params','keys','find','create','body','destroy','getConfigurations','findOne','FreshdeskConfiguration','rawAttributes','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','FreshdeskField','Descriptions','getFields','remoteUri','apiKey','slice','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','toString','base64','requester','agent','description','priority','group','source','ticket_type','company','remove','includes','default','custom_dropdown','label','choices','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment'];(function(_0x5cb97e,_0x132a39){var _0x1714b4=function(_0x384210){while(--_0x384210){_0x5cb97e['push'](_0x5cb97e['shift']());}};_0x1714b4(++_0x132a39);}(_0xd5b6,0x73));var _0x6d5b=function(_0x306803,_0x34a407){_0x306803=_0x306803-0x0;var _0x111228=_0xd5b6[_0x306803];return _0x111228;};'use strict';var emlformat=require(_0x6d5b('0x0'));var rimraf=require(_0x6d5b('0x1'));var zipdir=require(_0x6d5b('0x2'));var jsonpatch=require(_0x6d5b('0x3'));var rp=require(_0x6d5b('0x4'));var moment=require(_0x6d5b('0x5'));var BPromise=require(_0x6d5b('0x6'));var Mustache=require(_0x6d5b('0x7'));var util=require('util');var path=require(_0x6d5b('0x8'));var sox=require(_0x6d5b('0x9'));var csv=require(_0x6d5b('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6d5b('0xb'));var _=require(_0x6d5b('0xc'));var squel=require(_0x6d5b('0xd'));var crypto=require(_0x6d5b('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x6d5b('0xa'));var querystring=require(_0x6d5b('0xf'));var Papa=require(_0x6d5b('0x10'));var Redis=require(_0x6d5b('0x11'));var authService=require(_0x6d5b('0x12'));var qs=require(_0x6d5b('0x13'));var as=require(_0x6d5b('0x14'));var hardwareService=require(_0x6d5b('0x15'));var logger=require(_0x6d5b('0x16'))(_0x6d5b('0x17'));var utils=require(_0x6d5b('0x18'));var config=require(_0x6d5b('0x19'));var licenseUtil=require(_0x6d5b('0x1a'));var db=require(_0x6d5b('0x1b'))['db'];var integrations=require(_0x6d5b('0x1c'));function respondWithStatusCode(_0x1e3c2b,_0x3c09bb){_0x3c09bb=_0x3c09bb||0xcc;return function(_0x132fe2){if(_0x132fe2){return _0x1e3c2b['sendStatus'](_0x3c09bb);}return _0x1e3c2b[_0x6d5b('0x1d')](_0x3c09bb)[_0x6d5b('0x1e')]();};}function respondWithResult(_0xe6fa49,_0x3a4ca5){_0x3a4ca5=_0x3a4ca5||0xc8;return function(_0x12b0dc){if(_0x12b0dc){return _0xe6fa49['status'](_0x3a4ca5)[_0x6d5b('0x1f')](_0x12b0dc);}};}function respondWithFilteredResult(_0x1e6814,_0x51eb25){return function(_0x2baf47){if(_0x2baf47){var _0x5debab=typeof _0x51eb25[_0x6d5b('0x20')]==='undefined'&&typeof _0x51eb25['limit']==='undefined';var _0x12bc62=_0x2baf47[_0x6d5b('0x21')];var _0x448cc3=_0x5debab?0x0:_0x51eb25['offset'];var _0xb12444=_0x5debab?_0x2baf47[_0x6d5b('0x21')]:_0x51eb25[_0x6d5b('0x20')]+_0x51eb25['limit'];var _0x407f2f;if(_0xb12444>=_0x12bc62){_0xb12444=_0x12bc62;_0x407f2f=0xc8;}else{_0x407f2f=0xce;}_0x1e6814['status'](_0x407f2f);return _0x1e6814[_0x6d5b('0x22')](_0x6d5b('0x23'),_0x448cc3+'-'+_0xb12444+'/'+_0x12bc62)[_0x6d5b('0x1f')](_0x2baf47);}return null;};}function patchUpdates(_0x4b67ca){return function(_0x885c41){try{jsonpatch[_0x6d5b('0x24')](_0x885c41,_0x4b67ca,!![]);}catch(_0xf59341){return BPromise[_0x6d5b('0x25')](_0xf59341);}return _0x885c41[_0x6d5b('0x26')]();};}function saveUpdates(_0x36d8da,_0x19148d){return function(_0x186631){if(_0x186631){return _0x186631[_0x6d5b('0x27')](_0x36d8da)[_0x6d5b('0x28')](function(_0x1b5261){return _0x1b5261;});}return null;};}function removeEntity(_0xc1087e,_0x2e3192){return function(_0xc0d36c){if(_0xc0d36c){return _0xc0d36c['destroy']()[_0x6d5b('0x28')](function(){_0xc1087e['status'](0xcc)[_0x6d5b('0x1e')]();});}};}function handleEntityNotFound(_0x6a398a,_0x322c57){return function(_0x127e27){if(!_0x127e27){_0x6a398a[_0x6d5b('0x29')](0x194);}return _0x127e27;};}function handleError(_0x161c12,_0x1be755){_0x1be755=_0x1be755||0x1f4;return function(_0x33ae72){logger[_0x6d5b('0x2a')](_0x33ae72[_0x6d5b('0x2b')]);if(_0x33ae72[_0x6d5b('0x2c')]){delete _0x33ae72[_0x6d5b('0x2c')];}_0x161c12[_0x6d5b('0x1d')](_0x1be755)['send'](_0x33ae72);};}exports['index']=function(_0x5a9f13,_0x32c57b){var _0x1acc3a={},_0x2d0da5={},_0x4c9875={'count':0x0,'rows':[]};var _0x27151a=_[_0x6d5b('0x2d')](db['FreshdeskAccount']['rawAttributes'],function(_0x4fce9f){return{'name':_0x4fce9f[_0x6d5b('0x2e')],'type':_0x4fce9f[_0x6d5b('0x2f')][_0x6d5b('0x30')]};});_0x2d0da5[_0x6d5b('0x31')]=_['map'](_0x27151a,'name');_0x2d0da5[_0x6d5b('0x32')]=_['keys'](_0x5a9f13[_0x6d5b('0x32')]);_0x2d0da5[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x2d0da5[_0x6d5b('0x31')],_0x2d0da5[_0x6d5b('0x32')]);_0x1acc3a[_0x6d5b('0x35')]=_[_0x6d5b('0x34')](_0x2d0da5[_0x6d5b('0x31')],qs['fields'](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x36')]));_0x1acc3a[_0x6d5b('0x35')]=_0x1acc3a[_0x6d5b('0x35')][_0x6d5b('0x37')]?_0x1acc3a[_0x6d5b('0x35')]:_0x2d0da5[_0x6d5b('0x31')];if(!_0x5a9f13[_0x6d5b('0x32')]['hasOwnProperty'](_0x6d5b('0x38'))){_0x1acc3a[_0x6d5b('0x39')]=qs[_0x6d5b('0x39')](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x39')]);_0x1acc3a[_0x6d5b('0x20')]=qs['offset'](_0x5a9f13['query'][_0x6d5b('0x20')]);}_0x1acc3a[_0x6d5b('0x3a')]=qs[_0x6d5b('0x3b')](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x3b')]);_0x1acc3a[_0x6d5b('0x3c')]=qs[_0x6d5b('0x33')](_[_0x6d5b('0x3d')](_0x5a9f13[_0x6d5b('0x32')],_0x2d0da5[_0x6d5b('0x33')]),_0x27151a);if(_0x5a9f13[_0x6d5b('0x32')]['filter']){_0x1acc3a['where']=_[_0x6d5b('0x3e')](_0x1acc3a[_0x6d5b('0x3c')],{'$or':_[_0x6d5b('0x2d')](_0x27151a,function(_0x2bd66d){if(_0x2bd66d['type']!==_0x6d5b('0x3f')){var _0xc55711={};_0xc55711[_0x2bd66d[_0x6d5b('0x2c')]]={'$like':'%'+_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x40')]+'%'};return _0xc55711;}})});}_0x1acc3a=_[_0x6d5b('0x3e')]({},_0x1acc3a,_0x5a9f13[_0x6d5b('0x41')]);var _0x1e989d={'where':_0x1acc3a[_0x6d5b('0x3c')]};return db[_0x6d5b('0x42')][_0x6d5b('0x21')](_0x1e989d)[_0x6d5b('0x28')](function(_0x192d14){_0x4c9875['count']=_0x192d14;if(_0x5a9f13['query'][_0x6d5b('0x43')]){_0x1acc3a[_0x6d5b('0x44')]=[{'all':!![]}];}return db[_0x6d5b('0x42')][_0x6d5b('0x45')](_0x1acc3a);})[_0x6d5b('0x28')](function(_0x40b7e7){_0x4c9875[_0x6d5b('0x46')]=_0x40b7e7;return _0x4c9875;})[_0x6d5b('0x28')](respondWithFilteredResult(_0x32c57b,_0x1acc3a))[_0x6d5b('0x47')](handleError(_0x32c57b,null));};exports['show']=function(_0x452d5b,_0x594733){var _0x10fc3c={'raw':![],'where':{'id':_0x452d5b[_0x6d5b('0x48')]['id']}},_0x51b9f9={};_0x51b9f9[_0x6d5b('0x31')]=_[_0x6d5b('0x49')](db['FreshdeskAccount']['rawAttributes']);_0x51b9f9[_0x6d5b('0x32')]=_['keys'](_0x452d5b[_0x6d5b('0x32')]);_0x51b9f9[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x51b9f9['model'],_0x51b9f9[_0x6d5b('0x32')]);_0x10fc3c['attributes']=_[_0x6d5b('0x34')](_0x51b9f9[_0x6d5b('0x31')],qs[_0x6d5b('0x36')](_0x452d5b['query']['fields']));_0x10fc3c['attributes']=_0x10fc3c['attributes']['length']?_0x10fc3c[_0x6d5b('0x35')]:_0x51b9f9[_0x6d5b('0x31')];if(_0x452d5b['query'][_0x6d5b('0x43')]){_0x10fc3c[_0x6d5b('0x44')]=[{'all':!![]}];}_0x10fc3c=_[_0x6d5b('0x3e')]({},_0x10fc3c,_0x452d5b[_0x6d5b('0x41')]);return db[_0x6d5b('0x42')][_0x6d5b('0x4a')](_0x10fc3c)[_0x6d5b('0x28')](handleEntityNotFound(_0x594733,null))[_0x6d5b('0x28')](respondWithResult(_0x594733,null))[_0x6d5b('0x47')](handleError(_0x594733,null));};exports['create']=function(_0xa031cc,_0x405621){return db[_0x6d5b('0x42')][_0x6d5b('0x4b')](_0xa031cc[_0x6d5b('0x4c')],{})[_0x6d5b('0x28')](respondWithResult(_0x405621,0xc9))[_0x6d5b('0x47')](handleError(_0x405621,null));};exports[_0x6d5b('0x27')]=function(_0x72479c,_0x3dd4fc){if(_0x72479c[_0x6d5b('0x4c')]['id']){delete _0x72479c['body']['id'];}return db['FreshdeskAccount'][_0x6d5b('0x4a')]({'where':{'id':_0x72479c[_0x6d5b('0x48')]['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x3dd4fc,null))[_0x6d5b('0x28')](saveUpdates(_0x72479c[_0x6d5b('0x4c')],null))[_0x6d5b('0x28')](respondWithResult(_0x3dd4fc,null))[_0x6d5b('0x47')](handleError(_0x3dd4fc,null));};exports[_0x6d5b('0x4d')]=function(_0x2a5fb3,_0x36569a){return db[_0x6d5b('0x42')][_0x6d5b('0x4a')]({'where':{'id':_0x2a5fb3['params']['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x36569a,null))[_0x6d5b('0x28')](removeEntity(_0x36569a,null))['catch'](handleError(_0x36569a,null));};exports[_0x6d5b('0x4e')]=function(_0x523f0e,_0x260499,_0x58bf66){var _0x3a474f={};var _0x25d530={};var _0x5697f9;var _0x29544f;return db['FreshdeskAccount'][_0x6d5b('0x4f')]({'where':{'id':_0x523f0e[_0x6d5b('0x48')]['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x260499,null))[_0x6d5b('0x28')](function(_0x1a52de){if(_0x1a52de){_0x5697f9=_0x1a52de;_0x25d530['model']=_[_0x6d5b('0x49')](db[_0x6d5b('0x50')][_0x6d5b('0x51')]);_0x25d530[_0x6d5b('0x32')]=_[_0x6d5b('0x49')](_0x523f0e[_0x6d5b('0x32')]);_0x25d530[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x25d530[_0x6d5b('0x31')],_0x25d530['query']);_0x3a474f[_0x6d5b('0x35')]=_[_0x6d5b('0x34')](_0x25d530[_0x6d5b('0x31')],qs['fields'](_0x523f0e['query'][_0x6d5b('0x36')]));_0x3a474f[_0x6d5b('0x35')]=_0x3a474f[_0x6d5b('0x35')][_0x6d5b('0x37')]?_0x3a474f['attributes']:_0x25d530['model'];_0x3a474f['order']=qs['sort'](_0x523f0e[_0x6d5b('0x32')][_0x6d5b('0x3b')]);_0x3a474f[_0x6d5b('0x3c')]=qs[_0x6d5b('0x33')](_['pick'](_0x523f0e[_0x6d5b('0x32')],_0x25d530[_0x6d5b('0x33')]));if(_0x523f0e[_0x6d5b('0x32')]['filter']){_0x3a474f['where']=_[_0x6d5b('0x3e')](_0x3a474f[_0x6d5b('0x3c')],{'$or':_[_0x6d5b('0x2d')](_0x3a474f[_0x6d5b('0x35')],function(_0x3e22be){var _0x53ee51={};_0x53ee51[_0x3e22be]={'$like':'%'+_0x523f0e[_0x6d5b('0x32')][_0x6d5b('0x40')]+'%'};return _0x53ee51;})});}_0x3a474f=_[_0x6d5b('0x3e')]({},_0x3a474f,_0x523f0e[_0x6d5b('0x41')]);return _0x5697f9[_0x6d5b('0x4e')](_0x3a474f);}})['then'](function(_0x119105){if(_0x119105){_0x29544f=_0x119105['length'];if(!_0x523f0e[_0x6d5b('0x32')]['hasOwnProperty'](_0x6d5b('0x38'))){_0x3a474f[_0x6d5b('0x39')]=qs[_0x6d5b('0x39')](_0x523f0e['query'][_0x6d5b('0x39')]);_0x3a474f['offset']=qs[_0x6d5b('0x20')](_0x523f0e[_0x6d5b('0x32')]['offset']);}return _0x5697f9[_0x6d5b('0x4e')](_0x3a474f);}})['then'](function(_0x519a55){if(_0x519a55){return _0x519a55?{'count':_0x29544f,'rows':_0x519a55}:null;}})[_0x6d5b('0x28')](respondWithResult(_0x260499,null))['catch'](handleError(_0x260499,null));};exports[_0x6d5b('0x52')]=function(_0x1fddb4,_0x2fc45c,_0x2ac5a1){if(_0x1fddb4['body']['id']){delete _0x1fddb4[_0x6d5b('0x4c')]['id'];}return db[_0x6d5b('0x42')][_0x6d5b('0x4f')]({'where':{'id':_0x1fddb4['params']['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x2fc45c,null))[_0x6d5b('0x28')](function(_0x5195c8){if(_0x5195c8){_0x1fddb4['body'][_0x6d5b('0x53')]=_0x5195c8['id'];_0x1fddb4['body'][_0x6d5b('0x54')]=integrations[_0x6d5b('0x55')](_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x56')],_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x2f')]);_0x1fddb4[_0x6d5b('0x4c')]['Descriptions']=integrations[_0x6d5b('0x57')](_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x56')],_0x1fddb4['body']['type']);return db['FreshdeskConfiguration'][_0x6d5b('0x4b')](_0x1fddb4[_0x6d5b('0x4c')],{'include':[{'model':db[_0x6d5b('0x58')],'as':_0x6d5b('0x54')},{'model':db['FreshdeskField'],'as':_0x6d5b('0x59')}]});}return null;})[_0x6d5b('0x28')](respondWithResult(_0x2fc45c,null))['catch'](handleError(_0x2fc45c,null));};exports[_0x6d5b('0x5a')]=function(_0x518e56,_0xfc32cb,_0x2fb18e){var _0x49f05e='';return db[_0x6d5b('0x42')][_0x6d5b('0x4f')]({'where':{'id':_0x518e56[_0x6d5b('0x48')]['id']},'attributes':['id',_0x6d5b('0x5b'),_0x6d5b('0x5c')]})[_0x6d5b('0x28')](handleEntityNotFound(_0xfc32cb,null))[_0x6d5b('0x28')](function(_0x4b5b1e){if(_0x4b5b1e){_0x49f05e=_0x4b5b1e[_0x6d5b('0x5b')];var _0xade321=_0x49f05e[_0x6d5b('0x5d')](-0x1);if(_0xade321==='/'){_0x49f05e=_0x49f05e['substring'](0x0,_0x49f05e[_0x6d5b('0x5e')](_0xade321));}return rp({'method':_0x6d5b('0x5f'),'uri':util[_0x6d5b('0x60')](_0x6d5b('0x61'),_0x49f05e,_0x6d5b('0x62')),'headers':{'Authorization':util['format'](_0x6d5b('0x63'),new Buffer(util[_0x6d5b('0x60')]('%s:X',_0x4b5b1e[_0x6d5b('0x5c')]))[_0x6d5b('0x64')](_0x6d5b('0x65')))},'json':!![]});}})['then'](function(_0x39b75b){if(_0x39b75b){var _0x188cfa=[_0x6d5b('0x66'),'subject',_0x6d5b('0x67'),_0x6d5b('0x68'),_0x6d5b('0x1d'),_0x6d5b('0x69'),_0x6d5b('0x6a'),_0x6d5b('0x6b'),_0x6d5b('0x6c'),'group',_0x6d5b('0x6d')];_[_0x6d5b('0x6e')](_0x39b75b,function(_0x3ec508){return _0x188cfa[_0x6d5b('0x6f')](_0x3ec508[_0x6d5b('0x2c')])||!_0x3ec508[_0x6d5b('0x70')]&&_0x3ec508['type']!=='custom_text'&&_0x3ec508[_0x6d5b('0x2f')]!==_0x6d5b('0x71');});return{'count':_0x39b75b['length'],'rows':_[_0x6d5b('0x2d')](_0x39b75b,function(_0x30c98a){return{'id':_0x30c98a[_0x6d5b('0x2c')],'name':_0x30c98a[_0x6d5b('0x72')],'custom':!_0x30c98a['default'],'options':_0x30c98a[_0x6d5b('0x73')]?_[_0x6d5b('0x2d')](_0x30c98a[_0x6d5b('0x73')],function(_0x25352f){return{'name':_['capitalize'](_0x25352f),'value':_0x25352f};}):[]};})};}})[_0x6d5b('0x28')](respondWithResult(_0xfc32cb,null))['catch'](function(_0x124300){var _0x585588=_0x518e56[_0x6d5b('0x32')][_0x6d5b('0x74')]?0x1f4:_0x124300[_0x6d5b('0x75')]||0x1f4;logger[_0x6d5b('0x2a')](_0x6d5b('0x76'),_0x6d5b('0x5a'),_0x585588,JSON[_0x6d5b('0x77')](_0x124300));delete _0x124300['name'];if(_0x585588===0x191){_0x585588=0x190;}_0xfc32cb['status'](_0x585588)['send'](_0x518e56[_0x6d5b('0x32')][_0x6d5b('0x74')]?{'message':_0x6d5b('0x78'),'statusCode':_0x124300['statusCode']}:_0x124300);});};
\ No newline at end of file