Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 2b6bdcb..adde065 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 _0x6fb3=['getFields','stringify','send','Wrong\x20credentials','html-pdf','rimraf','fast-json-patch','request-promise','moment','mustache','path','ejs','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','FreshdeskAccount,\x20%s,\x20%s','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','sendStatus','status','json','offset','set','save','then','end','stack','name','index','map','FreshdeskAccount','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','options','count','includeAll','include','rows','create','body','update','destroy','find','params','getConfigurations','findOne','FreshdeskConfiguration','AccountId','Subjects','getDescriptions','channel','FreshdeskField','Descriptions','remoteUri','apiKey','substring','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','%s:X','toString','requester','agent','description','priority','group','source','ticket_type','company','remove','includes','default','custom_text','custom_dropdown','choices','capitalize','test','statusCode'];(function(_0x1d38fc,_0x27cd20){var _0x1a260c=function(_0x3f31ab){while(--_0x3f31ab){_0x1d38fc['push'](_0x1d38fc['shift']());}};_0x1a260c(++_0x27cd20);}(_0x6fb3,0x7e));var _0x36fb=function(_0x23baed,_0x2554a1){_0x23baed=_0x23baed-0x0;var _0x36faa7=_0x6fb3[_0x23baed];return _0x36faa7;};'use strict';var pdf=require(_0x36fb('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x36fb('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x36fb('0x2'));var rp=require(_0x36fb('0x3'));var moment=require(_0x36fb('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x36fb('0x5'));var util=require('util');var path=require(_0x36fb('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x36fb('0x7'));var fs=require('fs');var _=require(_0x36fb('0x8'));var squel=require('squel');var crypto=require(_0x36fb('0x9'));var jsforce=require(_0x36fb('0xa'));var deskjs=require(_0x36fb('0xb'));var toCsv=require(_0x36fb('0xc'));var querystring=require(_0x36fb('0xd'));var Papa=require(_0x36fb('0xe'));var Redis=require(_0x36fb('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x36fb('0x10'));var as=require(_0x36fb('0x11'));var hardwareService=require(_0x36fb('0x12'));var logger=require(_0x36fb('0x13'))(_0x36fb('0x14'));var utils=require('../../config/utils');var config=require(_0x36fb('0x15'));var licenseUtil=require(_0x36fb('0x16'));var db=require(_0x36fb('0x17'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0x36fb('0x18'));var client=jayson[_0x36fb('0x19')][_0x36fb('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x12dc4a,_0x33a15b,_0x521510,_0x272faa){return new BPromise(function(_0x10e608,_0x499f04){var _0x24f8ef=_0x272faa||client;return _0x24f8ef[_0x36fb('0x1b')](_0x12dc4a,_0x521510)['then'](function(_0x120e9f){logger[_0x36fb('0x1c')](_0x36fb('0x1d'),_0x33a15b,'request\x20sent');logger[_0x36fb('0x1e')](_0x36fb('0x1f'),_0x33a15b,_0x36fb('0x20'),JSON['stringify'](_0x120e9f));if(_0x120e9f[_0x36fb('0x21')]){if(_0x120e9f[_0x36fb('0x21')][_0x36fb('0x22')]===0x1f4){logger[_0x36fb('0x21')](_0x36fb('0x1d'),_0x33a15b,_0x120e9f[_0x36fb('0x21')]['message']);return _0x499f04(_0x120e9f[_0x36fb('0x21')]['message']);}logger[_0x36fb('0x21')](_0x36fb('0x1d'),_0x33a15b,_0x120e9f[_0x36fb('0x21')]['message']);return _0x10e608(_0x120e9f[_0x36fb('0x21')][_0x36fb('0x23')]);}else{logger[_0x36fb('0x1c')]('FreshdeskAccount,\x20%s,\x20%s',_0x33a15b,_0x36fb('0x20'));_0x10e608(_0x120e9f[_0x36fb('0x24')][_0x36fb('0x23')]);}})[_0x36fb('0x25')](function(_0x299f88){logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x33a15b,_0x299f88);_0x499f04(_0x299f88);});});}function respondWithStatusCode(_0x305435,_0x250892){_0x250892=_0x250892||0xcc;return function(_0x29eb09){if(_0x29eb09){return _0x305435[_0x36fb('0x26')](_0x250892);}return _0x305435[_0x36fb('0x27')](_0x250892)['end']();};}function respondWithResult(_0x361c38,_0xf0deb7){_0xf0deb7=_0xf0deb7||0xc8;return function(_0x5e33c8){if(_0x5e33c8){return _0x361c38[_0x36fb('0x27')](_0xf0deb7)[_0x36fb('0x28')](_0x5e33c8);}};}function respondWithFilteredResult(_0x4ed231,_0x84d50b){return function(_0x2065cc){if(_0x2065cc){var _0x589c4e=_0x2065cc['count'],_0xff37d=_0x84d50b[_0x36fb('0x29')],_0x27f716=_0x84d50b[_0x36fb('0x29')]+_0x84d50b['limit'],_0x4810af;if(_0x27f716>=_0x589c4e){_0x27f716=_0x589c4e;_0x4810af=0xc8;}else{_0x4810af=0xce;}_0x4ed231[_0x36fb('0x27')](_0x4810af);return _0x4ed231[_0x36fb('0x2a')]('Content-Range',_0xff37d+'-'+_0x27f716+'/'+_0x589c4e)[_0x36fb('0x28')](_0x2065cc);}return null;};}function patchUpdates(_0x4cb6a3){return function(_0x3b5c37){try{jsonpatch['apply'](_0x3b5c37,_0x4cb6a3,!![]);}catch(_0x39aed7){return BPromise['reject'](_0x39aed7);}return _0x3b5c37[_0x36fb('0x2b')]();};}function saveUpdates(_0x1dffeb,_0x4f88a4){return function(_0x15a154){if(_0x15a154){return _0x15a154['update'](_0x1dffeb)[_0x36fb('0x2c')](function(_0x4f02f5){return _0x4f02f5;});}return null;};}function removeEntity(_0x4c5943,_0x19f2f3){return function(_0x41e663){if(_0x41e663){return _0x41e663['destroy']()[_0x36fb('0x2c')](function(){_0x4c5943[_0x36fb('0x27')](0xcc)[_0x36fb('0x2d')]();});}};}function handleEntityNotFound(_0x2335df,_0x2bb22f){return function(_0x109cd6){if(!_0x109cd6){_0x2335df['sendStatus'](0x194);}return _0x109cd6;};}function handleError(_0x384742,_0x4e7736){_0x4e7736=_0x4e7736||0x1f4;return function(_0x5dc30d){logger[_0x36fb('0x21')](_0x5dc30d[_0x36fb('0x2e')]);if(_0x5dc30d[_0x36fb('0x2f')]){delete _0x5dc30d[_0x36fb('0x2f')];}_0x384742[_0x36fb('0x27')](_0x4e7736)['send'](_0x5dc30d);};}exports[_0x36fb('0x30')]=function(_0x4ebbd1,_0x3247aa){var _0x471e65={},_0x2129c3={},_0xd1c24a={'count':0x0,'rows':[]};var _0x132fdb=_[_0x36fb('0x31')](db[_0x36fb('0x32')]['rawAttributes'],function(_0x4fcb66){return{'name':_0x4fcb66['fieldName'],'type':_0x4fcb66[_0x36fb('0x33')][_0x36fb('0x34')]};});_0x2129c3[_0x36fb('0x35')]=_['map'](_0x132fdb,_0x36fb('0x2f'));_0x2129c3[_0x36fb('0x36')]=_[_0x36fb('0x37')](_0x4ebbd1[_0x36fb('0x36')]);_0x2129c3[_0x36fb('0x38')]=_[_0x36fb('0x39')](_0x2129c3[_0x36fb('0x35')],_0x2129c3[_0x36fb('0x36')]);_0x471e65[_0x36fb('0x3a')]=_[_0x36fb('0x39')](_0x2129c3[_0x36fb('0x35')],qs[_0x36fb('0x3b')](_0x4ebbd1[_0x36fb('0x36')][_0x36fb('0x3b')]));_0x471e65[_0x36fb('0x3a')]=_0x471e65[_0x36fb('0x3a')][_0x36fb('0x3c')]?_0x471e65[_0x36fb('0x3a')]:_0x2129c3[_0x36fb('0x35')];if(!_0x4ebbd1[_0x36fb('0x36')][_0x36fb('0x3d')](_0x36fb('0x3e'))){_0x471e65[_0x36fb('0x3f')]=qs[_0x36fb('0x3f')](_0x4ebbd1['query'][_0x36fb('0x3f')]);_0x471e65[_0x36fb('0x29')]=qs[_0x36fb('0x29')](_0x4ebbd1[_0x36fb('0x36')][_0x36fb('0x29')]);}_0x471e65[_0x36fb('0x40')]=qs[_0x36fb('0x41')](_0x4ebbd1[_0x36fb('0x36')]['sort']);_0x471e65[_0x36fb('0x42')]=qs[_0x36fb('0x38')](_[_0x36fb('0x43')](_0x4ebbd1['query'],_0x2129c3['filters']),_0x132fdb);if(_0x4ebbd1[_0x36fb('0x36')]['filter']){_0x471e65['where']=_['merge'](_0x471e65[_0x36fb('0x42')],{'$or':_[_0x36fb('0x31')](_0x132fdb,function(_0xc9f014){if(_0xc9f014['type']!=='VIRTUAL'){var _0x513b79={};_0x513b79[_0xc9f014[_0x36fb('0x2f')]]={'$like':'%'+_0x4ebbd1[_0x36fb('0x36')][_0x36fb('0x44')]+'%'};return _0x513b79;}})});}_0x471e65=_[_0x36fb('0x45')]({},_0x471e65,_0x4ebbd1[_0x36fb('0x46')]);var _0x513fec={'where':_0x471e65[_0x36fb('0x42')]};return db[_0x36fb('0x32')][_0x36fb('0x47')](_0x513fec)[_0x36fb('0x2c')](function(_0x5d925e){_0xd1c24a[_0x36fb('0x47')]=_0x5d925e;if(_0x4ebbd1[_0x36fb('0x36')][_0x36fb('0x48')]){_0x471e65[_0x36fb('0x49')]=[{'all':!![]}];}return db[_0x36fb('0x32')]['findAll'](_0x471e65);})['then'](function(_0x54a048){_0xd1c24a[_0x36fb('0x4a')]=_0x54a048;return _0xd1c24a;})[_0x36fb('0x2c')](respondWithFilteredResult(_0x3247aa,_0x471e65))[_0x36fb('0x25')](handleError(_0x3247aa,null));};exports['show']=function(_0x2cee6d,_0x21353f){var _0x5bac46={'raw':![],'where':{'id':_0x2cee6d['params']['id']}},_0xf4a2aa={};_0xf4a2aa[_0x36fb('0x35')]=_['keys'](db[_0x36fb('0x32')]['rawAttributes']);_0xf4a2aa['query']=_[_0x36fb('0x37')](_0x2cee6d['query']);_0xf4a2aa[_0x36fb('0x38')]=_[_0x36fb('0x39')](_0xf4a2aa[_0x36fb('0x35')],_0xf4a2aa[_0x36fb('0x36')]);_0x5bac46['attributes']=_['intersection'](_0xf4a2aa[_0x36fb('0x35')],qs[_0x36fb('0x3b')](_0x2cee6d['query'][_0x36fb('0x3b')]));_0x5bac46[_0x36fb('0x3a')]=_0x5bac46[_0x36fb('0x3a')][_0x36fb('0x3c')]?_0x5bac46['attributes']:_0xf4a2aa[_0x36fb('0x35')];if(_0x2cee6d[_0x36fb('0x36')][_0x36fb('0x48')]){_0x5bac46[_0x36fb('0x49')]=[{'all':!![]}];}_0x5bac46=_[_0x36fb('0x45')]({},_0x5bac46,_0x2cee6d['options']);return db['FreshdeskAccount']['find'](_0x5bac46)['then'](handleEntityNotFound(_0x21353f,null))[_0x36fb('0x2c')](respondWithResult(_0x21353f,null))[_0x36fb('0x25')](handleError(_0x21353f,null));};exports['create']=function(_0x42c920,_0x3d2fbb){return db[_0x36fb('0x32')][_0x36fb('0x4b')](_0x42c920[_0x36fb('0x4c')],{})['then'](respondWithResult(_0x3d2fbb,0xc9))['catch'](handleError(_0x3d2fbb,null));};exports[_0x36fb('0x4d')]=function(_0x302ad3,_0x5a5b75){if(_0x302ad3[_0x36fb('0x4c')]['id']){delete _0x302ad3[_0x36fb('0x4c')]['id'];}return db[_0x36fb('0x32')]['find']({'where':{'id':_0x302ad3['params']['id']}})[_0x36fb('0x2c')](handleEntityNotFound(_0x5a5b75,null))['then'](saveUpdates(_0x302ad3[_0x36fb('0x4c')],null))['then'](respondWithResult(_0x5a5b75,null))['catch'](handleError(_0x5a5b75,null));};exports[_0x36fb('0x4e')]=function(_0x235580,_0x10c7a9){return db[_0x36fb('0x32')][_0x36fb('0x4f')]({'where':{'id':_0x235580[_0x36fb('0x50')]['id']}})['then'](handleEntityNotFound(_0x10c7a9,null))[_0x36fb('0x2c')](removeEntity(_0x10c7a9,null))[_0x36fb('0x25')](handleError(_0x10c7a9,null));};exports[_0x36fb('0x51')]=function(_0x4bcfc3,_0x4095e9,_0x400da4){var _0x32a086={};var _0x2d91ad={};var _0x8d2608;var _0x32042a;return db[_0x36fb('0x32')][_0x36fb('0x52')]({'where':{'id':_0x4bcfc3[_0x36fb('0x50')]['id']}})['then'](handleEntityNotFound(_0x4095e9,null))[_0x36fb('0x2c')](function(_0x2d5b27){if(_0x2d5b27){_0x8d2608=_0x2d5b27;_0x2d91ad['model']=_[_0x36fb('0x37')](db[_0x36fb('0x53')]['rawAttributes']);_0x2d91ad[_0x36fb('0x36')]=_['keys'](_0x4bcfc3['query']);_0x2d91ad[_0x36fb('0x38')]=_[_0x36fb('0x39')](_0x2d91ad[_0x36fb('0x35')],_0x2d91ad[_0x36fb('0x36')]);_0x32a086[_0x36fb('0x3a')]=_['intersection'](_0x2d91ad[_0x36fb('0x35')],qs['fields'](_0x4bcfc3[_0x36fb('0x36')][_0x36fb('0x3b')]));_0x32a086[_0x36fb('0x3a')]=_0x32a086[_0x36fb('0x3a')][_0x36fb('0x3c')]?_0x32a086[_0x36fb('0x3a')]:_0x2d91ad['model'];_0x32a086[_0x36fb('0x40')]=qs[_0x36fb('0x41')](_0x4bcfc3['query'][_0x36fb('0x41')]);_0x32a086[_0x36fb('0x42')]=qs['filters'](_[_0x36fb('0x43')](_0x4bcfc3[_0x36fb('0x36')],_0x2d91ad[_0x36fb('0x38')]));if(_0x4bcfc3[_0x36fb('0x36')]['filter']){_0x32a086[_0x36fb('0x42')]=_[_0x36fb('0x45')](_0x32a086[_0x36fb('0x42')],{'$or':_[_0x36fb('0x31')](_0x32a086[_0x36fb('0x3a')],function(_0x19c4b8){var _0x1b5b90={};_0x1b5b90[_0x19c4b8]={'$like':'%'+_0x4bcfc3[_0x36fb('0x36')][_0x36fb('0x44')]+'%'};return _0x1b5b90;})});}_0x32a086=_['merge']({},_0x32a086,_0x4bcfc3[_0x36fb('0x46')]);return _0x8d2608[_0x36fb('0x51')](_0x32a086);}})[_0x36fb('0x2c')](function(_0x3edfee){if(_0x3edfee){_0x32042a=_0x3edfee[_0x36fb('0x3c')];if(!_0x4bcfc3[_0x36fb('0x36')][_0x36fb('0x3d')](_0x36fb('0x3e'))){_0x32a086[_0x36fb('0x3f')]=qs['limit'](_0x4bcfc3[_0x36fb('0x36')][_0x36fb('0x3f')]);_0x32a086[_0x36fb('0x29')]=qs[_0x36fb('0x29')](_0x4bcfc3['query'][_0x36fb('0x29')]);}return _0x8d2608[_0x36fb('0x51')](_0x32a086);}})[_0x36fb('0x2c')](function(_0x48c8f5){if(_0x48c8f5){return _0x48c8f5?{'count':_0x32042a,'rows':_0x48c8f5}:null;}})[_0x36fb('0x2c')](respondWithResult(_0x4095e9,null))['catch'](handleError(_0x4095e9,null));};exports['addConfiguration']=function(_0x5885bd,_0x56d693,_0x5d47f7){if(_0x5885bd[_0x36fb('0x4c')]['id']){delete _0x5885bd[_0x36fb('0x4c')]['id'];}return db[_0x36fb('0x32')]['findOne']({'where':{'id':_0x5885bd[_0x36fb('0x50')]['id']}})[_0x36fb('0x2c')](handleEntityNotFound(_0x56d693,null))[_0x36fb('0x2c')](function(_0x3f3062){if(_0x3f3062){_0x5885bd[_0x36fb('0x4c')][_0x36fb('0x54')]=_0x3f3062['id'];_0x5885bd[_0x36fb('0x4c')][_0x36fb('0x55')]=integrations['getSubjects'](_0x5885bd[_0x36fb('0x4c')]['channel'],_0x5885bd[_0x36fb('0x4c')][_0x36fb('0x33')]);_0x5885bd[_0x36fb('0x4c')]['Descriptions']=integrations[_0x36fb('0x56')](_0x5885bd[_0x36fb('0x4c')][_0x36fb('0x57')],_0x5885bd[_0x36fb('0x4c')][_0x36fb('0x33')]);return db[_0x36fb('0x53')]['create'](_0x5885bd[_0x36fb('0x4c')],{'include':[{'model':db[_0x36fb('0x58')],'as':'Subjects'},{'model':db[_0x36fb('0x58')],'as':_0x36fb('0x59')}]});}return null;})[_0x36fb('0x2c')](respondWithResult(_0x56d693,null))[_0x36fb('0x25')](handleError(_0x56d693,null));};exports['getFields']=function(_0xc3217f,_0x402335,_0x4ec2d7){var _0x4ab0c8='';return db[_0x36fb('0x32')][_0x36fb('0x52')]({'where':{'id':_0xc3217f[_0x36fb('0x50')]['id']},'attributes':['id',_0x36fb('0x5a'),_0x36fb('0x5b')]})[_0x36fb('0x2c')](handleEntityNotFound(_0x402335,null))[_0x36fb('0x2c')](function(_0x55639f){if(_0x55639f){_0x4ab0c8=_0x55639f[_0x36fb('0x5a')];var _0x2fe4bf=_0x4ab0c8['slice'](-0x1);if(_0x2fe4bf==='/'){_0x4ab0c8=_0x4ab0c8[_0x36fb('0x5c')](0x0,_0x4ab0c8[_0x36fb('0x5d')](_0x2fe4bf));}return rp({'method':_0x36fb('0x5e'),'uri':util[_0x36fb('0x5f')](_0x36fb('0x60'),_0x4ab0c8,_0x36fb('0x61')),'headers':{'Authorization':util['format'](_0x36fb('0x62'),new Buffer(util[_0x36fb('0x5f')](_0x36fb('0x63'),_0x55639f[_0x36fb('0x5b')]))[_0x36fb('0x64')]('base64'))},'json':!![]});}})[_0x36fb('0x2c')](function(_0xd65a9e){if(_0xd65a9e){var _0x349f2a=[_0x36fb('0x65'),'subject',_0x36fb('0x66'),_0x36fb('0x67'),_0x36fb('0x27'),_0x36fb('0x68'),_0x36fb('0x69'),_0x36fb('0x6a'),_0x36fb('0x6b'),_0x36fb('0x69'),_0x36fb('0x6c')];_[_0x36fb('0x6d')](_0xd65a9e,function(_0x1d0380){return _0x349f2a[_0x36fb('0x6e')](_0x1d0380['name'])||!_0x1d0380[_0x36fb('0x6f')]&&_0x1d0380[_0x36fb('0x33')]!==_0x36fb('0x70')&&_0x1d0380[_0x36fb('0x33')]!==_0x36fb('0x71');});return{'count':_0xd65a9e[_0x36fb('0x3c')],'rows':_[_0x36fb('0x31')](_0xd65a9e,function(_0x1d4726){return{'id':_0x1d4726[_0x36fb('0x2f')],'name':_0x1d4726['label'],'custom':!_0x1d4726['default'],'options':_0x1d4726[_0x36fb('0x72')]?_[_0x36fb('0x31')](_0x1d4726[_0x36fb('0x72')],function(_0x16e263){return{'name':_[_0x36fb('0x73')](_0x16e263),'value':_0x16e263};}):[]};})};}})[_0x36fb('0x2c')](respondWithResult(_0x402335,null))[_0x36fb('0x25')](function(_0x23850b){var _0x557542=_0xc3217f[_0x36fb('0x36')][_0x36fb('0x74')]?0x1f4:_0x23850b[_0x36fb('0x75')]||0x1f4;logger[_0x36fb('0x21')]('getFields,\x20%s,\x20%s,\x20%s',_0x36fb('0x76'),_0x557542,JSON[_0x36fb('0x77')](_0x23850b));delete _0x23850b[_0x36fb('0x2f')];if(_0x557542===0x191){_0x557542=0x190;}_0x402335[_0x36fb('0x27')](_0x557542)[_0x36fb('0x78')](_0xc3217f['query']['test']?{'message':_0x36fb('0x79'),'statusCode':_0x23850b[_0x36fb('0x75')]}:_0x23850b);});};
\ No newline at end of file