Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / api / intFreshdeskAccount / intFreshdeskAccount.controller.js
index 0162499..5111eb8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc961=['base64','requester','agent','description','priority','group','source','company','remove','default','custom_dropdown','choices','capitalize','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','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','../../components/integrations/configuration','sendStatus','status','end','json','undefined','count','offset','limit','Content-Range','reject','save','update','then','destroy','stack','name','send','index','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','order','sort','pick','filter','where','merge','map','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','FreshdeskAccount','create','body','find','FreshdeskConfiguration','getConfigurations','hasOwnProperty','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshdeskField','getFields','remoteUri','slice','substring','lastIndexOf','GET','%s/%s','api/v2/ticket_fields','format','Basic\x20%s','apiKey','toString'];(function(_0x26788d,_0x42b12a){var _0x2e74e7=function(_0x307f24){while(--_0x307f24){_0x26788d['push'](_0x26788d['shift']());}};_0x2e74e7(++_0x42b12a);}(_0xc961,0x17a));var _0x1c96=function(_0x4dd0a7,_0xb4399f){_0x4dd0a7=_0x4dd0a7-0x0;var _0x487e9b=_0xc961[_0x4dd0a7];return _0x487e9b;};'use strict';var emlformat=require(_0x1c96('0x0'));var rimraf=require(_0x1c96('0x1'));var zipdir=require(_0x1c96('0x2'));var jsonpatch=require(_0x1c96('0x3'));var rp=require(_0x1c96('0x4'));var moment=require(_0x1c96('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x1c96('0x6'));var sox=require('sox');var csv=require(_0x1c96('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1c96('0x8'));var _=require(_0x1c96('0x9'));var squel=require(_0x1c96('0xa'));var crypto=require(_0x1c96('0xb'));var jsforce=require(_0x1c96('0xc'));var deskjs=require(_0x1c96('0xd'));var toCsv=require('to-csv');var querystring=require(_0x1c96('0xe'));var Papa=require(_0x1c96('0xf'));var Redis=require(_0x1c96('0x10'));var authService=require(_0x1c96('0x11'));var qs=require(_0x1c96('0x12'));var as=require(_0x1c96('0x13'));var hardwareService=require(_0x1c96('0x14'));var logger=require(_0x1c96('0x15'))(_0x1c96('0x16'));var utils=require(_0x1c96('0x17'));var config=require(_0x1c96('0x18'));var licenseUtil=require(_0x1c96('0x19'));var db=require('../../mysqldb')['db'];var integrations=require(_0x1c96('0x1a'));function respondWithStatusCode(_0x3c9850,_0x5a8f97){_0x5a8f97=_0x5a8f97||0xcc;return function(_0x425345){if(_0x425345){return _0x3c9850[_0x1c96('0x1b')](_0x5a8f97);}return _0x3c9850[_0x1c96('0x1c')](_0x5a8f97)[_0x1c96('0x1d')]();};}function respondWithResult(_0x4c410d,_0x242bb1){_0x242bb1=_0x242bb1||0xc8;return function(_0x36710e){if(_0x36710e){return _0x4c410d[_0x1c96('0x1c')](_0x242bb1)[_0x1c96('0x1e')](_0x36710e);}};}function respondWithFilteredResult(_0x199719,_0x8f03c4){return function(_0x7cfdeb){if(_0x7cfdeb){var _0x3441a7=typeof _0x8f03c4['offset']===_0x1c96('0x1f')&&typeof _0x8f03c4['limit']===_0x1c96('0x1f');var _0x151c85=_0x7cfdeb['count'];var _0x29dafb=_0x3441a7?0x0:_0x8f03c4['offset'];var _0x57efce=_0x3441a7?_0x7cfdeb[_0x1c96('0x20')]:_0x8f03c4[_0x1c96('0x21')]+_0x8f03c4[_0x1c96('0x22')];var _0x4aff57;if(_0x57efce>=_0x151c85){_0x57efce=_0x151c85;_0x4aff57=0xc8;}else{_0x4aff57=0xce;}_0x199719[_0x1c96('0x1c')](_0x4aff57);return _0x199719['set'](_0x1c96('0x23'),_0x29dafb+'-'+_0x57efce+'/'+_0x151c85)[_0x1c96('0x1e')](_0x7cfdeb);}return null;};}function patchUpdates(_0x5e11b8){return function(_0x5a5829){try{jsonpatch['apply'](_0x5a5829,_0x5e11b8,!![]);}catch(_0x321598){return BPromise[_0x1c96('0x24')](_0x321598);}return _0x5a5829[_0x1c96('0x25')]();};}function saveUpdates(_0x3f4293,_0x30e8b8){return function(_0x46b969){if(_0x46b969){return _0x46b969[_0x1c96('0x26')](_0x3f4293)[_0x1c96('0x27')](function(_0xad92bd){return _0xad92bd;});}return null;};}function removeEntity(_0xc40964,_0x4d2c9c){return function(_0x24c60c){if(_0x24c60c){return _0x24c60c[_0x1c96('0x28')]()[_0x1c96('0x27')](function(){_0xc40964['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2d5aaa,_0xd57e1b){return function(_0x48798a){if(!_0x48798a){_0x2d5aaa[_0x1c96('0x1b')](0x194);}return _0x48798a;};}function handleError(_0x43b822,_0x1b31d0){_0x1b31d0=_0x1b31d0||0x1f4;return function(_0x4e6066){logger['error'](_0x4e6066[_0x1c96('0x29')]);if(_0x4e6066[_0x1c96('0x2a')]){delete _0x4e6066['name'];}_0x43b822[_0x1c96('0x1c')](_0x1b31d0)[_0x1c96('0x2b')](_0x4e6066);};}exports[_0x1c96('0x2c')]=function(_0x25db8a,_0x5a6b49){var _0x523b43={},_0x3466e6={},_0x556730={'count':0x0,'rows':[]};var _0x1ab997=_['map'](db['FreshdeskAccount'][_0x1c96('0x2d')],function(_0x4438fb){return{'name':_0x4438fb[_0x1c96('0x2e')],'type':_0x4438fb[_0x1c96('0x2f')][_0x1c96('0x30')]};});_0x3466e6[_0x1c96('0x31')]=_['map'](_0x1ab997,'name');_0x3466e6[_0x1c96('0x32')]=_[_0x1c96('0x33')](_0x25db8a[_0x1c96('0x32')]);_0x3466e6[_0x1c96('0x34')]=_[_0x1c96('0x35')](_0x3466e6[_0x1c96('0x31')],_0x3466e6[_0x1c96('0x32')]);_0x523b43[_0x1c96('0x36')]=_[_0x1c96('0x35')](_0x3466e6['model'],qs[_0x1c96('0x37')](_0x25db8a[_0x1c96('0x32')][_0x1c96('0x37')]));_0x523b43[_0x1c96('0x36')]=_0x523b43[_0x1c96('0x36')][_0x1c96('0x38')]?_0x523b43['attributes']:_0x3466e6[_0x1c96('0x31')];if(!_0x25db8a[_0x1c96('0x32')]['hasOwnProperty'](_0x1c96('0x39'))){_0x523b43[_0x1c96('0x22')]=qs[_0x1c96('0x22')](_0x25db8a[_0x1c96('0x32')][_0x1c96('0x22')]);_0x523b43[_0x1c96('0x21')]=qs[_0x1c96('0x21')](_0x25db8a['query']['offset']);}_0x523b43[_0x1c96('0x3a')]=qs[_0x1c96('0x3b')](_0x25db8a['query'][_0x1c96('0x3b')]);_0x523b43['where']=qs[_0x1c96('0x34')](_[_0x1c96('0x3c')](_0x25db8a['query'],_0x3466e6['filters']),_0x1ab997);if(_0x25db8a[_0x1c96('0x32')][_0x1c96('0x3d')]){_0x523b43[_0x1c96('0x3e')]=_[_0x1c96('0x3f')](_0x523b43[_0x1c96('0x3e')],{'$or':_[_0x1c96('0x40')](_0x1ab997,function(_0x2d1ea1){if(_0x2d1ea1['type']!==_0x1c96('0x41')){var _0x2b422e={};_0x2b422e[_0x2d1ea1['name']]={'$like':'%'+_0x25db8a[_0x1c96('0x32')]['filter']+'%'};return _0x2b422e;}})});}_0x523b43=_[_0x1c96('0x3f')]({},_0x523b43,_0x25db8a[_0x1c96('0x42')]);var _0x4167f8={'where':_0x523b43[_0x1c96('0x3e')]};return db['FreshdeskAccount'][_0x1c96('0x20')](_0x4167f8)[_0x1c96('0x27')](function(_0x2b2113){_0x556730[_0x1c96('0x20')]=_0x2b2113;if(_0x25db8a['query'][_0x1c96('0x43')]){_0x523b43[_0x1c96('0x44')]=[{'all':!![]}];}return db['FreshdeskAccount'][_0x1c96('0x45')](_0x523b43);})[_0x1c96('0x27')](function(_0x2676cf){_0x556730[_0x1c96('0x46')]=_0x2676cf;return _0x556730;})[_0x1c96('0x27')](respondWithFilteredResult(_0x5a6b49,_0x523b43))[_0x1c96('0x47')](handleError(_0x5a6b49,null));};exports[_0x1c96('0x48')]=function(_0xb74171,_0x49260f){var _0x1404b0={'raw':![],'where':{'id':_0xb74171[_0x1c96('0x49')]['id']}},_0x24ee34={};_0x24ee34[_0x1c96('0x31')]=_[_0x1c96('0x33')](db[_0x1c96('0x4a')][_0x1c96('0x2d')]);_0x24ee34[_0x1c96('0x32')]=_[_0x1c96('0x33')](_0xb74171['query']);_0x24ee34['filters']=_[_0x1c96('0x35')](_0x24ee34[_0x1c96('0x31')],_0x24ee34[_0x1c96('0x32')]);_0x1404b0[_0x1c96('0x36')]=_[_0x1c96('0x35')](_0x24ee34['model'],qs['fields'](_0xb74171[_0x1c96('0x32')][_0x1c96('0x37')]));_0x1404b0[_0x1c96('0x36')]=_0x1404b0['attributes'][_0x1c96('0x38')]?_0x1404b0[_0x1c96('0x36')]:_0x24ee34['model'];if(_0xb74171[_0x1c96('0x32')]['includeAll']){_0x1404b0['include']=[{'all':!![]}];}_0x1404b0=_[_0x1c96('0x3f')]({},_0x1404b0,_0xb74171[_0x1c96('0x42')]);return db[_0x1c96('0x4a')]['find'](_0x1404b0)['then'](handleEntityNotFound(_0x49260f,null))['then'](respondWithResult(_0x49260f,null))[_0x1c96('0x47')](handleError(_0x49260f,null));};exports['create']=function(_0x4679f2,_0x59b235){return db[_0x1c96('0x4a')][_0x1c96('0x4b')](_0x4679f2[_0x1c96('0x4c')],{})[_0x1c96('0x27')](respondWithResult(_0x59b235,0xc9))['catch'](handleError(_0x59b235,null));};exports[_0x1c96('0x26')]=function(_0xa5effb,_0x124cb3){if(_0xa5effb[_0x1c96('0x4c')]['id']){delete _0xa5effb['body']['id'];}return db[_0x1c96('0x4a')][_0x1c96('0x4d')]({'where':{'id':_0xa5effb[_0x1c96('0x49')]['id']}})[_0x1c96('0x27')](handleEntityNotFound(_0x124cb3,null))[_0x1c96('0x27')](saveUpdates(_0xa5effb[_0x1c96('0x4c')],null))[_0x1c96('0x27')](respondWithResult(_0x124cb3,null))['catch'](handleError(_0x124cb3,null));};exports[_0x1c96('0x28')]=function(_0x47db08,_0x1082c3){return db[_0x1c96('0x4a')]['find']({'where':{'id':_0x47db08['params']['id']}})[_0x1c96('0x27')](handleEntityNotFound(_0x1082c3,null))[_0x1c96('0x27')](removeEntity(_0x1082c3,null))[_0x1c96('0x47')](handleError(_0x1082c3,null));};exports['getConfigurations']=function(_0x1265af,_0x25ec33,_0x4784bd){var _0x5ba591={};var _0x5b6fa1={};var _0x33c8fc;var _0x534f61;return db['FreshdeskAccount']['findOne']({'where':{'id':_0x1265af['params']['id']}})[_0x1c96('0x27')](handleEntityNotFound(_0x25ec33,null))['then'](function(_0x51309f){if(_0x51309f){_0x33c8fc=_0x51309f;_0x5b6fa1['model']=_[_0x1c96('0x33')](db[_0x1c96('0x4e')][_0x1c96('0x2d')]);_0x5b6fa1[_0x1c96('0x32')]=_[_0x1c96('0x33')](_0x1265af[_0x1c96('0x32')]);_0x5b6fa1[_0x1c96('0x34')]=_[_0x1c96('0x35')](_0x5b6fa1[_0x1c96('0x31')],_0x5b6fa1['query']);_0x5ba591[_0x1c96('0x36')]=_[_0x1c96('0x35')](_0x5b6fa1[_0x1c96('0x31')],qs[_0x1c96('0x37')](_0x1265af['query'][_0x1c96('0x37')]));_0x5ba591[_0x1c96('0x36')]=_0x5ba591[_0x1c96('0x36')][_0x1c96('0x38')]?_0x5ba591[_0x1c96('0x36')]:_0x5b6fa1[_0x1c96('0x31')];_0x5ba591[_0x1c96('0x3a')]=qs[_0x1c96('0x3b')](_0x1265af['query'][_0x1c96('0x3b')]);_0x5ba591[_0x1c96('0x3e')]=qs[_0x1c96('0x34')](_['pick'](_0x1265af[_0x1c96('0x32')],_0x5b6fa1[_0x1c96('0x34')]));if(_0x1265af[_0x1c96('0x32')]['filter']){_0x5ba591['where']=_[_0x1c96('0x3f')](_0x5ba591[_0x1c96('0x3e')],{'$or':_['map'](_0x5ba591['attributes'],function(_0x4df1ef){var _0x1c9d98={};_0x1c9d98[_0x4df1ef]={'$like':'%'+_0x1265af[_0x1c96('0x32')][_0x1c96('0x3d')]+'%'};return _0x1c9d98;})});}_0x5ba591=_[_0x1c96('0x3f')]({},_0x5ba591,_0x1265af['options']);return _0x33c8fc[_0x1c96('0x4f')](_0x5ba591);}})[_0x1c96('0x27')](function(_0x1c774d){if(_0x1c774d){_0x534f61=_0x1c774d[_0x1c96('0x38')];if(!_0x1265af[_0x1c96('0x32')][_0x1c96('0x50')](_0x1c96('0x39'))){_0x5ba591['limit']=qs['limit'](_0x1265af[_0x1c96('0x32')][_0x1c96('0x22')]);_0x5ba591[_0x1c96('0x21')]=qs[_0x1c96('0x21')](_0x1265af[_0x1c96('0x32')]['offset']);}return _0x33c8fc['getConfigurations'](_0x5ba591);}})[_0x1c96('0x27')](function(_0xf91a09){if(_0xf91a09){return _0xf91a09?{'count':_0x534f61,'rows':_0xf91a09}:null;}})[_0x1c96('0x27')](respondWithResult(_0x25ec33,null))[_0x1c96('0x47')](handleError(_0x25ec33,null));};exports[_0x1c96('0x51')]=function(_0x5d3e70,_0x54fa49,_0x2274c0){if(_0x5d3e70[_0x1c96('0x4c')]['id']){delete _0x5d3e70[_0x1c96('0x4c')]['id'];}return db[_0x1c96('0x4a')][_0x1c96('0x52')]({'where':{'id':_0x5d3e70['params']['id']}})['then'](handleEntityNotFound(_0x54fa49,null))[_0x1c96('0x27')](function(_0x391804){if(_0x391804){_0x5d3e70['body'][_0x1c96('0x53')]=_0x391804['id'];_0x5d3e70[_0x1c96('0x4c')][_0x1c96('0x54')]=integrations[_0x1c96('0x55')](_0x5d3e70['body'][_0x1c96('0x56')],_0x5d3e70['body']['type']);_0x5d3e70[_0x1c96('0x4c')][_0x1c96('0x57')]=integrations[_0x1c96('0x58')](_0x5d3e70[_0x1c96('0x4c')]['channel'],_0x5d3e70[_0x1c96('0x4c')][_0x1c96('0x2f')]);return db['FreshdeskConfiguration'][_0x1c96('0x4b')](_0x5d3e70[_0x1c96('0x4c')],{'include':[{'model':db[_0x1c96('0x59')],'as':'Subjects'},{'model':db[_0x1c96('0x59')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x54fa49,null))[_0x1c96('0x47')](handleError(_0x54fa49,null));};exports[_0x1c96('0x5a')]=function(_0x4aeeee,_0x5f11db,_0x94892){var _0x4a7c4c='';return db[_0x1c96('0x4a')][_0x1c96('0x52')]({'where':{'id':_0x4aeeee[_0x1c96('0x49')]['id']},'attributes':['id',_0x1c96('0x5b'),'apiKey']})['then'](handleEntityNotFound(_0x5f11db,null))['then'](function(_0x5f0f78){if(_0x5f0f78){_0x4a7c4c=_0x5f0f78[_0x1c96('0x5b')];var _0xd9fc2f=_0x4a7c4c[_0x1c96('0x5c')](-0x1);if(_0xd9fc2f==='/'){_0x4a7c4c=_0x4a7c4c[_0x1c96('0x5d')](0x0,_0x4a7c4c[_0x1c96('0x5e')](_0xd9fc2f));}return rp({'method':_0x1c96('0x5f'),'uri':util['format'](_0x1c96('0x60'),_0x4a7c4c,_0x1c96('0x61')),'headers':{'Authorization':util[_0x1c96('0x62')](_0x1c96('0x63'),new Buffer(util[_0x1c96('0x62')]('%s:X',_0x5f0f78[_0x1c96('0x64')]))[_0x1c96('0x65')](_0x1c96('0x66')))},'json':!![]});}})[_0x1c96('0x27')](function(_0x2565b0){if(_0x2565b0){var _0x28d7d4=[_0x1c96('0x67'),'subject',_0x1c96('0x68'),_0x1c96('0x69'),_0x1c96('0x1c'),_0x1c96('0x6a'),_0x1c96('0x6b'),_0x1c96('0x6c'),'ticket_type','group',_0x1c96('0x6d')];_[_0x1c96('0x6e')](_0x2565b0,function(_0x3d1823){return _0x28d7d4['includes'](_0x3d1823[_0x1c96('0x2a')])||!_0x3d1823[_0x1c96('0x6f')]&&_0x3d1823[_0x1c96('0x2f')]!=='custom_text'&&_0x3d1823[_0x1c96('0x2f')]!==_0x1c96('0x70');});return{'count':_0x2565b0['length'],'rows':_[_0x1c96('0x40')](_0x2565b0,function(_0x38ae53){return{'id':_0x38ae53[_0x1c96('0x2a')],'name':_0x38ae53['label'],'custom':!_0x38ae53[_0x1c96('0x6f')],'options':_0x38ae53['choices']?_[_0x1c96('0x40')](_0x38ae53[_0x1c96('0x71')],function(_0x404bf1){return{'name':_[_0x1c96('0x72')](_0x404bf1),'value':_0x404bf1};}):[]};})};}})[_0x1c96('0x27')](respondWithResult(_0x5f11db,null))[_0x1c96('0x47')](function(_0xb26dac){var _0x2b3c3a=_0x4aeeee[_0x1c96('0x32')]['test']?0x1f4:_0xb26dac[_0x1c96('0x73')]||0x1f4;logger[_0x1c96('0x74')](_0x1c96('0x75'),_0x1c96('0x5a'),_0x2b3c3a,JSON['stringify'](_0xb26dac));delete _0xb26dac['name'];if(_0x2b3c3a===0x191){_0x2b3c3a=0x190;}_0x5f11db[_0x1c96('0x1c')](_0x2b3c3a)[_0x1c96('0x2b')](_0x4aeeee[_0x1c96('0x32')][_0x1c96('0x76')]?{'message':_0x1c96('0x77'),'statusCode':_0xb26dac[_0x1c96('0x73')]}:_0xb26dac);});};
\ No newline at end of file
+var _0xbf1a=['ticket_type','company','default','custom_text','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','bluebird','util','path','sox','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','apply','reject','then','error','stack','name','send','FreshdeskAccount','rawAttributes','fieldName','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','merge','where','type','VIRTUAL','includeAll','include','findAll','catch','params','options','find','create','body','getConfigurations','findOne','pick','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','FreshdeskField','getFields','remoteUri','slice','substring','lastIndexOf','GET','format','%s/%s','api/v2/ticket_fields','%s:X','apiKey','base64','subject','agent','description','priority','group'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0xbf1a,0x7c));var _0xabf1=function(_0x177d42,_0x52d476){_0x177d42=_0x177d42-0x0;var _0x15031d=_0xbf1a[_0x177d42];return _0x15031d;};'use strict';var emlformat=require(_0xabf1('0x0'));var rimraf=require(_0xabf1('0x1'));var zipdir=require(_0xabf1('0x2'));var jsonpatch=require(_0xabf1('0x3'));var rp=require(_0xabf1('0x4'));var moment=require('moment');var BPromise=require(_0xabf1('0x5'));var Mustache=require('mustache');var util=require(_0xabf1('0x6'));var path=require(_0xabf1('0x7'));var sox=require(_0xabf1('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xabf1('0x9'));var _=require('lodash');var squel=require(_0xabf1('0xa'));var crypto=require(_0xabf1('0xb'));var jsforce=require(_0xabf1('0xc'));var deskjs=require(_0xabf1('0xd'));var toCsv=require(_0xabf1('0xe'));var querystring=require(_0xabf1('0xf'));var Papa=require('papaparse');var Redis=require(_0xabf1('0x10'));var authService=require(_0xabf1('0x11'));var qs=require(_0xabf1('0x12'));var as=require(_0xabf1('0x13'));var hardwareService=require(_0xabf1('0x14'));var logger=require(_0xabf1('0x15'))('api');var utils=require(_0xabf1('0x16'));var config=require(_0xabf1('0x17'));var licenseUtil=require(_0xabf1('0x18'));var db=require(_0xabf1('0x19'))['db'];var integrations=require(_0xabf1('0x1a'));function respondWithStatusCode(_0x1186b7,_0x27ade4){_0x27ade4=_0x27ade4||0xcc;return function(_0x4853d5){if(_0x4853d5){return _0x1186b7[_0xabf1('0x1b')](_0x27ade4);}return _0x1186b7[_0xabf1('0x1c')](_0x27ade4)['end']();};}function respondWithResult(_0x783976,_0xcbe7da){_0xcbe7da=_0xcbe7da||0xc8;return function(_0x248705){if(_0x248705){return _0x783976['status'](_0xcbe7da)[_0xabf1('0x1d')](_0x248705);}};}function respondWithFilteredResult(_0x3dd81a,_0x719d3e){return function(_0x3537e4){if(_0x3537e4){var _0x49cfe3=typeof _0x719d3e[_0xabf1('0x1e')]==='undefined'&&typeof _0x719d3e[_0xabf1('0x1f')]===_0xabf1('0x20');var _0x392c5f=_0x3537e4[_0xabf1('0x21')];var _0x26e9f8=_0x49cfe3?0x0:_0x719d3e[_0xabf1('0x1e')];var _0x3cfc35=_0x49cfe3?_0x3537e4[_0xabf1('0x21')]:_0x719d3e[_0xabf1('0x1e')]+_0x719d3e[_0xabf1('0x1f')];var _0x2d34db;if(_0x3cfc35>=_0x392c5f){_0x3cfc35=_0x392c5f;_0x2d34db=0xc8;}else{_0x2d34db=0xce;}_0x3dd81a[_0xabf1('0x1c')](_0x2d34db);return _0x3dd81a[_0xabf1('0x22')](_0xabf1('0x23'),_0x26e9f8+'-'+_0x3cfc35+'/'+_0x392c5f)[_0xabf1('0x1d')](_0x3537e4);}return null;};}function patchUpdates(_0x5a0413){return function(_0x5444b4){try{jsonpatch[_0xabf1('0x24')](_0x5444b4,_0x5a0413,!![]);}catch(_0x167d5d){return BPromise[_0xabf1('0x25')](_0x167d5d);}return _0x5444b4['save']();};}function saveUpdates(_0x216862,_0x3fbce0){return function(_0x3bd4b6){if(_0x3bd4b6){return _0x3bd4b6['update'](_0x216862)[_0xabf1('0x26')](function(_0x57fea6){return _0x57fea6;});}return null;};}function removeEntity(_0x30fac8,_0x551401){return function(_0x5ccb6f){if(_0x5ccb6f){return _0x5ccb6f['destroy']()[_0xabf1('0x26')](function(){_0x30fac8[_0xabf1('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x14c6f0,_0x69ddb8){return function(_0x577b0f){if(!_0x577b0f){_0x14c6f0['sendStatus'](0x194);}return _0x577b0f;};}function handleError(_0x25d432,_0x175678){_0x175678=_0x175678||0x1f4;return function(_0x3e58f6){logger[_0xabf1('0x27')](_0x3e58f6[_0xabf1('0x28')]);if(_0x3e58f6['name']){delete _0x3e58f6[_0xabf1('0x29')];}_0x25d432['status'](_0x175678)[_0xabf1('0x2a')](_0x3e58f6);};}exports['index']=function(_0xb54b63,_0x582fbf){var _0x45e64f={},_0x139540={},_0xe3ecbb={'count':0x0,'rows':[]};var _0x139802=_['map'](db[_0xabf1('0x2b')][_0xabf1('0x2c')],function(_0x4d3dd7){return{'name':_0x4d3dd7[_0xabf1('0x2d')],'type':_0x4d3dd7['type']['key']};});_0x139540['model']=_[_0xabf1('0x2e')](_0x139802,_0xabf1('0x29'));_0x139540[_0xabf1('0x2f')]=_[_0xabf1('0x30')](_0xb54b63['query']);_0x139540[_0xabf1('0x31')]=_[_0xabf1('0x32')](_0x139540[_0xabf1('0x33')],_0x139540[_0xabf1('0x2f')]);_0x45e64f['attributes']=_[_0xabf1('0x32')](_0x139540['model'],qs[_0xabf1('0x34')](_0xb54b63['query']['fields']));_0x45e64f[_0xabf1('0x35')]=_0x45e64f[_0xabf1('0x35')][_0xabf1('0x36')]?_0x45e64f[_0xabf1('0x35')]:_0x139540[_0xabf1('0x33')];if(!_0xb54b63[_0xabf1('0x2f')][_0xabf1('0x37')](_0xabf1('0x38'))){_0x45e64f['limit']=qs[_0xabf1('0x1f')](_0xb54b63[_0xabf1('0x2f')]['limit']);_0x45e64f['offset']=qs['offset'](_0xb54b63[_0xabf1('0x2f')]['offset']);}_0x45e64f[_0xabf1('0x39')]=qs[_0xabf1('0x3a')](_0xb54b63[_0xabf1('0x2f')][_0xabf1('0x3a')]);_0x45e64f['where']=qs[_0xabf1('0x31')](_['pick'](_0xb54b63[_0xabf1('0x2f')],_0x139540[_0xabf1('0x31')]),_0x139802);if(_0xb54b63[_0xabf1('0x2f')][_0xabf1('0x3b')]){_0x45e64f['where']=_[_0xabf1('0x3c')](_0x45e64f[_0xabf1('0x3d')],{'$or':_[_0xabf1('0x2e')](_0x139802,function(_0x284a36){if(_0x284a36[_0xabf1('0x3e')]!==_0xabf1('0x3f')){var _0x378b54={};_0x378b54[_0x284a36[_0xabf1('0x29')]]={'$like':'%'+_0xb54b63[_0xabf1('0x2f')][_0xabf1('0x3b')]+'%'};return _0x378b54;}})});}_0x45e64f=_['merge']({},_0x45e64f,_0xb54b63['options']);var _0x3d52bc={'where':_0x45e64f[_0xabf1('0x3d')]};return db[_0xabf1('0x2b')][_0xabf1('0x21')](_0x3d52bc)[_0xabf1('0x26')](function(_0x588e20){_0xe3ecbb[_0xabf1('0x21')]=_0x588e20;if(_0xb54b63['query'][_0xabf1('0x40')]){_0x45e64f[_0xabf1('0x41')]=[{'all':!![]}];}return db[_0xabf1('0x2b')][_0xabf1('0x42')](_0x45e64f);})[_0xabf1('0x26')](function(_0x6719e0){_0xe3ecbb['rows']=_0x6719e0;return _0xe3ecbb;})['then'](respondWithFilteredResult(_0x582fbf,_0x45e64f))[_0xabf1('0x43')](handleError(_0x582fbf,null));};exports['show']=function(_0x2500d5,_0xdf51f2){var _0x14368a={'raw':![],'where':{'id':_0x2500d5[_0xabf1('0x44')]['id']}},_0x3757fb={};_0x3757fb['model']=_[_0xabf1('0x30')](db[_0xabf1('0x2b')]['rawAttributes']);_0x3757fb[_0xabf1('0x2f')]=_[_0xabf1('0x30')](_0x2500d5[_0xabf1('0x2f')]);_0x3757fb[_0xabf1('0x31')]=_['intersection'](_0x3757fb[_0xabf1('0x33')],_0x3757fb['query']);_0x14368a[_0xabf1('0x35')]=_[_0xabf1('0x32')](_0x3757fb[_0xabf1('0x33')],qs['fields'](_0x2500d5[_0xabf1('0x2f')][_0xabf1('0x34')]));_0x14368a['attributes']=_0x14368a['attributes'][_0xabf1('0x36')]?_0x14368a[_0xabf1('0x35')]:_0x3757fb[_0xabf1('0x33')];if(_0x2500d5['query']['includeAll']){_0x14368a['include']=[{'all':!![]}];}_0x14368a=_[_0xabf1('0x3c')]({},_0x14368a,_0x2500d5[_0xabf1('0x45')]);return db[_0xabf1('0x2b')][_0xabf1('0x46')](_0x14368a)['then'](handleEntityNotFound(_0xdf51f2,null))['then'](respondWithResult(_0xdf51f2,null))[_0xabf1('0x43')](handleError(_0xdf51f2,null));};exports[_0xabf1('0x47')]=function(_0xb1bb2e,_0x47df69){return db[_0xabf1('0x2b')][_0xabf1('0x47')](_0xb1bb2e['body'],{})['then'](respondWithResult(_0x47df69,0xc9))['catch'](handleError(_0x47df69,null));};exports['update']=function(_0x4771b5,_0x307507){if(_0x4771b5[_0xabf1('0x48')]['id']){delete _0x4771b5[_0xabf1('0x48')]['id'];}return db[_0xabf1('0x2b')][_0xabf1('0x46')]({'where':{'id':_0x4771b5[_0xabf1('0x44')]['id']}})[_0xabf1('0x26')](handleEntityNotFound(_0x307507,null))[_0xabf1('0x26')](saveUpdates(_0x4771b5['body'],null))['then'](respondWithResult(_0x307507,null))['catch'](handleError(_0x307507,null));};exports['destroy']=function(_0x2ba3d1,_0x565122){return db[_0xabf1('0x2b')]['find']({'where':{'id':_0x2ba3d1['params']['id']}})['then'](handleEntityNotFound(_0x565122,null))['then'](removeEntity(_0x565122,null))[_0xabf1('0x43')](handleError(_0x565122,null));};exports[_0xabf1('0x49')]=function(_0x2d8259,_0x390f9b,_0x529a08){var _0x2dace7={};var _0x3ee213={};var _0x1cd6d8;var _0x40210b;return db[_0xabf1('0x2b')][_0xabf1('0x4a')]({'where':{'id':_0x2d8259[_0xabf1('0x44')]['id']}})['then'](handleEntityNotFound(_0x390f9b,null))[_0xabf1('0x26')](function(_0x192d92){if(_0x192d92){_0x1cd6d8=_0x192d92;_0x3ee213[_0xabf1('0x33')]=_['keys'](db['FreshdeskConfiguration'][_0xabf1('0x2c')]);_0x3ee213[_0xabf1('0x2f')]=_['keys'](_0x2d8259['query']);_0x3ee213[_0xabf1('0x31')]=_[_0xabf1('0x32')](_0x3ee213[_0xabf1('0x33')],_0x3ee213[_0xabf1('0x2f')]);_0x2dace7[_0xabf1('0x35')]=_[_0xabf1('0x32')](_0x3ee213[_0xabf1('0x33')],qs[_0xabf1('0x34')](_0x2d8259['query']['fields']));_0x2dace7['attributes']=_0x2dace7['attributes'][_0xabf1('0x36')]?_0x2dace7[_0xabf1('0x35')]:_0x3ee213[_0xabf1('0x33')];_0x2dace7['order']=qs[_0xabf1('0x3a')](_0x2d8259['query']['sort']);_0x2dace7[_0xabf1('0x3d')]=qs['filters'](_[_0xabf1('0x4b')](_0x2d8259[_0xabf1('0x2f')],_0x3ee213[_0xabf1('0x31')]));if(_0x2d8259[_0xabf1('0x2f')][_0xabf1('0x3b')]){_0x2dace7[_0xabf1('0x3d')]=_[_0xabf1('0x3c')](_0x2dace7[_0xabf1('0x3d')],{'$or':_['map'](_0x2dace7[_0xabf1('0x35')],function(_0xd7be58){var _0x4a2b0b={};_0x4a2b0b[_0xd7be58]={'$like':'%'+_0x2d8259[_0xabf1('0x2f')]['filter']+'%'};return _0x4a2b0b;})});}_0x2dace7=_['merge']({},_0x2dace7,_0x2d8259[_0xabf1('0x45')]);return _0x1cd6d8['getConfigurations'](_0x2dace7);}})[_0xabf1('0x26')](function(_0x2beb5b){if(_0x2beb5b){_0x40210b=_0x2beb5b[_0xabf1('0x36')];if(!_0x2d8259[_0xabf1('0x2f')][_0xabf1('0x37')](_0xabf1('0x38'))){_0x2dace7['limit']=qs[_0xabf1('0x1f')](_0x2d8259[_0xabf1('0x2f')][_0xabf1('0x1f')]);_0x2dace7['offset']=qs[_0xabf1('0x1e')](_0x2d8259['query']['offset']);}return _0x1cd6d8[_0xabf1('0x49')](_0x2dace7);}})['then'](function(_0x429aa8){if(_0x429aa8){return _0x429aa8?{'count':_0x40210b,'rows':_0x429aa8}:null;}})[_0xabf1('0x26')](respondWithResult(_0x390f9b,null))[_0xabf1('0x43')](handleError(_0x390f9b,null));};exports[_0xabf1('0x4c')]=function(_0x51725e,_0x451489,_0x34bff8){if(_0x51725e['body']['id']){delete _0x51725e[_0xabf1('0x48')]['id'];}return db['FreshdeskAccount'][_0xabf1('0x4a')]({'where':{'id':_0x51725e[_0xabf1('0x44')]['id']}})[_0xabf1('0x26')](handleEntityNotFound(_0x451489,null))[_0xabf1('0x26')](function(_0x204feb){if(_0x204feb){_0x51725e[_0xabf1('0x48')][_0xabf1('0x4d')]=_0x204feb['id'];_0x51725e[_0xabf1('0x48')][_0xabf1('0x4e')]=integrations[_0xabf1('0x4f')](_0x51725e[_0xabf1('0x48')][_0xabf1('0x50')],_0x51725e[_0xabf1('0x48')]['type']);_0x51725e[_0xabf1('0x48')]['Descriptions']=integrations[_0xabf1('0x51')](_0x51725e[_0xabf1('0x48')][_0xabf1('0x50')],_0x51725e[_0xabf1('0x48')]['type']);return db['FreshdeskConfiguration']['create'](_0x51725e[_0xabf1('0x48')],{'include':[{'model':db[_0xabf1('0x52')],'as':'Subjects'},{'model':db[_0xabf1('0x52')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x451489,null))[_0xabf1('0x43')](handleError(_0x451489,null));};exports[_0xabf1('0x53')]=function(_0x3e1f8e,_0x41e78f,_0x23d9a4){var _0x54979b='';return db[_0xabf1('0x2b')]['findOne']({'where':{'id':_0x3e1f8e[_0xabf1('0x44')]['id']},'attributes':['id',_0xabf1('0x54'),'apiKey']})[_0xabf1('0x26')](handleEntityNotFound(_0x41e78f,null))[_0xabf1('0x26')](function(_0x86f04e){if(_0x86f04e){_0x54979b=_0x86f04e['remoteUri'];var _0x2e15d2=_0x54979b[_0xabf1('0x55')](-0x1);if(_0x2e15d2==='/'){_0x54979b=_0x54979b[_0xabf1('0x56')](0x0,_0x54979b[_0xabf1('0x57')](_0x2e15d2));}return rp({'method':_0xabf1('0x58'),'uri':util[_0xabf1('0x59')](_0xabf1('0x5a'),_0x54979b,_0xabf1('0x5b')),'headers':{'Authorization':util['format']('Basic\x20%s',new Buffer(util[_0xabf1('0x59')](_0xabf1('0x5c'),_0x86f04e[_0xabf1('0x5d')]))['toString'](_0xabf1('0x5e')))},'json':!![]});}})[_0xabf1('0x26')](function(_0xce15a1){if(_0xce15a1){var _0x4af8c2=['requester',_0xabf1('0x5f'),_0xabf1('0x60'),_0xabf1('0x61'),_0xabf1('0x1c'),_0xabf1('0x62'),_0xabf1('0x63'),'source',_0xabf1('0x64'),_0xabf1('0x63'),_0xabf1('0x65')];_['remove'](_0xce15a1,function(_0x4a0c54){return _0x4af8c2['includes'](_0x4a0c54[_0xabf1('0x29')])||!_0x4a0c54[_0xabf1('0x66')]&&_0x4a0c54[_0xabf1('0x3e')]!==_0xabf1('0x67')&&_0x4a0c54[_0xabf1('0x3e')]!==_0xabf1('0x68');});return{'count':_0xce15a1[_0xabf1('0x36')],'rows':_[_0xabf1('0x2e')](_0xce15a1,function(_0x5c771e){return{'id':_0x5c771e['name'],'name':_0x5c771e[_0xabf1('0x69')],'custom':!_0x5c771e[_0xabf1('0x66')],'options':_0x5c771e[_0xabf1('0x6a')]?_[_0xabf1('0x2e')](_0x5c771e[_0xabf1('0x6a')],function(_0x4f2143){return{'name':_['capitalize'](_0x4f2143),'value':_0x4f2143};}):[]};})};}})['then'](respondWithResult(_0x41e78f,null))[_0xabf1('0x43')](function(_0x4cd09a){var _0xde5c57=_0x3e1f8e[_0xabf1('0x2f')][_0xabf1('0x6b')]?0x1f4:_0x4cd09a[_0xabf1('0x6c')]||0x1f4;logger[_0xabf1('0x27')](_0xabf1('0x6d'),_0xabf1('0x53'),_0xde5c57,JSON[_0xabf1('0x6e')](_0x4cd09a));delete _0x4cd09a[_0xabf1('0x29')];if(_0xde5c57===0x191){_0xde5c57=0x190;}_0x41e78f['status'](_0xde5c57)[_0xabf1('0x2a')](_0x3e1f8e[_0xabf1('0x2f')][_0xabf1('0x6b')]?{'message':_0xabf1('0x6f'),'statusCode':_0x4cd09a[_0xabf1('0x6c')]}:_0x4cd09a);});};
\ No newline at end of file