Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 4df437a..2b328c1 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(_0x49cb98,_0x18669b){var _0x47177c=function(_0xfe1af8){while(--_0xfe1af8){_0x49cb98['push'](_0x49cb98['shift']());}};_0x47177c(++_0x18669b);}(_0x91a7,0xe7));var _0x791a=function(_0x5345a5,_0x3c08fd){_0x5345a5=_0x5345a5-0x0;var _0x25fc15=_0x91a7[_0x5345a5];return _0x25fc15;};'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 _0x02ce=['sendStatus','stack','name','send','index','map','ZendeskAccount','rawAttributes','fieldName','type','key','model','keys','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','VIRTUAL','options','include','findAll','rows','catch','show','params','length','merge','find','create','body','ZendeskConfiguration','getConfigurations','addConfiguration','findOne','channel','getDescriptions','Subjects','ZendeskField','Descriptions','username','password','authType','remoteUri','GET','format','%s/%s','ticket_fields','headers','toString','base64','%s/token:%s','token','Sequelize','ValidationError','subject','description','group','assignee','remove','title','position','system_field_options','custom_field_options','error','getFields,\x20%s,\x20%s,\x20%s','stringify','test','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','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','../../mysqldb','../../components/integrations/configuration','end','status','offset','limit','undefined','count','set','reject','update','then','destroy'];(function(_0x1d8458,_0x113b11){var _0x381c19=function(_0x1fbce1){while(--_0x1fbce1){_0x1d8458['push'](_0x1d8458['shift']());}};_0x381c19(++_0x113b11);}(_0x02ce,0x1ac));var _0xe02c=function(_0x180152,_0x448d8c){_0x180152=_0x180152-0x0;var _0x1da90a=_0x02ce[_0x180152];return _0x1da90a;};'use strict';var emlformat=require(_0xe02c('0x0'));var rimraf=require(_0xe02c('0x1'));var zipdir=require(_0xe02c('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe02c('0x3'));var moment=require('moment');var BPromise=require(_0xe02c('0x4'));var Mustache=require(_0xe02c('0x5'));var util=require(_0xe02c('0x6'));var path=require(_0xe02c('0x7'));var sox=require(_0xe02c('0x8'));var csv=require(_0xe02c('0x9'));var ejs=require(_0xe02c('0xa'));var fs=require('fs');var fs_extra=require(_0xe02c('0xb'));var _=require(_0xe02c('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xe02c('0xd'));var deskjs=require(_0xe02c('0xe'));var toCsv=require(_0xe02c('0x9'));var querystring=require(_0xe02c('0xf'));var Papa=require(_0xe02c('0x10'));var Redis=require(_0xe02c('0x11'));var authService=require(_0xe02c('0x12'));var qs=require(_0xe02c('0x13'));var as=require(_0xe02c('0x14'));var hardwareService=require(_0xe02c('0x15'));var logger=require(_0xe02c('0x16'))(_0xe02c('0x17'));var utils=require(_0xe02c('0x18'));var config=require(_0xe02c('0x19'));var licenseUtil=require(_0xe02c('0x1a'));var db=require(_0xe02c('0x1b'))['db'];var integrations=require(_0xe02c('0x1c'));function respondWithStatusCode(_0x32fc45,_0x5d6d13){_0x5d6d13=_0x5d6d13||0xcc;return function(_0x43079c){if(_0x43079c){return _0x32fc45['sendStatus'](_0x5d6d13);}return _0x32fc45['status'](_0x5d6d13)[_0xe02c('0x1d')]();};}function respondWithResult(_0x56405a,_0x221910){_0x221910=_0x221910||0xc8;return function(_0x59614c){if(_0x59614c){return _0x56405a[_0xe02c('0x1e')](_0x221910)['json'](_0x59614c);}};}function respondWithFilteredResult(_0x256311,_0x366893){return function(_0x59f2f6){if(_0x59f2f6){var _0x10a2a6=typeof _0x366893[_0xe02c('0x1f')]==='undefined'&&typeof _0x366893[_0xe02c('0x20')]===_0xe02c('0x21');var _0x5a4583=_0x59f2f6['count'];var _0x3e37bf=_0x10a2a6?0x0:_0x366893['offset'];var _0x1f8f37=_0x10a2a6?_0x59f2f6[_0xe02c('0x22')]:_0x366893[_0xe02c('0x1f')]+_0x366893[_0xe02c('0x20')];var _0x3898dc;if(_0x1f8f37>=_0x5a4583){_0x1f8f37=_0x5a4583;_0x3898dc=0xc8;}else{_0x3898dc=0xce;}_0x256311['status'](_0x3898dc);return _0x256311[_0xe02c('0x23')]('Content-Range',_0x3e37bf+'-'+_0x1f8f37+'/'+_0x5a4583)['json'](_0x59f2f6);}return null;};}function patchUpdates(_0x393621){return function(_0x4514ac){try{jsonpatch['apply'](_0x4514ac,_0x393621,!![]);}catch(_0x3fe8f7){return BPromise[_0xe02c('0x24')](_0x3fe8f7);}return _0x4514ac['save']();};}function saveUpdates(_0x38dce2,_0x45fd82){return function(_0x39b00c){if(_0x39b00c){return _0x39b00c[_0xe02c('0x25')](_0x38dce2)[_0xe02c('0x26')](function(_0x557142){return _0x557142;});}return null;};}function removeEntity(_0x3e80e3,_0xf41d4c){return function(_0xeae877){if(_0xeae877){return _0xeae877[_0xe02c('0x27')]()[_0xe02c('0x26')](function(){_0x3e80e3['status'](0xcc)[_0xe02c('0x1d')]();});}};}function handleEntityNotFound(_0x4411d8,_0x3592ca){return function(_0x14ffba){if(!_0x14ffba){_0x4411d8[_0xe02c('0x28')](0x194);}return _0x14ffba;};}function handleError(_0x303d24,_0x43dc78){_0x43dc78=_0x43dc78||0x1f4;return function(_0x1c14d6){logger['error'](_0x1c14d6[_0xe02c('0x29')]);if(_0x1c14d6[_0xe02c('0x2a')]){delete _0x1c14d6[_0xe02c('0x2a')];}_0x303d24['status'](_0x43dc78)[_0xe02c('0x2b')](_0x1c14d6);};}exports[_0xe02c('0x2c')]=function(_0x445421,_0x287f7e){var _0x1e7eab={},_0x35a309={},_0x22a285={'count':0x0,'rows':[]};var _0x1b8f21=_[_0xe02c('0x2d')](db[_0xe02c('0x2e')][_0xe02c('0x2f')],function(_0x5a2da0){return{'name':_0x5a2da0[_0xe02c('0x30')],'type':_0x5a2da0[_0xe02c('0x31')][_0xe02c('0x32')]};});_0x35a309[_0xe02c('0x33')]=_[_0xe02c('0x2d')](_0x1b8f21,_0xe02c('0x2a'));_0x35a309['query']=_[_0xe02c('0x34')](_0x445421[_0xe02c('0x35')]);_0x35a309['filters']=_[_0xe02c('0x36')](_0x35a309[_0xe02c('0x33')],_0x35a309[_0xe02c('0x35')]);_0x1e7eab[_0xe02c('0x37')]=_[_0xe02c('0x36')](_0x35a309['model'],qs['fields'](_0x445421[_0xe02c('0x35')][_0xe02c('0x38')]));_0x1e7eab['attributes']=_0x1e7eab[_0xe02c('0x37')]['length']?_0x1e7eab[_0xe02c('0x37')]:_0x35a309[_0xe02c('0x33')];if(!_0x445421[_0xe02c('0x35')][_0xe02c('0x39')](_0xe02c('0x3a'))){_0x1e7eab['limit']=qs[_0xe02c('0x20')](_0x445421['query'][_0xe02c('0x20')]);_0x1e7eab[_0xe02c('0x1f')]=qs[_0xe02c('0x1f')](_0x445421[_0xe02c('0x35')][_0xe02c('0x1f')]);}_0x1e7eab[_0xe02c('0x3b')]=qs['sort'](_0x445421[_0xe02c('0x35')][_0xe02c('0x3c')]);_0x1e7eab['where']=qs[_0xe02c('0x3d')](_[_0xe02c('0x3e')](_0x445421['query'],_0x35a309[_0xe02c('0x3d')]),_0x1b8f21);if(_0x445421['query'][_0xe02c('0x3f')]){_0x1e7eab[_0xe02c('0x40')]=_['merge'](_0x1e7eab[_0xe02c('0x40')],{'$or':_[_0xe02c('0x2d')](_0x1b8f21,function(_0x2502c8){if(_0x2502c8[_0xe02c('0x31')]!==_0xe02c('0x41')){var _0x28922a={};_0x28922a[_0x2502c8['name']]={'$like':'%'+_0x445421[_0xe02c('0x35')]['filter']+'%'};return _0x28922a;}})});}_0x1e7eab=_['merge']({},_0x1e7eab,_0x445421[_0xe02c('0x42')]);var _0x1095fb={'where':_0x1e7eab[_0xe02c('0x40')]};return db[_0xe02c('0x2e')]['count'](_0x1095fb)[_0xe02c('0x26')](function(_0x17830e){_0x22a285[_0xe02c('0x22')]=_0x17830e;if(_0x445421['query']['includeAll']){_0x1e7eab[_0xe02c('0x43')]=[{'all':!![]}];}return db[_0xe02c('0x2e')][_0xe02c('0x44')](_0x1e7eab);})[_0xe02c('0x26')](function(_0x1b0876){_0x22a285[_0xe02c('0x45')]=_0x1b0876;return _0x22a285;})[_0xe02c('0x26')](respondWithFilteredResult(_0x287f7e,_0x1e7eab))[_0xe02c('0x46')](handleError(_0x287f7e,null));};exports[_0xe02c('0x47')]=function(_0x53d123,_0xc7e935){var _0x5ef4a1={'raw':![],'where':{'id':_0x53d123[_0xe02c('0x48')]['id']}},_0x4d4be5={};_0x4d4be5[_0xe02c('0x33')]=_[_0xe02c('0x34')](db[_0xe02c('0x2e')][_0xe02c('0x2f')]);_0x4d4be5[_0xe02c('0x35')]=_[_0xe02c('0x34')](_0x53d123[_0xe02c('0x35')]);_0x4d4be5['filters']=_['intersection'](_0x4d4be5[_0xe02c('0x33')],_0x4d4be5[_0xe02c('0x35')]);_0x5ef4a1[_0xe02c('0x37')]=_['intersection'](_0x4d4be5[_0xe02c('0x33')],qs[_0xe02c('0x38')](_0x53d123[_0xe02c('0x35')][_0xe02c('0x38')]));_0x5ef4a1[_0xe02c('0x37')]=_0x5ef4a1[_0xe02c('0x37')][_0xe02c('0x49')]?_0x5ef4a1[_0xe02c('0x37')]:_0x4d4be5[_0xe02c('0x33')];if(_0x53d123[_0xe02c('0x35')]['includeAll']){_0x5ef4a1[_0xe02c('0x43')]=[{'all':!![]}];}_0x5ef4a1=_[_0xe02c('0x4a')]({},_0x5ef4a1,_0x53d123[_0xe02c('0x42')]);return db[_0xe02c('0x2e')][_0xe02c('0x4b')](_0x5ef4a1)[_0xe02c('0x26')](handleEntityNotFound(_0xc7e935,null))[_0xe02c('0x26')](respondWithResult(_0xc7e935,null))[_0xe02c('0x46')](handleError(_0xc7e935,null));};exports[_0xe02c('0x4c')]=function(_0x1176c9,_0xfed475){return db[_0xe02c('0x2e')][_0xe02c('0x4c')](_0x1176c9['body'],{})[_0xe02c('0x26')](respondWithResult(_0xfed475,0xc9))['catch'](handleError(_0xfed475,null));};exports[_0xe02c('0x25')]=function(_0x324911,_0x45a6df){if(_0x324911[_0xe02c('0x4d')]['id']){delete _0x324911[_0xe02c('0x4d')]['id'];}return db[_0xe02c('0x2e')][_0xe02c('0x4b')]({'where':{'id':_0x324911[_0xe02c('0x48')]['id']}})[_0xe02c('0x26')](handleEntityNotFound(_0x45a6df,null))[_0xe02c('0x26')](saveUpdates(_0x324911['body'],null))[_0xe02c('0x26')](respondWithResult(_0x45a6df,null))[_0xe02c('0x46')](handleError(_0x45a6df,null));};exports[_0xe02c('0x27')]=function(_0x536cf7,_0xdab6cb){return db['ZendeskAccount'][_0xe02c('0x4b')]({'where':{'id':_0x536cf7['params']['id']}})['then'](handleEntityNotFound(_0xdab6cb,null))['then'](removeEntity(_0xdab6cb,null))['catch'](handleError(_0xdab6cb,null));};exports['getConfigurations']=function(_0x5740df,_0x107f3f,_0x3ac0a5){var _0x1510aa={};var _0x35fbe2={};var _0x5d963d;var _0x274beb;return db[_0xe02c('0x2e')]['findOne']({'where':{'id':_0x5740df[_0xe02c('0x48')]['id']}})[_0xe02c('0x26')](handleEntityNotFound(_0x107f3f,null))[_0xe02c('0x26')](function(_0x51f940){if(_0x51f940){_0x5d963d=_0x51f940;_0x35fbe2['model']=_[_0xe02c('0x34')](db[_0xe02c('0x4e')][_0xe02c('0x2f')]);_0x35fbe2['query']=_[_0xe02c('0x34')](_0x5740df['query']);_0x35fbe2['filters']=_[_0xe02c('0x36')](_0x35fbe2[_0xe02c('0x33')],_0x35fbe2['query']);_0x1510aa[_0xe02c('0x37')]=_[_0xe02c('0x36')](_0x35fbe2[_0xe02c('0x33')],qs['fields'](_0x5740df[_0xe02c('0x35')][_0xe02c('0x38')]));_0x1510aa['attributes']=_0x1510aa[_0xe02c('0x37')][_0xe02c('0x49')]?_0x1510aa[_0xe02c('0x37')]:_0x35fbe2[_0xe02c('0x33')];_0x1510aa[_0xe02c('0x3b')]=qs[_0xe02c('0x3c')](_0x5740df[_0xe02c('0x35')][_0xe02c('0x3c')]);_0x1510aa[_0xe02c('0x40')]=qs['filters'](_['pick'](_0x5740df['query'],_0x35fbe2[_0xe02c('0x3d')]));if(_0x5740df[_0xe02c('0x35')][_0xe02c('0x3f')]){_0x1510aa['where']=_['merge'](_0x1510aa[_0xe02c('0x40')],{'$or':_[_0xe02c('0x2d')](_0x1510aa[_0xe02c('0x37')],function(_0xb50cfa){var _0xe02798={};_0xe02798[_0xb50cfa]={'$like':'%'+_0x5740df['query'][_0xe02c('0x3f')]+'%'};return _0xe02798;})});}_0x1510aa=_[_0xe02c('0x4a')]({},_0x1510aa,_0x5740df['options']);return _0x5d963d['getConfigurations'](_0x1510aa);}})[_0xe02c('0x26')](function(_0x566204){if(_0x566204){_0x274beb=_0x566204['length'];if(!_0x5740df['query'][_0xe02c('0x39')](_0xe02c('0x3a'))){_0x1510aa[_0xe02c('0x20')]=qs[_0xe02c('0x20')](_0x5740df[_0xe02c('0x35')][_0xe02c('0x20')]);_0x1510aa['offset']=qs[_0xe02c('0x1f')](_0x5740df['query']['offset']);}return _0x5d963d[_0xe02c('0x4f')](_0x1510aa);}})[_0xe02c('0x26')](function(_0x44ba68){if(_0x44ba68){return _0x44ba68?{'count':_0x274beb,'rows':_0x44ba68}:null;}})[_0xe02c('0x26')](respondWithResult(_0x107f3f,null))['catch'](handleError(_0x107f3f,null));};exports[_0xe02c('0x50')]=function(_0x31c287,_0x5d2119,_0xa7133f){if(_0x31c287[_0xe02c('0x4d')]['id']){delete _0x31c287['body']['id'];}return db[_0xe02c('0x2e')][_0xe02c('0x51')]({'where':{'id':_0x31c287[_0xe02c('0x48')]['id']}})[_0xe02c('0x26')](handleEntityNotFound(_0x5d2119,null))[_0xe02c('0x26')](function(_0x3a62a2){if(_0x3a62a2){_0x31c287[_0xe02c('0x4d')]['AccountId']=_0x3a62a2['id'];_0x31c287[_0xe02c('0x4d')]['Subjects']=integrations['getSubjects'](_0x31c287['body'][_0xe02c('0x52')],_0x31c287[_0xe02c('0x4d')][_0xe02c('0x31')]);_0x31c287[_0xe02c('0x4d')]['Descriptions']=integrations[_0xe02c('0x53')](_0x31c287[_0xe02c('0x4d')]['channel'],_0x31c287['body']['type']);return db[_0xe02c('0x4e')][_0xe02c('0x4c')](_0x31c287['body'],{'include':[{'model':db['ZendeskField'],'as':_0xe02c('0x54')},{'model':db[_0xe02c('0x55')],'as':_0xe02c('0x56')}]});}return null;})[_0xe02c('0x26')](respondWithResult(_0x5d2119,null))[_0xe02c('0x46')](handleError(_0x5d2119,null));};exports['getFields']=function(_0x39c7db,_0x12ac9f,_0x3f277b){var _0x2776c0='';return db[_0xe02c('0x2e')][_0xe02c('0x51')]({'where':{'id':_0x39c7db['params']['id']},'attributes':['id',_0xe02c('0x57'),_0xe02c('0x58'),'token',_0xe02c('0x59'),_0xe02c('0x5a')]})[_0xe02c('0x26')](handleEntityNotFound(_0x12ac9f,null))[_0xe02c('0x26')](function(_0x5d2455){if(_0x5d2455){_0x2776c0=_0x5d2455[_0xe02c('0x5a')];var _0x2229ae=_0x2776c0['slice'](-0x1);if(_0x2229ae==='/'){_0x2776c0=_0x2776c0['substring'](0x0,_0x2776c0['lastIndexOf'](_0x2229ae));}var _0x43977c={'method':_0xe02c('0x5b'),'uri':util[_0xe02c('0x5c')](_0xe02c('0x5d'),_0x2776c0,_0xe02c('0x5e')),'json':!![]};switch(_0x5d2455['authType']){case _0xe02c('0x58'):_0x43977c[_0xe02c('0x5f')]={'Authorization':util[_0xe02c('0x5c')]('Basic\x20%s',new Buffer(util['format']('%s:%s',_0x5d2455[_0xe02c('0x57')],_0x5d2455[_0xe02c('0x58')]))[_0xe02c('0x60')](_0xe02c('0x61')))};break;case'token':_0x43977c[_0xe02c('0x5f')]={'Authorization':util['format']('Basic\x20%s',new Buffer(util[_0xe02c('0x5c')](_0xe02c('0x62'),_0x5d2455[_0xe02c('0x57')],_0x5d2455[_0xe02c('0x63')]))[_0xe02c('0x60')](_0xe02c('0x61')))};break;default:throw new db[(_0xe02c('0x64'))][(_0xe02c('0x65'))]('Unknown\x20authentication\x20type');}return rp(_0x43977c);}})[_0xe02c('0x26')](function(_0x21049f){if(_0x21049f){var _0x2386cf=[_0xe02c('0x66'),_0xe02c('0x67'),_0xe02c('0x68'),_0xe02c('0x69')];_[_0xe02c('0x6a')](_0x21049f[_0xe02c('0x5e')],function(_0x411cd5){return _0x2386cf['includes'](_0x411cd5['type']);});return{'count':_0x21049f[_0xe02c('0x5e')][_0xe02c('0x49')],'rows':_[_0xe02c('0x2d')](_0x21049f[_0xe02c('0x5e')],function(_0x108566){return{'id':_0x108566['id'],'name':_0x108566['position']>0x7?_0x108566[_0xe02c('0x6b')]:_0x108566[_0xe02c('0x31')],'custom':_0x108566[_0xe02c('0x6c')]>0x7?!![]:![],'options':_0x108566[_0xe02c('0x6d')]?_0x108566[_0xe02c('0x6d')]:_0x108566[_0xe02c('0x6e')]?_0x108566[_0xe02c('0x6e')]:[]};})};}})[_0xe02c('0x26')](respondWithResult(_0x12ac9f,null))[_0xe02c('0x46')](function(_0x159f58){var _0x287eca=_0x39c7db[_0xe02c('0x35')]['test']?0x1f4:_0x159f58['statusCode']||0x1f4;logger[_0xe02c('0x6f')](_0xe02c('0x70'),'getFields',_0x287eca,JSON[_0xe02c('0x71')](_0x159f58));delete _0x159f58['name'];if(_0x287eca===0x191){_0x287eca=0x190;}_0x12ac9f[_0xe02c('0x1e')](_0x287eca)['send'](_0x39c7db[_0xe02c('0x35')][_0xe02c('0x72')]?{'message':_0xe02c('0x73'),'statusCode':_0x159f58[_0xe02c('0x74')]}:_0x159f58);});};
\ No newline at end of file