Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 0d87876..b676ca1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc08b=['default','custom_text','custom_dropdown','label','choices','capitalize','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','send','Wrong\x20credentials','html-pdf','eml-format','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','client','http','test','request','info','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','then','destroy','stack','name','index','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','type','key','VIRTUAL','field','options','includeAll','include','FreshdeskAccount','rows','params','rawAttributes','find','create','body','update','getConfigurations','findOne','FreshdeskConfiguration','map','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshdeskField','remoteUri','substring','lastIndexOf','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','%s:X','apiKey','toString','requester','subject','agent','description','priority','group','source','ticket_type','remove'];(function(_0x5a5ebc,_0x584a43){var _0x51984f=function(_0x5cc36a){while(--_0x5cc36a){_0x5a5ebc['push'](_0x5a5ebc['shift']());}};_0x51984f(++_0x584a43);}(_0xc08b,0x8a));var _0xbc08=function(_0x2f108a,_0x4bc26b){_0x2f108a=_0x2f108a-0x0;var _0x2ac339=_0xc08b[_0x2f108a];return _0x2ac339;};'use strict';var pdf=require(_0xbc08('0x0'));var emlformat=require(_0xbc08('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xbc08('0x2'));var jsonpatch=require(_0xbc08('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xbc08('0x4'));var Mustache=require(_0xbc08('0x5'));var util=require(_0xbc08('0x6'));var path=require(_0xbc08('0x7'));var sox=require(_0xbc08('0x8'));var csv=require(_0xbc08('0x9'));var ejs=require(_0xbc08('0xa'));var fs=require('fs');var _=require(_0xbc08('0xb'));var squel=require(_0xbc08('0xc'));var crypto=require(_0xbc08('0xd'));var jsforce=require(_0xbc08('0xe'));var deskjs=require(_0xbc08('0xf'));var toCsv=require(_0xbc08('0x9'));var querystring=require('querystring');var Papa=require(_0xbc08('0x10'));var Redis=require(_0xbc08('0x11'));var authService=require(_0xbc08('0x12'));var qs=require(_0xbc08('0x13'));var hardwareService=require(_0xbc08('0x14'));var logger=require(_0xbc08('0x15'))(_0xbc08('0x16'));var utils=require(_0xbc08('0x17'));var config=require(_0xbc08('0x18'));var db=require(_0xbc08('0x19'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0xbc08('0x1a'));var client=jayson[_0xbc08('0x1b')][_0xbc08('0x1c')]({'port':0x232a});function checkPasswordPattern(_0x5f03d2,_0x11a88d,_0x2b7f30){if(_0x2b7f30){var _0x3ded28=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x3ded28[_0xbc08('0x1d')](_0x11a88d)){return _0x5f03d2;}else{throw new Error('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x5f03d2;}}function respondWithRpcPromise(_0x356c98,_0x1c6e91,_0x2051d0,_0x27778c){return new BPromise(function(_0x570950,_0x20f85c){var _0xd77da1=_0x27778c||client;return _0xd77da1[_0xbc08('0x1e')](_0x356c98,_0x2051d0)['then'](function(_0x452d5c){logger[_0xbc08('0x1f')](_0xbc08('0x20'),_0x1c6e91,_0xbc08('0x21'));logger['debug']('FreshdeskAccount,\x20%s,\x20%s,\x20%s',_0x1c6e91,_0xbc08('0x21'),JSON[_0xbc08('0x22')](_0x452d5c));if(_0x452d5c[_0xbc08('0x23')]){if(_0x452d5c[_0xbc08('0x23')][_0xbc08('0x24')]===0x1f4){logger[_0xbc08('0x23')](_0xbc08('0x20'),_0x1c6e91,_0x452d5c[_0xbc08('0x23')][_0xbc08('0x25')]);return _0x20f85c(_0x452d5c[_0xbc08('0x23')][_0xbc08('0x25')]);}logger[_0xbc08('0x23')](_0xbc08('0x20'),_0x1c6e91,_0x452d5c[_0xbc08('0x23')][_0xbc08('0x25')]);return _0x570950(_0x452d5c[_0xbc08('0x23')]['message']);}else{logger['info'](_0xbc08('0x20'),_0x1c6e91,_0xbc08('0x21'));_0x570950(_0x452d5c[_0xbc08('0x26')]['message']);}})[_0xbc08('0x27')](function(_0x2b61b1){logger[_0xbc08('0x23')](_0xbc08('0x20'),_0x1c6e91,_0x2b61b1);_0x20f85c(_0x2b61b1);});});}function respondWithStatusCode(_0x17bdee,_0x53eb14){_0x53eb14=_0x53eb14||0xcc;return function(_0x380b24){if(_0x380b24){return _0x17bdee[_0xbc08('0x28')](_0x53eb14);}return _0x17bdee[_0xbc08('0x29')](_0x53eb14)[_0xbc08('0x2a')]();};}function respondWithResult(_0x4e3141,_0x11fbf1){_0x11fbf1=_0x11fbf1||0xc8;return function(_0x6304d0){if(_0x6304d0){return _0x4e3141['status'](_0x11fbf1)[_0xbc08('0x2b')](_0x6304d0);}};}function respondWithFilteredResult(_0x42d302,_0x34fa2c){return function(_0x342ef5){if(_0x342ef5){var _0x226240=_0x342ef5[_0xbc08('0x2c')],_0x290924=_0x34fa2c[_0xbc08('0x2d')],_0x27f6ff=_0x34fa2c['offset']+_0x34fa2c[_0xbc08('0x2e')],_0x4e44d2;if(_0x27f6ff>=_0x226240){_0x27f6ff=_0x226240;_0x4e44d2=0xc8;}else{_0x4e44d2=0xce;}_0x42d302[_0xbc08('0x29')](_0x4e44d2);return _0x42d302[_0xbc08('0x2f')](_0xbc08('0x30'),_0x290924+'-'+_0x27f6ff+'/'+_0x226240)['json'](_0x342ef5);}return null;};}function patchUpdates(_0x4413d9){return function(_0xda4aee){try{jsonpatch[_0xbc08('0x31')](_0xda4aee,_0x4413d9,!![]);}catch(_0x409592){return BPromise['reject'](_0x409592);}return _0xda4aee[_0xbc08('0x32')]();};}function saveUpdates(_0x2ba820,_0x23ddef){return function(_0x1b1153){if(_0x1b1153){return _0x1b1153['update'](_0x2ba820)[_0xbc08('0x33')](function(_0x28ccf2){return _0x28ccf2;});}return null;};}function removeEntity(_0x42ece4,_0x25a5af){return function(_0xe178dc){if(_0xe178dc){return _0xe178dc[_0xbc08('0x34')]()[_0xbc08('0x33')](function(){_0x42ece4[_0xbc08('0x29')](0xcc)[_0xbc08('0x2a')]();});}};}function handleEntityNotFound(_0x487e83,_0x7aa4eb){return function(_0xde8fd0){if(!_0xde8fd0){_0x487e83[_0xbc08('0x28')](0x194);}return _0xde8fd0;};}function handleError(_0x385f75,_0x3d50b1){_0x3d50b1=_0x3d50b1||0x1f4;return function(_0x2fc39d){logger[_0xbc08('0x23')](_0x2fc39d[_0xbc08('0x35')]);if(_0x2fc39d[_0xbc08('0x36')]){delete _0x2fc39d[_0xbc08('0x36')];}_0x385f75['status'](_0x3d50b1)['send'](_0x2fc39d);};}exports[_0xbc08('0x37')]=function(_0x29103b,_0x4d3c49){var _0x35bd7c={},_0x32e0d3={},_0x369615={'count':0x0,'rows':[]};var _0x11ee42=db['FreshdeskAccount']['rawAttributes'];_0x32e0d3[_0xbc08('0x38')]=_[_0xbc08('0x39')](_0x11ee42);_0x32e0d3[_0xbc08('0x3a')]=_[_0xbc08('0x39')](_0x29103b[_0xbc08('0x3a')]);_0x32e0d3[_0xbc08('0x3b')]=_[_0xbc08('0x3c')](_0x32e0d3[_0xbc08('0x38')],_0x32e0d3[_0xbc08('0x3a')]);_0x35bd7c[_0xbc08('0x3d')]=_[_0xbc08('0x3c')](_0x32e0d3['model'],qs[_0xbc08('0x3e')](_0x29103b['query'][_0xbc08('0x3e')]));_0x35bd7c[_0xbc08('0x3d')]=_0x35bd7c[_0xbc08('0x3d')][_0xbc08('0x3f')]?_0x35bd7c[_0xbc08('0x3d')]:_0x32e0d3['model'];if(!_0x29103b['query'][_0xbc08('0x40')](_0xbc08('0x41'))){_0x35bd7c[_0xbc08('0x2e')]=qs[_0xbc08('0x2e')](_0x29103b[_0xbc08('0x3a')][_0xbc08('0x2e')]);_0x35bd7c['offset']=qs[_0xbc08('0x2d')](_0x29103b['query']['offset']);}_0x35bd7c[_0xbc08('0x42')]=qs[_0xbc08('0x43')](_0x29103b['query'][_0xbc08('0x43')]);_0x35bd7c[_0xbc08('0x44')]=qs[_0xbc08('0x3b')](_['pick'](_0x29103b[_0xbc08('0x3a')],_0x32e0d3[_0xbc08('0x3b')]));if(_0x29103b['query'][_0xbc08('0x45')]){_0x35bd7c[_0xbc08('0x44')]=_[_0xbc08('0x46')](_0x35bd7c[_0xbc08('0x44')],{'$or':_['map'](_0x11ee42,function(_0x7efae6){if(_0x7efae6[_0xbc08('0x47')][_0xbc08('0x48')]!==_0xbc08('0x49')){var _0x121887={};_0x121887[_0x7efae6[_0xbc08('0x4a')]]={'$like':'%'+_0x29103b['query'][_0xbc08('0x45')]+'%'};return _0x121887;}})});}_0x35bd7c=_['merge']({},_0x35bd7c,_0x29103b[_0xbc08('0x4b')]);var _0x5027c6={'where':_0x35bd7c['where']};return db['FreshdeskAccount'][_0xbc08('0x2c')](_0x5027c6)[_0xbc08('0x33')](function(_0x5b8c2b){_0x369615[_0xbc08('0x2c')]=_0x5b8c2b;if(_0x29103b[_0xbc08('0x3a')][_0xbc08('0x4c')]){_0x35bd7c[_0xbc08('0x4d')]=[{'all':!![]}];}return db[_0xbc08('0x4e')]['findAll'](_0x35bd7c);})[_0xbc08('0x33')](function(_0x5d3b87){_0x369615[_0xbc08('0x4f')]=_0x5d3b87;return _0x369615;})['then'](respondWithFilteredResult(_0x4d3c49,_0x35bd7c))['catch'](handleError(_0x4d3c49,null));};exports['show']=function(_0x138d87,_0x577437){var _0x371b07={'raw':![],'where':{'id':_0x138d87[_0xbc08('0x50')]['id']}},_0x5a5e09={};_0x5a5e09['model']=_[_0xbc08('0x39')](db[_0xbc08('0x4e')][_0xbc08('0x51')]);_0x5a5e09[_0xbc08('0x3a')]=_['keys'](_0x138d87[_0xbc08('0x3a')]);_0x5a5e09['filters']=_[_0xbc08('0x3c')](_0x5a5e09[_0xbc08('0x38')],_0x5a5e09['query']);_0x371b07[_0xbc08('0x3d')]=_[_0xbc08('0x3c')](_0x5a5e09[_0xbc08('0x38')],qs[_0xbc08('0x3e')](_0x138d87[_0xbc08('0x3a')]['fields']));_0x371b07['attributes']=_0x371b07[_0xbc08('0x3d')][_0xbc08('0x3f')]?_0x371b07[_0xbc08('0x3d')]:_0x5a5e09[_0xbc08('0x38')];if(_0x138d87[_0xbc08('0x3a')][_0xbc08('0x4c')]){_0x371b07[_0xbc08('0x4d')]=[{'all':!![]}];}_0x371b07=_[_0xbc08('0x46')]({},_0x371b07,_0x138d87[_0xbc08('0x4b')]);return db['FreshdeskAccount'][_0xbc08('0x52')](_0x371b07)[_0xbc08('0x33')](handleEntityNotFound(_0x577437,null))[_0xbc08('0x33')](respondWithResult(_0x577437,null))['catch'](handleError(_0x577437,null));};exports[_0xbc08('0x53')]=function(_0xa398b9,_0x79ee86){return db['FreshdeskAccount'][_0xbc08('0x53')](_0xa398b9[_0xbc08('0x54')],{})[_0xbc08('0x33')](respondWithResult(_0x79ee86,0xc9))['catch'](handleError(_0x79ee86,null));};exports[_0xbc08('0x55')]=function(_0x3f2c61,_0x1196b8){if(_0x3f2c61[_0xbc08('0x54')]['id']){delete _0x3f2c61[_0xbc08('0x54')]['id'];}return db['FreshdeskAccount']['find']({'where':{'id':_0x3f2c61['params']['id']}})[_0xbc08('0x33')](handleEntityNotFound(_0x1196b8,null))['then'](saveUpdates(_0x3f2c61[_0xbc08('0x54')],null))['then'](respondWithResult(_0x1196b8,null))[_0xbc08('0x27')](handleError(_0x1196b8,null));};exports[_0xbc08('0x34')]=function(_0x597613,_0x1911e1){return db[_0xbc08('0x4e')][_0xbc08('0x52')]({'where':{'id':_0x597613[_0xbc08('0x50')]['id']}})['then'](handleEntityNotFound(_0x1911e1,null))[_0xbc08('0x33')](removeEntity(_0x1911e1,null))['catch'](handleError(_0x1911e1,null));};exports[_0xbc08('0x56')]=function(_0x1dd746,_0x20600c,_0x158e36){var _0xd8d585={};var _0x128a55={};var _0x42785d;var _0x393904;return db['FreshdeskAccount'][_0xbc08('0x57')]({'where':{'id':_0x1dd746[_0xbc08('0x50')]['id']}})['then'](handleEntityNotFound(_0x20600c,null))[_0xbc08('0x33')](function(_0x3f1c38){if(_0x3f1c38){_0x42785d=_0x3f1c38;_0x128a55[_0xbc08('0x38')]=_[_0xbc08('0x39')](db[_0xbc08('0x58')][_0xbc08('0x51')]);_0x128a55[_0xbc08('0x3a')]=_[_0xbc08('0x39')](_0x1dd746[_0xbc08('0x3a')]);_0x128a55[_0xbc08('0x3b')]=_[_0xbc08('0x3c')](_0x128a55[_0xbc08('0x38')],_0x128a55[_0xbc08('0x3a')]);_0xd8d585[_0xbc08('0x3d')]=_[_0xbc08('0x3c')](_0x128a55[_0xbc08('0x38')],qs['fields'](_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x3e')]));_0xd8d585[_0xbc08('0x3d')]=_0xd8d585[_0xbc08('0x3d')]['length']?_0xd8d585[_0xbc08('0x3d')]:_0x128a55[_0xbc08('0x38')];_0xd8d585[_0xbc08('0x42')]=qs[_0xbc08('0x43')](_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x43')]);_0xd8d585[_0xbc08('0x44')]=qs[_0xbc08('0x3b')](_['pick'](_0x1dd746[_0xbc08('0x3a')],_0x128a55['filters']));if(_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x45')]){_0xd8d585[_0xbc08('0x44')]=_[_0xbc08('0x46')](_0xd8d585[_0xbc08('0x44')],{'$or':_[_0xbc08('0x59')](_0xd8d585[_0xbc08('0x3d')],function(_0x1af861){var _0x6449ef={};_0x6449ef[_0x1af861]={'$like':'%'+_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x45')]+'%'};return _0x6449ef;})});}_0xd8d585=_[_0xbc08('0x46')]({},_0xd8d585,_0x1dd746[_0xbc08('0x4b')]);return _0x42785d[_0xbc08('0x56')](_0xd8d585);}})[_0xbc08('0x33')](function(_0x297269){if(_0x297269){_0x393904=_0x297269[_0xbc08('0x3f')];if(!_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x40')](_0xbc08('0x41'))){_0xd8d585[_0xbc08('0x2e')]=qs[_0xbc08('0x2e')](_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x2e')]);_0xd8d585[_0xbc08('0x2d')]=qs[_0xbc08('0x2d')](_0x1dd746[_0xbc08('0x3a')][_0xbc08('0x2d')]);}return _0x42785d[_0xbc08('0x56')](_0xd8d585);}})[_0xbc08('0x33')](function(_0x4f8c3a){if(_0x4f8c3a){return _0x4f8c3a?{'count':_0x393904,'rows':_0x4f8c3a}:null;}})['then'](respondWithResult(_0x20600c,null))['catch'](handleError(_0x20600c,null));};exports['addConfiguration']=function(_0x55f1ff,_0x32f34d,_0x1b7ddc){if(_0x55f1ff[_0xbc08('0x54')]['id']){delete _0x55f1ff[_0xbc08('0x54')]['id'];}return db[_0xbc08('0x4e')][_0xbc08('0x57')]({'where':{'id':_0x55f1ff[_0xbc08('0x50')]['id']}})[_0xbc08('0x33')](handleEntityNotFound(_0x32f34d,null))[_0xbc08('0x33')](function(_0x2eb71d){if(_0x2eb71d){_0x55f1ff['body'][_0xbc08('0x5a')]=_0x2eb71d['id'];_0x55f1ff[_0xbc08('0x54')][_0xbc08('0x5b')]=integrations[_0xbc08('0x5c')](_0x55f1ff[_0xbc08('0x54')][_0xbc08('0x5d')],_0x55f1ff['body'][_0xbc08('0x47')]);_0x55f1ff[_0xbc08('0x54')][_0xbc08('0x5e')]=integrations[_0xbc08('0x5f')](_0x55f1ff[_0xbc08('0x54')][_0xbc08('0x5d')],_0x55f1ff[_0xbc08('0x54')]['type']);return db['FreshdeskConfiguration']['create'](_0x55f1ff[_0xbc08('0x54')],{'include':[{'model':db['FreshdeskField'],'as':_0xbc08('0x5b')},{'model':db[_0xbc08('0x60')],'as':_0xbc08('0x5e')}]});}return null;})[_0xbc08('0x33')](respondWithResult(_0x32f34d,null))[_0xbc08('0x27')](handleError(_0x32f34d,null));};exports['getFields']=function(_0x3e2c06,_0x417984,_0x12ad22){var _0x2d9dc5='';return db['FreshdeskAccount'][_0xbc08('0x57')]({'where':{'id':_0x3e2c06['params']['id']},'attributes':['id',_0xbc08('0x61'),'apiKey']})[_0xbc08('0x33')](handleEntityNotFound(_0x417984,null))[_0xbc08('0x33')](function(_0x46108b){if(_0x46108b){_0x2d9dc5=_0x46108b[_0xbc08('0x61')];var _0x321de9=_0x2d9dc5['slice'](-0x1);if(_0x321de9==='/'){_0x2d9dc5=_0x2d9dc5[_0xbc08('0x62')](0x0,_0x2d9dc5[_0xbc08('0x63')](_0x321de9));}return rp({'method':'GET','uri':util[_0xbc08('0x64')](_0xbc08('0x65'),_0x2d9dc5,_0xbc08('0x66')),'headers':{'Authorization':util[_0xbc08('0x64')](_0xbc08('0x67'),new Buffer(util[_0xbc08('0x64')](_0xbc08('0x68'),_0x46108b[_0xbc08('0x69')]))[_0xbc08('0x6a')]('base64'))},'json':!![]});}})[_0xbc08('0x33')](function(_0x1de58e){if(_0x1de58e){var _0x559781=[_0xbc08('0x6b'),_0xbc08('0x6c'),_0xbc08('0x6d'),_0xbc08('0x6e'),'status',_0xbc08('0x6f'),_0xbc08('0x70'),_0xbc08('0x71'),_0xbc08('0x72'),_0xbc08('0x70'),'company'];_[_0xbc08('0x73')](_0x1de58e,function(_0x5092a5){return _0x559781['includes'](_0x5092a5['name'])||!_0x5092a5[_0xbc08('0x74')]&&_0x5092a5['type']!==_0xbc08('0x75')&&_0x5092a5[_0xbc08('0x47')]!==_0xbc08('0x76');});return{'count':_0x1de58e[_0xbc08('0x3f')],'rows':_[_0xbc08('0x59')](_0x1de58e,function(_0x10271c){return{'id':_0x10271c[_0xbc08('0x36')],'name':_0x10271c[_0xbc08('0x77')],'custom':!_0x10271c[_0xbc08('0x74')],'options':_0x10271c[_0xbc08('0x78')]?_[_0xbc08('0x59')](_0x10271c[_0xbc08('0x78')],function(_0x51b019){return{'name':_[_0xbc08('0x79')](_0x51b019),'value':_0x51b019};}):[]};})};}})[_0xbc08('0x33')](respondWithResult(_0x417984,null))[_0xbc08('0x27')](function(_0x1141fe){var _0x1f855e=_0x3e2c06['query'][_0xbc08('0x1d')]?0x1f4:_0x1141fe[_0xbc08('0x7a')]||0x1f4;logger[_0xbc08('0x23')](_0xbc08('0x7b'),_0xbc08('0x7c'),_0x1f855e,JSON[_0xbc08('0x22')](_0x1141fe));delete _0x1141fe['name'];if(_0x1f855e===0x191){_0x1f855e=0x190;}_0x417984['status'](_0x1f855e)[_0xbc08('0x7d')](_0x3e2c06['query'][_0xbc08('0x1d')]?{'message':_0xbc08('0x7e'),'statusCode':_0x1141fe[_0xbc08('0x7a')]}:_0x1141fe);});};
\ No newline at end of file
+var _0xf440=['to-csv','lodash','squel','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','test','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','FreshdeskAccount,\x20%s,\x20%s','request\x20sent','FreshdeskAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','end','stack','name','send','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','filter','merge','map','key','VIRTUAL','field','options','includeAll','include','FreshdeskAccount','findAll','rows','show','rawAttributes','find','create','body','params','getConfigurations','FreshdeskConfiguration','pick','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','type','Descriptions','getDescriptions','FreshdeskField','remoteUri','apiKey','slice','substring','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','requester','subject','agent','description','group','source','ticket_type','company','remove','includes','default','custom_dropdown','label','choices','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox'];(function(_0x2e0ba6,_0x2b3337){var _0x3b638a=function(_0x3e462b){while(--_0x3e462b){_0x2e0ba6['push'](_0x2e0ba6['shift']());}};_0x3b638a(++_0x2b3337);}(_0xf440,0x1ea));var _0x0f44=function(_0x1035c1,_0x2d8583){_0x1035c1=_0x1035c1-0x0;var _0x308d67=_0xf440[_0x1035c1];return _0x308d67;};'use strict';var pdf=require(_0x0f44('0x0'));var emlformat=require(_0x0f44('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x0f44('0x2'));var jsonpatch=require(_0x0f44('0x3'));var rp=require(_0x0f44('0x4'));var moment=require(_0x0f44('0x5'));var BPromise=require(_0x0f44('0x6'));var Mustache=require('mustache');var util=require(_0x0f44('0x7'));var path=require(_0x0f44('0x8'));var sox=require(_0x0f44('0x9'));var csv=require(_0x0f44('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x0f44('0xb'));var squel=require(_0x0f44('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0f44('0xd'));var toCsv=require('to-csv');var querystring=require(_0x0f44('0xe'));var Papa=require('papaparse');var Redis=require(_0x0f44('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x0f44('0x10'));var hardwareService=require(_0x0f44('0x11'));var logger=require(_0x0f44('0x12'))(_0x0f44('0x13'));var utils=require('../../config/utils');var config=require(_0x0f44('0x14'));var db=require(_0x0f44('0x15'))['db'];var integrations=require(_0x0f44('0x16'));var jayson=require(_0x0f44('0x17'));var client=jayson[_0x0f44('0x18')]['http']({'port':0x232a});function checkPasswordPattern(_0x2c141d,_0x44e371,_0x10e71b){if(_0x10e71b){var _0x6e9663=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x6e9663[_0x0f44('0x19')](_0x44e371)){return _0x2c141d;}else{throw new Error(_0x0f44('0x1a'));}}else{return _0x2c141d;}}function respondWithRpcPromise(_0x2f4b68,_0x5b4438,_0x7807e8,_0x49c9b2){return new BPromise(function(_0x12567c,_0x577e54){var _0x4df0c6=_0x49c9b2||client;return _0x4df0c6[_0x0f44('0x1b')](_0x2f4b68,_0x7807e8)[_0x0f44('0x1c')](function(_0x5bb2f2){logger[_0x0f44('0x1d')](_0x0f44('0x1e'),_0x5b4438,_0x0f44('0x1f'));logger['debug'](_0x0f44('0x20'),_0x5b4438,'request\x20sent',JSON['stringify'](_0x5bb2f2));if(_0x5bb2f2[_0x0f44('0x21')]){if(_0x5bb2f2['error'][_0x0f44('0x22')]===0x1f4){logger[_0x0f44('0x21')]('FreshdeskAccount,\x20%s,\x20%s',_0x5b4438,_0x5bb2f2[_0x0f44('0x21')]['message']);return _0x577e54(_0x5bb2f2['error'][_0x0f44('0x23')]);}logger[_0x0f44('0x21')](_0x0f44('0x1e'),_0x5b4438,_0x5bb2f2[_0x0f44('0x21')][_0x0f44('0x23')]);return _0x12567c(_0x5bb2f2[_0x0f44('0x21')][_0x0f44('0x23')]);}else{logger['info'](_0x0f44('0x1e'),_0x5b4438,'request\x20sent');_0x12567c(_0x5bb2f2[_0x0f44('0x24')]['message']);}})[_0x0f44('0x25')](function(_0x769a6d){logger[_0x0f44('0x21')]('FreshdeskAccount,\x20%s,\x20%s',_0x5b4438,_0x769a6d);_0x577e54(_0x769a6d);});});}function respondWithStatusCode(_0x2430ff,_0x326231){_0x326231=_0x326231||0xcc;return function(_0x2da3ea){if(_0x2da3ea){return _0x2430ff[_0x0f44('0x26')](_0x326231);}return _0x2430ff[_0x0f44('0x27')](_0x326231)['end']();};}function respondWithResult(_0x36a206,_0x32b0da){_0x32b0da=_0x32b0da||0xc8;return function(_0xc07d44){if(_0xc07d44){return _0x36a206['status'](_0x32b0da)[_0x0f44('0x28')](_0xc07d44);}};}function respondWithFilteredResult(_0x46fc43,_0x5e714c){return function(_0x50644c){if(_0x50644c){var _0x26b32b=_0x50644c[_0x0f44('0x29')],_0xb86e44=_0x5e714c[_0x0f44('0x2a')],_0x2aa295=_0x5e714c['offset']+_0x5e714c[_0x0f44('0x2b')],_0x378126;if(_0x2aa295>=_0x26b32b){_0x2aa295=_0x26b32b;_0x378126=0xc8;}else{_0x378126=0xce;}_0x46fc43[_0x0f44('0x27')](_0x378126);return _0x46fc43[_0x0f44('0x2c')](_0x0f44('0x2d'),_0xb86e44+'-'+_0x2aa295+'/'+_0x26b32b)['json'](_0x50644c);}return null;};}function patchUpdates(_0x4e9f10){return function(_0x2d5968){try{jsonpatch[_0x0f44('0x2e')](_0x2d5968,_0x4e9f10,!![]);}catch(_0x43e943){return BPromise[_0x0f44('0x2f')](_0x43e943);}return _0x2d5968[_0x0f44('0x30')]();};}function saveUpdates(_0x4749b6,_0x23d82e){return function(_0x45de6d){if(_0x45de6d){return _0x45de6d[_0x0f44('0x31')](_0x4749b6)[_0x0f44('0x1c')](function(_0x4d03c1){return _0x4d03c1;});}return null;};}function removeEntity(_0x4fbc58,_0x45b3d0){return function(_0x76c934){if(_0x76c934){return _0x76c934[_0x0f44('0x32')]()[_0x0f44('0x1c')](function(){_0x4fbc58[_0x0f44('0x27')](0xcc)[_0x0f44('0x33')]();});}};}function handleEntityNotFound(_0x397a2f,_0x2634d3){return function(_0x16fc4f){if(!_0x16fc4f){_0x397a2f[_0x0f44('0x26')](0x194);}return _0x16fc4f;};}function handleError(_0x2f6c64,_0x276da0){_0x276da0=_0x276da0||0x1f4;return function(_0xd3de49){logger[_0x0f44('0x21')](_0xd3de49[_0x0f44('0x34')]);if(_0xd3de49[_0x0f44('0x35')]){delete _0xd3de49['name'];}_0x2f6c64['status'](_0x276da0)[_0x0f44('0x36')](_0xd3de49);};}exports['index']=function(_0x533d86,_0x248088){var _0x6653c4={},_0x26ed3c={},_0x27eef6={'count':0x0,'rows':[]};var _0x1b375c=db['FreshdeskAccount']['rawAttributes'];_0x26ed3c[_0x0f44('0x37')]=_[_0x0f44('0x38')](_0x1b375c);_0x26ed3c[_0x0f44('0x39')]=_['keys'](_0x533d86[_0x0f44('0x39')]);_0x26ed3c[_0x0f44('0x3a')]=_[_0x0f44('0x3b')](_0x26ed3c['model'],_0x26ed3c[_0x0f44('0x39')]);_0x6653c4['attributes']=_['intersection'](_0x26ed3c['model'],qs[_0x0f44('0x3c')](_0x533d86[_0x0f44('0x39')][_0x0f44('0x3c')]));_0x6653c4[_0x0f44('0x3d')]=_0x6653c4[_0x0f44('0x3d')][_0x0f44('0x3e')]?_0x6653c4['attributes']:_0x26ed3c[_0x0f44('0x37')];if(!_0x533d86[_0x0f44('0x39')][_0x0f44('0x3f')]('nolimit')){_0x6653c4[_0x0f44('0x2b')]=qs[_0x0f44('0x2b')](_0x533d86['query']['limit']);_0x6653c4[_0x0f44('0x2a')]=qs[_0x0f44('0x2a')](_0x533d86[_0x0f44('0x39')]['offset']);}_0x6653c4[_0x0f44('0x40')]=qs[_0x0f44('0x41')](_0x533d86['query'][_0x0f44('0x41')]);_0x6653c4[_0x0f44('0x42')]=qs['filters'](_['pick'](_0x533d86['query'],_0x26ed3c[_0x0f44('0x3a')]));if(_0x533d86[_0x0f44('0x39')][_0x0f44('0x43')]){_0x6653c4[_0x0f44('0x42')]=_[_0x0f44('0x44')](_0x6653c4['where'],{'$or':_[_0x0f44('0x45')](_0x1b375c,function(_0x428384){if(_0x428384['type'][_0x0f44('0x46')]!==_0x0f44('0x47')){var _0x1a6827={};_0x1a6827[_0x428384[_0x0f44('0x48')]]={'$like':'%'+_0x533d86[_0x0f44('0x39')][_0x0f44('0x43')]+'%'};return _0x1a6827;}})});}_0x6653c4=_[_0x0f44('0x44')]({},_0x6653c4,_0x533d86[_0x0f44('0x49')]);var _0x24a532={'where':_0x6653c4[_0x0f44('0x42')]};return db['FreshdeskAccount'][_0x0f44('0x29')](_0x24a532)[_0x0f44('0x1c')](function(_0x53958e){_0x27eef6[_0x0f44('0x29')]=_0x53958e;if(_0x533d86[_0x0f44('0x39')][_0x0f44('0x4a')]){_0x6653c4[_0x0f44('0x4b')]=[{'all':!![]}];}return db[_0x0f44('0x4c')][_0x0f44('0x4d')](_0x6653c4);})['then'](function(_0x387132){_0x27eef6[_0x0f44('0x4e')]=_0x387132;return _0x27eef6;})[_0x0f44('0x1c')](respondWithFilteredResult(_0x248088,_0x6653c4))[_0x0f44('0x25')](handleError(_0x248088,null));};exports[_0x0f44('0x4f')]=function(_0x59add8,_0x46ed58){var _0x32b63b={'raw':![],'where':{'id':_0x59add8['params']['id']}},_0x2700fa={};_0x2700fa[_0x0f44('0x37')]=_['keys'](db[_0x0f44('0x4c')][_0x0f44('0x50')]);_0x2700fa['query']=_[_0x0f44('0x38')](_0x59add8['query']);_0x2700fa[_0x0f44('0x3a')]=_[_0x0f44('0x3b')](_0x2700fa[_0x0f44('0x37')],_0x2700fa[_0x0f44('0x39')]);_0x32b63b[_0x0f44('0x3d')]=_['intersection'](_0x2700fa[_0x0f44('0x37')],qs[_0x0f44('0x3c')](_0x59add8[_0x0f44('0x39')]['fields']));_0x32b63b[_0x0f44('0x3d')]=_0x32b63b[_0x0f44('0x3d')][_0x0f44('0x3e')]?_0x32b63b[_0x0f44('0x3d')]:_0x2700fa[_0x0f44('0x37')];if(_0x59add8[_0x0f44('0x39')]['includeAll']){_0x32b63b[_0x0f44('0x4b')]=[{'all':!![]}];}_0x32b63b=_[_0x0f44('0x44')]({},_0x32b63b,_0x59add8['options']);return db[_0x0f44('0x4c')][_0x0f44('0x51')](_0x32b63b)[_0x0f44('0x1c')](handleEntityNotFound(_0x46ed58,null))['then'](respondWithResult(_0x46ed58,null))[_0x0f44('0x25')](handleError(_0x46ed58,null));};exports[_0x0f44('0x52')]=function(_0x5cb167,_0x257223){return db[_0x0f44('0x4c')][_0x0f44('0x52')](_0x5cb167[_0x0f44('0x53')],{})[_0x0f44('0x1c')](respondWithResult(_0x257223,0xc9))[_0x0f44('0x25')](handleError(_0x257223,null));};exports[_0x0f44('0x31')]=function(_0x27e4b0,_0x562bca){if(_0x27e4b0[_0x0f44('0x53')]['id']){delete _0x27e4b0[_0x0f44('0x53')]['id'];}return db[_0x0f44('0x4c')]['find']({'where':{'id':_0x27e4b0[_0x0f44('0x54')]['id']}})[_0x0f44('0x1c')](handleEntityNotFound(_0x562bca,null))[_0x0f44('0x1c')](saveUpdates(_0x27e4b0[_0x0f44('0x53')],null))[_0x0f44('0x1c')](respondWithResult(_0x562bca,null))['catch'](handleError(_0x562bca,null));};exports[_0x0f44('0x32')]=function(_0x48cbf3,_0x3ae23a){return db['FreshdeskAccount']['find']({'where':{'id':_0x48cbf3[_0x0f44('0x54')]['id']}})[_0x0f44('0x1c')](handleEntityNotFound(_0x3ae23a,null))[_0x0f44('0x1c')](removeEntity(_0x3ae23a,null))[_0x0f44('0x25')](handleError(_0x3ae23a,null));};exports[_0x0f44('0x55')]=function(_0x2e9935,_0x51d4ae,_0x4c0320){var _0x25df7f={};var _0x1d88f2={};var _0x25a693;var _0x1955be;return db[_0x0f44('0x4c')]['findOne']({'where':{'id':_0x2e9935['params']['id']}})[_0x0f44('0x1c')](handleEntityNotFound(_0x51d4ae,null))[_0x0f44('0x1c')](function(_0x73ad4d){if(_0x73ad4d){_0x25a693=_0x73ad4d;_0x1d88f2[_0x0f44('0x37')]=_['keys'](db[_0x0f44('0x56')][_0x0f44('0x50')]);_0x1d88f2['query']=_[_0x0f44('0x38')](_0x2e9935[_0x0f44('0x39')]);_0x1d88f2[_0x0f44('0x3a')]=_['intersection'](_0x1d88f2[_0x0f44('0x37')],_0x1d88f2[_0x0f44('0x39')]);_0x25df7f[_0x0f44('0x3d')]=_['intersection'](_0x1d88f2[_0x0f44('0x37')],qs[_0x0f44('0x3c')](_0x2e9935['query']['fields']));_0x25df7f['attributes']=_0x25df7f[_0x0f44('0x3d')][_0x0f44('0x3e')]?_0x25df7f[_0x0f44('0x3d')]:_0x1d88f2[_0x0f44('0x37')];_0x25df7f[_0x0f44('0x40')]=qs[_0x0f44('0x41')](_0x2e9935[_0x0f44('0x39')][_0x0f44('0x41')]);_0x25df7f[_0x0f44('0x42')]=qs[_0x0f44('0x3a')](_[_0x0f44('0x57')](_0x2e9935[_0x0f44('0x39')],_0x1d88f2[_0x0f44('0x3a')]));if(_0x2e9935['query']['filter']){_0x25df7f[_0x0f44('0x42')]=_[_0x0f44('0x44')](_0x25df7f[_0x0f44('0x42')],{'$or':_[_0x0f44('0x45')](_0x25df7f[_0x0f44('0x3d')],function(_0x187c24){var _0x4fceb1={};_0x4fceb1[_0x187c24]={'$like':'%'+_0x2e9935[_0x0f44('0x39')][_0x0f44('0x43')]+'%'};return _0x4fceb1;})});}_0x25df7f=_[_0x0f44('0x44')]({},_0x25df7f,_0x2e9935[_0x0f44('0x49')]);return _0x25a693['getConfigurations'](_0x25df7f);}})['then'](function(_0x37e97e){if(_0x37e97e){_0x1955be=_0x37e97e[_0x0f44('0x3e')];if(!_0x2e9935['query'][_0x0f44('0x3f')]('nolimit')){_0x25df7f[_0x0f44('0x2b')]=qs[_0x0f44('0x2b')](_0x2e9935['query'][_0x0f44('0x2b')]);_0x25df7f[_0x0f44('0x2a')]=qs['offset'](_0x2e9935[_0x0f44('0x39')]['offset']);}return _0x25a693[_0x0f44('0x55')](_0x25df7f);}})[_0x0f44('0x1c')](function(_0x3df588){if(_0x3df588){return _0x3df588?{'count':_0x1955be,'rows':_0x3df588}:null;}})[_0x0f44('0x1c')](respondWithResult(_0x51d4ae,null))[_0x0f44('0x25')](handleError(_0x51d4ae,null));};exports[_0x0f44('0x58')]=function(_0x310131,_0x3d0294,_0x550a4e){if(_0x310131[_0x0f44('0x53')]['id']){delete _0x310131['body']['id'];}return db[_0x0f44('0x4c')][_0x0f44('0x59')]({'where':{'id':_0x310131['params']['id']}})[_0x0f44('0x1c')](handleEntityNotFound(_0x3d0294,null))[_0x0f44('0x1c')](function(_0x278183){if(_0x278183){_0x310131[_0x0f44('0x53')][_0x0f44('0x5a')]=_0x278183['id'];_0x310131[_0x0f44('0x53')][_0x0f44('0x5b')]=integrations[_0x0f44('0x5c')](_0x310131[_0x0f44('0x53')][_0x0f44('0x5d')],_0x310131[_0x0f44('0x53')][_0x0f44('0x5e')]);_0x310131[_0x0f44('0x53')][_0x0f44('0x5f')]=integrations[_0x0f44('0x60')](_0x310131[_0x0f44('0x53')][_0x0f44('0x5d')],_0x310131[_0x0f44('0x53')][_0x0f44('0x5e')]);return db[_0x0f44('0x56')]['create'](_0x310131['body'],{'include':[{'model':db[_0x0f44('0x61')],'as':_0x0f44('0x5b')},{'model':db[_0x0f44('0x61')],'as':'Descriptions'}]});}return null;})[_0x0f44('0x1c')](respondWithResult(_0x3d0294,null))[_0x0f44('0x25')](handleError(_0x3d0294,null));};exports['getFields']=function(_0x42bf44,_0x3f0776,_0x1a37e5){var _0x305f94='';return db['FreshdeskAccount'][_0x0f44('0x59')]({'where':{'id':_0x42bf44[_0x0f44('0x54')]['id']},'attributes':['id',_0x0f44('0x62'),_0x0f44('0x63')]})[_0x0f44('0x1c')](handleEntityNotFound(_0x3f0776,null))['then'](function(_0x2e82fb){if(_0x2e82fb){_0x305f94=_0x2e82fb['remoteUri'];var _0x9c7561=_0x305f94[_0x0f44('0x64')](-0x1);if(_0x9c7561==='/'){_0x305f94=_0x305f94[_0x0f44('0x65')](0x0,_0x305f94[_0x0f44('0x66')](_0x9c7561));}return rp({'method':_0x0f44('0x67'),'uri':util[_0x0f44('0x68')](_0x0f44('0x69'),_0x305f94,_0x0f44('0x6a')),'headers':{'Authorization':util[_0x0f44('0x68')]('Basic\x20%s',new Buffer(util[_0x0f44('0x68')]('%s:X',_0x2e82fb['apiKey']))['toString']('base64'))},'json':!![]});}})[_0x0f44('0x1c')](function(_0x217b27){if(_0x217b27){var _0x440ab5=[_0x0f44('0x6b'),_0x0f44('0x6c'),_0x0f44('0x6d'),_0x0f44('0x6e'),_0x0f44('0x27'),'priority',_0x0f44('0x6f'),_0x0f44('0x70'),_0x0f44('0x71'),_0x0f44('0x6f'),_0x0f44('0x72')];_[_0x0f44('0x73')](_0x217b27,function(_0xfdef50){return _0x440ab5[_0x0f44('0x74')](_0xfdef50[_0x0f44('0x35')])||!_0xfdef50[_0x0f44('0x75')]&&_0xfdef50[_0x0f44('0x5e')]!=='custom_text'&&_0xfdef50[_0x0f44('0x5e')]!==_0x0f44('0x76');});return{'count':_0x217b27[_0x0f44('0x3e')],'rows':_[_0x0f44('0x45')](_0x217b27,function(_0x490d79){return{'id':_0x490d79['name'],'name':_0x490d79[_0x0f44('0x77')],'custom':!_0x490d79[_0x0f44('0x75')],'options':_0x490d79['choices']?_[_0x0f44('0x45')](_0x490d79[_0x0f44('0x78')],function(_0x4da9cd){return{'name':_['capitalize'](_0x4da9cd),'value':_0x4da9cd};}):[]};})};}})[_0x0f44('0x1c')](respondWithResult(_0x3f0776,null))[_0x0f44('0x25')](function(_0x3c369f){var _0x3c24b4=_0x42bf44[_0x0f44('0x39')][_0x0f44('0x19')]?0x1f4:_0x3c369f[_0x0f44('0x79')]||0x1f4;logger['error'](_0x0f44('0x7a'),_0x0f44('0x7b'),_0x3c24b4,JSON[_0x0f44('0x7c')](_0x3c369f));delete _0x3c369f[_0x0f44('0x35')];if(_0x3c24b4===0x191){_0x3c24b4=0x190;}_0x3f0776[_0x0f44('0x27')](_0x3c24b4)['send'](_0x42bf44[_0x0f44('0x39')][_0x0f44('0x19')]?{'message':'Wrong\x20credentials','statusCode':_0x3c369f['statusCode']}:_0x3c369f);});};
\ No newline at end of file