Built motion from commit f7863d46.|2.5.41
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 0f1ec6a..8f0353b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff76=['group','source','company','includes','default','custom_dropdown','label','choices','capitalize','test','statusCode','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','then','info','debug','FreshdeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FreshdeskAccount,\x20%s,\x20%s','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','update','destroy','stack','name','send','map','FreshdeskAccount','rawAttributes','fieldName','type','model','query','keys','intersection','attributes','fields','nolimit','order','filters','pick','filter','where','merge','VIRTUAL','includeAll','rows','show','params','length','include','options','find','create','body','getConfigurations','findOne','FreshdeskConfiguration','sort','addConfiguration','Subjects','getSubjects','Descriptions','getDescriptions','channel','FreshdeskField','getFields','remoteUri','substring','GET','format','%s:X','requester','subject','priority'];(function(_0x27f9d3,_0x54ee48){var _0x1d2c10=function(_0x591eae){while(--_0x591eae){_0x27f9d3['push'](_0x27f9d3['shift']());}};_0x1d2c10(++_0x54ee48);}(_0xff76,0xf6));var _0x6ff7=function(_0xa1e3e3,_0x29fe0e){_0xa1e3e3=_0xa1e3e3-0x0;var _0xc980e9=_0xff76[_0xa1e3e3];return _0xc980e9;};'use strict';var pdf=require(_0x6ff7('0x0'));var emlformat=require(_0x6ff7('0x1'));var rimraf=require(_0x6ff7('0x2'));var zipdir=require(_0x6ff7('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6ff7('0x4'));var moment=require(_0x6ff7('0x5'));var BPromise=require(_0x6ff7('0x6'));var Mustache=require(_0x6ff7('0x7'));var util=require(_0x6ff7('0x8'));var path=require(_0x6ff7('0x9'));var sox=require('sox');var csv=require(_0x6ff7('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x6ff7('0xb'));var squel=require('squel');var crypto=require(_0x6ff7('0xc'));var jsforce=require(_0x6ff7('0xd'));var deskjs=require(_0x6ff7('0xe'));var toCsv=require('to-csv');var querystring=require(_0x6ff7('0xf'));var Papa=require(_0x6ff7('0x10'));var Redis=require(_0x6ff7('0x11'));var authService=require(_0x6ff7('0x12'));var qs=require(_0x6ff7('0x13'));var as=require(_0x6ff7('0x14'));var hardwareService=require(_0x6ff7('0x15'));var logger=require(_0x6ff7('0x16'))(_0x6ff7('0x17'));var utils=require('../../config/utils');var config=require(_0x6ff7('0x18'));var licenseUtil=require(_0x6ff7('0x19'));var db=require(_0x6ff7('0x1a'))['db'];var integrations=require(_0x6ff7('0x1b'));var jayson=require(_0x6ff7('0x1c'));var client=jayson[_0x6ff7('0x1d')][_0x6ff7('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x49da13,_0x3ee507,_0x2f25c3,_0x151150){return new BPromise(function(_0x11ec60,_0x432d2b){var _0x3518ea=_0x151150||client;return _0x3518ea['request'](_0x49da13,_0x2f25c3)[_0x6ff7('0x1f')](function(_0x26421a){logger[_0x6ff7('0x20')]('FreshdeskAccount,\x20%s,\x20%s',_0x3ee507,'request\x20sent');logger[_0x6ff7('0x21')](_0x6ff7('0x22'),_0x3ee507,'request\x20sent',JSON[_0x6ff7('0x23')](_0x26421a));if(_0x26421a['error']){if(_0x26421a[_0x6ff7('0x24')][_0x6ff7('0x25')]===0x1f4){logger[_0x6ff7('0x24')]('FreshdeskAccount,\x20%s,\x20%s',_0x3ee507,_0x26421a[_0x6ff7('0x24')][_0x6ff7('0x26')]);return _0x432d2b(_0x26421a[_0x6ff7('0x24')][_0x6ff7('0x26')]);}logger[_0x6ff7('0x24')](_0x6ff7('0x27'),_0x3ee507,_0x26421a[_0x6ff7('0x24')][_0x6ff7('0x26')]);return _0x11ec60(_0x26421a[_0x6ff7('0x24')][_0x6ff7('0x26')]);}else{logger[_0x6ff7('0x20')](_0x6ff7('0x27'),_0x3ee507,'request\x20sent');_0x11ec60(_0x26421a['result'][_0x6ff7('0x26')]);}})[_0x6ff7('0x28')](function(_0x5d18b){logger[_0x6ff7('0x24')]('FreshdeskAccount,\x20%s,\x20%s',_0x3ee507,_0x5d18b);_0x432d2b(_0x5d18b);});});}function respondWithStatusCode(_0x2fd7e8,_0x396055){_0x396055=_0x396055||0xcc;return function(_0x17901e){if(_0x17901e){return _0x2fd7e8[_0x6ff7('0x29')](_0x396055);}return _0x2fd7e8[_0x6ff7('0x2a')](_0x396055)[_0x6ff7('0x2b')]();};}function respondWithResult(_0x441677,_0x519cc9){_0x519cc9=_0x519cc9||0xc8;return function(_0x7cee87){if(_0x7cee87){return _0x441677['status'](_0x519cc9)['json'](_0x7cee87);}};}function respondWithFilteredResult(_0x55047b,_0x101faf){return function(_0x91c07e){if(_0x91c07e){var _0x533e86=_0x91c07e[_0x6ff7('0x2c')],_0x4d4aeb=_0x101faf[_0x6ff7('0x2d')],_0x401e08=_0x101faf[_0x6ff7('0x2d')]+_0x101faf[_0x6ff7('0x2e')],_0x4f0c98;if(_0x401e08>=_0x533e86){_0x401e08=_0x533e86;_0x4f0c98=0xc8;}else{_0x4f0c98=0xce;}_0x55047b[_0x6ff7('0x2a')](_0x4f0c98);return _0x55047b[_0x6ff7('0x2f')](_0x6ff7('0x30'),_0x4d4aeb+'-'+_0x401e08+'/'+_0x533e86)[_0x6ff7('0x31')](_0x91c07e);}return null;};}function patchUpdates(_0x1a97a7){return function(_0x5925c5){try{jsonpatch[_0x6ff7('0x32')](_0x5925c5,_0x1a97a7,!![]);}catch(_0x137026){return BPromise['reject'](_0x137026);}return _0x5925c5['save']();};}function saveUpdates(_0x12b5cc,_0x34d459){return function(_0x42b9de){if(_0x42b9de){return _0x42b9de[_0x6ff7('0x33')](_0x12b5cc)['then'](function(_0x258493){return _0x258493;});}return null;};}function removeEntity(_0x18dfb3,_0x1d4b57){return function(_0x29704a){if(_0x29704a){return _0x29704a[_0x6ff7('0x34')]()['then'](function(){_0x18dfb3['status'](0xcc)[_0x6ff7('0x2b')]();});}};}function handleEntityNotFound(_0x1d4c82,_0x4fde7d){return function(_0x55a589){if(!_0x55a589){_0x1d4c82[_0x6ff7('0x29')](0x194);}return _0x55a589;};}function handleError(_0x2c8a71,_0x2aec73){_0x2aec73=_0x2aec73||0x1f4;return function(_0x2d169a){logger[_0x6ff7('0x24')](_0x2d169a[_0x6ff7('0x35')]);if(_0x2d169a[_0x6ff7('0x36')]){delete _0x2d169a[_0x6ff7('0x36')];}_0x2c8a71['status'](_0x2aec73)[_0x6ff7('0x37')](_0x2d169a);};}exports['index']=function(_0x231954,_0x36f500){var _0x310115={},_0x445a45={},_0x1c5556={'count':0x0,'rows':[]};var _0x3d4bbc=_[_0x6ff7('0x38')](db[_0x6ff7('0x39')][_0x6ff7('0x3a')],function(_0x5bf55d){return{'name':_0x5bf55d[_0x6ff7('0x3b')],'type':_0x5bf55d[_0x6ff7('0x3c')]['key']};});_0x445a45[_0x6ff7('0x3d')]=_[_0x6ff7('0x38')](_0x3d4bbc,_0x6ff7('0x36'));_0x445a45[_0x6ff7('0x3e')]=_[_0x6ff7('0x3f')](_0x231954[_0x6ff7('0x3e')]);_0x445a45['filters']=_[_0x6ff7('0x40')](_0x445a45[_0x6ff7('0x3d')],_0x445a45[_0x6ff7('0x3e')]);_0x310115[_0x6ff7('0x41')]=_['intersection'](_0x445a45[_0x6ff7('0x3d')],qs[_0x6ff7('0x42')](_0x231954[_0x6ff7('0x3e')]['fields']));_0x310115['attributes']=_0x310115[_0x6ff7('0x41')]['length']?_0x310115[_0x6ff7('0x41')]:_0x445a45[_0x6ff7('0x3d')];if(!_0x231954[_0x6ff7('0x3e')]['hasOwnProperty'](_0x6ff7('0x43'))){_0x310115['limit']=qs[_0x6ff7('0x2e')](_0x231954[_0x6ff7('0x3e')][_0x6ff7('0x2e')]);_0x310115[_0x6ff7('0x2d')]=qs[_0x6ff7('0x2d')](_0x231954[_0x6ff7('0x3e')][_0x6ff7('0x2d')]);}_0x310115[_0x6ff7('0x44')]=qs['sort'](_0x231954['query']['sort']);_0x310115['where']=qs[_0x6ff7('0x45')](_[_0x6ff7('0x46')](_0x231954[_0x6ff7('0x3e')],_0x445a45[_0x6ff7('0x45')]),_0x3d4bbc);if(_0x231954['query'][_0x6ff7('0x47')]){_0x310115[_0x6ff7('0x48')]=_[_0x6ff7('0x49')](_0x310115[_0x6ff7('0x48')],{'$or':_[_0x6ff7('0x38')](_0x3d4bbc,function(_0x198f89){if(_0x198f89[_0x6ff7('0x3c')]!==_0x6ff7('0x4a')){var _0xea9a31={};_0xea9a31[_0x198f89[_0x6ff7('0x36')]]={'$like':'%'+_0x231954[_0x6ff7('0x3e')][_0x6ff7('0x47')]+'%'};return _0xea9a31;}})});}_0x310115=_[_0x6ff7('0x49')]({},_0x310115,_0x231954['options']);var _0x1569ce={'where':_0x310115[_0x6ff7('0x48')]};return db[_0x6ff7('0x39')][_0x6ff7('0x2c')](_0x1569ce)['then'](function(_0x1000ef){_0x1c5556['count']=_0x1000ef;if(_0x231954[_0x6ff7('0x3e')][_0x6ff7('0x4b')]){_0x310115['include']=[{'all':!![]}];}return db[_0x6ff7('0x39')]['findAll'](_0x310115);})[_0x6ff7('0x1f')](function(_0x7d403a){_0x1c5556[_0x6ff7('0x4c')]=_0x7d403a;return _0x1c5556;})['then'](respondWithFilteredResult(_0x36f500,_0x310115))['catch'](handleError(_0x36f500,null));};exports[_0x6ff7('0x4d')]=function(_0xa4b428,_0x3c3b54){var _0xb0378b={'raw':![],'where':{'id':_0xa4b428[_0x6ff7('0x4e')]['id']}},_0x9bc11a={};_0x9bc11a[_0x6ff7('0x3d')]=_[_0x6ff7('0x3f')](db['FreshdeskAccount'][_0x6ff7('0x3a')]);_0x9bc11a['query']=_[_0x6ff7('0x3f')](_0xa4b428['query']);_0x9bc11a[_0x6ff7('0x45')]=_[_0x6ff7('0x40')](_0x9bc11a['model'],_0x9bc11a['query']);_0xb0378b[_0x6ff7('0x41')]=_[_0x6ff7('0x40')](_0x9bc11a[_0x6ff7('0x3d')],qs[_0x6ff7('0x42')](_0xa4b428[_0x6ff7('0x3e')][_0x6ff7('0x42')]));_0xb0378b[_0x6ff7('0x41')]=_0xb0378b[_0x6ff7('0x41')][_0x6ff7('0x4f')]?_0xb0378b[_0x6ff7('0x41')]:_0x9bc11a[_0x6ff7('0x3d')];if(_0xa4b428[_0x6ff7('0x3e')][_0x6ff7('0x4b')]){_0xb0378b[_0x6ff7('0x50')]=[{'all':!![]}];}_0xb0378b=_[_0x6ff7('0x49')]({},_0xb0378b,_0xa4b428[_0x6ff7('0x51')]);return db[_0x6ff7('0x39')][_0x6ff7('0x52')](_0xb0378b)[_0x6ff7('0x1f')](handleEntityNotFound(_0x3c3b54,null))[_0x6ff7('0x1f')](respondWithResult(_0x3c3b54,null))['catch'](handleError(_0x3c3b54,null));};exports[_0x6ff7('0x53')]=function(_0x3120a5,_0x360425){return db[_0x6ff7('0x39')][_0x6ff7('0x53')](_0x3120a5['body'],{})[_0x6ff7('0x1f')](respondWithResult(_0x360425,0xc9))[_0x6ff7('0x28')](handleError(_0x360425,null));};exports[_0x6ff7('0x33')]=function(_0x517870,_0x255bda){if(_0x517870[_0x6ff7('0x54')]['id']){delete _0x517870[_0x6ff7('0x54')]['id'];}return db[_0x6ff7('0x39')][_0x6ff7('0x52')]({'where':{'id':_0x517870[_0x6ff7('0x4e')]['id']}})['then'](handleEntityNotFound(_0x255bda,null))[_0x6ff7('0x1f')](saveUpdates(_0x517870[_0x6ff7('0x54')],null))[_0x6ff7('0x1f')](respondWithResult(_0x255bda,null))[_0x6ff7('0x28')](handleError(_0x255bda,null));};exports[_0x6ff7('0x34')]=function(_0x25ef65,_0x32f6b4){return db['FreshdeskAccount']['find']({'where':{'id':_0x25ef65[_0x6ff7('0x4e')]['id']}})[_0x6ff7('0x1f')](handleEntityNotFound(_0x32f6b4,null))[_0x6ff7('0x1f')](removeEntity(_0x32f6b4,null))['catch'](handleError(_0x32f6b4,null));};exports[_0x6ff7('0x55')]=function(_0x127288,_0x37c7dd,_0x4bda6e){var _0x49fc43={};var _0x224ee2={};var _0x35e228;var _0x5a268a;return db[_0x6ff7('0x39')][_0x6ff7('0x56')]({'where':{'id':_0x127288[_0x6ff7('0x4e')]['id']}})[_0x6ff7('0x1f')](handleEntityNotFound(_0x37c7dd,null))[_0x6ff7('0x1f')](function(_0x2adbf0){if(_0x2adbf0){_0x35e228=_0x2adbf0;_0x224ee2[_0x6ff7('0x3d')]=_['keys'](db[_0x6ff7('0x57')][_0x6ff7('0x3a')]);_0x224ee2[_0x6ff7('0x3e')]=_[_0x6ff7('0x3f')](_0x127288['query']);_0x224ee2[_0x6ff7('0x45')]=_[_0x6ff7('0x40')](_0x224ee2[_0x6ff7('0x3d')],_0x224ee2[_0x6ff7('0x3e')]);_0x49fc43[_0x6ff7('0x41')]=_[_0x6ff7('0x40')](_0x224ee2['model'],qs[_0x6ff7('0x42')](_0x127288[_0x6ff7('0x3e')]['fields']));_0x49fc43['attributes']=_0x49fc43['attributes'][_0x6ff7('0x4f')]?_0x49fc43[_0x6ff7('0x41')]:_0x224ee2[_0x6ff7('0x3d')];_0x49fc43[_0x6ff7('0x44')]=qs[_0x6ff7('0x58')](_0x127288[_0x6ff7('0x3e')][_0x6ff7('0x58')]);_0x49fc43['where']=qs[_0x6ff7('0x45')](_[_0x6ff7('0x46')](_0x127288[_0x6ff7('0x3e')],_0x224ee2[_0x6ff7('0x45')]));if(_0x127288[_0x6ff7('0x3e')]['filter']){_0x49fc43[_0x6ff7('0x48')]=_[_0x6ff7('0x49')](_0x49fc43[_0x6ff7('0x48')],{'$or':_[_0x6ff7('0x38')](_0x49fc43[_0x6ff7('0x41')],function(_0x38652c){var _0x54303d={};_0x54303d[_0x38652c]={'$like':'%'+_0x127288['query'][_0x6ff7('0x47')]+'%'};return _0x54303d;})});}_0x49fc43=_[_0x6ff7('0x49')]({},_0x49fc43,_0x127288[_0x6ff7('0x51')]);return _0x35e228[_0x6ff7('0x55')](_0x49fc43);}})[_0x6ff7('0x1f')](function(_0x4158e7){if(_0x4158e7){_0x5a268a=_0x4158e7[_0x6ff7('0x4f')];if(!_0x127288[_0x6ff7('0x3e')]['hasOwnProperty'](_0x6ff7('0x43'))){_0x49fc43[_0x6ff7('0x2e')]=qs[_0x6ff7('0x2e')](_0x127288['query'][_0x6ff7('0x2e')]);_0x49fc43[_0x6ff7('0x2d')]=qs[_0x6ff7('0x2d')](_0x127288[_0x6ff7('0x3e')]['offset']);}return _0x35e228[_0x6ff7('0x55')](_0x49fc43);}})[_0x6ff7('0x1f')](function(_0x12343f){if(_0x12343f){return _0x12343f?{'count':_0x5a268a,'rows':_0x12343f}:null;}})[_0x6ff7('0x1f')](respondWithResult(_0x37c7dd,null))[_0x6ff7('0x28')](handleError(_0x37c7dd,null));};exports[_0x6ff7('0x59')]=function(_0x3fbeb6,_0x2fc295,_0x344580){if(_0x3fbeb6[_0x6ff7('0x54')]['id']){delete _0x3fbeb6['body']['id'];}return db[_0x6ff7('0x39')]['findOne']({'where':{'id':_0x3fbeb6[_0x6ff7('0x4e')]['id']}})[_0x6ff7('0x1f')](handleEntityNotFound(_0x2fc295,null))[_0x6ff7('0x1f')](function(_0x2ad67c){if(_0x2ad67c){_0x3fbeb6[_0x6ff7('0x54')]['AccountId']=_0x2ad67c['id'];_0x3fbeb6[_0x6ff7('0x54')][_0x6ff7('0x5a')]=integrations[_0x6ff7('0x5b')](_0x3fbeb6[_0x6ff7('0x54')]['channel'],_0x3fbeb6[_0x6ff7('0x54')][_0x6ff7('0x3c')]);_0x3fbeb6[_0x6ff7('0x54')][_0x6ff7('0x5c')]=integrations[_0x6ff7('0x5d')](_0x3fbeb6['body'][_0x6ff7('0x5e')],_0x3fbeb6['body'][_0x6ff7('0x3c')]);return db[_0x6ff7('0x57')][_0x6ff7('0x53')](_0x3fbeb6['body'],{'include':[{'model':db[_0x6ff7('0x5f')],'as':_0x6ff7('0x5a')},{'model':db[_0x6ff7('0x5f')],'as':_0x6ff7('0x5c')}]});}return null;})['then'](respondWithResult(_0x2fc295,null))[_0x6ff7('0x28')](handleError(_0x2fc295,null));};exports[_0x6ff7('0x60')]=function(_0x2e042d,_0x4d7a83,_0x2adaa4){var _0x13a015='';return db[_0x6ff7('0x39')]['findOne']({'where':{'id':_0x2e042d['params']['id']},'attributes':['id',_0x6ff7('0x61'),'apiKey']})[_0x6ff7('0x1f')](handleEntityNotFound(_0x4d7a83,null))[_0x6ff7('0x1f')](function(_0x38550a){if(_0x38550a){_0x13a015=_0x38550a['remoteUri'];var _0xa7bbe8=_0x13a015['slice'](-0x1);if(_0xa7bbe8==='/'){_0x13a015=_0x13a015[_0x6ff7('0x62')](0x0,_0x13a015['lastIndexOf'](_0xa7bbe8));}return rp({'method':_0x6ff7('0x63'),'uri':util['format']('%s/%s',_0x13a015,'api/v2/ticket_fields'),'headers':{'Authorization':util[_0x6ff7('0x64')]('Basic\x20%s',new Buffer(util[_0x6ff7('0x64')](_0x6ff7('0x65'),_0x38550a['apiKey']))['toString']('base64'))},'json':!![]});}})[_0x6ff7('0x1f')](function(_0x2e6e0f){if(_0x2e6e0f){var _0x243c02=[_0x6ff7('0x66'),_0x6ff7('0x67'),'agent','description','status',_0x6ff7('0x68'),_0x6ff7('0x69'),_0x6ff7('0x6a'),'ticket_type',_0x6ff7('0x69'),_0x6ff7('0x6b')];_['remove'](_0x2e6e0f,function(_0x2daff2){return _0x243c02[_0x6ff7('0x6c')](_0x2daff2['name'])||!_0x2daff2[_0x6ff7('0x6d')]&&_0x2daff2[_0x6ff7('0x3c')]!=='custom_text'&&_0x2daff2[_0x6ff7('0x3c')]!==_0x6ff7('0x6e');});return{'count':_0x2e6e0f[_0x6ff7('0x4f')],'rows':_['map'](_0x2e6e0f,function(_0x35005b){return{'id':_0x35005b[_0x6ff7('0x36')],'name':_0x35005b[_0x6ff7('0x6f')],'custom':!_0x35005b[_0x6ff7('0x6d')],'options':_0x35005b[_0x6ff7('0x70')]?_[_0x6ff7('0x38')](_0x35005b[_0x6ff7('0x70')],function(_0x1a56aa){return{'name':_[_0x6ff7('0x71')](_0x1a56aa),'value':_0x1a56aa};}):[]};})};}})[_0x6ff7('0x1f')](respondWithResult(_0x4d7a83,null))[_0x6ff7('0x28')](function(_0x62fb21){var _0x288eec=_0x2e042d[_0x6ff7('0x3e')][_0x6ff7('0x72')]?0x1f4:_0x62fb21[_0x6ff7('0x73')]||0x1f4;logger[_0x6ff7('0x24')]('getFields,\x20%s,\x20%s,\x20%s',_0x6ff7('0x60'),_0x288eec,JSON['stringify'](_0x62fb21));delete _0x62fb21['name'];if(_0x288eec===0x191){_0x288eec=0x190;}_0x4d7a83[_0x6ff7('0x2a')](_0x288eec)[_0x6ff7('0x37')](_0x2e042d['query']['test']?{'message':_0x6ff7('0x74'),'statusCode':_0x62fb21[_0x6ff7('0x73')]}:_0x62fb21);});};
\ No newline at end of file
+var _0xd5b6=['bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','count','set','Content-Range','apply','reject','save','update','then','sendStatus','error','stack','name','map','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','limit','order','sort','where','pick','merge','VIRTUAL','filter','options','FreshdeskAccount','includeAll','include','findAll','rows','catch','params','keys','find','create','body','destroy','getConfigurations','findOne','FreshdeskConfiguration','rawAttributes','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','FreshdeskField','Descriptions','getFields','remoteUri','apiKey','slice','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','Basic\x20%s','toString','base64','requester','agent','description','priority','group','source','ticket_type','company','remove','includes','default','custom_dropdown','label','choices','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment'];(function(_0x5cb97e,_0x132a39){var _0x1714b4=function(_0x384210){while(--_0x384210){_0x5cb97e['push'](_0x5cb97e['shift']());}};_0x1714b4(++_0x132a39);}(_0xd5b6,0x73));var _0x6d5b=function(_0x306803,_0x34a407){_0x306803=_0x306803-0x0;var _0x111228=_0xd5b6[_0x306803];return _0x111228;};'use strict';var emlformat=require(_0x6d5b('0x0'));var rimraf=require(_0x6d5b('0x1'));var zipdir=require(_0x6d5b('0x2'));var jsonpatch=require(_0x6d5b('0x3'));var rp=require(_0x6d5b('0x4'));var moment=require(_0x6d5b('0x5'));var BPromise=require(_0x6d5b('0x6'));var Mustache=require(_0x6d5b('0x7'));var util=require('util');var path=require(_0x6d5b('0x8'));var sox=require(_0x6d5b('0x9'));var csv=require(_0x6d5b('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x6d5b('0xb'));var _=require(_0x6d5b('0xc'));var squel=require(_0x6d5b('0xd'));var crypto=require(_0x6d5b('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x6d5b('0xa'));var querystring=require(_0x6d5b('0xf'));var Papa=require(_0x6d5b('0x10'));var Redis=require(_0x6d5b('0x11'));var authService=require(_0x6d5b('0x12'));var qs=require(_0x6d5b('0x13'));var as=require(_0x6d5b('0x14'));var hardwareService=require(_0x6d5b('0x15'));var logger=require(_0x6d5b('0x16'))(_0x6d5b('0x17'));var utils=require(_0x6d5b('0x18'));var config=require(_0x6d5b('0x19'));var licenseUtil=require(_0x6d5b('0x1a'));var db=require(_0x6d5b('0x1b'))['db'];var integrations=require(_0x6d5b('0x1c'));function respondWithStatusCode(_0x1e3c2b,_0x3c09bb){_0x3c09bb=_0x3c09bb||0xcc;return function(_0x132fe2){if(_0x132fe2){return _0x1e3c2b['sendStatus'](_0x3c09bb);}return _0x1e3c2b[_0x6d5b('0x1d')](_0x3c09bb)[_0x6d5b('0x1e')]();};}function respondWithResult(_0xe6fa49,_0x3a4ca5){_0x3a4ca5=_0x3a4ca5||0xc8;return function(_0x12b0dc){if(_0x12b0dc){return _0xe6fa49['status'](_0x3a4ca5)[_0x6d5b('0x1f')](_0x12b0dc);}};}function respondWithFilteredResult(_0x1e6814,_0x51eb25){return function(_0x2baf47){if(_0x2baf47){var _0x5debab=typeof _0x51eb25[_0x6d5b('0x20')]==='undefined'&&typeof _0x51eb25['limit']==='undefined';var _0x12bc62=_0x2baf47[_0x6d5b('0x21')];var _0x448cc3=_0x5debab?0x0:_0x51eb25['offset'];var _0xb12444=_0x5debab?_0x2baf47[_0x6d5b('0x21')]:_0x51eb25[_0x6d5b('0x20')]+_0x51eb25['limit'];var _0x407f2f;if(_0xb12444>=_0x12bc62){_0xb12444=_0x12bc62;_0x407f2f=0xc8;}else{_0x407f2f=0xce;}_0x1e6814['status'](_0x407f2f);return _0x1e6814[_0x6d5b('0x22')](_0x6d5b('0x23'),_0x448cc3+'-'+_0xb12444+'/'+_0x12bc62)[_0x6d5b('0x1f')](_0x2baf47);}return null;};}function patchUpdates(_0x4b67ca){return function(_0x885c41){try{jsonpatch[_0x6d5b('0x24')](_0x885c41,_0x4b67ca,!![]);}catch(_0xf59341){return BPromise[_0x6d5b('0x25')](_0xf59341);}return _0x885c41[_0x6d5b('0x26')]();};}function saveUpdates(_0x36d8da,_0x19148d){return function(_0x186631){if(_0x186631){return _0x186631[_0x6d5b('0x27')](_0x36d8da)[_0x6d5b('0x28')](function(_0x1b5261){return _0x1b5261;});}return null;};}function removeEntity(_0xc1087e,_0x2e3192){return function(_0xc0d36c){if(_0xc0d36c){return _0xc0d36c['destroy']()[_0x6d5b('0x28')](function(){_0xc1087e['status'](0xcc)[_0x6d5b('0x1e')]();});}};}function handleEntityNotFound(_0x6a398a,_0x322c57){return function(_0x127e27){if(!_0x127e27){_0x6a398a[_0x6d5b('0x29')](0x194);}return _0x127e27;};}function handleError(_0x161c12,_0x1be755){_0x1be755=_0x1be755||0x1f4;return function(_0x33ae72){logger[_0x6d5b('0x2a')](_0x33ae72[_0x6d5b('0x2b')]);if(_0x33ae72[_0x6d5b('0x2c')]){delete _0x33ae72[_0x6d5b('0x2c')];}_0x161c12[_0x6d5b('0x1d')](_0x1be755)['send'](_0x33ae72);};}exports['index']=function(_0x5a9f13,_0x32c57b){var _0x1acc3a={},_0x2d0da5={},_0x4c9875={'count':0x0,'rows':[]};var _0x27151a=_[_0x6d5b('0x2d')](db['FreshdeskAccount']['rawAttributes'],function(_0x4fce9f){return{'name':_0x4fce9f[_0x6d5b('0x2e')],'type':_0x4fce9f[_0x6d5b('0x2f')][_0x6d5b('0x30')]};});_0x2d0da5[_0x6d5b('0x31')]=_['map'](_0x27151a,'name');_0x2d0da5[_0x6d5b('0x32')]=_['keys'](_0x5a9f13[_0x6d5b('0x32')]);_0x2d0da5[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x2d0da5[_0x6d5b('0x31')],_0x2d0da5[_0x6d5b('0x32')]);_0x1acc3a[_0x6d5b('0x35')]=_[_0x6d5b('0x34')](_0x2d0da5[_0x6d5b('0x31')],qs['fields'](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x36')]));_0x1acc3a[_0x6d5b('0x35')]=_0x1acc3a[_0x6d5b('0x35')][_0x6d5b('0x37')]?_0x1acc3a[_0x6d5b('0x35')]:_0x2d0da5[_0x6d5b('0x31')];if(!_0x5a9f13[_0x6d5b('0x32')]['hasOwnProperty'](_0x6d5b('0x38'))){_0x1acc3a[_0x6d5b('0x39')]=qs[_0x6d5b('0x39')](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x39')]);_0x1acc3a[_0x6d5b('0x20')]=qs['offset'](_0x5a9f13['query'][_0x6d5b('0x20')]);}_0x1acc3a[_0x6d5b('0x3a')]=qs[_0x6d5b('0x3b')](_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x3b')]);_0x1acc3a[_0x6d5b('0x3c')]=qs[_0x6d5b('0x33')](_[_0x6d5b('0x3d')](_0x5a9f13[_0x6d5b('0x32')],_0x2d0da5[_0x6d5b('0x33')]),_0x27151a);if(_0x5a9f13[_0x6d5b('0x32')]['filter']){_0x1acc3a['where']=_[_0x6d5b('0x3e')](_0x1acc3a[_0x6d5b('0x3c')],{'$or':_[_0x6d5b('0x2d')](_0x27151a,function(_0x2bd66d){if(_0x2bd66d['type']!==_0x6d5b('0x3f')){var _0xc55711={};_0xc55711[_0x2bd66d[_0x6d5b('0x2c')]]={'$like':'%'+_0x5a9f13[_0x6d5b('0x32')][_0x6d5b('0x40')]+'%'};return _0xc55711;}})});}_0x1acc3a=_[_0x6d5b('0x3e')]({},_0x1acc3a,_0x5a9f13[_0x6d5b('0x41')]);var _0x1e989d={'where':_0x1acc3a[_0x6d5b('0x3c')]};return db[_0x6d5b('0x42')][_0x6d5b('0x21')](_0x1e989d)[_0x6d5b('0x28')](function(_0x192d14){_0x4c9875['count']=_0x192d14;if(_0x5a9f13['query'][_0x6d5b('0x43')]){_0x1acc3a[_0x6d5b('0x44')]=[{'all':!![]}];}return db[_0x6d5b('0x42')][_0x6d5b('0x45')](_0x1acc3a);})[_0x6d5b('0x28')](function(_0x40b7e7){_0x4c9875[_0x6d5b('0x46')]=_0x40b7e7;return _0x4c9875;})[_0x6d5b('0x28')](respondWithFilteredResult(_0x32c57b,_0x1acc3a))[_0x6d5b('0x47')](handleError(_0x32c57b,null));};exports['show']=function(_0x452d5b,_0x594733){var _0x10fc3c={'raw':![],'where':{'id':_0x452d5b[_0x6d5b('0x48')]['id']}},_0x51b9f9={};_0x51b9f9[_0x6d5b('0x31')]=_[_0x6d5b('0x49')](db['FreshdeskAccount']['rawAttributes']);_0x51b9f9[_0x6d5b('0x32')]=_['keys'](_0x452d5b[_0x6d5b('0x32')]);_0x51b9f9[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x51b9f9['model'],_0x51b9f9[_0x6d5b('0x32')]);_0x10fc3c['attributes']=_[_0x6d5b('0x34')](_0x51b9f9[_0x6d5b('0x31')],qs[_0x6d5b('0x36')](_0x452d5b['query']['fields']));_0x10fc3c['attributes']=_0x10fc3c['attributes']['length']?_0x10fc3c[_0x6d5b('0x35')]:_0x51b9f9[_0x6d5b('0x31')];if(_0x452d5b['query'][_0x6d5b('0x43')]){_0x10fc3c[_0x6d5b('0x44')]=[{'all':!![]}];}_0x10fc3c=_[_0x6d5b('0x3e')]({},_0x10fc3c,_0x452d5b[_0x6d5b('0x41')]);return db[_0x6d5b('0x42')][_0x6d5b('0x4a')](_0x10fc3c)[_0x6d5b('0x28')](handleEntityNotFound(_0x594733,null))[_0x6d5b('0x28')](respondWithResult(_0x594733,null))[_0x6d5b('0x47')](handleError(_0x594733,null));};exports['create']=function(_0xa031cc,_0x405621){return db[_0x6d5b('0x42')][_0x6d5b('0x4b')](_0xa031cc[_0x6d5b('0x4c')],{})[_0x6d5b('0x28')](respondWithResult(_0x405621,0xc9))[_0x6d5b('0x47')](handleError(_0x405621,null));};exports[_0x6d5b('0x27')]=function(_0x72479c,_0x3dd4fc){if(_0x72479c[_0x6d5b('0x4c')]['id']){delete _0x72479c['body']['id'];}return db['FreshdeskAccount'][_0x6d5b('0x4a')]({'where':{'id':_0x72479c[_0x6d5b('0x48')]['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x3dd4fc,null))[_0x6d5b('0x28')](saveUpdates(_0x72479c[_0x6d5b('0x4c')],null))[_0x6d5b('0x28')](respondWithResult(_0x3dd4fc,null))[_0x6d5b('0x47')](handleError(_0x3dd4fc,null));};exports[_0x6d5b('0x4d')]=function(_0x2a5fb3,_0x36569a){return db[_0x6d5b('0x42')][_0x6d5b('0x4a')]({'where':{'id':_0x2a5fb3['params']['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x36569a,null))[_0x6d5b('0x28')](removeEntity(_0x36569a,null))['catch'](handleError(_0x36569a,null));};exports[_0x6d5b('0x4e')]=function(_0x523f0e,_0x260499,_0x58bf66){var _0x3a474f={};var _0x25d530={};var _0x5697f9;var _0x29544f;return db['FreshdeskAccount'][_0x6d5b('0x4f')]({'where':{'id':_0x523f0e[_0x6d5b('0x48')]['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x260499,null))[_0x6d5b('0x28')](function(_0x1a52de){if(_0x1a52de){_0x5697f9=_0x1a52de;_0x25d530['model']=_[_0x6d5b('0x49')](db[_0x6d5b('0x50')][_0x6d5b('0x51')]);_0x25d530[_0x6d5b('0x32')]=_[_0x6d5b('0x49')](_0x523f0e[_0x6d5b('0x32')]);_0x25d530[_0x6d5b('0x33')]=_[_0x6d5b('0x34')](_0x25d530[_0x6d5b('0x31')],_0x25d530['query']);_0x3a474f[_0x6d5b('0x35')]=_[_0x6d5b('0x34')](_0x25d530[_0x6d5b('0x31')],qs['fields'](_0x523f0e['query'][_0x6d5b('0x36')]));_0x3a474f[_0x6d5b('0x35')]=_0x3a474f[_0x6d5b('0x35')][_0x6d5b('0x37')]?_0x3a474f['attributes']:_0x25d530['model'];_0x3a474f['order']=qs['sort'](_0x523f0e[_0x6d5b('0x32')][_0x6d5b('0x3b')]);_0x3a474f[_0x6d5b('0x3c')]=qs[_0x6d5b('0x33')](_['pick'](_0x523f0e[_0x6d5b('0x32')],_0x25d530[_0x6d5b('0x33')]));if(_0x523f0e[_0x6d5b('0x32')]['filter']){_0x3a474f['where']=_[_0x6d5b('0x3e')](_0x3a474f[_0x6d5b('0x3c')],{'$or':_[_0x6d5b('0x2d')](_0x3a474f[_0x6d5b('0x35')],function(_0x3e22be){var _0x53ee51={};_0x53ee51[_0x3e22be]={'$like':'%'+_0x523f0e[_0x6d5b('0x32')][_0x6d5b('0x40')]+'%'};return _0x53ee51;})});}_0x3a474f=_[_0x6d5b('0x3e')]({},_0x3a474f,_0x523f0e[_0x6d5b('0x41')]);return _0x5697f9[_0x6d5b('0x4e')](_0x3a474f);}})['then'](function(_0x119105){if(_0x119105){_0x29544f=_0x119105['length'];if(!_0x523f0e[_0x6d5b('0x32')]['hasOwnProperty'](_0x6d5b('0x38'))){_0x3a474f[_0x6d5b('0x39')]=qs[_0x6d5b('0x39')](_0x523f0e['query'][_0x6d5b('0x39')]);_0x3a474f['offset']=qs[_0x6d5b('0x20')](_0x523f0e[_0x6d5b('0x32')]['offset']);}return _0x5697f9[_0x6d5b('0x4e')](_0x3a474f);}})['then'](function(_0x519a55){if(_0x519a55){return _0x519a55?{'count':_0x29544f,'rows':_0x519a55}:null;}})[_0x6d5b('0x28')](respondWithResult(_0x260499,null))['catch'](handleError(_0x260499,null));};exports[_0x6d5b('0x52')]=function(_0x1fddb4,_0x2fc45c,_0x2ac5a1){if(_0x1fddb4['body']['id']){delete _0x1fddb4[_0x6d5b('0x4c')]['id'];}return db[_0x6d5b('0x42')][_0x6d5b('0x4f')]({'where':{'id':_0x1fddb4['params']['id']}})[_0x6d5b('0x28')](handleEntityNotFound(_0x2fc45c,null))[_0x6d5b('0x28')](function(_0x5195c8){if(_0x5195c8){_0x1fddb4['body'][_0x6d5b('0x53')]=_0x5195c8['id'];_0x1fddb4['body'][_0x6d5b('0x54')]=integrations[_0x6d5b('0x55')](_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x56')],_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x2f')]);_0x1fddb4[_0x6d5b('0x4c')]['Descriptions']=integrations[_0x6d5b('0x57')](_0x1fddb4[_0x6d5b('0x4c')][_0x6d5b('0x56')],_0x1fddb4['body']['type']);return db['FreshdeskConfiguration'][_0x6d5b('0x4b')](_0x1fddb4[_0x6d5b('0x4c')],{'include':[{'model':db[_0x6d5b('0x58')],'as':_0x6d5b('0x54')},{'model':db['FreshdeskField'],'as':_0x6d5b('0x59')}]});}return null;})[_0x6d5b('0x28')](respondWithResult(_0x2fc45c,null))['catch'](handleError(_0x2fc45c,null));};exports[_0x6d5b('0x5a')]=function(_0x518e56,_0xfc32cb,_0x2fb18e){var _0x49f05e='';return db[_0x6d5b('0x42')][_0x6d5b('0x4f')]({'where':{'id':_0x518e56[_0x6d5b('0x48')]['id']},'attributes':['id',_0x6d5b('0x5b'),_0x6d5b('0x5c')]})[_0x6d5b('0x28')](handleEntityNotFound(_0xfc32cb,null))[_0x6d5b('0x28')](function(_0x4b5b1e){if(_0x4b5b1e){_0x49f05e=_0x4b5b1e[_0x6d5b('0x5b')];var _0xade321=_0x49f05e[_0x6d5b('0x5d')](-0x1);if(_0xade321==='/'){_0x49f05e=_0x49f05e['substring'](0x0,_0x49f05e[_0x6d5b('0x5e')](_0xade321));}return rp({'method':_0x6d5b('0x5f'),'uri':util[_0x6d5b('0x60')](_0x6d5b('0x61'),_0x49f05e,_0x6d5b('0x62')),'headers':{'Authorization':util['format'](_0x6d5b('0x63'),new Buffer(util[_0x6d5b('0x60')]('%s:X',_0x4b5b1e[_0x6d5b('0x5c')]))[_0x6d5b('0x64')](_0x6d5b('0x65')))},'json':!![]});}})['then'](function(_0x39b75b){if(_0x39b75b){var _0x188cfa=[_0x6d5b('0x66'),'subject',_0x6d5b('0x67'),_0x6d5b('0x68'),_0x6d5b('0x1d'),_0x6d5b('0x69'),_0x6d5b('0x6a'),_0x6d5b('0x6b'),_0x6d5b('0x6c'),'group',_0x6d5b('0x6d')];_[_0x6d5b('0x6e')](_0x39b75b,function(_0x3ec508){return _0x188cfa[_0x6d5b('0x6f')](_0x3ec508[_0x6d5b('0x2c')])||!_0x3ec508[_0x6d5b('0x70')]&&_0x3ec508['type']!=='custom_text'&&_0x3ec508[_0x6d5b('0x2f')]!==_0x6d5b('0x71');});return{'count':_0x39b75b['length'],'rows':_[_0x6d5b('0x2d')](_0x39b75b,function(_0x30c98a){return{'id':_0x30c98a[_0x6d5b('0x2c')],'name':_0x30c98a[_0x6d5b('0x72')],'custom':!_0x30c98a['default'],'options':_0x30c98a[_0x6d5b('0x73')]?_[_0x6d5b('0x2d')](_0x30c98a[_0x6d5b('0x73')],function(_0x25352f){return{'name':_['capitalize'](_0x25352f),'value':_0x25352f};}):[]};})};}})[_0x6d5b('0x28')](respondWithResult(_0xfc32cb,null))['catch'](function(_0x124300){var _0x585588=_0x518e56[_0x6d5b('0x32')][_0x6d5b('0x74')]?0x1f4:_0x124300[_0x6d5b('0x75')]||0x1f4;logger[_0x6d5b('0x2a')](_0x6d5b('0x76'),_0x6d5b('0x5a'),_0x585588,JSON[_0x6d5b('0x77')](_0x124300));delete _0x124300['name'];if(_0x585588===0x191){_0x585588=0x190;}_0xfc32cb['status'](_0x585588)['send'](_0x518e56[_0x6d5b('0x32')][_0x6d5b('0x74')]?{'message':_0x6d5b('0x78'),'statusCode':_0x124300['statusCode']}:_0x124300);});};
\ No newline at end of file