Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index e57e49a..c010975 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf290=['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','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','undefined','limit','set','Content-Range','update','then','destroy','sendStatus','send','ZendeskAccount','fieldName','type','key','model','query','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','name','options','count','include','findAll','rows','catch','show','params','keys','rawAttributes','length','includeAll','create','body','find','getConfigurations','findOne','nolimit','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','username','authType','remoteUri','lastIndexOf','%s/%s','password','headers','format','%s:%s','toString','token','Basic\x20%s','%s/token:%s','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','subject','description','group','assignee','includes','ticket_fields','position','title','system_field_options','custom_field_options','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','to-csv'];(function(_0x36e932,_0x23110e){var _0x4bf23d=function(_0x55f4ef){while(--_0x55f4ef){_0x36e932['push'](_0x36e932['shift']());}};_0x4bf23d(++_0x23110e);}(_0xf290,0xde));var _0x0f29=function(_0x441f7a,_0x576321){_0x441f7a=_0x441f7a-0x0;var _0x4821da=_0xf290[_0x441f7a];return _0x4821da;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0f29('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0f29('0x1'));var rp=require('request-promise');var moment=require(_0x0f29('0x2'));var BPromise=require(_0x0f29('0x3'));var Mustache=require(_0x0f29('0x4'));var util=require(_0x0f29('0x5'));var path=require(_0x0f29('0x6'));var sox=require('sox');var csv=require(_0x0f29('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0f29('0x8'));var _=require(_0x0f29('0x9'));var squel=require(_0x0f29('0xa'));var crypto=require(_0x0f29('0xb'));var jsforce=require(_0x0f29('0xc'));var deskjs=require(_0x0f29('0xd'));var toCsv=require(_0x0f29('0x7'));var querystring=require(_0x0f29('0xe'));var Papa=require(_0x0f29('0xf'));var Redis=require(_0x0f29('0x10'));var authService=require(_0x0f29('0x11'));var qs=require(_0x0f29('0x12'));var as=require(_0x0f29('0x13'));var hardwareService=require(_0x0f29('0x14'));var logger=require(_0x0f29('0x15'))('api');var utils=require(_0x0f29('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x0f29('0x17'));var db=require(_0x0f29('0x18'))['db'];var integrations=require(_0x0f29('0x19'));function respondWithStatusCode(_0x222c42,_0x195424){_0x195424=_0x195424||0xcc;return function(_0x2d2573){if(_0x2d2573){return _0x222c42['sendStatus'](_0x195424);}return _0x222c42[_0x0f29('0x1a')](_0x195424)[_0x0f29('0x1b')]();};}function respondWithResult(_0x2bb7b8,_0x368984){_0x368984=_0x368984||0xc8;return function(_0x234856){if(_0x234856){return _0x2bb7b8[_0x0f29('0x1a')](_0x368984)[_0x0f29('0x1c')](_0x234856);}};}function respondWithFilteredResult(_0x69df36,_0x547404){return function(_0x4ac37d){if(_0x4ac37d){var _0x2be27f=typeof _0x547404[_0x0f29('0x1d')]===_0x0f29('0x1e')&&typeof _0x547404[_0x0f29('0x1f')]==='undefined';var _0x122bfa=_0x4ac37d['count'];var _0x17b994=_0x2be27f?0x0:_0x547404['offset'];var _0x5ddc74=_0x2be27f?_0x4ac37d['count']:_0x547404[_0x0f29('0x1d')]+_0x547404[_0x0f29('0x1f')];var _0x13e8ff;if(_0x5ddc74>=_0x122bfa){_0x5ddc74=_0x122bfa;_0x13e8ff=0xc8;}else{_0x13e8ff=0xce;}_0x69df36[_0x0f29('0x1a')](_0x13e8ff);return _0x69df36[_0x0f29('0x20')](_0x0f29('0x21'),_0x17b994+'-'+_0x5ddc74+'/'+_0x122bfa)[_0x0f29('0x1c')](_0x4ac37d);}return null;};}function patchUpdates(_0x4888b6){return function(_0x49d954){try{jsonpatch['apply'](_0x49d954,_0x4888b6,!![]);}catch(_0x5ab592){return BPromise['reject'](_0x5ab592);}return _0x49d954['save']();};}function saveUpdates(_0x38a1ce,_0x4a9dd8){return function(_0x563d15){if(_0x563d15){return _0x563d15[_0x0f29('0x22')](_0x38a1ce)[_0x0f29('0x23')](function(_0x346db8){return _0x346db8;});}return null;};}function removeEntity(_0x3402dc,_0x29ca73){return function(_0x568ad9){if(_0x568ad9){return _0x568ad9[_0x0f29('0x24')]()['then'](function(){_0x3402dc[_0x0f29('0x1a')](0xcc)[_0x0f29('0x1b')]();});}};}function handleEntityNotFound(_0x23c09e,_0x28cfaa){return function(_0x57667b){if(!_0x57667b){_0x23c09e[_0x0f29('0x25')](0x194);}return _0x57667b;};}function handleError(_0x540d72,_0x58b201){_0x58b201=_0x58b201||0x1f4;return function(_0x92876){logger['error'](_0x92876['stack']);if(_0x92876['name']){delete _0x92876['name'];}_0x540d72[_0x0f29('0x1a')](_0x58b201)[_0x0f29('0x26')](_0x92876);};}exports['index']=function(_0x1fc4fd,_0x2ab528){var _0x274c9d={},_0x51e7dc={},_0x56e729={'count':0x0,'rows':[]};var _0x37ebcc=_['map'](db[_0x0f29('0x27')]['rawAttributes'],function(_0x526364){return{'name':_0x526364[_0x0f29('0x28')],'type':_0x526364[_0x0f29('0x29')][_0x0f29('0x2a')]};});_0x51e7dc[_0x0f29('0x2b')]=_['map'](_0x37ebcc,'name');_0x51e7dc[_0x0f29('0x2c')]=_['keys'](_0x1fc4fd['query']);_0x51e7dc[_0x0f29('0x2d')]=_['intersection'](_0x51e7dc[_0x0f29('0x2b')],_0x51e7dc['query']);_0x274c9d['attributes']=_[_0x0f29('0x2e')](_0x51e7dc[_0x0f29('0x2b')],qs[_0x0f29('0x2f')](_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x2f')]));_0x274c9d['attributes']=_0x274c9d[_0x0f29('0x30')]['length']?_0x274c9d[_0x0f29('0x30')]:_0x51e7dc[_0x0f29('0x2b')];if(!_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x31')]('nolimit')){_0x274c9d[_0x0f29('0x1f')]=qs[_0x0f29('0x1f')](_0x1fc4fd['query'][_0x0f29('0x1f')]);_0x274c9d[_0x0f29('0x1d')]=qs['offset'](_0x1fc4fd['query'][_0x0f29('0x1d')]);}_0x274c9d[_0x0f29('0x32')]=qs[_0x0f29('0x33')](_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x33')]);_0x274c9d[_0x0f29('0x34')]=qs['filters'](_[_0x0f29('0x35')](_0x1fc4fd['query'],_0x51e7dc[_0x0f29('0x2d')]),_0x37ebcc);if(_0x1fc4fd['query'][_0x0f29('0x36')]){_0x274c9d[_0x0f29('0x34')]=_[_0x0f29('0x37')](_0x274c9d['where'],{'$or':_['map'](_0x37ebcc,function(_0x16a9eb){if(_0x16a9eb['type']!==_0x0f29('0x38')){var _0x3f49f8={};_0x3f49f8[_0x16a9eb[_0x0f29('0x39')]]={'$like':'%'+_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x36')]+'%'};return _0x3f49f8;}})});}_0x274c9d=_['merge']({},_0x274c9d,_0x1fc4fd[_0x0f29('0x3a')]);var _0xf77c66={'where':_0x274c9d[_0x0f29('0x34')]};return db[_0x0f29('0x27')][_0x0f29('0x3b')](_0xf77c66)[_0x0f29('0x23')](function(_0xac4fb2){_0x56e729[_0x0f29('0x3b')]=_0xac4fb2;if(_0x1fc4fd[_0x0f29('0x2c')]['includeAll']){_0x274c9d[_0x0f29('0x3c')]=[{'all':!![]}];}return db[_0x0f29('0x27')][_0x0f29('0x3d')](_0x274c9d);})[_0x0f29('0x23')](function(_0x504908){_0x56e729[_0x0f29('0x3e')]=_0x504908;return _0x56e729;})[_0x0f29('0x23')](respondWithFilteredResult(_0x2ab528,_0x274c9d))[_0x0f29('0x3f')](handleError(_0x2ab528,null));};exports[_0x0f29('0x40')]=function(_0x185493,_0x56062d){var _0x410c59={'raw':![],'where':{'id':_0x185493[_0x0f29('0x41')]['id']}},_0x245bf9={};_0x245bf9['model']=_[_0x0f29('0x42')](db[_0x0f29('0x27')][_0x0f29('0x43')]);_0x245bf9[_0x0f29('0x2c')]=_[_0x0f29('0x42')](_0x185493[_0x0f29('0x2c')]);_0x245bf9[_0x0f29('0x2d')]=_[_0x0f29('0x2e')](_0x245bf9['model'],_0x245bf9['query']);_0x410c59['attributes']=_[_0x0f29('0x2e')](_0x245bf9[_0x0f29('0x2b')],qs[_0x0f29('0x2f')](_0x185493[_0x0f29('0x2c')][_0x0f29('0x2f')]));_0x410c59[_0x0f29('0x30')]=_0x410c59['attributes'][_0x0f29('0x44')]?_0x410c59['attributes']:_0x245bf9[_0x0f29('0x2b')];if(_0x185493['query'][_0x0f29('0x45')]){_0x410c59[_0x0f29('0x3c')]=[{'all':!![]}];}_0x410c59=_[_0x0f29('0x37')]({},_0x410c59,_0x185493[_0x0f29('0x3a')]);return db[_0x0f29('0x27')]['find'](_0x410c59)[_0x0f29('0x23')](handleEntityNotFound(_0x56062d,null))[_0x0f29('0x23')](respondWithResult(_0x56062d,null))[_0x0f29('0x3f')](handleError(_0x56062d,null));};exports['create']=function(_0x14b747,_0x563fe2){return db['ZendeskAccount'][_0x0f29('0x46')](_0x14b747[_0x0f29('0x47')],{})[_0x0f29('0x23')](respondWithResult(_0x563fe2,0xc9))[_0x0f29('0x3f')](handleError(_0x563fe2,null));};exports[_0x0f29('0x22')]=function(_0x335435,_0x5e3546){if(_0x335435[_0x0f29('0x47')]['id']){delete _0x335435[_0x0f29('0x47')]['id'];}return db[_0x0f29('0x27')][_0x0f29('0x48')]({'where':{'id':_0x335435[_0x0f29('0x41')]['id']}})[_0x0f29('0x23')](handleEntityNotFound(_0x5e3546,null))[_0x0f29('0x23')](saveUpdates(_0x335435[_0x0f29('0x47')],null))[_0x0f29('0x23')](respondWithResult(_0x5e3546,null))[_0x0f29('0x3f')](handleError(_0x5e3546,null));};exports['destroy']=function(_0x5e4479,_0xa6231e){return db[_0x0f29('0x27')][_0x0f29('0x48')]({'where':{'id':_0x5e4479[_0x0f29('0x41')]['id']}})['then'](handleEntityNotFound(_0xa6231e,null))[_0x0f29('0x23')](removeEntity(_0xa6231e,null))[_0x0f29('0x3f')](handleError(_0xa6231e,null));};exports[_0x0f29('0x49')]=function(_0x30387c,_0xbf8f22,_0x2b3797){var _0x277ced={};var _0x59aeb9={};var _0x17f33;var _0x6c1800;return db[_0x0f29('0x27')][_0x0f29('0x4a')]({'where':{'id':_0x30387c[_0x0f29('0x41')]['id']}})[_0x0f29('0x23')](handleEntityNotFound(_0xbf8f22,null))['then'](function(_0x8c9780){if(_0x8c9780){_0x17f33=_0x8c9780;_0x59aeb9[_0x0f29('0x2b')]=_[_0x0f29('0x42')](db['ZendeskConfiguration'][_0x0f29('0x43')]);_0x59aeb9['query']=_[_0x0f29('0x42')](_0x30387c['query']);_0x59aeb9[_0x0f29('0x2d')]=_[_0x0f29('0x2e')](_0x59aeb9['model'],_0x59aeb9[_0x0f29('0x2c')]);_0x277ced[_0x0f29('0x30')]=_[_0x0f29('0x2e')](_0x59aeb9['model'],qs[_0x0f29('0x2f')](_0x30387c['query'][_0x0f29('0x2f')]));_0x277ced[_0x0f29('0x30')]=_0x277ced['attributes'][_0x0f29('0x44')]?_0x277ced[_0x0f29('0x30')]:_0x59aeb9['model'];_0x277ced[_0x0f29('0x32')]=qs['sort'](_0x30387c[_0x0f29('0x2c')]['sort']);_0x277ced[_0x0f29('0x34')]=qs[_0x0f29('0x2d')](_[_0x0f29('0x35')](_0x30387c['query'],_0x59aeb9[_0x0f29('0x2d')]));if(_0x30387c[_0x0f29('0x2c')][_0x0f29('0x36')]){_0x277ced[_0x0f29('0x34')]=_['merge'](_0x277ced[_0x0f29('0x34')],{'$or':_['map'](_0x277ced[_0x0f29('0x30')],function(_0x5159ac){var _0x1a4c57={};_0x1a4c57[_0x5159ac]={'$like':'%'+_0x30387c[_0x0f29('0x2c')][_0x0f29('0x36')]+'%'};return _0x1a4c57;})});}_0x277ced=_[_0x0f29('0x37')]({},_0x277ced,_0x30387c[_0x0f29('0x3a')]);return _0x17f33[_0x0f29('0x49')](_0x277ced);}})[_0x0f29('0x23')](function(_0x536ab1){if(_0x536ab1){_0x6c1800=_0x536ab1[_0x0f29('0x44')];if(!_0x30387c['query'][_0x0f29('0x31')](_0x0f29('0x4b'))){_0x277ced[_0x0f29('0x1f')]=qs['limit'](_0x30387c[_0x0f29('0x2c')][_0x0f29('0x1f')]);_0x277ced[_0x0f29('0x1d')]=qs[_0x0f29('0x1d')](_0x30387c[_0x0f29('0x2c')]['offset']);}return _0x17f33['getConfigurations'](_0x277ced);}})[_0x0f29('0x23')](function(_0x441fe8){if(_0x441fe8){return _0x441fe8?{'count':_0x6c1800,'rows':_0x441fe8}:null;}})[_0x0f29('0x23')](respondWithResult(_0xbf8f22,null))['catch'](handleError(_0xbf8f22,null));};exports['addConfiguration']=function(_0xebd543,_0x204a27,_0x280433){if(_0xebd543['body']['id']){delete _0xebd543['body']['id'];}return db['ZendeskAccount'][_0x0f29('0x4a')]({'where':{'id':_0xebd543[_0x0f29('0x41')]['id']}})['then'](handleEntityNotFound(_0x204a27,null))[_0x0f29('0x23')](function(_0x1c5eb4){if(_0x1c5eb4){_0xebd543['body'][_0x0f29('0x4c')]=_0x1c5eb4['id'];_0xebd543['body'][_0x0f29('0x4d')]=integrations[_0x0f29('0x4e')](_0xebd543['body'][_0x0f29('0x4f')],_0xebd543[_0x0f29('0x47')][_0x0f29('0x29')]);_0xebd543[_0x0f29('0x47')][_0x0f29('0x50')]=integrations[_0x0f29('0x51')](_0xebd543['body'][_0x0f29('0x4f')],_0xebd543[_0x0f29('0x47')][_0x0f29('0x29')]);return db['ZendeskConfiguration'][_0x0f29('0x46')](_0xebd543[_0x0f29('0x47')],{'include':[{'model':db['ZendeskField'],'as':_0x0f29('0x4d')},{'model':db['ZendeskField'],'as':_0x0f29('0x50')}]});}return null;})[_0x0f29('0x23')](respondWithResult(_0x204a27,null))[_0x0f29('0x3f')](handleError(_0x204a27,null));};exports['getFields']=function(_0x3c46d7,_0x1c0cb2,_0x2325cf){var _0x1a7d0c='';return db[_0x0f29('0x27')][_0x0f29('0x4a')]({'where':{'id':_0x3c46d7['params']['id']},'attributes':['id',_0x0f29('0x52'),'password','token',_0x0f29('0x53'),_0x0f29('0x54')]})['then'](handleEntityNotFound(_0x1c0cb2,null))[_0x0f29('0x23')](function(_0x1668a3){if(_0x1668a3){_0x1a7d0c=_0x1668a3['remoteUri'];var _0x5767b3=_0x1a7d0c['slice'](-0x1);if(_0x5767b3==='/'){_0x1a7d0c=_0x1a7d0c['substring'](0x0,_0x1a7d0c[_0x0f29('0x55')](_0x5767b3));}var _0x353472={'method':'GET','uri':util['format'](_0x0f29('0x56'),_0x1a7d0c,'ticket_fields'),'json':!![]};switch(_0x1668a3[_0x0f29('0x53')]){case _0x0f29('0x57'):_0x353472[_0x0f29('0x58')]={'Authorization':util[_0x0f29('0x59')]('Basic\x20%s',new Buffer(util[_0x0f29('0x59')](_0x0f29('0x5a'),_0x1668a3[_0x0f29('0x52')],_0x1668a3[_0x0f29('0x57')]))[_0x0f29('0x5b')]('base64'))};break;case _0x0f29('0x5c'):_0x353472[_0x0f29('0x58')]={'Authorization':util[_0x0f29('0x59')](_0x0f29('0x5d'),new Buffer(util[_0x0f29('0x59')](_0x0f29('0x5e'),_0x1668a3[_0x0f29('0x52')],_0x1668a3[_0x0f29('0x5c')]))[_0x0f29('0x5b')](_0x0f29('0x5f')))};break;default:throw new db[(_0x0f29('0x60'))][(_0x0f29('0x61'))](_0x0f29('0x62'));}return rp(_0x353472);}})[_0x0f29('0x23')](function(_0x46a8c1){if(_0x46a8c1){var _0x58f4cc=[_0x0f29('0x63'),_0x0f29('0x64'),_0x0f29('0x65'),_0x0f29('0x66')];_['remove'](_0x46a8c1['ticket_fields'],function(_0x5c0695){return _0x58f4cc[_0x0f29('0x67')](_0x5c0695[_0x0f29('0x29')]);});return{'count':_0x46a8c1['ticket_fields'][_0x0f29('0x44')],'rows':_['map'](_0x46a8c1[_0x0f29('0x68')],function(_0x5548dd){return{'id':_0x5548dd['id'],'name':_0x5548dd[_0x0f29('0x69')]>0x7?_0x5548dd[_0x0f29('0x6a')]:_0x5548dd[_0x0f29('0x29')],'custom':_0x5548dd['position']>0x7?!![]:![],'options':_0x5548dd[_0x0f29('0x6b')]?_0x5548dd['system_field_options']:_0x5548dd['custom_field_options']?_0x5548dd[_0x0f29('0x6c')]:[]};})};}})['then'](respondWithResult(_0x1c0cb2,null))[_0x0f29('0x3f')](function(_0x2b4390){var _0x55b810=_0x3c46d7[_0x0f29('0x2c')][_0x0f29('0x6d')]?0x1f4:_0x2b4390[_0x0f29('0x6e')]||0x1f4;logger[_0x0f29('0x6f')](_0x0f29('0x70'),_0x0f29('0x71'),_0x55b810,JSON[_0x0f29('0x72')](_0x2b4390));delete _0x2b4390[_0x0f29('0x39')];if(_0x55b810===0x191){_0x55b810=0x190;}_0x1c0cb2['status'](_0x55b810)[_0x0f29('0x26')](_0x3c46d7[_0x0f29('0x2c')][_0x0f29('0x6d')]?{'message':'Wrong\x20credentials','statusCode':_0x2b4390[_0x0f29('0x6e')]}:_0x2b4390);});};
\ No newline at end of file
+var _0xf290=['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','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','undefined','limit','set','Content-Range','update','then','destroy','sendStatus','send','ZendeskAccount','fieldName','type','key','model','query','filters','intersection','fields','attributes','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','name','options','count','include','findAll','rows','catch','show','params','keys','rawAttributes','length','includeAll','create','body','find','getConfigurations','findOne','nolimit','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','username','authType','remoteUri','lastIndexOf','%s/%s','password','headers','format','%s:%s','toString','token','Basic\x20%s','%s/token:%s','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','subject','description','group','assignee','includes','ticket_fields','position','title','system_field_options','custom_field_options','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','to-csv'];(function(_0x321bf4,_0x3c3036){var _0x2354c4=function(_0x3eec28){while(--_0x3eec28){_0x321bf4['push'](_0x321bf4['shift']());}};_0x2354c4(++_0x3c3036);}(_0xf290,0xde));var _0x0f29=function(_0xa8883,_0x1f107f){_0xa8883=_0xa8883-0x0;var _0x479426=_0xf290[_0xa8883];return _0x479426;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0f29('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0f29('0x1'));var rp=require('request-promise');var moment=require(_0x0f29('0x2'));var BPromise=require(_0x0f29('0x3'));var Mustache=require(_0x0f29('0x4'));var util=require(_0x0f29('0x5'));var path=require(_0x0f29('0x6'));var sox=require('sox');var csv=require(_0x0f29('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0f29('0x8'));var _=require(_0x0f29('0x9'));var squel=require(_0x0f29('0xa'));var crypto=require(_0x0f29('0xb'));var jsforce=require(_0x0f29('0xc'));var deskjs=require(_0x0f29('0xd'));var toCsv=require(_0x0f29('0x7'));var querystring=require(_0x0f29('0xe'));var Papa=require(_0x0f29('0xf'));var Redis=require(_0x0f29('0x10'));var authService=require(_0x0f29('0x11'));var qs=require(_0x0f29('0x12'));var as=require(_0x0f29('0x13'));var hardwareService=require(_0x0f29('0x14'));var logger=require(_0x0f29('0x15'))('api');var utils=require(_0x0f29('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x0f29('0x17'));var db=require(_0x0f29('0x18'))['db'];var integrations=require(_0x0f29('0x19'));function respondWithStatusCode(_0x222c42,_0x195424){_0x195424=_0x195424||0xcc;return function(_0x2d2573){if(_0x2d2573){return _0x222c42['sendStatus'](_0x195424);}return _0x222c42[_0x0f29('0x1a')](_0x195424)[_0x0f29('0x1b')]();};}function respondWithResult(_0x2bb7b8,_0x368984){_0x368984=_0x368984||0xc8;return function(_0x234856){if(_0x234856){return _0x2bb7b8[_0x0f29('0x1a')](_0x368984)[_0x0f29('0x1c')](_0x234856);}};}function respondWithFilteredResult(_0x69df36,_0x547404){return function(_0x4ac37d){if(_0x4ac37d){var _0x2be27f=typeof _0x547404[_0x0f29('0x1d')]===_0x0f29('0x1e')&&typeof _0x547404[_0x0f29('0x1f')]==='undefined';var _0x122bfa=_0x4ac37d['count'];var _0x17b994=_0x2be27f?0x0:_0x547404['offset'];var _0x5ddc74=_0x2be27f?_0x4ac37d['count']:_0x547404[_0x0f29('0x1d')]+_0x547404[_0x0f29('0x1f')];var _0x13e8ff;if(_0x5ddc74>=_0x122bfa){_0x5ddc74=_0x122bfa;_0x13e8ff=0xc8;}else{_0x13e8ff=0xce;}_0x69df36[_0x0f29('0x1a')](_0x13e8ff);return _0x69df36[_0x0f29('0x20')](_0x0f29('0x21'),_0x17b994+'-'+_0x5ddc74+'/'+_0x122bfa)[_0x0f29('0x1c')](_0x4ac37d);}return null;};}function patchUpdates(_0x4888b6){return function(_0x49d954){try{jsonpatch['apply'](_0x49d954,_0x4888b6,!![]);}catch(_0x5ab592){return BPromise['reject'](_0x5ab592);}return _0x49d954['save']();};}function saveUpdates(_0x38a1ce,_0x4a9dd8){return function(_0x563d15){if(_0x563d15){return _0x563d15[_0x0f29('0x22')](_0x38a1ce)[_0x0f29('0x23')](function(_0x346db8){return _0x346db8;});}return null;};}function removeEntity(_0x3402dc,_0x29ca73){return function(_0x568ad9){if(_0x568ad9){return _0x568ad9[_0x0f29('0x24')]()['then'](function(){_0x3402dc[_0x0f29('0x1a')](0xcc)[_0x0f29('0x1b')]();});}};}function handleEntityNotFound(_0x23c09e,_0x28cfaa){return function(_0x57667b){if(!_0x57667b){_0x23c09e[_0x0f29('0x25')](0x194);}return _0x57667b;};}function handleError(_0x540d72,_0x58b201){_0x58b201=_0x58b201||0x1f4;return function(_0x92876){logger['error'](_0x92876['stack']);if(_0x92876['name']){delete _0x92876['name'];}_0x540d72[_0x0f29('0x1a')](_0x58b201)[_0x0f29('0x26')](_0x92876);};}exports['index']=function(_0x1fc4fd,_0x2ab528){var _0x274c9d={},_0x51e7dc={},_0x56e729={'count':0x0,'rows':[]};var _0x37ebcc=_['map'](db[_0x0f29('0x27')]['rawAttributes'],function(_0x526364){return{'name':_0x526364[_0x0f29('0x28')],'type':_0x526364[_0x0f29('0x29')][_0x0f29('0x2a')]};});_0x51e7dc[_0x0f29('0x2b')]=_['map'](_0x37ebcc,'name');_0x51e7dc[_0x0f29('0x2c')]=_['keys'](_0x1fc4fd['query']);_0x51e7dc[_0x0f29('0x2d')]=_['intersection'](_0x51e7dc[_0x0f29('0x2b')],_0x51e7dc['query']);_0x274c9d['attributes']=_[_0x0f29('0x2e')](_0x51e7dc[_0x0f29('0x2b')],qs[_0x0f29('0x2f')](_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x2f')]));_0x274c9d['attributes']=_0x274c9d[_0x0f29('0x30')]['length']?_0x274c9d[_0x0f29('0x30')]:_0x51e7dc[_0x0f29('0x2b')];if(!_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x31')]('nolimit')){_0x274c9d[_0x0f29('0x1f')]=qs[_0x0f29('0x1f')](_0x1fc4fd['query'][_0x0f29('0x1f')]);_0x274c9d[_0x0f29('0x1d')]=qs['offset'](_0x1fc4fd['query'][_0x0f29('0x1d')]);}_0x274c9d[_0x0f29('0x32')]=qs[_0x0f29('0x33')](_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x33')]);_0x274c9d[_0x0f29('0x34')]=qs['filters'](_[_0x0f29('0x35')](_0x1fc4fd['query'],_0x51e7dc[_0x0f29('0x2d')]),_0x37ebcc);if(_0x1fc4fd['query'][_0x0f29('0x36')]){_0x274c9d[_0x0f29('0x34')]=_[_0x0f29('0x37')](_0x274c9d['where'],{'$or':_['map'](_0x37ebcc,function(_0x16a9eb){if(_0x16a9eb['type']!==_0x0f29('0x38')){var _0x3f49f8={};_0x3f49f8[_0x16a9eb[_0x0f29('0x39')]]={'$like':'%'+_0x1fc4fd[_0x0f29('0x2c')][_0x0f29('0x36')]+'%'};return _0x3f49f8;}})});}_0x274c9d=_['merge']({},_0x274c9d,_0x1fc4fd[_0x0f29('0x3a')]);var _0xf77c66={'where':_0x274c9d[_0x0f29('0x34')]};return db[_0x0f29('0x27')][_0x0f29('0x3b')](_0xf77c66)[_0x0f29('0x23')](function(_0xac4fb2){_0x56e729[_0x0f29('0x3b')]=_0xac4fb2;if(_0x1fc4fd[_0x0f29('0x2c')]['includeAll']){_0x274c9d[_0x0f29('0x3c')]=[{'all':!![]}];}return db[_0x0f29('0x27')][_0x0f29('0x3d')](_0x274c9d);})[_0x0f29('0x23')](function(_0x504908){_0x56e729[_0x0f29('0x3e')]=_0x504908;return _0x56e729;})[_0x0f29('0x23')](respondWithFilteredResult(_0x2ab528,_0x274c9d))[_0x0f29('0x3f')](handleError(_0x2ab528,null));};exports[_0x0f29('0x40')]=function(_0x185493,_0x56062d){var _0x410c59={'raw':![],'where':{'id':_0x185493[_0x0f29('0x41')]['id']}},_0x245bf9={};_0x245bf9['model']=_[_0x0f29('0x42')](db[_0x0f29('0x27')][_0x0f29('0x43')]);_0x245bf9[_0x0f29('0x2c')]=_[_0x0f29('0x42')](_0x185493[_0x0f29('0x2c')]);_0x245bf9[_0x0f29('0x2d')]=_[_0x0f29('0x2e')](_0x245bf9['model'],_0x245bf9['query']);_0x410c59['attributes']=_[_0x0f29('0x2e')](_0x245bf9[_0x0f29('0x2b')],qs[_0x0f29('0x2f')](_0x185493[_0x0f29('0x2c')][_0x0f29('0x2f')]));_0x410c59[_0x0f29('0x30')]=_0x410c59['attributes'][_0x0f29('0x44')]?_0x410c59['attributes']:_0x245bf9[_0x0f29('0x2b')];if(_0x185493['query'][_0x0f29('0x45')]){_0x410c59[_0x0f29('0x3c')]=[{'all':!![]}];}_0x410c59=_[_0x0f29('0x37')]({},_0x410c59,_0x185493[_0x0f29('0x3a')]);return db[_0x0f29('0x27')]['find'](_0x410c59)[_0x0f29('0x23')](handleEntityNotFound(_0x56062d,null))[_0x0f29('0x23')](respondWithResult(_0x56062d,null))[_0x0f29('0x3f')](handleError(_0x56062d,null));};exports['create']=function(_0x14b747,_0x563fe2){return db['ZendeskAccount'][_0x0f29('0x46')](_0x14b747[_0x0f29('0x47')],{})[_0x0f29('0x23')](respondWithResult(_0x563fe2,0xc9))[_0x0f29('0x3f')](handleError(_0x563fe2,null));};exports[_0x0f29('0x22')]=function(_0x335435,_0x5e3546){if(_0x335435[_0x0f29('0x47')]['id']){delete _0x335435[_0x0f29('0x47')]['id'];}return db[_0x0f29('0x27')][_0x0f29('0x48')]({'where':{'id':_0x335435[_0x0f29('0x41')]['id']}})[_0x0f29('0x23')](handleEntityNotFound(_0x5e3546,null))[_0x0f29('0x23')](saveUpdates(_0x335435[_0x0f29('0x47')],null))[_0x0f29('0x23')](respondWithResult(_0x5e3546,null))[_0x0f29('0x3f')](handleError(_0x5e3546,null));};exports['destroy']=function(_0x5e4479,_0xa6231e){return db[_0x0f29('0x27')][_0x0f29('0x48')]({'where':{'id':_0x5e4479[_0x0f29('0x41')]['id']}})['then'](handleEntityNotFound(_0xa6231e,null))[_0x0f29('0x23')](removeEntity(_0xa6231e,null))[_0x0f29('0x3f')](handleError(_0xa6231e,null));};exports[_0x0f29('0x49')]=function(_0x30387c,_0xbf8f22,_0x2b3797){var _0x277ced={};var _0x59aeb9={};var _0x17f33;var _0x6c1800;return db[_0x0f29('0x27')][_0x0f29('0x4a')]({'where':{'id':_0x30387c[_0x0f29('0x41')]['id']}})[_0x0f29('0x23')](handleEntityNotFound(_0xbf8f22,null))['then'](function(_0x8c9780){if(_0x8c9780){_0x17f33=_0x8c9780;_0x59aeb9[_0x0f29('0x2b')]=_[_0x0f29('0x42')](db['ZendeskConfiguration'][_0x0f29('0x43')]);_0x59aeb9['query']=_[_0x0f29('0x42')](_0x30387c['query']);_0x59aeb9[_0x0f29('0x2d')]=_[_0x0f29('0x2e')](_0x59aeb9['model'],_0x59aeb9[_0x0f29('0x2c')]);_0x277ced[_0x0f29('0x30')]=_[_0x0f29('0x2e')](_0x59aeb9['model'],qs[_0x0f29('0x2f')](_0x30387c['query'][_0x0f29('0x2f')]));_0x277ced[_0x0f29('0x30')]=_0x277ced['attributes'][_0x0f29('0x44')]?_0x277ced[_0x0f29('0x30')]:_0x59aeb9['model'];_0x277ced[_0x0f29('0x32')]=qs['sort'](_0x30387c[_0x0f29('0x2c')]['sort']);_0x277ced[_0x0f29('0x34')]=qs[_0x0f29('0x2d')](_[_0x0f29('0x35')](_0x30387c['query'],_0x59aeb9[_0x0f29('0x2d')]));if(_0x30387c[_0x0f29('0x2c')][_0x0f29('0x36')]){_0x277ced[_0x0f29('0x34')]=_['merge'](_0x277ced[_0x0f29('0x34')],{'$or':_['map'](_0x277ced[_0x0f29('0x30')],function(_0x5159ac){var _0x1a4c57={};_0x1a4c57[_0x5159ac]={'$like':'%'+_0x30387c[_0x0f29('0x2c')][_0x0f29('0x36')]+'%'};return _0x1a4c57;})});}_0x277ced=_[_0x0f29('0x37')]({},_0x277ced,_0x30387c[_0x0f29('0x3a')]);return _0x17f33[_0x0f29('0x49')](_0x277ced);}})[_0x0f29('0x23')](function(_0x536ab1){if(_0x536ab1){_0x6c1800=_0x536ab1[_0x0f29('0x44')];if(!_0x30387c['query'][_0x0f29('0x31')](_0x0f29('0x4b'))){_0x277ced[_0x0f29('0x1f')]=qs['limit'](_0x30387c[_0x0f29('0x2c')][_0x0f29('0x1f')]);_0x277ced[_0x0f29('0x1d')]=qs[_0x0f29('0x1d')](_0x30387c[_0x0f29('0x2c')]['offset']);}return _0x17f33['getConfigurations'](_0x277ced);}})[_0x0f29('0x23')](function(_0x441fe8){if(_0x441fe8){return _0x441fe8?{'count':_0x6c1800,'rows':_0x441fe8}:null;}})[_0x0f29('0x23')](respondWithResult(_0xbf8f22,null))['catch'](handleError(_0xbf8f22,null));};exports['addConfiguration']=function(_0xebd543,_0x204a27,_0x280433){if(_0xebd543['body']['id']){delete _0xebd543['body']['id'];}return db['ZendeskAccount'][_0x0f29('0x4a')]({'where':{'id':_0xebd543[_0x0f29('0x41')]['id']}})['then'](handleEntityNotFound(_0x204a27,null))[_0x0f29('0x23')](function(_0x1c5eb4){if(_0x1c5eb4){_0xebd543['body'][_0x0f29('0x4c')]=_0x1c5eb4['id'];_0xebd543['body'][_0x0f29('0x4d')]=integrations[_0x0f29('0x4e')](_0xebd543['body'][_0x0f29('0x4f')],_0xebd543[_0x0f29('0x47')][_0x0f29('0x29')]);_0xebd543[_0x0f29('0x47')][_0x0f29('0x50')]=integrations[_0x0f29('0x51')](_0xebd543['body'][_0x0f29('0x4f')],_0xebd543[_0x0f29('0x47')][_0x0f29('0x29')]);return db['ZendeskConfiguration'][_0x0f29('0x46')](_0xebd543[_0x0f29('0x47')],{'include':[{'model':db['ZendeskField'],'as':_0x0f29('0x4d')},{'model':db['ZendeskField'],'as':_0x0f29('0x50')}]});}return null;})[_0x0f29('0x23')](respondWithResult(_0x204a27,null))[_0x0f29('0x3f')](handleError(_0x204a27,null));};exports['getFields']=function(_0x3c46d7,_0x1c0cb2,_0x2325cf){var _0x1a7d0c='';return db[_0x0f29('0x27')][_0x0f29('0x4a')]({'where':{'id':_0x3c46d7['params']['id']},'attributes':['id',_0x0f29('0x52'),'password','token',_0x0f29('0x53'),_0x0f29('0x54')]})['then'](handleEntityNotFound(_0x1c0cb2,null))[_0x0f29('0x23')](function(_0x1668a3){if(_0x1668a3){_0x1a7d0c=_0x1668a3['remoteUri'];var _0x5767b3=_0x1a7d0c['slice'](-0x1);if(_0x5767b3==='/'){_0x1a7d0c=_0x1a7d0c['substring'](0x0,_0x1a7d0c[_0x0f29('0x55')](_0x5767b3));}var _0x353472={'method':'GET','uri':util['format'](_0x0f29('0x56'),_0x1a7d0c,'ticket_fields'),'json':!![]};switch(_0x1668a3[_0x0f29('0x53')]){case _0x0f29('0x57'):_0x353472[_0x0f29('0x58')]={'Authorization':util[_0x0f29('0x59')]('Basic\x20%s',new Buffer(util[_0x0f29('0x59')](_0x0f29('0x5a'),_0x1668a3[_0x0f29('0x52')],_0x1668a3[_0x0f29('0x57')]))[_0x0f29('0x5b')]('base64'))};break;case _0x0f29('0x5c'):_0x353472[_0x0f29('0x58')]={'Authorization':util[_0x0f29('0x59')](_0x0f29('0x5d'),new Buffer(util[_0x0f29('0x59')](_0x0f29('0x5e'),_0x1668a3[_0x0f29('0x52')],_0x1668a3[_0x0f29('0x5c')]))[_0x0f29('0x5b')](_0x0f29('0x5f')))};break;default:throw new db[(_0x0f29('0x60'))][(_0x0f29('0x61'))](_0x0f29('0x62'));}return rp(_0x353472);}})[_0x0f29('0x23')](function(_0x46a8c1){if(_0x46a8c1){var _0x58f4cc=[_0x0f29('0x63'),_0x0f29('0x64'),_0x0f29('0x65'),_0x0f29('0x66')];_['remove'](_0x46a8c1['ticket_fields'],function(_0x5c0695){return _0x58f4cc[_0x0f29('0x67')](_0x5c0695[_0x0f29('0x29')]);});return{'count':_0x46a8c1['ticket_fields'][_0x0f29('0x44')],'rows':_['map'](_0x46a8c1[_0x0f29('0x68')],function(_0x5548dd){return{'id':_0x5548dd['id'],'name':_0x5548dd[_0x0f29('0x69')]>0x7?_0x5548dd[_0x0f29('0x6a')]:_0x5548dd[_0x0f29('0x29')],'custom':_0x5548dd['position']>0x7?!![]:![],'options':_0x5548dd[_0x0f29('0x6b')]?_0x5548dd['system_field_options']:_0x5548dd['custom_field_options']?_0x5548dd[_0x0f29('0x6c')]:[]};})};}})['then'](respondWithResult(_0x1c0cb2,null))[_0x0f29('0x3f')](function(_0x2b4390){var _0x55b810=_0x3c46d7[_0x0f29('0x2c')][_0x0f29('0x6d')]?0x1f4:_0x2b4390[_0x0f29('0x6e')]||0x1f4;logger[_0x0f29('0x6f')](_0x0f29('0x70'),_0x0f29('0x71'),_0x55b810,JSON[_0x0f29('0x72')](_0x2b4390));delete _0x2b4390[_0x0f29('0x39')];if(_0x55b810===0x191){_0x55b810=0x190;}_0x1c0cb2['status'](_0x55b810)[_0x0f29('0x26')](_0x3c46d7[_0x0f29('0x2c')][_0x0f29('0x6d')]?{'message':'Wrong\x20credentials','statusCode':_0x2b4390[_0x0f29('0x6e')]}:_0x2b4390);});};
\ No newline at end of file