Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 48c51d8..2b9e89c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x91a7=['includes','position','system_field_options','custom_field_options','test','getFields,\x20%s,\x20%s,\x20%s','statusCode','rimraf','zip-dir','fast-json-patch','moment','mustache','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','limit','set','apply','reject','save','update','then','sendStatus','error','name','send','index','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','ZendeskAccount','count','include','rows','params','keys','includeAll','find','catch','create','body','destroy','getConfigurations','ZendeskConfiguration','hasOwnProperty','AccountId','Subjects','getSubjects','channel','ZendeskField','Descriptions','getFields','findOne','username','password','token','authType','remoteUri','slice','substring','lastIndexOf','GET','format','%s/%s','Basic\x20%s','headers','toString','base64','Sequelize','ValidationError','subject','description','group','assignee','remove','ticket_fields'];(function(_0x9d9faf,_0x131737){var _0x4adf7a=function(_0x54f7d3){while(--_0x54f7d3){_0x9d9faf['push'](_0x9d9faf['shift']());}};_0x4adf7a(++_0x131737);}(_0x91a7,0xe7));var _0x791a=function(_0x565da9,_0x109b21){_0x565da9=_0x565da9-0x0;var _0x55f70f=_0x91a7[_0x565da9];return _0x55f70f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x791a('0x0'));var zipdir=require(_0x791a('0x1'));var jsonpatch=require(_0x791a('0x2'));var rp=require('request-promise');var moment=require(_0x791a('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x791a('0x4'));var util=require('util');var path=require('path');var sox=require(_0x791a('0x5'));var csv=require(_0x791a('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x791a('0x7'));var _=require('lodash');var squel=require(_0x791a('0x8'));var crypto=require(_0x791a('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x791a('0xa'));var toCsv=require(_0x791a('0x6'));var querystring=require(_0x791a('0xb'));var Papa=require(_0x791a('0xc'));var Redis=require(_0x791a('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x791a('0xe'));var as=require(_0x791a('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x791a('0x10'))(_0x791a('0x11'));var utils=require(_0x791a('0x12'));var config=require(_0x791a('0x13'));var licenseUtil=require(_0x791a('0x14'));var db=require(_0x791a('0x15'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x5daecd,_0xc92016){_0xc92016=_0xc92016||0xcc;return function(_0x2f2d8d){if(_0x2f2d8d){return _0x5daecd['sendStatus'](_0xc92016);}return _0x5daecd[_0x791a('0x16')](_0xc92016)[_0x791a('0x17')]();};}function respondWithResult(_0x5d5b11,_0x2887f0){_0x2887f0=_0x2887f0||0xc8;return function(_0x31b86d){if(_0x31b86d){return _0x5d5b11[_0x791a('0x16')](_0x2887f0)[_0x791a('0x18')](_0x31b86d);}};}function respondWithFilteredResult(_0x55e845,_0x2ce2e0){return function(_0x575d11){if(_0x575d11){var _0x43dea6=typeof _0x2ce2e0[_0x791a('0x19')]==='undefined'&&typeof _0x2ce2e0[_0x791a('0x1a')]==='undefined';var _0x35fe48=_0x575d11['count'];var _0x4a84ee=_0x43dea6?0x0:_0x2ce2e0['offset'];var _0x40f0d3=_0x43dea6?_0x575d11['count']:_0x2ce2e0['offset']+_0x2ce2e0[_0x791a('0x1a')];var _0x5a702e;if(_0x40f0d3>=_0x35fe48){_0x40f0d3=_0x35fe48;_0x5a702e=0xc8;}else{_0x5a702e=0xce;}_0x55e845[_0x791a('0x16')](_0x5a702e);return _0x55e845[_0x791a('0x1b')]('Content-Range',_0x4a84ee+'-'+_0x40f0d3+'/'+_0x35fe48)[_0x791a('0x18')](_0x575d11);}return null;};}function patchUpdates(_0xcb5e66){return function(_0x234514){try{jsonpatch[_0x791a('0x1c')](_0x234514,_0xcb5e66,!![]);}catch(_0x530e32){return BPromise[_0x791a('0x1d')](_0x530e32);}return _0x234514[_0x791a('0x1e')]();};}function saveUpdates(_0x25bae5,_0x9e17b5){return function(_0x3200dd){if(_0x3200dd){return _0x3200dd[_0x791a('0x1f')](_0x25bae5)[_0x791a('0x20')](function(_0x45a67d){return _0x45a67d;});}return null;};}function removeEntity(_0x323c6a,_0xe8e452){return function(_0x137992){if(_0x137992){return _0x137992['destroy']()[_0x791a('0x20')](function(){_0x323c6a[_0x791a('0x16')](0xcc)[_0x791a('0x17')]();});}};}function handleEntityNotFound(_0x2966b8,_0x4d748a){return function(_0x456480){if(!_0x456480){_0x2966b8[_0x791a('0x21')](0x194);}return _0x456480;};}function handleError(_0x51dcca,_0xdfa84f){_0xdfa84f=_0xdfa84f||0x1f4;return function(_0x1785f5){logger[_0x791a('0x22')](_0x1785f5['stack']);if(_0x1785f5[_0x791a('0x23')]){delete _0x1785f5[_0x791a('0x23')];}_0x51dcca[_0x791a('0x16')](_0xdfa84f)[_0x791a('0x24')](_0x1785f5);};}exports[_0x791a('0x25')]=function(_0x1a9c6b,_0x628816){var _0x889534={},_0x58bbc0={},_0xbc3436={'count':0x0,'rows':[]};var _0x9e9332=_[_0x791a('0x26')](db['ZendeskAccount'][_0x791a('0x27')],function(_0x5df656){return{'name':_0x5df656[_0x791a('0x28')],'type':_0x5df656[_0x791a('0x29')][_0x791a('0x2a')]};});_0x58bbc0[_0x791a('0x2b')]=_[_0x791a('0x26')](_0x9e9332,_0x791a('0x23'));_0x58bbc0[_0x791a('0x2c')]=_['keys'](_0x1a9c6b[_0x791a('0x2c')]);_0x58bbc0[_0x791a('0x2d')]=_[_0x791a('0x2e')](_0x58bbc0[_0x791a('0x2b')],_0x58bbc0[_0x791a('0x2c')]);_0x889534['attributes']=_[_0x791a('0x2e')](_0x58bbc0[_0x791a('0x2b')],qs[_0x791a('0x2f')](_0x1a9c6b[_0x791a('0x2c')][_0x791a('0x2f')]));_0x889534['attributes']=_0x889534[_0x791a('0x30')][_0x791a('0x31')]?_0x889534[_0x791a('0x30')]:_0x58bbc0[_0x791a('0x2b')];if(!_0x1a9c6b[_0x791a('0x2c')]['hasOwnProperty'](_0x791a('0x32'))){_0x889534['limit']=qs[_0x791a('0x1a')](_0x1a9c6b['query']['limit']);_0x889534[_0x791a('0x19')]=qs[_0x791a('0x19')](_0x1a9c6b[_0x791a('0x2c')][_0x791a('0x19')]);}_0x889534[_0x791a('0x33')]=qs[_0x791a('0x34')](_0x1a9c6b[_0x791a('0x2c')]['sort']);_0x889534[_0x791a('0x35')]=qs['filters'](_[_0x791a('0x36')](_0x1a9c6b['query'],_0x58bbc0[_0x791a('0x2d')]),_0x9e9332);if(_0x1a9c6b[_0x791a('0x2c')]['filter']){_0x889534[_0x791a('0x35')]=_[_0x791a('0x37')](_0x889534['where'],{'$or':_[_0x791a('0x26')](_0x9e9332,function(_0x165e2b){if(_0x165e2b[_0x791a('0x29')]!==_0x791a('0x38')){var _0x29d267={};_0x29d267[_0x165e2b[_0x791a('0x23')]]={'$like':'%'+_0x1a9c6b[_0x791a('0x2c')][_0x791a('0x39')]+'%'};return _0x29d267;}})});}_0x889534=_[_0x791a('0x37')]({},_0x889534,_0x1a9c6b[_0x791a('0x3a')]);var _0x587481={'where':_0x889534[_0x791a('0x35')]};return db[_0x791a('0x3b')][_0x791a('0x3c')](_0x587481)['then'](function(_0xf4e2fa){_0xbc3436['count']=_0xf4e2fa;if(_0x1a9c6b['query']['includeAll']){_0x889534[_0x791a('0x3d')]=[{'all':!![]}];}return db[_0x791a('0x3b')]['findAll'](_0x889534);})[_0x791a('0x20')](function(_0x2d1692){_0xbc3436[_0x791a('0x3e')]=_0x2d1692;return _0xbc3436;})[_0x791a('0x20')](respondWithFilteredResult(_0x628816,_0x889534))['catch'](handleError(_0x628816,null));};exports['show']=function(_0x57b9ba,_0x2f0395){var _0x216dd3={'raw':![],'where':{'id':_0x57b9ba[_0x791a('0x3f')]['id']}},_0x4e0191={};_0x4e0191[_0x791a('0x2b')]=_[_0x791a('0x40')](db[_0x791a('0x3b')]['rawAttributes']);_0x4e0191[_0x791a('0x2c')]=_['keys'](_0x57b9ba[_0x791a('0x2c')]);_0x4e0191[_0x791a('0x2d')]=_[_0x791a('0x2e')](_0x4e0191[_0x791a('0x2b')],_0x4e0191[_0x791a('0x2c')]);_0x216dd3['attributes']=_[_0x791a('0x2e')](_0x4e0191[_0x791a('0x2b')],qs[_0x791a('0x2f')](_0x57b9ba[_0x791a('0x2c')][_0x791a('0x2f')]));_0x216dd3['attributes']=_0x216dd3[_0x791a('0x30')][_0x791a('0x31')]?_0x216dd3['attributes']:_0x4e0191['model'];if(_0x57b9ba[_0x791a('0x2c')][_0x791a('0x41')]){_0x216dd3[_0x791a('0x3d')]=[{'all':!![]}];}_0x216dd3=_['merge']({},_0x216dd3,_0x57b9ba['options']);return db[_0x791a('0x3b')][_0x791a('0x42')](_0x216dd3)['then'](handleEntityNotFound(_0x2f0395,null))[_0x791a('0x20')](respondWithResult(_0x2f0395,null))[_0x791a('0x43')](handleError(_0x2f0395,null));};exports[_0x791a('0x44')]=function(_0x549980,_0x5a30a6){return db[_0x791a('0x3b')][_0x791a('0x44')](_0x549980[_0x791a('0x45')],{})[_0x791a('0x20')](respondWithResult(_0x5a30a6,0xc9))['catch'](handleError(_0x5a30a6,null));};exports[_0x791a('0x1f')]=function(_0x9f768a,_0x4e6d0d){if(_0x9f768a[_0x791a('0x45')]['id']){delete _0x9f768a['body']['id'];}return db[_0x791a('0x3b')][_0x791a('0x42')]({'where':{'id':_0x9f768a[_0x791a('0x3f')]['id']}})[_0x791a('0x20')](handleEntityNotFound(_0x4e6d0d,null))[_0x791a('0x20')](saveUpdates(_0x9f768a[_0x791a('0x45')],null))[_0x791a('0x20')](respondWithResult(_0x4e6d0d,null))['catch'](handleError(_0x4e6d0d,null));};exports[_0x791a('0x46')]=function(_0x1fd826,_0x4bffa6){return db[_0x791a('0x3b')][_0x791a('0x42')]({'where':{'id':_0x1fd826['params']['id']}})[_0x791a('0x20')](handleEntityNotFound(_0x4bffa6,null))[_0x791a('0x20')](removeEntity(_0x4bffa6,null))[_0x791a('0x43')](handleError(_0x4bffa6,null));};exports[_0x791a('0x47')]=function(_0xd5ec90,_0x4d82eb,_0x4ab42f){var _0x5a616f={};var _0x305033={};var _0x51b556;var _0x4c7555;return db[_0x791a('0x3b')]['findOne']({'where':{'id':_0xd5ec90[_0x791a('0x3f')]['id']}})[_0x791a('0x20')](handleEntityNotFound(_0x4d82eb,null))['then'](function(_0x5166b5){if(_0x5166b5){_0x51b556=_0x5166b5;_0x305033[_0x791a('0x2b')]=_['keys'](db[_0x791a('0x48')][_0x791a('0x27')]);_0x305033[_0x791a('0x2c')]=_['keys'](_0xd5ec90[_0x791a('0x2c')]);_0x305033[_0x791a('0x2d')]=_['intersection'](_0x305033[_0x791a('0x2b')],_0x305033[_0x791a('0x2c')]);_0x5a616f[_0x791a('0x30')]=_[_0x791a('0x2e')](_0x305033[_0x791a('0x2b')],qs[_0x791a('0x2f')](_0xd5ec90['query']['fields']));_0x5a616f[_0x791a('0x30')]=_0x5a616f['attributes'][_0x791a('0x31')]?_0x5a616f[_0x791a('0x30')]:_0x305033[_0x791a('0x2b')];_0x5a616f[_0x791a('0x33')]=qs[_0x791a('0x34')](_0xd5ec90[_0x791a('0x2c')][_0x791a('0x34')]);_0x5a616f['where']=qs[_0x791a('0x2d')](_[_0x791a('0x36')](_0xd5ec90[_0x791a('0x2c')],_0x305033[_0x791a('0x2d')]));if(_0xd5ec90[_0x791a('0x2c')][_0x791a('0x39')]){_0x5a616f[_0x791a('0x35')]=_['merge'](_0x5a616f[_0x791a('0x35')],{'$or':_['map'](_0x5a616f['attributes'],function(_0x1cc240){var _0x3c81e2={};_0x3c81e2[_0x1cc240]={'$like':'%'+_0xd5ec90[_0x791a('0x2c')][_0x791a('0x39')]+'%'};return _0x3c81e2;})});}_0x5a616f=_[_0x791a('0x37')]({},_0x5a616f,_0xd5ec90[_0x791a('0x3a')]);return _0x51b556[_0x791a('0x47')](_0x5a616f);}})[_0x791a('0x20')](function(_0x2bfb66){if(_0x2bfb66){_0x4c7555=_0x2bfb66[_0x791a('0x31')];if(!_0xd5ec90[_0x791a('0x2c')][_0x791a('0x49')](_0x791a('0x32'))){_0x5a616f[_0x791a('0x1a')]=qs[_0x791a('0x1a')](_0xd5ec90[_0x791a('0x2c')][_0x791a('0x1a')]);_0x5a616f[_0x791a('0x19')]=qs[_0x791a('0x19')](_0xd5ec90[_0x791a('0x2c')]['offset']);}return _0x51b556[_0x791a('0x47')](_0x5a616f);}})[_0x791a('0x20')](function(_0x380087){if(_0x380087){return _0x380087?{'count':_0x4c7555,'rows':_0x380087}:null;}})[_0x791a('0x20')](respondWithResult(_0x4d82eb,null))[_0x791a('0x43')](handleError(_0x4d82eb,null));};exports['addConfiguration']=function(_0x42ce59,_0x3d24bd,_0x277774){if(_0x42ce59[_0x791a('0x45')]['id']){delete _0x42ce59['body']['id'];}return db[_0x791a('0x3b')]['findOne']({'where':{'id':_0x42ce59['params']['id']}})['then'](handleEntityNotFound(_0x3d24bd,null))['then'](function(_0x22aaf2){if(_0x22aaf2){_0x42ce59[_0x791a('0x45')][_0x791a('0x4a')]=_0x22aaf2['id'];_0x42ce59[_0x791a('0x45')][_0x791a('0x4b')]=integrations[_0x791a('0x4c')](_0x42ce59[_0x791a('0x45')]['channel'],_0x42ce59['body'][_0x791a('0x29')]);_0x42ce59[_0x791a('0x45')]['Descriptions']=integrations['getDescriptions'](_0x42ce59[_0x791a('0x45')][_0x791a('0x4d')],_0x42ce59['body'][_0x791a('0x29')]);return db[_0x791a('0x48')][_0x791a('0x44')](_0x42ce59[_0x791a('0x45')],{'include':[{'model':db['ZendeskField'],'as':'Subjects'},{'model':db[_0x791a('0x4e')],'as':_0x791a('0x4f')}]});}return null;})['then'](respondWithResult(_0x3d24bd,null))[_0x791a('0x43')](handleError(_0x3d24bd,null));};exports[_0x791a('0x50')]=function(_0x10b51f,_0x3838c4,_0x565c83){var _0x24efc2='';return db[_0x791a('0x3b')][_0x791a('0x51')]({'where':{'id':_0x10b51f[_0x791a('0x3f')]['id']},'attributes':['id',_0x791a('0x52'),_0x791a('0x53'),_0x791a('0x54'),_0x791a('0x55'),'remoteUri']})['then'](handleEntityNotFound(_0x3838c4,null))['then'](function(_0xf8ac72){if(_0xf8ac72){_0x24efc2=_0xf8ac72[_0x791a('0x56')];var _0x1118a8=_0x24efc2[_0x791a('0x57')](-0x1);if(_0x1118a8==='/'){_0x24efc2=_0x24efc2[_0x791a('0x58')](0x0,_0x24efc2[_0x791a('0x59')](_0x1118a8));}var _0x348e54={'method':_0x791a('0x5a'),'uri':util[_0x791a('0x5b')](_0x791a('0x5c'),_0x24efc2,'ticket_fields'),'json':!![]};switch(_0xf8ac72[_0x791a('0x55')]){case _0x791a('0x53'):_0x348e54['headers']={'Authorization':util[_0x791a('0x5b')](_0x791a('0x5d'),new Buffer(util['format']('%s:%s',_0xf8ac72[_0x791a('0x52')],_0xf8ac72[_0x791a('0x53')]))['toString']('base64'))};break;case _0x791a('0x54'):_0x348e54[_0x791a('0x5e')]={'Authorization':util[_0x791a('0x5b')]('Basic\x20%s',new Buffer(util[_0x791a('0x5b')]('%s/token:%s',_0xf8ac72[_0x791a('0x52')],_0xf8ac72[_0x791a('0x54')]))[_0x791a('0x5f')](_0x791a('0x60')))};break;default:throw new db[(_0x791a('0x61'))][(_0x791a('0x62'))]('Unknown\x20authentication\x20type');}return rp(_0x348e54);}})[_0x791a('0x20')](function(_0x2e666e){if(_0x2e666e){var _0x41d1a5=[_0x791a('0x63'),_0x791a('0x64'),_0x791a('0x65'),_0x791a('0x66')];_[_0x791a('0x67')](_0x2e666e[_0x791a('0x68')],function(_0x203fc5){return _0x41d1a5[_0x791a('0x69')](_0x203fc5[_0x791a('0x29')]);});return{'count':_0x2e666e[_0x791a('0x68')][_0x791a('0x31')],'rows':_[_0x791a('0x26')](_0x2e666e[_0x791a('0x68')],function(_0x3272c0){return{'id':_0x3272c0['id'],'name':_0x3272c0[_0x791a('0x6a')]>0x7?_0x3272c0['title']:_0x3272c0[_0x791a('0x29')],'custom':_0x3272c0[_0x791a('0x6a')]>0x7?!![]:![],'options':_0x3272c0[_0x791a('0x6b')]?_0x3272c0[_0x791a('0x6b')]:_0x3272c0[_0x791a('0x6c')]?_0x3272c0['custom_field_options']:[]};})};}})[_0x791a('0x20')](respondWithResult(_0x3838c4,null))['catch'](function(_0x467d65){var _0x48b8dc=_0x10b51f[_0x791a('0x2c')][_0x791a('0x6d')]?0x1f4:_0x467d65['statusCode']||0x1f4;logger[_0x791a('0x22')](_0x791a('0x6e'),_0x791a('0x50'),_0x48b8dc,JSON['stringify'](_0x467d65));delete _0x467d65[_0x791a('0x23')];if(_0x48b8dc===0x191){_0x48b8dc=0x190;}_0x3838c4['status'](_0x48b8dc)[_0x791a('0x24')](_0x10b51f['query']['test']?{'message':'Wrong\x20credentials','statusCode':_0x467d65[_0x791a('0x6f')]}:_0x467d65);});};
\ No newline at end of file
+var _0x44a3=['save','update','then','error','stack','name','send','index','map','ZendeskAccount','rawAttributes','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','catch','params','find','create','body','destroy','getConfigurations','ZendeskConfiguration','addConfiguration','Subjects','getSubjects','Descriptions','ZendeskField','getFields','username','password','token','remoteUri','slice','substring','GET','format','%s/%s','ticket_fields','authType','headers','Basic\x20%s','%s:%s','toString','base64','%s/token:%s','Sequelize','Unknown\x20authentication\x20type','subject','description','assignee','remove','includes','position','title','custom_field_options','test','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject'];(function(_0x55f8b4,_0x43f30d){var _0x2475f9=function(_0xdd6f4a){while(--_0xdd6f4a){_0x55f8b4['push'](_0x55f8b4['shift']());}};_0x2475f9(++_0x43f30d);}(_0x44a3,0x1a9));var _0x344a=function(_0x12954a,_0x304691){_0x12954a=_0x12954a-0x0;var _0x5ccde2=_0x44a3[_0x12954a];return _0x5ccde2;};'use strict';var emlformat=require(_0x344a('0x0'));var rimraf=require(_0x344a('0x1'));var zipdir=require(_0x344a('0x2'));var jsonpatch=require(_0x344a('0x3'));var rp=require(_0x344a('0x4'));var moment=require(_0x344a('0x5'));var BPromise=require(_0x344a('0x6'));var Mustache=require(_0x344a('0x7'));var util=require('util');var path=require(_0x344a('0x8'));var sox=require(_0x344a('0x9'));var csv=require(_0x344a('0xa'));var ejs=require(_0x344a('0xb'));var fs=require('fs');var fs_extra=require(_0x344a('0xc'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x344a('0xd'));var toCsv=require(_0x344a('0xa'));var querystring=require(_0x344a('0xe'));var Papa=require(_0x344a('0xf'));var Redis=require(_0x344a('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x344a('0x11'));var as=require(_0x344a('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x344a('0x13'))('api');var utils=require(_0x344a('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x344a('0x15'));var db=require(_0x344a('0x16'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x4a69ea,_0x304b70){_0x304b70=_0x304b70||0xcc;return function(_0x2ad7eb){if(_0x2ad7eb){return _0x4a69ea[_0x344a('0x17')](_0x304b70);}return _0x4a69ea[_0x344a('0x18')](_0x304b70)[_0x344a('0x19')]();};}function respondWithResult(_0x133ad4,_0x4ee562){_0x4ee562=_0x4ee562||0xc8;return function(_0x4032d7){if(_0x4032d7){return _0x133ad4[_0x344a('0x18')](_0x4ee562)[_0x344a('0x1a')](_0x4032d7);}};}function respondWithFilteredResult(_0x6e1639,_0x58c8cd){return function(_0x54a643){if(_0x54a643){var _0x3609ce=typeof _0x58c8cd[_0x344a('0x1b')]===_0x344a('0x1c')&&typeof _0x58c8cd[_0x344a('0x1d')]==='undefined';var _0x397de6=_0x54a643[_0x344a('0x1e')];var _0x49b55f=_0x3609ce?0x0:_0x58c8cd[_0x344a('0x1b')];var _0x274016=_0x3609ce?_0x54a643[_0x344a('0x1e')]:_0x58c8cd[_0x344a('0x1b')]+_0x58c8cd[_0x344a('0x1d')];var _0x43fa0f;if(_0x274016>=_0x397de6){_0x274016=_0x397de6;_0x43fa0f=0xc8;}else{_0x43fa0f=0xce;}_0x6e1639[_0x344a('0x18')](_0x43fa0f);return _0x6e1639[_0x344a('0x1f')](_0x344a('0x20'),_0x49b55f+'-'+_0x274016+'/'+_0x397de6)[_0x344a('0x1a')](_0x54a643);}return null;};}function patchUpdates(_0x4b3552){return function(_0x16c0fe){try{jsonpatch[_0x344a('0x21')](_0x16c0fe,_0x4b3552,!![]);}catch(_0xe0bdd4){return BPromise[_0x344a('0x22')](_0xe0bdd4);}return _0x16c0fe[_0x344a('0x23')]();};}function saveUpdates(_0x80ae12,_0x185303){return function(_0x976bcf){if(_0x976bcf){return _0x976bcf[_0x344a('0x24')](_0x80ae12)[_0x344a('0x25')](function(_0x90070c){return _0x90070c;});}return null;};}function removeEntity(_0x3b2ab9,_0x5ce9da){return function(_0x266fce){if(_0x266fce){return _0x266fce['destroy']()[_0x344a('0x25')](function(){_0x3b2ab9['status'](0xcc)[_0x344a('0x19')]();});}};}function handleEntityNotFound(_0x484f97,_0x36c920){return function(_0x8bf0b0){if(!_0x8bf0b0){_0x484f97[_0x344a('0x17')](0x194);}return _0x8bf0b0;};}function handleError(_0x16d404,_0x26f059){_0x26f059=_0x26f059||0x1f4;return function(_0x28749b){logger[_0x344a('0x26')](_0x28749b[_0x344a('0x27')]);if(_0x28749b['name']){delete _0x28749b[_0x344a('0x28')];}_0x16d404[_0x344a('0x18')](_0x26f059)[_0x344a('0x29')](_0x28749b);};}exports[_0x344a('0x2a')]=function(_0x14bd54,_0x2d72c9){var _0x5b877d={},_0x3d25fe={},_0x49bbf8={'count':0x0,'rows':[]};var _0x593cf6=_[_0x344a('0x2b')](db[_0x344a('0x2c')][_0x344a('0x2d')],function(_0x4803db){return{'name':_0x4803db['fieldName'],'type':_0x4803db['type'][_0x344a('0x2e')]};});_0x3d25fe[_0x344a('0x2f')]=_[_0x344a('0x2b')](_0x593cf6,'name');_0x3d25fe[_0x344a('0x30')]=_[_0x344a('0x31')](_0x14bd54[_0x344a('0x30')]);_0x3d25fe[_0x344a('0x32')]=_[_0x344a('0x33')](_0x3d25fe[_0x344a('0x2f')],_0x3d25fe[_0x344a('0x30')]);_0x5b877d['attributes']=_[_0x344a('0x33')](_0x3d25fe['model'],qs['fields'](_0x14bd54['query'][_0x344a('0x34')]));_0x5b877d[_0x344a('0x35')]=_0x5b877d[_0x344a('0x35')][_0x344a('0x36')]?_0x5b877d[_0x344a('0x35')]:_0x3d25fe[_0x344a('0x2f')];if(!_0x14bd54['query'][_0x344a('0x37')](_0x344a('0x38'))){_0x5b877d[_0x344a('0x1d')]=qs['limit'](_0x14bd54[_0x344a('0x30')][_0x344a('0x1d')]);_0x5b877d[_0x344a('0x1b')]=qs[_0x344a('0x1b')](_0x14bd54[_0x344a('0x30')]['offset']);}_0x5b877d[_0x344a('0x39')]=qs[_0x344a('0x3a')](_0x14bd54[_0x344a('0x30')][_0x344a('0x3a')]);_0x5b877d[_0x344a('0x3b')]=qs['filters'](_[_0x344a('0x3c')](_0x14bd54[_0x344a('0x30')],_0x3d25fe[_0x344a('0x32')]),_0x593cf6);if(_0x14bd54[_0x344a('0x30')][_0x344a('0x3d')]){_0x5b877d['where']=_[_0x344a('0x3e')](_0x5b877d[_0x344a('0x3b')],{'$or':_[_0x344a('0x2b')](_0x593cf6,function(_0x3356fb){if(_0x3356fb[_0x344a('0x3f')]!==_0x344a('0x40')){var _0x335a0a={};_0x335a0a[_0x3356fb[_0x344a('0x28')]]={'$like':'%'+_0x14bd54['query'][_0x344a('0x3d')]+'%'};return _0x335a0a;}})});}_0x5b877d=_[_0x344a('0x3e')]({},_0x5b877d,_0x14bd54[_0x344a('0x41')]);var _0x28bad9={'where':_0x5b877d[_0x344a('0x3b')]};return db['ZendeskAccount'][_0x344a('0x1e')](_0x28bad9)[_0x344a('0x25')](function(_0x7a33d7){_0x49bbf8[_0x344a('0x1e')]=_0x7a33d7;if(_0x14bd54[_0x344a('0x30')][_0x344a('0x42')]){_0x5b877d[_0x344a('0x43')]=[{'all':!![]}];}return db[_0x344a('0x2c')][_0x344a('0x44')](_0x5b877d);})['then'](function(_0x115a9c){_0x49bbf8[_0x344a('0x45')]=_0x115a9c;return _0x49bbf8;})[_0x344a('0x25')](respondWithFilteredResult(_0x2d72c9,_0x5b877d))[_0x344a('0x46')](handleError(_0x2d72c9,null));};exports['show']=function(_0x32bfa6,_0x3069ca){var _0x2b0ee9={'raw':![],'where':{'id':_0x32bfa6[_0x344a('0x47')]['id']}},_0x41f25b={};_0x41f25b[_0x344a('0x2f')]=_[_0x344a('0x31')](db[_0x344a('0x2c')][_0x344a('0x2d')]);_0x41f25b[_0x344a('0x30')]=_[_0x344a('0x31')](_0x32bfa6['query']);_0x41f25b[_0x344a('0x32')]=_[_0x344a('0x33')](_0x41f25b['model'],_0x41f25b[_0x344a('0x30')]);_0x2b0ee9[_0x344a('0x35')]=_['intersection'](_0x41f25b[_0x344a('0x2f')],qs[_0x344a('0x34')](_0x32bfa6['query'][_0x344a('0x34')]));_0x2b0ee9[_0x344a('0x35')]=_0x2b0ee9[_0x344a('0x35')]['length']?_0x2b0ee9[_0x344a('0x35')]:_0x41f25b['model'];if(_0x32bfa6[_0x344a('0x30')][_0x344a('0x42')]){_0x2b0ee9[_0x344a('0x43')]=[{'all':!![]}];}_0x2b0ee9=_[_0x344a('0x3e')]({},_0x2b0ee9,_0x32bfa6['options']);return db['ZendeskAccount'][_0x344a('0x48')](_0x2b0ee9)[_0x344a('0x25')](handleEntityNotFound(_0x3069ca,null))[_0x344a('0x25')](respondWithResult(_0x3069ca,null))[_0x344a('0x46')](handleError(_0x3069ca,null));};exports[_0x344a('0x49')]=function(_0xa3c8f0,_0x44962b){return db[_0x344a('0x2c')][_0x344a('0x49')](_0xa3c8f0[_0x344a('0x4a')],{})['then'](respondWithResult(_0x44962b,0xc9))[_0x344a('0x46')](handleError(_0x44962b,null));};exports[_0x344a('0x24')]=function(_0x6fad37,_0xbad7ca){if(_0x6fad37['body']['id']){delete _0x6fad37[_0x344a('0x4a')]['id'];}return db['ZendeskAccount']['find']({'where':{'id':_0x6fad37[_0x344a('0x47')]['id']}})[_0x344a('0x25')](handleEntityNotFound(_0xbad7ca,null))['then'](saveUpdates(_0x6fad37[_0x344a('0x4a')],null))[_0x344a('0x25')](respondWithResult(_0xbad7ca,null))[_0x344a('0x46')](handleError(_0xbad7ca,null));};exports[_0x344a('0x4b')]=function(_0x51e411,_0x225fce){return db[_0x344a('0x2c')][_0x344a('0x48')]({'where':{'id':_0x51e411[_0x344a('0x47')]['id']}})[_0x344a('0x25')](handleEntityNotFound(_0x225fce,null))[_0x344a('0x25')](removeEntity(_0x225fce,null))[_0x344a('0x46')](handleError(_0x225fce,null));};exports[_0x344a('0x4c')]=function(_0x292357,_0x1911d0,_0x5e0885){var _0x15928a={};var _0x47ce9c={};var _0x1b7f6c;var _0xb744c6;return db[_0x344a('0x2c')]['findOne']({'where':{'id':_0x292357[_0x344a('0x47')]['id']}})[_0x344a('0x25')](handleEntityNotFound(_0x1911d0,null))[_0x344a('0x25')](function(_0x14921e){if(_0x14921e){_0x1b7f6c=_0x14921e;_0x47ce9c[_0x344a('0x2f')]=_[_0x344a('0x31')](db[_0x344a('0x4d')][_0x344a('0x2d')]);_0x47ce9c[_0x344a('0x30')]=_['keys'](_0x292357[_0x344a('0x30')]);_0x47ce9c[_0x344a('0x32')]=_[_0x344a('0x33')](_0x47ce9c[_0x344a('0x2f')],_0x47ce9c[_0x344a('0x30')]);_0x15928a['attributes']=_[_0x344a('0x33')](_0x47ce9c[_0x344a('0x2f')],qs[_0x344a('0x34')](_0x292357[_0x344a('0x30')]['fields']));_0x15928a[_0x344a('0x35')]=_0x15928a[_0x344a('0x35')]['length']?_0x15928a[_0x344a('0x35')]:_0x47ce9c[_0x344a('0x2f')];_0x15928a[_0x344a('0x39')]=qs[_0x344a('0x3a')](_0x292357[_0x344a('0x30')][_0x344a('0x3a')]);_0x15928a[_0x344a('0x3b')]=qs['filters'](_['pick'](_0x292357['query'],_0x47ce9c[_0x344a('0x32')]));if(_0x292357[_0x344a('0x30')][_0x344a('0x3d')]){_0x15928a[_0x344a('0x3b')]=_['merge'](_0x15928a[_0x344a('0x3b')],{'$or':_['map'](_0x15928a['attributes'],function(_0x57241e){var _0x56b562={};_0x56b562[_0x57241e]={'$like':'%'+_0x292357[_0x344a('0x30')][_0x344a('0x3d')]+'%'};return _0x56b562;})});}_0x15928a=_[_0x344a('0x3e')]({},_0x15928a,_0x292357[_0x344a('0x41')]);return _0x1b7f6c['getConfigurations'](_0x15928a);}})['then'](function(_0x56e76e){if(_0x56e76e){_0xb744c6=_0x56e76e[_0x344a('0x36')];if(!_0x292357[_0x344a('0x30')][_0x344a('0x37')](_0x344a('0x38'))){_0x15928a[_0x344a('0x1d')]=qs['limit'](_0x292357[_0x344a('0x30')][_0x344a('0x1d')]);_0x15928a[_0x344a('0x1b')]=qs['offset'](_0x292357[_0x344a('0x30')]['offset']);}return _0x1b7f6c['getConfigurations'](_0x15928a);}})[_0x344a('0x25')](function(_0x532bcf){if(_0x532bcf){return _0x532bcf?{'count':_0xb744c6,'rows':_0x532bcf}:null;}})['then'](respondWithResult(_0x1911d0,null))[_0x344a('0x46')](handleError(_0x1911d0,null));};exports[_0x344a('0x4e')]=function(_0x4f2e35,_0x1bf894,_0x5808f2){if(_0x4f2e35[_0x344a('0x4a')]['id']){delete _0x4f2e35[_0x344a('0x4a')]['id'];}return db[_0x344a('0x2c')]['findOne']({'where':{'id':_0x4f2e35['params']['id']}})[_0x344a('0x25')](handleEntityNotFound(_0x1bf894,null))[_0x344a('0x25')](function(_0xb4ddd7){if(_0xb4ddd7){_0x4f2e35[_0x344a('0x4a')]['AccountId']=_0xb4ddd7['id'];_0x4f2e35['body'][_0x344a('0x4f')]=integrations[_0x344a('0x50')](_0x4f2e35[_0x344a('0x4a')]['channel'],_0x4f2e35[_0x344a('0x4a')][_0x344a('0x3f')]);_0x4f2e35['body'][_0x344a('0x51')]=integrations['getDescriptions'](_0x4f2e35[_0x344a('0x4a')]['channel'],_0x4f2e35['body']['type']);return db[_0x344a('0x4d')][_0x344a('0x49')](_0x4f2e35[_0x344a('0x4a')],{'include':[{'model':db[_0x344a('0x52')],'as':_0x344a('0x4f')},{'model':db[_0x344a('0x52')],'as':'Descriptions'}]});}return null;})[_0x344a('0x25')](respondWithResult(_0x1bf894,null))[_0x344a('0x46')](handleError(_0x1bf894,null));};exports[_0x344a('0x53')]=function(_0x1c4284,_0x26688e,_0x523774){var _0x23a761='';return db[_0x344a('0x2c')]['findOne']({'where':{'id':_0x1c4284[_0x344a('0x47')]['id']},'attributes':['id',_0x344a('0x54'),_0x344a('0x55'),_0x344a('0x56'),'authType',_0x344a('0x57')]})[_0x344a('0x25')](handleEntityNotFound(_0x26688e,null))[_0x344a('0x25')](function(_0x42e1c0){if(_0x42e1c0){_0x23a761=_0x42e1c0[_0x344a('0x57')];var _0x421a09=_0x23a761[_0x344a('0x58')](-0x1);if(_0x421a09==='/'){_0x23a761=_0x23a761[_0x344a('0x59')](0x0,_0x23a761['lastIndexOf'](_0x421a09));}var _0x33113e={'method':_0x344a('0x5a'),'uri':util[_0x344a('0x5b')](_0x344a('0x5c'),_0x23a761,_0x344a('0x5d')),'json':!![]};switch(_0x42e1c0[_0x344a('0x5e')]){case _0x344a('0x55'):_0x33113e[_0x344a('0x5f')]={'Authorization':util['format'](_0x344a('0x60'),new Buffer(util[_0x344a('0x5b')](_0x344a('0x61'),_0x42e1c0[_0x344a('0x54')],_0x42e1c0['password']))[_0x344a('0x62')](_0x344a('0x63')))};break;case _0x344a('0x56'):_0x33113e[_0x344a('0x5f')]={'Authorization':util[_0x344a('0x5b')](_0x344a('0x60'),new Buffer(util[_0x344a('0x5b')](_0x344a('0x64'),_0x42e1c0['username'],_0x42e1c0[_0x344a('0x56')]))[_0x344a('0x62')](_0x344a('0x63')))};break;default:throw new db[(_0x344a('0x65'))]['ValidationError'](_0x344a('0x66'));}return rp(_0x33113e);}})[_0x344a('0x25')](function(_0x1d0025){if(_0x1d0025){var _0x2ff11d=[_0x344a('0x67'),_0x344a('0x68'),'group',_0x344a('0x69')];_[_0x344a('0x6a')](_0x1d0025[_0x344a('0x5d')],function(_0x5584d5){return _0x2ff11d[_0x344a('0x6b')](_0x5584d5[_0x344a('0x3f')]);});return{'count':_0x1d0025[_0x344a('0x5d')][_0x344a('0x36')],'rows':_[_0x344a('0x2b')](_0x1d0025['ticket_fields'],function(_0x15aadb){return{'id':_0x15aadb['id'],'name':_0x15aadb[_0x344a('0x6c')]>0x7?_0x15aadb[_0x344a('0x6d')]:_0x15aadb['type'],'custom':_0x15aadb[_0x344a('0x6c')]>0x7?!![]:![],'options':_0x15aadb['system_field_options']?_0x15aadb['system_field_options']:_0x15aadb[_0x344a('0x6e')]?_0x15aadb[_0x344a('0x6e')]:[]};})};}})[_0x344a('0x25')](respondWithResult(_0x26688e,null))[_0x344a('0x46')](function(_0x375c34){var _0x5e8df4=_0x1c4284[_0x344a('0x30')][_0x344a('0x6f')]?0x1f4:_0x375c34['statusCode']||0x1f4;logger[_0x344a('0x26')](_0x344a('0x70'),'getFields',_0x5e8df4,JSON['stringify'](_0x375c34));delete _0x375c34[_0x344a('0x28')];if(_0x5e8df4===0x191){_0x5e8df4=0x190;}_0x26688e[_0x344a('0x18')](_0x5e8df4)[_0x344a('0x29')](_0x1c4284[_0x344a('0x30')]['test']?{'message':_0x344a('0x71'),'statusCode':_0x375c34[_0x344a('0x72')]}:_0x375c34);});};
\ No newline at end of file