Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 6496c78..a34e06b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0713=['rawAttributes','fieldName','type','key','model','keys','query','intersection','attributes','fields','length','order','sort','filters','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','params','find','create','body','catch','getConfigurations','hasOwnProperty','nolimit','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','ZendeskConfiguration','ZendeskField','Descriptions','getFields','username','password','token','remoteUri','slice','substring','lastIndexOf','GET','%s/%s','ticket_fields','authType','headers','format','Basic\x20%s','toString','%s/token:%s','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','subject','description','group','assignee','remove','position','title','system_field_options','custom_field_options','test','statusCode','Wrong\x20credentials','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','end','error','stack','name','send','index','map','ZendeskAccount'];(function(_0x4def1b,_0xa61dda){var _0x1dc1f0=function(_0x14b741){while(--_0x14b741){_0x4def1b['push'](_0x4def1b['shift']());}};_0x1dc1f0(++_0xa61dda);}(_0x0713,0x1ba));var _0x3071=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0713[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x3071('0x0'));var jsonpatch=require(_0x3071('0x1'));var rp=require(_0x3071('0x2'));var moment=require(_0x3071('0x3'));var BPromise=require(_0x3071('0x4'));var Mustache=require('mustache');var util=require(_0x3071('0x5'));var path=require(_0x3071('0x6'));var sox=require(_0x3071('0x7'));var csv=require(_0x3071('0x8'));var ejs=require(_0x3071('0x9'));var fs=require('fs');var fs_extra=require(_0x3071('0xa'));var _=require(_0x3071('0xb'));var squel=require(_0x3071('0xc'));var crypto=require(_0x3071('0xd'));var jsforce=require(_0x3071('0xe'));var deskjs=require(_0x3071('0xf'));var toCsv=require(_0x3071('0x8'));var querystring=require(_0x3071('0x10'));var Papa=require('papaparse');var Redis=require(_0x3071('0x11'));var authService=require(_0x3071('0x12'));var qs=require(_0x3071('0x13'));var as=require(_0x3071('0x14'));var hardwareService=require(_0x3071('0x15'));var logger=require('../../config/logger')(_0x3071('0x16'));var utils=require(_0x3071('0x17'));var config=require(_0x3071('0x18'));var licenseUtil=require(_0x3071('0x19'));var db=require(_0x3071('0x1a'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x5330a8,_0x1826ca){_0x1826ca=_0x1826ca||0xcc;return function(_0x5dc13b){if(_0x5dc13b){return _0x5330a8[_0x3071('0x1b')](_0x1826ca);}return _0x5330a8[_0x3071('0x1c')](_0x1826ca)['end']();};}function respondWithResult(_0x104e73,_0x4e1219){_0x4e1219=_0x4e1219||0xc8;return function(_0x2fc15d){if(_0x2fc15d){return _0x104e73[_0x3071('0x1c')](_0x4e1219)[_0x3071('0x1d')](_0x2fc15d);}};}function respondWithFilteredResult(_0x1f14e1,_0x1caa5d){return function(_0x2a6a4b){if(_0x2a6a4b){var _0x157a47=typeof _0x1caa5d[_0x3071('0x1e')]===_0x3071('0x1f')&&typeof _0x1caa5d[_0x3071('0x20')]==='undefined';var _0x224996=_0x2a6a4b[_0x3071('0x21')];var _0x1068d9=_0x157a47?0x0:_0x1caa5d[_0x3071('0x1e')];var _0x3acf0e=_0x157a47?_0x2a6a4b[_0x3071('0x21')]:_0x1caa5d[_0x3071('0x1e')]+_0x1caa5d[_0x3071('0x20')];var _0x502a16;if(_0x3acf0e>=_0x224996){_0x3acf0e=_0x224996;_0x502a16=0xc8;}else{_0x502a16=0xce;}_0x1f14e1[_0x3071('0x1c')](_0x502a16);return _0x1f14e1[_0x3071('0x22')](_0x3071('0x23'),_0x1068d9+'-'+_0x3acf0e+'/'+_0x224996)['json'](_0x2a6a4b);}return null;};}function patchUpdates(_0xb8f4e3){return function(_0x5cd80d){try{jsonpatch[_0x3071('0x24')](_0x5cd80d,_0xb8f4e3,!![]);}catch(_0x43128c){return BPromise[_0x3071('0x25')](_0x43128c);}return _0x5cd80d[_0x3071('0x26')]();};}function saveUpdates(_0x33090c,_0x34c50e){return function(_0x3c5cef){if(_0x3c5cef){return _0x3c5cef[_0x3071('0x27')](_0x33090c)['then'](function(_0x481a51){return _0x481a51;});}return null;};}function removeEntity(_0x2ce48a,_0xb05b1d){return function(_0x412652){if(_0x412652){return _0x412652[_0x3071('0x28')]()[_0x3071('0x29')](function(){_0x2ce48a[_0x3071('0x1c')](0xcc)[_0x3071('0x2a')]();});}};}function handleEntityNotFound(_0x1fe727,_0x1de5fb){return function(_0x4c7130){if(!_0x4c7130){_0x1fe727[_0x3071('0x1b')](0x194);}return _0x4c7130;};}function handleError(_0x3f1e6e,_0x177138){_0x177138=_0x177138||0x1f4;return function(_0x4d5c4b){logger[_0x3071('0x2b')](_0x4d5c4b[_0x3071('0x2c')]);if(_0x4d5c4b[_0x3071('0x2d')]){delete _0x4d5c4b[_0x3071('0x2d')];}_0x3f1e6e[_0x3071('0x1c')](_0x177138)[_0x3071('0x2e')](_0x4d5c4b);};}exports[_0x3071('0x2f')]=function(_0x3921a1,_0x32f1b4){var _0x292205={},_0x254fc8={},_0x5aba96={'count':0x0,'rows':[]};var _0x4f1484=_[_0x3071('0x30')](db[_0x3071('0x31')][_0x3071('0x32')],function(_0x40be95){return{'name':_0x40be95[_0x3071('0x33')],'type':_0x40be95[_0x3071('0x34')][_0x3071('0x35')]};});_0x254fc8[_0x3071('0x36')]=_['map'](_0x4f1484,'name');_0x254fc8['query']=_[_0x3071('0x37')](_0x3921a1[_0x3071('0x38')]);_0x254fc8['filters']=_[_0x3071('0x39')](_0x254fc8[_0x3071('0x36')],_0x254fc8[_0x3071('0x38')]);_0x292205[_0x3071('0x3a')]=_['intersection'](_0x254fc8[_0x3071('0x36')],qs[_0x3071('0x3b')](_0x3921a1[_0x3071('0x38')][_0x3071('0x3b')]));_0x292205[_0x3071('0x3a')]=_0x292205[_0x3071('0x3a')][_0x3071('0x3c')]?_0x292205[_0x3071('0x3a')]:_0x254fc8['model'];if(!_0x3921a1[_0x3071('0x38')]['hasOwnProperty']('nolimit')){_0x292205[_0x3071('0x20')]=qs[_0x3071('0x20')](_0x3921a1['query'][_0x3071('0x20')]);_0x292205[_0x3071('0x1e')]=qs[_0x3071('0x1e')](_0x3921a1[_0x3071('0x38')][_0x3071('0x1e')]);}_0x292205[_0x3071('0x3d')]=qs['sort'](_0x3921a1[_0x3071('0x38')][_0x3071('0x3e')]);_0x292205['where']=qs[_0x3071('0x3f')](_['pick'](_0x3921a1[_0x3071('0x38')],_0x254fc8[_0x3071('0x3f')]),_0x4f1484);if(_0x3921a1['query']['filter']){_0x292205[_0x3071('0x40')]=_[_0x3071('0x41')](_0x292205[_0x3071('0x40')],{'$or':_['map'](_0x4f1484,function(_0x4dea69){if(_0x4dea69['type']!==_0x3071('0x42')){var _0x4b7928={};_0x4b7928[_0x4dea69[_0x3071('0x2d')]]={'$like':'%'+_0x3921a1[_0x3071('0x38')][_0x3071('0x43')]+'%'};return _0x4b7928;}})});}_0x292205=_[_0x3071('0x41')]({},_0x292205,_0x3921a1[_0x3071('0x44')]);var _0x593c9c={'where':_0x292205['where']};return db[_0x3071('0x31')][_0x3071('0x21')](_0x593c9c)[_0x3071('0x29')](function(_0x1f69a6){_0x5aba96['count']=_0x1f69a6;if(_0x3921a1[_0x3071('0x38')][_0x3071('0x45')]){_0x292205[_0x3071('0x46')]=[{'all':!![]}];}return db[_0x3071('0x31')][_0x3071('0x47')](_0x292205);})[_0x3071('0x29')](function(_0x56a9d8){_0x5aba96[_0x3071('0x48')]=_0x56a9d8;return _0x5aba96;})['then'](respondWithFilteredResult(_0x32f1b4,_0x292205))['catch'](handleError(_0x32f1b4,null));};exports['show']=function(_0x47ceaf,_0x2992e6){var _0x1be8b6={'raw':![],'where':{'id':_0x47ceaf[_0x3071('0x49')]['id']}},_0x67b2fb={};_0x67b2fb[_0x3071('0x36')]=_[_0x3071('0x37')](db[_0x3071('0x31')][_0x3071('0x32')]);_0x67b2fb['query']=_[_0x3071('0x37')](_0x47ceaf[_0x3071('0x38')]);_0x67b2fb[_0x3071('0x3f')]=_[_0x3071('0x39')](_0x67b2fb[_0x3071('0x36')],_0x67b2fb['query']);_0x1be8b6['attributes']=_[_0x3071('0x39')](_0x67b2fb[_0x3071('0x36')],qs[_0x3071('0x3b')](_0x47ceaf[_0x3071('0x38')][_0x3071('0x3b')]));_0x1be8b6['attributes']=_0x1be8b6[_0x3071('0x3a')]['length']?_0x1be8b6[_0x3071('0x3a')]:_0x67b2fb['model'];if(_0x47ceaf['query'][_0x3071('0x45')]){_0x1be8b6['include']=[{'all':!![]}];}_0x1be8b6=_[_0x3071('0x41')]({},_0x1be8b6,_0x47ceaf['options']);return db[_0x3071('0x31')][_0x3071('0x4a')](_0x1be8b6)[_0x3071('0x29')](handleEntityNotFound(_0x2992e6,null))[_0x3071('0x29')](respondWithResult(_0x2992e6,null))['catch'](handleError(_0x2992e6,null));};exports[_0x3071('0x4b')]=function(_0x575c12,_0xd273ec){return db['ZendeskAccount'][_0x3071('0x4b')](_0x575c12[_0x3071('0x4c')],{})['then'](respondWithResult(_0xd273ec,0xc9))[_0x3071('0x4d')](handleError(_0xd273ec,null));};exports[_0x3071('0x27')]=function(_0x224a70,_0x38bcc2){if(_0x224a70[_0x3071('0x4c')]['id']){delete _0x224a70[_0x3071('0x4c')]['id'];}return db[_0x3071('0x31')]['find']({'where':{'id':_0x224a70[_0x3071('0x49')]['id']}})[_0x3071('0x29')](handleEntityNotFound(_0x38bcc2,null))[_0x3071('0x29')](saveUpdates(_0x224a70[_0x3071('0x4c')],null))['then'](respondWithResult(_0x38bcc2,null))[_0x3071('0x4d')](handleError(_0x38bcc2,null));};exports[_0x3071('0x28')]=function(_0x1b832e,_0x2307dd){return db[_0x3071('0x31')][_0x3071('0x4a')]({'where':{'id':_0x1b832e[_0x3071('0x49')]['id']}})[_0x3071('0x29')](handleEntityNotFound(_0x2307dd,null))[_0x3071('0x29')](removeEntity(_0x2307dd,null))[_0x3071('0x4d')](handleError(_0x2307dd,null));};exports[_0x3071('0x4e')]=function(_0x111115,_0x24977b,_0x114f1f){var _0x1656de={};var _0x12be97={};var _0x596cdd;var _0x47a438;return db[_0x3071('0x31')]['findOne']({'where':{'id':_0x111115[_0x3071('0x49')]['id']}})[_0x3071('0x29')](handleEntityNotFound(_0x24977b,null))[_0x3071('0x29')](function(_0x514821){if(_0x514821){_0x596cdd=_0x514821;_0x12be97[_0x3071('0x36')]=_[_0x3071('0x37')](db['ZendeskConfiguration']['rawAttributes']);_0x12be97[_0x3071('0x38')]=_[_0x3071('0x37')](_0x111115[_0x3071('0x38')]);_0x12be97[_0x3071('0x3f')]=_['intersection'](_0x12be97[_0x3071('0x36')],_0x12be97[_0x3071('0x38')]);_0x1656de[_0x3071('0x3a')]=_[_0x3071('0x39')](_0x12be97[_0x3071('0x36')],qs['fields'](_0x111115[_0x3071('0x38')][_0x3071('0x3b')]));_0x1656de[_0x3071('0x3a')]=_0x1656de[_0x3071('0x3a')][_0x3071('0x3c')]?_0x1656de[_0x3071('0x3a')]:_0x12be97[_0x3071('0x36')];_0x1656de['order']=qs['sort'](_0x111115[_0x3071('0x38')]['sort']);_0x1656de[_0x3071('0x40')]=qs[_0x3071('0x3f')](_['pick'](_0x111115[_0x3071('0x38')],_0x12be97[_0x3071('0x3f')]));if(_0x111115['query'][_0x3071('0x43')]){_0x1656de[_0x3071('0x40')]=_[_0x3071('0x41')](_0x1656de[_0x3071('0x40')],{'$or':_[_0x3071('0x30')](_0x1656de['attributes'],function(_0x327ef0){var _0x313a54={};_0x313a54[_0x327ef0]={'$like':'%'+_0x111115[_0x3071('0x38')]['filter']+'%'};return _0x313a54;})});}_0x1656de=_[_0x3071('0x41')]({},_0x1656de,_0x111115[_0x3071('0x44')]);return _0x596cdd[_0x3071('0x4e')](_0x1656de);}})[_0x3071('0x29')](function(_0x379723){if(_0x379723){_0x47a438=_0x379723[_0x3071('0x3c')];if(!_0x111115[_0x3071('0x38')][_0x3071('0x4f')](_0x3071('0x50'))){_0x1656de['limit']=qs[_0x3071('0x20')](_0x111115[_0x3071('0x38')][_0x3071('0x20')]);_0x1656de[_0x3071('0x1e')]=qs[_0x3071('0x1e')](_0x111115[_0x3071('0x38')][_0x3071('0x1e')]);}return _0x596cdd[_0x3071('0x4e')](_0x1656de);}})[_0x3071('0x29')](function(_0x302680){if(_0x302680){return _0x302680?{'count':_0x47a438,'rows':_0x302680}:null;}})[_0x3071('0x29')](respondWithResult(_0x24977b,null))['catch'](handleError(_0x24977b,null));};exports[_0x3071('0x51')]=function(_0x315044,_0x279594,_0x3ed86c){if(_0x315044[_0x3071('0x4c')]['id']){delete _0x315044[_0x3071('0x4c')]['id'];}return db[_0x3071('0x31')][_0x3071('0x52')]({'where':{'id':_0x315044['params']['id']}})[_0x3071('0x29')](handleEntityNotFound(_0x279594,null))[_0x3071('0x29')](function(_0x59ba87){if(_0x59ba87){_0x315044['body'][_0x3071('0x53')]=_0x59ba87['id'];_0x315044[_0x3071('0x4c')][_0x3071('0x54')]=integrations[_0x3071('0x55')](_0x315044['body']['channel'],_0x315044[_0x3071('0x4c')]['type']);_0x315044['body']['Descriptions']=integrations['getDescriptions'](_0x315044[_0x3071('0x4c')][_0x3071('0x56')],_0x315044[_0x3071('0x4c')]['type']);return db[_0x3071('0x57')][_0x3071('0x4b')](_0x315044[_0x3071('0x4c')],{'include':[{'model':db[_0x3071('0x58')],'as':'Subjects'},{'model':db[_0x3071('0x58')],'as':_0x3071('0x59')}]});}return null;})['then'](respondWithResult(_0x279594,null))[_0x3071('0x4d')](handleError(_0x279594,null));};exports[_0x3071('0x5a')]=function(_0x388cd1,_0x40c258,_0x4edd23){var _0x11ffdd='';return db[_0x3071('0x31')]['findOne']({'where':{'id':_0x388cd1['params']['id']},'attributes':['id',_0x3071('0x5b'),_0x3071('0x5c'),_0x3071('0x5d'),'authType','remoteUri']})[_0x3071('0x29')](handleEntityNotFound(_0x40c258,null))[_0x3071('0x29')](function(_0x3bad84){if(_0x3bad84){_0x11ffdd=_0x3bad84[_0x3071('0x5e')];var _0x2f1935=_0x11ffdd[_0x3071('0x5f')](-0x1);if(_0x2f1935==='/'){_0x11ffdd=_0x11ffdd[_0x3071('0x60')](0x0,_0x11ffdd[_0x3071('0x61')](_0x2f1935));}var _0x5eed64={'method':_0x3071('0x62'),'uri':util['format'](_0x3071('0x63'),_0x11ffdd,_0x3071('0x64')),'json':!![]};switch(_0x3bad84[_0x3071('0x65')]){case _0x3071('0x5c'):_0x5eed64[_0x3071('0x66')]={'Authorization':util[_0x3071('0x67')](_0x3071('0x68'),new Buffer(util[_0x3071('0x67')]('%s:%s',_0x3bad84[_0x3071('0x5b')],_0x3bad84[_0x3071('0x5c')]))[_0x3071('0x69')]('base64'))};break;case _0x3071('0x5d'):_0x5eed64[_0x3071('0x66')]={'Authorization':util[_0x3071('0x67')]('Basic\x20%s',new Buffer(util['format'](_0x3071('0x6a'),_0x3bad84['username'],_0x3bad84[_0x3071('0x5d')]))[_0x3071('0x69')](_0x3071('0x6b')))};break;default:throw new db[(_0x3071('0x6c'))][(_0x3071('0x6d'))](_0x3071('0x6e'));}return rp(_0x5eed64);}})[_0x3071('0x29')](function(_0x4c67ec){if(_0x4c67ec){var _0x1f2be3=[_0x3071('0x6f'),_0x3071('0x70'),_0x3071('0x71'),_0x3071('0x72')];_[_0x3071('0x73')](_0x4c67ec[_0x3071('0x64')],function(_0x277377){return _0x1f2be3['includes'](_0x277377[_0x3071('0x34')]);});return{'count':_0x4c67ec['ticket_fields'][_0x3071('0x3c')],'rows':_[_0x3071('0x30')](_0x4c67ec[_0x3071('0x64')],function(_0x45879b){return{'id':_0x45879b['id'],'name':_0x45879b[_0x3071('0x74')]>0x7?_0x45879b[_0x3071('0x75')]:_0x45879b[_0x3071('0x34')],'custom':_0x45879b[_0x3071('0x74')]>0x7?!![]:![],'options':_0x45879b[_0x3071('0x76')]?_0x45879b[_0x3071('0x76')]:_0x45879b['custom_field_options']?_0x45879b[_0x3071('0x77')]:[]};})};}})[_0x3071('0x29')](respondWithResult(_0x40c258,null))['catch'](function(_0x156826){var _0x3b7c95=_0x388cd1[_0x3071('0x38')][_0x3071('0x78')]?0x1f4:_0x156826[_0x3071('0x79')]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0x3071('0x5a'),_0x3b7c95,JSON['stringify'](_0x156826));delete _0x156826[_0x3071('0x2d')];if(_0x3b7c95===0x191){_0x3b7c95=0x190;}_0x40c258[_0x3071('0x1c')](_0x3b7c95)[_0x3071('0x2e')](_0x388cd1[_0x3071('0x38')][_0x3071('0x78')]?{'message':_0x3071('0x7a'),'statusCode':_0x156826['statusCode']}:_0x156826);});};
\ No newline at end of file
+var _0xbaf0=['findAll','rows','catch','show','params','create','body','find','getConfigurations','findOne','ZendeskConfiguration','pick','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZendeskField','getFields','username','password','token','remoteUri','slice','substring','lastIndexOf','GET','format','%s/%s','ticket_fields','authType','%s:%s','toString','headers','%s/token:%s','base64','Sequelize','ValidationError','subject','description','assignee','remove','includes','position','title','system_field_options','custom_field_options','test','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','statusCode','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','end','sendStatus','error','stack','name','send','index','map','ZendeskAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','merge','where','VIRTUAL','filter','options','includeAll','include'];(function(_0x52e817,_0x34ce6d){var _0x2c4811=function(_0x26ff4e){while(--_0x26ff4e){_0x52e817['push'](_0x52e817['shift']());}};_0x2c4811(++_0x34ce6d);}(_0xbaf0,0x12a));var _0x0baf=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xbaf0[_0x14add3];return _0x4a174f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0baf('0x0'));var zipdir=require(_0x0baf('0x1'));var jsonpatch=require(_0x0baf('0x2'));var rp=require(_0x0baf('0x3'));var moment=require(_0x0baf('0x4'));var BPromise=require(_0x0baf('0x5'));var Mustache=require('mustache');var util=require(_0x0baf('0x6'));var path=require(_0x0baf('0x7'));var sox=require(_0x0baf('0x8'));var csv=require(_0x0baf('0x9'));var ejs=require(_0x0baf('0xa'));var fs=require('fs');var fs_extra=require(_0x0baf('0xb'));var _=require(_0x0baf('0xc'));var squel=require(_0x0baf('0xd'));var crypto=require(_0x0baf('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x0baf('0xf'));var toCsv=require('to-csv');var querystring=require(_0x0baf('0x10'));var Papa=require(_0x0baf('0x11'));var Redis=require(_0x0baf('0x12'));var authService=require(_0x0baf('0x13'));var qs=require(_0x0baf('0x14'));var as=require(_0x0baf('0x15'));var hardwareService=require(_0x0baf('0x16'));var logger=require(_0x0baf('0x17'))(_0x0baf('0x18'));var utils=require(_0x0baf('0x19'));var config=require(_0x0baf('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0x0baf('0x1b'));function respondWithStatusCode(_0xe4378c,_0x5db689){_0x5db689=_0x5db689||0xcc;return function(_0x13df17){if(_0x13df17){return _0xe4378c['sendStatus'](_0x5db689);}return _0xe4378c[_0x0baf('0x1c')](_0x5db689)['end']();};}function respondWithResult(_0x1c76a8,_0x1f50c3){_0x1f50c3=_0x1f50c3||0xc8;return function(_0x7fbf67){if(_0x7fbf67){return _0x1c76a8[_0x0baf('0x1c')](_0x1f50c3)[_0x0baf('0x1d')](_0x7fbf67);}};}function respondWithFilteredResult(_0x469599,_0x4f80a8){return function(_0x4cd79d){if(_0x4cd79d){var _0x2312c7=typeof _0x4f80a8[_0x0baf('0x1e')]===_0x0baf('0x1f')&&typeof _0x4f80a8[_0x0baf('0x20')]===_0x0baf('0x1f');var _0x288a98=_0x4cd79d['count'];var _0x63c820=_0x2312c7?0x0:_0x4f80a8[_0x0baf('0x1e')];var _0x1ef0e5=_0x2312c7?_0x4cd79d[_0x0baf('0x21')]:_0x4f80a8[_0x0baf('0x1e')]+_0x4f80a8[_0x0baf('0x20')];var _0x4ff793;if(_0x1ef0e5>=_0x288a98){_0x1ef0e5=_0x288a98;_0x4ff793=0xc8;}else{_0x4ff793=0xce;}_0x469599['status'](_0x4ff793);return _0x469599[_0x0baf('0x22')](_0x0baf('0x23'),_0x63c820+'-'+_0x1ef0e5+'/'+_0x288a98)[_0x0baf('0x1d')](_0x4cd79d);}return null;};}function patchUpdates(_0x1848e8){return function(_0x1fa92b){try{jsonpatch[_0x0baf('0x24')](_0x1fa92b,_0x1848e8,!![]);}catch(_0x210cd8){return BPromise[_0x0baf('0x25')](_0x210cd8);}return _0x1fa92b[_0x0baf('0x26')]();};}function saveUpdates(_0x15a2c3,_0x54f2fa){return function(_0x334bd6){if(_0x334bd6){return _0x334bd6['update'](_0x15a2c3)[_0x0baf('0x27')](function(_0x5dbf00){return _0x5dbf00;});}return null;};}function removeEntity(_0x4de74c,_0x2ef0aa){return function(_0x48a0e9){if(_0x48a0e9){return _0x48a0e9['destroy']()[_0x0baf('0x27')](function(){_0x4de74c[_0x0baf('0x1c')](0xcc)[_0x0baf('0x28')]();});}};}function handleEntityNotFound(_0x19d9fd,_0x3a1ba1){return function(_0x56b299){if(!_0x56b299){_0x19d9fd[_0x0baf('0x29')](0x194);}return _0x56b299;};}function handleError(_0x4681c5,_0x1ca35a){_0x1ca35a=_0x1ca35a||0x1f4;return function(_0x366e71){logger[_0x0baf('0x2a')](_0x366e71[_0x0baf('0x2b')]);if(_0x366e71[_0x0baf('0x2c')]){delete _0x366e71['name'];}_0x4681c5[_0x0baf('0x1c')](_0x1ca35a)[_0x0baf('0x2d')](_0x366e71);};}exports[_0x0baf('0x2e')]=function(_0x265915,_0x55c715){var _0x29dbdf={},_0x34a58a={},_0x5d9d7f={'count':0x0,'rows':[]};var _0x44ec31=_[_0x0baf('0x2f')](db[_0x0baf('0x30')][_0x0baf('0x31')],function(_0xd14f0f){return{'name':_0xd14f0f[_0x0baf('0x32')],'type':_0xd14f0f[_0x0baf('0x33')]['key']};});_0x34a58a[_0x0baf('0x34')]=_[_0x0baf('0x2f')](_0x44ec31,_0x0baf('0x2c'));_0x34a58a[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x265915[_0x0baf('0x35')]);_0x34a58a[_0x0baf('0x37')]=_[_0x0baf('0x38')](_0x34a58a[_0x0baf('0x34')],_0x34a58a[_0x0baf('0x35')]);_0x29dbdf[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x34a58a[_0x0baf('0x34')],qs[_0x0baf('0x3a')](_0x265915['query'][_0x0baf('0x3a')]));_0x29dbdf['attributes']=_0x29dbdf[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x29dbdf[_0x0baf('0x39')]:_0x34a58a[_0x0baf('0x34')];if(!_0x265915['query'][_0x0baf('0x3c')](_0x0baf('0x3d'))){_0x29dbdf['limit']=qs[_0x0baf('0x20')](_0x265915[_0x0baf('0x35')][_0x0baf('0x20')]);_0x29dbdf[_0x0baf('0x1e')]=qs[_0x0baf('0x1e')](_0x265915[_0x0baf('0x35')][_0x0baf('0x1e')]);}_0x29dbdf[_0x0baf('0x3e')]=qs['sort'](_0x265915[_0x0baf('0x35')][_0x0baf('0x3f')]);_0x29dbdf['where']=qs[_0x0baf('0x37')](_['pick'](_0x265915['query'],_0x34a58a[_0x0baf('0x37')]),_0x44ec31);if(_0x265915[_0x0baf('0x35')]['filter']){_0x29dbdf['where']=_[_0x0baf('0x40')](_0x29dbdf[_0x0baf('0x41')],{'$or':_[_0x0baf('0x2f')](_0x44ec31,function(_0xb2d9ab){if(_0xb2d9ab[_0x0baf('0x33')]!==_0x0baf('0x42')){var _0x290464={};_0x290464[_0xb2d9ab[_0x0baf('0x2c')]]={'$like':'%'+_0x265915[_0x0baf('0x35')][_0x0baf('0x43')]+'%'};return _0x290464;}})});}_0x29dbdf=_[_0x0baf('0x40')]({},_0x29dbdf,_0x265915[_0x0baf('0x44')]);var _0x354cb1={'where':_0x29dbdf[_0x0baf('0x41')]};return db['ZendeskAccount'][_0x0baf('0x21')](_0x354cb1)[_0x0baf('0x27')](function(_0x4f1de9){_0x5d9d7f[_0x0baf('0x21')]=_0x4f1de9;if(_0x265915[_0x0baf('0x35')][_0x0baf('0x45')]){_0x29dbdf[_0x0baf('0x46')]=[{'all':!![]}];}return db[_0x0baf('0x30')][_0x0baf('0x47')](_0x29dbdf);})['then'](function(_0x23ad34){_0x5d9d7f[_0x0baf('0x48')]=_0x23ad34;return _0x5d9d7f;})['then'](respondWithFilteredResult(_0x55c715,_0x29dbdf))[_0x0baf('0x49')](handleError(_0x55c715,null));};exports[_0x0baf('0x4a')]=function(_0x45c6aa,_0x57903e){var _0x504031={'raw':![],'where':{'id':_0x45c6aa[_0x0baf('0x4b')]['id']}},_0x193fd3={};_0x193fd3[_0x0baf('0x34')]=_[_0x0baf('0x36')](db[_0x0baf('0x30')][_0x0baf('0x31')]);_0x193fd3[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x45c6aa[_0x0baf('0x35')]);_0x193fd3[_0x0baf('0x37')]=_['intersection'](_0x193fd3[_0x0baf('0x34')],_0x193fd3[_0x0baf('0x35')]);_0x504031[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x193fd3[_0x0baf('0x34')],qs['fields'](_0x45c6aa[_0x0baf('0x35')][_0x0baf('0x3a')]));_0x504031[_0x0baf('0x39')]=_0x504031[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x504031['attributes']:_0x193fd3[_0x0baf('0x34')];if(_0x45c6aa[_0x0baf('0x35')][_0x0baf('0x45')]){_0x504031[_0x0baf('0x46')]=[{'all':!![]}];}_0x504031=_[_0x0baf('0x40')]({},_0x504031,_0x45c6aa[_0x0baf('0x44')]);return db[_0x0baf('0x30')]['find'](_0x504031)[_0x0baf('0x27')](handleEntityNotFound(_0x57903e,null))[_0x0baf('0x27')](respondWithResult(_0x57903e,null))[_0x0baf('0x49')](handleError(_0x57903e,null));};exports['create']=function(_0x3c9de3,_0x2222b6){return db[_0x0baf('0x30')][_0x0baf('0x4c')](_0x3c9de3[_0x0baf('0x4d')],{})[_0x0baf('0x27')](respondWithResult(_0x2222b6,0xc9))[_0x0baf('0x49')](handleError(_0x2222b6,null));};exports['update']=function(_0x22c451,_0x428c9b){if(_0x22c451[_0x0baf('0x4d')]['id']){delete _0x22c451[_0x0baf('0x4d')]['id'];}return db[_0x0baf('0x30')][_0x0baf('0x4e')]({'where':{'id':_0x22c451[_0x0baf('0x4b')]['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0x428c9b,null))[_0x0baf('0x27')](saveUpdates(_0x22c451[_0x0baf('0x4d')],null))[_0x0baf('0x27')](respondWithResult(_0x428c9b,null))['catch'](handleError(_0x428c9b,null));};exports['destroy']=function(_0x354329,_0x3d6b19){return db[_0x0baf('0x30')][_0x0baf('0x4e')]({'where':{'id':_0x354329[_0x0baf('0x4b')]['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0x3d6b19,null))[_0x0baf('0x27')](removeEntity(_0x3d6b19,null))['catch'](handleError(_0x3d6b19,null));};exports[_0x0baf('0x4f')]=function(_0x2ef4c1,_0xf2424,_0x16d9fb){var _0x3fdb41={};var _0x1e2671={};var _0x5e1849;var _0x3eebe5;return db['ZendeskAccount'][_0x0baf('0x50')]({'where':{'id':_0x2ef4c1['params']['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0xf2424,null))['then'](function(_0x35b1a5){if(_0x35b1a5){_0x5e1849=_0x35b1a5;_0x1e2671['model']=_[_0x0baf('0x36')](db[_0x0baf('0x51')][_0x0baf('0x31')]);_0x1e2671[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x2ef4c1['query']);_0x1e2671[_0x0baf('0x37')]=_[_0x0baf('0x38')](_0x1e2671[_0x0baf('0x34')],_0x1e2671[_0x0baf('0x35')]);_0x3fdb41[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x1e2671['model'],qs[_0x0baf('0x3a')](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x3a')]));_0x3fdb41[_0x0baf('0x39')]=_0x3fdb41[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x3fdb41[_0x0baf('0x39')]:_0x1e2671['model'];_0x3fdb41['order']=qs[_0x0baf('0x3f')](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x3f')]);_0x3fdb41[_0x0baf('0x41')]=qs[_0x0baf('0x37')](_[_0x0baf('0x52')](_0x2ef4c1[_0x0baf('0x35')],_0x1e2671[_0x0baf('0x37')]));if(_0x2ef4c1[_0x0baf('0x35')]['filter']){_0x3fdb41[_0x0baf('0x41')]=_[_0x0baf('0x40')](_0x3fdb41[_0x0baf('0x41')],{'$or':_[_0x0baf('0x2f')](_0x3fdb41[_0x0baf('0x39')],function(_0xebfc0c){var _0x26f5c9={};_0x26f5c9[_0xebfc0c]={'$like':'%'+_0x2ef4c1['query'][_0x0baf('0x43')]+'%'};return _0x26f5c9;})});}_0x3fdb41=_[_0x0baf('0x40')]({},_0x3fdb41,_0x2ef4c1[_0x0baf('0x44')]);return _0x5e1849[_0x0baf('0x4f')](_0x3fdb41);}})[_0x0baf('0x27')](function(_0x1a6d22){if(_0x1a6d22){_0x3eebe5=_0x1a6d22[_0x0baf('0x3b')];if(!_0x2ef4c1[_0x0baf('0x35')]['hasOwnProperty'](_0x0baf('0x3d'))){_0x3fdb41['limit']=qs[_0x0baf('0x20')](_0x2ef4c1['query']['limit']);_0x3fdb41[_0x0baf('0x1e')]=qs['offset'](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x1e')]);}return _0x5e1849['getConfigurations'](_0x3fdb41);}})[_0x0baf('0x27')](function(_0xfb6708){if(_0xfb6708){return _0xfb6708?{'count':_0x3eebe5,'rows':_0xfb6708}:null;}})[_0x0baf('0x27')](respondWithResult(_0xf2424,null))['catch'](handleError(_0xf2424,null));};exports['addConfiguration']=function(_0x2438df,_0x7e8946,_0x6d789f){if(_0x2438df[_0x0baf('0x4d')]['id']){delete _0x2438df[_0x0baf('0x4d')]['id'];}return db['ZendeskAccount'][_0x0baf('0x50')]({'where':{'id':_0x2438df['params']['id']}})['then'](handleEntityNotFound(_0x7e8946,null))['then'](function(_0x427ed1){if(_0x427ed1){_0x2438df['body']['AccountId']=_0x427ed1['id'];_0x2438df[_0x0baf('0x4d')][_0x0baf('0x53')]=integrations[_0x0baf('0x54')](_0x2438df[_0x0baf('0x4d')][_0x0baf('0x55')],_0x2438df[_0x0baf('0x4d')]['type']);_0x2438df[_0x0baf('0x4d')][_0x0baf('0x56')]=integrations[_0x0baf('0x57')](_0x2438df[_0x0baf('0x4d')][_0x0baf('0x55')],_0x2438df[_0x0baf('0x4d')]['type']);return db[_0x0baf('0x51')][_0x0baf('0x4c')](_0x2438df[_0x0baf('0x4d')],{'include':[{'model':db['ZendeskField'],'as':_0x0baf('0x53')},{'model':db[_0x0baf('0x58')],'as':_0x0baf('0x56')}]});}return null;})[_0x0baf('0x27')](respondWithResult(_0x7e8946,null))[_0x0baf('0x49')](handleError(_0x7e8946,null));};exports[_0x0baf('0x59')]=function(_0x4cc046,_0x5874cc,_0x54353a){var _0x4b7caa='';return db[_0x0baf('0x30')][_0x0baf('0x50')]({'where':{'id':_0x4cc046[_0x0baf('0x4b')]['id']},'attributes':['id',_0x0baf('0x5a'),_0x0baf('0x5b'),_0x0baf('0x5c'),'authType','remoteUri']})[_0x0baf('0x27')](handleEntityNotFound(_0x5874cc,null))['then'](function(_0x22cd07){if(_0x22cd07){_0x4b7caa=_0x22cd07[_0x0baf('0x5d')];var _0x4cca39=_0x4b7caa[_0x0baf('0x5e')](-0x1);if(_0x4cca39==='/'){_0x4b7caa=_0x4b7caa[_0x0baf('0x5f')](0x0,_0x4b7caa[_0x0baf('0x60')](_0x4cca39));}var _0xb1d719={'method':_0x0baf('0x61'),'uri':util[_0x0baf('0x62')](_0x0baf('0x63'),_0x4b7caa,_0x0baf('0x64')),'json':!![]};switch(_0x22cd07[_0x0baf('0x65')]){case'password':_0xb1d719['headers']={'Authorization':util['format']('Basic\x20%s',new Buffer(util['format'](_0x0baf('0x66'),_0x22cd07[_0x0baf('0x5a')],_0x22cd07[_0x0baf('0x5b')]))[_0x0baf('0x67')]('base64'))};break;case _0x0baf('0x5c'):_0xb1d719[_0x0baf('0x68')]={'Authorization':util['format']('Basic\x20%s',new Buffer(util[_0x0baf('0x62')](_0x0baf('0x69'),_0x22cd07[_0x0baf('0x5a')],_0x22cd07[_0x0baf('0x5c')]))[_0x0baf('0x67')](_0x0baf('0x6a')))};break;default:throw new db[(_0x0baf('0x6b'))][(_0x0baf('0x6c'))]('Unknown\x20authentication\x20type');}return rp(_0xb1d719);}})[_0x0baf('0x27')](function(_0x1a3b7b){if(_0x1a3b7b){var _0x560c0f=[_0x0baf('0x6d'),_0x0baf('0x6e'),'group',_0x0baf('0x6f')];_[_0x0baf('0x70')](_0x1a3b7b[_0x0baf('0x64')],function(_0x2baede){return _0x560c0f[_0x0baf('0x71')](_0x2baede['type']);});return{'count':_0x1a3b7b['ticket_fields'][_0x0baf('0x3b')],'rows':_[_0x0baf('0x2f')](_0x1a3b7b['ticket_fields'],function(_0x28bc1c){return{'id':_0x28bc1c['id'],'name':_0x28bc1c[_0x0baf('0x72')]>0x7?_0x28bc1c[_0x0baf('0x73')]:_0x28bc1c['type'],'custom':_0x28bc1c[_0x0baf('0x72')]>0x7?!![]:![],'options':_0x28bc1c[_0x0baf('0x74')]?_0x28bc1c[_0x0baf('0x74')]:_0x28bc1c['custom_field_options']?_0x28bc1c[_0x0baf('0x75')]:[]};})};}})['then'](respondWithResult(_0x5874cc,null))[_0x0baf('0x49')](function(_0x3fee46){var _0x3fd039=_0x4cc046[_0x0baf('0x35')][_0x0baf('0x76')]?0x1f4:_0x3fee46['statusCode']||0x1f4;logger[_0x0baf('0x2a')](_0x0baf('0x77'),'getFields',_0x3fd039,JSON[_0x0baf('0x78')](_0x3fee46));delete _0x3fee46[_0x0baf('0x2c')];if(_0x3fd039===0x191){_0x3fd039=0x190;}_0x5874cc[_0x0baf('0x1c')](_0x3fd039)[_0x0baf('0x2d')](_0x4cc046[_0x0baf('0x35')][_0x0baf('0x76')]?{'message':_0x0baf('0x79'),'statusCode':_0x3fee46[_0x0baf('0x7a')]}:_0x3fee46);});};
\ No newline at end of file