Built motion from commit (unavailable).|2.4.20
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 2b6bdcb..e4468fb 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 _0xbc2c=['GET','format','api/v2/ticket_fields','Basic\x20%s','%s:X','toString','base64','agent','description','group','source','ticket_type','company','remove','includes','default','custom_text','custom_dropdown','label','choices','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../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~!@#$%^&-_=+[{]}.','request','then','info','request\x20sent','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error','code','FreshdeskAccount,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','reject','update','destroy','stack','name','index','map','FreshdeskAccount','fieldName','type','key','model','keys','filters','intersection','query','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','show','params','rawAttributes','includeAll','create','body','find','findOne','FreshdeskConfiguration','order','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','channel','FreshdeskField','getFields','apiKey','remoteUri','slice','substring','lastIndexOf'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xbc2c,0x9b));var _0xcbc2=function(_0x11e03f,_0x20b967){_0x11e03f=_0x11e03f-0x0;var _0x5666fe=_0xbc2c[_0x11e03f];return _0x5666fe;};'use strict';var pdf=require(_0xcbc2('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xcbc2('0x1'));var zipdir=require(_0xcbc2('0x2'));var jsonpatch=require(_0xcbc2('0x3'));var rp=require(_0xcbc2('0x4'));var moment=require(_0xcbc2('0x5'));var BPromise=require(_0xcbc2('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0xcbc2('0x7'));var sox=require(_0xcbc2('0x8'));var csv=require(_0xcbc2('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xcbc2('0xa'));var squel=require(_0xcbc2('0xb'));var crypto=require(_0xcbc2('0xc'));var jsforce=require(_0xcbc2('0xd'));var deskjs=require(_0xcbc2('0xe'));var toCsv=require(_0xcbc2('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xcbc2('0xf'));var authService=require(_0xcbc2('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xcbc2('0x11'));var hardwareService=require(_0xcbc2('0x12'));var logger=require(_0xcbc2('0x13'))(_0xcbc2('0x14'));var utils=require(_0xcbc2('0x15'));var config=require('../../config/environment');var db=require(_0xcbc2('0x16'))['db'];var integrations=require(_0xcbc2('0x17'));var jayson=require(_0xcbc2('0x18'));var client=jayson[_0xcbc2('0x19')]['http']({'port':0x232a});function checkPasswordPattern(_0x45c06c,_0x4b6f63,_0x5dfb49){if(_0x5dfb49){var _0x1ee2f4=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1ee2f4[_0xcbc2('0x1a')](_0x4b6f63)){return _0x45c06c;}else{throw new db[(_0xcbc2('0x1b'))][(_0xcbc2('0x1c'))](_0xcbc2('0x1d'));}}else{return _0x45c06c;}}function respondWithRpcPromise(_0x5ea881,_0x5ec394,_0x3b0a33,_0x4e288e){return new BPromise(function(_0x39a5e5,_0x155f5e){var _0x246436=_0x4e288e||client;return _0x246436[_0xcbc2('0x1e')](_0x5ea881,_0x3b0a33)[_0xcbc2('0x1f')](function(_0x4f3b24){logger[_0xcbc2('0x20')]('FreshdeskAccount,\x20%s,\x20%s',_0x5ec394,_0xcbc2('0x21'));logger[_0xcbc2('0x22')](_0xcbc2('0x23'),_0x5ec394,_0xcbc2('0x21'),JSON['stringify'](_0x4f3b24));if(_0x4f3b24[_0xcbc2('0x24')]){if(_0x4f3b24[_0xcbc2('0x24')][_0xcbc2('0x25')]===0x1f4){logger[_0xcbc2('0x24')]('FreshdeskAccount,\x20%s,\x20%s',_0x5ec394,_0x4f3b24[_0xcbc2('0x24')]['message']);return _0x155f5e(_0x4f3b24[_0xcbc2('0x24')]['message']);}logger[_0xcbc2('0x24')](_0xcbc2('0x26'),_0x5ec394,_0x4f3b24[_0xcbc2('0x24')][_0xcbc2('0x27')]);return _0x39a5e5(_0x4f3b24['error'][_0xcbc2('0x27')]);}else{logger[_0xcbc2('0x20')](_0xcbc2('0x26'),_0x5ec394,_0xcbc2('0x21'));_0x39a5e5(_0x4f3b24[_0xcbc2('0x28')][_0xcbc2('0x27')]);}})[_0xcbc2('0x29')](function(_0x4bcc9c){logger['error']('FreshdeskAccount,\x20%s,\x20%s',_0x5ec394,_0x4bcc9c);_0x155f5e(_0x4bcc9c);});});}function respondWithStatusCode(_0x416d75,_0x55e235){_0x55e235=_0x55e235||0xcc;return function(_0x4e4a95){if(_0x4e4a95){return _0x416d75[_0xcbc2('0x2a')](_0x55e235);}return _0x416d75[_0xcbc2('0x2b')](_0x55e235)[_0xcbc2('0x2c')]();};}function respondWithResult(_0x463db1,_0x127af8){_0x127af8=_0x127af8||0xc8;return function(_0x36887e){if(_0x36887e){return _0x463db1[_0xcbc2('0x2b')](_0x127af8)['json'](_0x36887e);}};}function respondWithFilteredResult(_0x118690,_0x243ca5){return function(_0x210f78){if(_0x210f78){var _0x2ee0cb=_0x210f78[_0xcbc2('0x2d')],_0x5d64fa=_0x243ca5[_0xcbc2('0x2e')],_0x16a223=_0x243ca5['offset']+_0x243ca5[_0xcbc2('0x2f')],_0x14b75d;if(_0x16a223>=_0x2ee0cb){_0x16a223=_0x2ee0cb;_0x14b75d=0xc8;}else{_0x14b75d=0xce;}_0x118690['status'](_0x14b75d);return _0x118690[_0xcbc2('0x30')](_0xcbc2('0x31'),_0x5d64fa+'-'+_0x16a223+'/'+_0x2ee0cb)[_0xcbc2('0x32')](_0x210f78);}return null;};}function patchUpdates(_0x450781){return function(_0x4e4d84){try{jsonpatch[_0xcbc2('0x33')](_0x4e4d84,_0x450781,!![]);}catch(_0x35faae){return BPromise[_0xcbc2('0x34')](_0x35faae);}return _0x4e4d84['save']();};}function saveUpdates(_0x3b494f,_0x3dcb55){return function(_0x1e0468){if(_0x1e0468){return _0x1e0468[_0xcbc2('0x35')](_0x3b494f)[_0xcbc2('0x1f')](function(_0x89a7f3){return _0x89a7f3;});}return null;};}function removeEntity(_0x1b0dcb,_0x5becb4){return function(_0x59a796){if(_0x59a796){return _0x59a796[_0xcbc2('0x36')]()[_0xcbc2('0x1f')](function(){_0x1b0dcb[_0xcbc2('0x2b')](0xcc)[_0xcbc2('0x2c')]();});}};}function handleEntityNotFound(_0x29c818,_0x4c407b){return function(_0x1ce150){if(!_0x1ce150){_0x29c818[_0xcbc2('0x2a')](0x194);}return _0x1ce150;};}function handleError(_0x2d9083,_0xf0ad28){_0xf0ad28=_0xf0ad28||0x1f4;return function(_0xf2f528){logger[_0xcbc2('0x24')](_0xf2f528[_0xcbc2('0x37')]);if(_0xf2f528[_0xcbc2('0x38')]){delete _0xf2f528[_0xcbc2('0x38')];}_0x2d9083[_0xcbc2('0x2b')](_0xf0ad28)['send'](_0xf2f528);};}exports[_0xcbc2('0x39')]=function(_0x119ce3,_0x460785){var _0x58b99f={},_0x2b1962={},_0x55c74b={'count':0x0,'rows':[]};var _0x21945b=_[_0xcbc2('0x3a')](db[_0xcbc2('0x3b')]['rawAttributes'],function(_0x58b515){return{'name':_0x58b515[_0xcbc2('0x3c')],'type':_0x58b515[_0xcbc2('0x3d')][_0xcbc2('0x3e')]};});_0x2b1962[_0xcbc2('0x3f')]=_['map'](_0x21945b,_0xcbc2('0x38'));_0x2b1962['query']=_[_0xcbc2('0x40')](_0x119ce3['query']);_0x2b1962[_0xcbc2('0x41')]=_[_0xcbc2('0x42')](_0x2b1962[_0xcbc2('0x3f')],_0x2b1962[_0xcbc2('0x43')]);_0x58b99f['attributes']=_[_0xcbc2('0x42')](_0x2b1962[_0xcbc2('0x3f')],qs['fields'](_0x119ce3['query'][_0xcbc2('0x44')]));_0x58b99f[_0xcbc2('0x45')]=_0x58b99f['attributes'][_0xcbc2('0x46')]?_0x58b99f['attributes']:_0x2b1962['model'];if(!_0x119ce3[_0xcbc2('0x43')][_0xcbc2('0x47')](_0xcbc2('0x48'))){_0x58b99f[_0xcbc2('0x2f')]=qs['limit'](_0x119ce3[_0xcbc2('0x43')][_0xcbc2('0x2f')]);_0x58b99f[_0xcbc2('0x2e')]=qs[_0xcbc2('0x2e')](_0x119ce3[_0xcbc2('0x43')][_0xcbc2('0x2e')]);}_0x58b99f['order']=qs[_0xcbc2('0x49')](_0x119ce3[_0xcbc2('0x43')][_0xcbc2('0x49')]);_0x58b99f[_0xcbc2('0x4a')]=qs['filters'](_[_0xcbc2('0x4b')](_0x119ce3[_0xcbc2('0x43')],_0x2b1962[_0xcbc2('0x41')]));if(_0x119ce3['query'][_0xcbc2('0x4c')]){_0x58b99f[_0xcbc2('0x4a')]=_[_0xcbc2('0x4d')](_0x58b99f[_0xcbc2('0x4a')],{'$or':_[_0xcbc2('0x3a')](_0x21945b,function(_0x478219){if(_0x478219['type']!==_0xcbc2('0x4e')){var _0x574487={};_0x574487[_0x478219[_0xcbc2('0x38')]]={'$like':'%'+_0x119ce3[_0xcbc2('0x43')]['filter']+'%'};return _0x574487;}})});}_0x58b99f=_[_0xcbc2('0x4d')]({},_0x58b99f,_0x119ce3[_0xcbc2('0x4f')]);var _0x3b1d3f={'where':_0x58b99f['where']};return db[_0xcbc2('0x3b')][_0xcbc2('0x2d')](_0x3b1d3f)['then'](function(_0x468c49){_0x55c74b['count']=_0x468c49;if(_0x119ce3[_0xcbc2('0x43')]['includeAll']){_0x58b99f[_0xcbc2('0x50')]=[{'all':!![]}];}return db[_0xcbc2('0x3b')][_0xcbc2('0x51')](_0x58b99f);})[_0xcbc2('0x1f')](function(_0x411389){_0x55c74b['rows']=_0x411389;return _0x55c74b;})['then'](respondWithFilteredResult(_0x460785,_0x58b99f))[_0xcbc2('0x29')](handleError(_0x460785,null));};exports[_0xcbc2('0x52')]=function(_0x438d82,_0x5a0cdf){var _0x412cf3={'raw':![],'where':{'id':_0x438d82[_0xcbc2('0x53')]['id']}},_0x2f03d7={};_0x2f03d7[_0xcbc2('0x3f')]=_[_0xcbc2('0x40')](db[_0xcbc2('0x3b')][_0xcbc2('0x54')]);_0x2f03d7[_0xcbc2('0x43')]=_[_0xcbc2('0x40')](_0x438d82[_0xcbc2('0x43')]);_0x2f03d7[_0xcbc2('0x41')]=_[_0xcbc2('0x42')](_0x2f03d7['model'],_0x2f03d7[_0xcbc2('0x43')]);_0x412cf3[_0xcbc2('0x45')]=_[_0xcbc2('0x42')](_0x2f03d7[_0xcbc2('0x3f')],qs[_0xcbc2('0x44')](_0x438d82[_0xcbc2('0x43')][_0xcbc2('0x44')]));_0x412cf3[_0xcbc2('0x45')]=_0x412cf3[_0xcbc2('0x45')][_0xcbc2('0x46')]?_0x412cf3[_0xcbc2('0x45')]:_0x2f03d7[_0xcbc2('0x3f')];if(_0x438d82[_0xcbc2('0x43')][_0xcbc2('0x55')]){_0x412cf3[_0xcbc2('0x50')]=[{'all':!![]}];}_0x412cf3=_[_0xcbc2('0x4d')]({},_0x412cf3,_0x438d82['options']);return db[_0xcbc2('0x3b')]['find'](_0x412cf3)[_0xcbc2('0x1f')](handleEntityNotFound(_0x5a0cdf,null))['then'](respondWithResult(_0x5a0cdf,null))[_0xcbc2('0x29')](handleError(_0x5a0cdf,null));};exports[_0xcbc2('0x56')]=function(_0x588ccb,_0x7e0a88){return db[_0xcbc2('0x3b')][_0xcbc2('0x56')](_0x588ccb['body'],{})['then'](respondWithResult(_0x7e0a88,0xc9))[_0xcbc2('0x29')](handleError(_0x7e0a88,null));};exports[_0xcbc2('0x35')]=function(_0x5975bf,_0x383fe1){if(_0x5975bf[_0xcbc2('0x57')]['id']){delete _0x5975bf[_0xcbc2('0x57')]['id'];}return db[_0xcbc2('0x3b')]['find']({'where':{'id':_0x5975bf[_0xcbc2('0x53')]['id']}})['then'](handleEntityNotFound(_0x383fe1,null))[_0xcbc2('0x1f')](saveUpdates(_0x5975bf['body'],null))[_0xcbc2('0x1f')](respondWithResult(_0x383fe1,null))[_0xcbc2('0x29')](handleError(_0x383fe1,null));};exports[_0xcbc2('0x36')]=function(_0x489525,_0x1dc62a){return db[_0xcbc2('0x3b')][_0xcbc2('0x58')]({'where':{'id':_0x489525[_0xcbc2('0x53')]['id']}})[_0xcbc2('0x1f')](handleEntityNotFound(_0x1dc62a,null))[_0xcbc2('0x1f')](removeEntity(_0x1dc62a,null))[_0xcbc2('0x29')](handleError(_0x1dc62a,null));};exports['getConfigurations']=function(_0x15446f,_0x4ead32,_0x182fa6){var _0x401de1={};var _0x2b5a2e={};var _0x14883e;var _0x19c583;return db['FreshdeskAccount'][_0xcbc2('0x59')]({'where':{'id':_0x15446f[_0xcbc2('0x53')]['id']}})[_0xcbc2('0x1f')](handleEntityNotFound(_0x4ead32,null))[_0xcbc2('0x1f')](function(_0x2c59b3){if(_0x2c59b3){_0x14883e=_0x2c59b3;_0x2b5a2e[_0xcbc2('0x3f')]=_[_0xcbc2('0x40')](db[_0xcbc2('0x5a')]['rawAttributes']);_0x2b5a2e[_0xcbc2('0x43')]=_['keys'](_0x15446f[_0xcbc2('0x43')]);_0x2b5a2e[_0xcbc2('0x41')]=_['intersection'](_0x2b5a2e['model'],_0x2b5a2e[_0xcbc2('0x43')]);_0x401de1['attributes']=_[_0xcbc2('0x42')](_0x2b5a2e['model'],qs['fields'](_0x15446f['query']['fields']));_0x401de1[_0xcbc2('0x45')]=_0x401de1['attributes']['length']?_0x401de1[_0xcbc2('0x45')]:_0x2b5a2e[_0xcbc2('0x3f')];_0x401de1[_0xcbc2('0x5b')]=qs[_0xcbc2('0x49')](_0x15446f[_0xcbc2('0x43')]['sort']);_0x401de1['where']=qs['filters'](_[_0xcbc2('0x4b')](_0x15446f['query'],_0x2b5a2e['filters']));if(_0x15446f[_0xcbc2('0x43')]['filter']){_0x401de1['where']=_['merge'](_0x401de1[_0xcbc2('0x4a')],{'$or':_[_0xcbc2('0x3a')](_0x401de1[_0xcbc2('0x45')],function(_0x733ef7){var _0x49e659={};_0x49e659[_0x733ef7]={'$like':'%'+_0x15446f[_0xcbc2('0x43')][_0xcbc2('0x4c')]+'%'};return _0x49e659;})});}_0x401de1=_[_0xcbc2('0x4d')]({},_0x401de1,_0x15446f[_0xcbc2('0x4f')]);return _0x14883e[_0xcbc2('0x5c')](_0x401de1);}})['then'](function(_0x37f0d2){if(_0x37f0d2){_0x19c583=_0x37f0d2[_0xcbc2('0x46')];if(!_0x15446f[_0xcbc2('0x43')][_0xcbc2('0x47')](_0xcbc2('0x48'))){_0x401de1[_0xcbc2('0x2f')]=qs['limit'](_0x15446f[_0xcbc2('0x43')]['limit']);_0x401de1[_0xcbc2('0x2e')]=qs[_0xcbc2('0x2e')](_0x15446f[_0xcbc2('0x43')][_0xcbc2('0x2e')]);}return _0x14883e['getConfigurations'](_0x401de1);}})[_0xcbc2('0x1f')](function(_0x1f0b12){if(_0x1f0b12){return _0x1f0b12?{'count':_0x19c583,'rows':_0x1f0b12}:null;}})[_0xcbc2('0x1f')](respondWithResult(_0x4ead32,null))[_0xcbc2('0x29')](handleError(_0x4ead32,null));};exports[_0xcbc2('0x5d')]=function(_0xa4b00d,_0x2ba813,_0x1479ed){if(_0xa4b00d['body']['id']){delete _0xa4b00d[_0xcbc2('0x57')]['id'];}return db[_0xcbc2('0x3b')][_0xcbc2('0x59')]({'where':{'id':_0xa4b00d[_0xcbc2('0x53')]['id']}})['then'](handleEntityNotFound(_0x2ba813,null))[_0xcbc2('0x1f')](function(_0x362ce9){if(_0x362ce9){_0xa4b00d['body'][_0xcbc2('0x5e')]=_0x362ce9['id'];_0xa4b00d[_0xcbc2('0x57')][_0xcbc2('0x5f')]=integrations[_0xcbc2('0x60')](_0xa4b00d[_0xcbc2('0x57')]['channel'],_0xa4b00d[_0xcbc2('0x57')][_0xcbc2('0x3d')]);_0xa4b00d[_0xcbc2('0x57')][_0xcbc2('0x61')]=integrations[_0xcbc2('0x62')](_0xa4b00d['body'][_0xcbc2('0x63')],_0xa4b00d[_0xcbc2('0x57')][_0xcbc2('0x3d')]);return db[_0xcbc2('0x5a')]['create'](_0xa4b00d[_0xcbc2('0x57')],{'include':[{'model':db[_0xcbc2('0x64')],'as':_0xcbc2('0x5f')},{'model':db[_0xcbc2('0x64')],'as':_0xcbc2('0x61')}]});}return null;})[_0xcbc2('0x1f')](respondWithResult(_0x2ba813,null))['catch'](handleError(_0x2ba813,null));};exports[_0xcbc2('0x65')]=function(_0x16fa2b,_0x2d5a5e,_0x38b4da){var _0x3bee73='';return db['FreshdeskAccount']['findOne']({'where':{'id':_0x16fa2b[_0xcbc2('0x53')]['id']},'attributes':['id','remoteUri',_0xcbc2('0x66')]})[_0xcbc2('0x1f')](handleEntityNotFound(_0x2d5a5e,null))['then'](function(_0x5e3747){if(_0x5e3747){_0x3bee73=_0x5e3747[_0xcbc2('0x67')];var _0x5193e7=_0x3bee73[_0xcbc2('0x68')](-0x1);if(_0x5193e7==='/'){_0x3bee73=_0x3bee73[_0xcbc2('0x69')](0x0,_0x3bee73[_0xcbc2('0x6a')](_0x5193e7));}return rp({'method':_0xcbc2('0x6b'),'uri':util[_0xcbc2('0x6c')]('%s/%s',_0x3bee73,_0xcbc2('0x6d')),'headers':{'Authorization':util['format'](_0xcbc2('0x6e'),new Buffer(util[_0xcbc2('0x6c')](_0xcbc2('0x6f'),_0x5e3747[_0xcbc2('0x66')]))[_0xcbc2('0x70')](_0xcbc2('0x71')))},'json':!![]});}})['then'](function(_0x4d8ecb){if(_0x4d8ecb){var _0x396ca6=['requester','subject',_0xcbc2('0x72'),_0xcbc2('0x73'),_0xcbc2('0x2b'),'priority',_0xcbc2('0x74'),_0xcbc2('0x75'),_0xcbc2('0x76'),_0xcbc2('0x74'),_0xcbc2('0x77')];_[_0xcbc2('0x78')](_0x4d8ecb,function(_0x354698){return _0x396ca6[_0xcbc2('0x79')](_0x354698['name'])||!_0x354698[_0xcbc2('0x7a')]&&_0x354698['type']!==_0xcbc2('0x7b')&&_0x354698['type']!==_0xcbc2('0x7c');});return{'count':_0x4d8ecb[_0xcbc2('0x46')],'rows':_[_0xcbc2('0x3a')](_0x4d8ecb,function(_0x523863){return{'id':_0x523863[_0xcbc2('0x38')],'name':_0x523863[_0xcbc2('0x7d')],'custom':!_0x523863[_0xcbc2('0x7a')],'options':_0x523863[_0xcbc2('0x7e')]?_[_0xcbc2('0x3a')](_0x523863['choices'],function(_0x5d0049){return{'name':_['capitalize'](_0x5d0049),'value':_0x5d0049};}):[]};})};}})['then'](respondWithResult(_0x2d5a5e,null))[_0xcbc2('0x29')](function(_0x2c7223){var _0x5a3ea7=_0x16fa2b[_0xcbc2('0x43')]['test']?0x1f4:_0x2c7223[_0xcbc2('0x7f')]||0x1f4;logger[_0xcbc2('0x24')](_0xcbc2('0x80'),_0xcbc2('0x65'),_0x5a3ea7,JSON['stringify'](_0x2c7223));delete _0x2c7223[_0xcbc2('0x38')];if(_0x5a3ea7===0x191){_0x5a3ea7=0x190;}_0x2d5a5e[_0xcbc2('0x2b')](_0x5a3ea7)[_0xcbc2('0x81')](_0x16fa2b[_0xcbc2('0x43')][_0xcbc2('0x1a')]?{'message':_0xcbc2('0x82'),'statusCode':_0x2c7223[_0xcbc2('0x7f')]}:_0x2c7223);});};
\ No newline at end of file