Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index ac5cb76..a34e06b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbfcc=['position','title','system_field_options','custom_field_options','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','fast-json-patch','request-promise','moment','bluebird','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','offset','set','Content-Range','apply','save','update','destroy','sendStatus','error','stack','name','send','map','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','ZendeskAccount','count','include','findAll','rows','then','catch','show','params','includeAll','find','create','body','findOne','ZendeskConfiguration','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','getFields','username','token','authType','remoteUri','slice','substring','lastIndexOf','GET','%s/%s','ticket_fields','headers','Basic\x20%s','format','%s:%s','password','toString','base64','%s/token:%s','ValidationError','Unknown\x20authentication\x20type','subject','group','assignee','includes'];(function(_0x557fd2,_0x2c0a7a){var _0x1b54a2=function(_0x2e439b){while(--_0x2e439b){_0x557fd2['push'](_0x557fd2['shift']());}};_0x1b54a2(++_0x2c0a7a);}(_0xbfcc,0x1dd));var _0xcbfc=function(_0x10004e,_0xd701e6){_0x10004e=_0x10004e-0x0;var _0x5af990=_0xbfcc[_0x10004e];return _0x5af990;};'use strict';var emlformat=require(_0xcbfc('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xcbfc('0x1'));var rp=require(_0xcbfc('0x2'));var moment=require(_0xcbfc('0x3'));var BPromise=require(_0xcbfc('0x4'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xcbfc('0x5'));var ejs=require(_0xcbfc('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xcbfc('0x7'));var squel=require('squel');var crypto=require(_0xcbfc('0x8'));var jsforce=require(_0xcbfc('0x9'));var deskjs=require(_0xcbfc('0xa'));var toCsv=require(_0xcbfc('0x5'));var querystring=require('querystring');var Papa=require(_0xcbfc('0xb'));var Redis=require(_0xcbfc('0xc'));var authService=require(_0xcbfc('0xd'));var qs=require(_0xcbfc('0xe'));var as=require(_0xcbfc('0xf'));var hardwareService=require(_0xcbfc('0x10'));var logger=require('../../config/logger')(_0xcbfc('0x11'));var utils=require(_0xcbfc('0x12'));var config=require(_0xcbfc('0x13'));var licenseUtil=require(_0xcbfc('0x14'));var db=require(_0xcbfc('0x15'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x3bfd05,_0x86f67c){_0x86f67c=_0x86f67c||0xcc;return function(_0x80d08d){if(_0x80d08d){return _0x3bfd05['sendStatus'](_0x86f67c);}return _0x3bfd05[_0xcbfc('0x16')](_0x86f67c)[_0xcbfc('0x17')]();};}function respondWithResult(_0x2f2bdd,_0x45a5cc){_0x45a5cc=_0x45a5cc||0xc8;return function(_0x16b659){if(_0x16b659){return _0x2f2bdd['status'](_0x45a5cc)[_0xcbfc('0x18')](_0x16b659);}};}function respondWithFilteredResult(_0x1963de,_0x1ec8c4){return function(_0x4317e4){if(_0x4317e4){var _0x50c6b6=typeof _0x1ec8c4['offset']===_0xcbfc('0x19')&&typeof _0x1ec8c4[_0xcbfc('0x1a')]===_0xcbfc('0x19');var _0x4d6946=_0x4317e4['count'];var _0x33f731=_0x50c6b6?0x0:_0x1ec8c4[_0xcbfc('0x1b')];var _0x344510=_0x50c6b6?_0x4317e4['count']:_0x1ec8c4[_0xcbfc('0x1b')]+_0x1ec8c4['limit'];var _0x28f7fb;if(_0x344510>=_0x4d6946){_0x344510=_0x4d6946;_0x28f7fb=0xc8;}else{_0x28f7fb=0xce;}_0x1963de[_0xcbfc('0x16')](_0x28f7fb);return _0x1963de[_0xcbfc('0x1c')](_0xcbfc('0x1d'),_0x33f731+'-'+_0x344510+'/'+_0x4d6946)[_0xcbfc('0x18')](_0x4317e4);}return null;};}function patchUpdates(_0x2653b1){return function(_0x5f09b0){try{jsonpatch[_0xcbfc('0x1e')](_0x5f09b0,_0x2653b1,!![]);}catch(_0x37ec3e){return BPromise['reject'](_0x37ec3e);}return _0x5f09b0[_0xcbfc('0x1f')]();};}function saveUpdates(_0x5a449b,_0x4cc8b3){return function(_0x4e2427){if(_0x4e2427){return _0x4e2427[_0xcbfc('0x20')](_0x5a449b)['then'](function(_0x4a1915){return _0x4a1915;});}return null;};}function removeEntity(_0x1b3e42,_0x34cffa){return function(_0x3ceeff){if(_0x3ceeff){return _0x3ceeff[_0xcbfc('0x21')]()['then'](function(){_0x1b3e42[_0xcbfc('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x280b78,_0x75bca0){return function(_0x53951a){if(!_0x53951a){_0x280b78[_0xcbfc('0x22')](0x194);}return _0x53951a;};}function handleError(_0x3b73a3,_0x4ab48e){_0x4ab48e=_0x4ab48e||0x1f4;return function(_0x1b2c01){logger[_0xcbfc('0x23')](_0x1b2c01[_0xcbfc('0x24')]);if(_0x1b2c01[_0xcbfc('0x25')]){delete _0x1b2c01['name'];}_0x3b73a3[_0xcbfc('0x16')](_0x4ab48e)[_0xcbfc('0x26')](_0x1b2c01);};}exports['index']=function(_0x1f6a14,_0x26463f){var _0x7cbdfa={},_0x388d41={},_0x2b4286={'count':0x0,'rows':[]};var _0x19d2e=_[_0xcbfc('0x27')](db['ZendeskAccount'][_0xcbfc('0x28')],function(_0x433300){return{'name':_0x433300[_0xcbfc('0x29')],'type':_0x433300[_0xcbfc('0x2a')]['key']};});_0x388d41[_0xcbfc('0x2b')]=_[_0xcbfc('0x27')](_0x19d2e,_0xcbfc('0x25'));_0x388d41[_0xcbfc('0x2c')]=_[_0xcbfc('0x2d')](_0x1f6a14[_0xcbfc('0x2c')]);_0x388d41[_0xcbfc('0x2e')]=_['intersection'](_0x388d41[_0xcbfc('0x2b')],_0x388d41[_0xcbfc('0x2c')]);_0x7cbdfa['attributes']=_[_0xcbfc('0x2f')](_0x388d41[_0xcbfc('0x2b')],qs[_0xcbfc('0x30')](_0x1f6a14['query']['fields']));_0x7cbdfa['attributes']=_0x7cbdfa[_0xcbfc('0x31')][_0xcbfc('0x32')]?_0x7cbdfa[_0xcbfc('0x31')]:_0x388d41[_0xcbfc('0x2b')];if(!_0x1f6a14[_0xcbfc('0x2c')][_0xcbfc('0x33')](_0xcbfc('0x34'))){_0x7cbdfa[_0xcbfc('0x1a')]=qs['limit'](_0x1f6a14[_0xcbfc('0x2c')][_0xcbfc('0x1a')]);_0x7cbdfa['offset']=qs[_0xcbfc('0x1b')](_0x1f6a14['query'][_0xcbfc('0x1b')]);}_0x7cbdfa[_0xcbfc('0x35')]=qs[_0xcbfc('0x36')](_0x1f6a14['query'][_0xcbfc('0x36')]);_0x7cbdfa['where']=qs['filters'](_[_0xcbfc('0x37')](_0x1f6a14[_0xcbfc('0x2c')],_0x388d41[_0xcbfc('0x2e')]),_0x19d2e);if(_0x1f6a14[_0xcbfc('0x2c')][_0xcbfc('0x38')]){_0x7cbdfa[_0xcbfc('0x39')]=_[_0xcbfc('0x3a')](_0x7cbdfa[_0xcbfc('0x39')],{'$or':_['map'](_0x19d2e,function(_0x15fb08){if(_0x15fb08['type']!==_0xcbfc('0x3b')){var _0x44064d={};_0x44064d[_0x15fb08[_0xcbfc('0x25')]]={'$like':'%'+_0x1f6a14[_0xcbfc('0x2c')]['filter']+'%'};return _0x44064d;}})});}_0x7cbdfa=_['merge']({},_0x7cbdfa,_0x1f6a14[_0xcbfc('0x3c')]);var _0x1c678b={'where':_0x7cbdfa[_0xcbfc('0x39')]};return db[_0xcbfc('0x3d')][_0xcbfc('0x3e')](_0x1c678b)['then'](function(_0x1901b4){_0x2b4286[_0xcbfc('0x3e')]=_0x1901b4;if(_0x1f6a14[_0xcbfc('0x2c')]['includeAll']){_0x7cbdfa[_0xcbfc('0x3f')]=[{'all':!![]}];}return db[_0xcbfc('0x3d')][_0xcbfc('0x40')](_0x7cbdfa);})['then'](function(_0x28266c){_0x2b4286[_0xcbfc('0x41')]=_0x28266c;return _0x2b4286;})[_0xcbfc('0x42')](respondWithFilteredResult(_0x26463f,_0x7cbdfa))[_0xcbfc('0x43')](handleError(_0x26463f,null));};exports[_0xcbfc('0x44')]=function(_0x28447a,_0x1e14bb){var _0x561544={'raw':![],'where':{'id':_0x28447a[_0xcbfc('0x45')]['id']}},_0x2de7fe={};_0x2de7fe['model']=_[_0xcbfc('0x2d')](db[_0xcbfc('0x3d')][_0xcbfc('0x28')]);_0x2de7fe[_0xcbfc('0x2c')]=_[_0xcbfc('0x2d')](_0x28447a[_0xcbfc('0x2c')]);_0x2de7fe[_0xcbfc('0x2e')]=_[_0xcbfc('0x2f')](_0x2de7fe['model'],_0x2de7fe[_0xcbfc('0x2c')]);_0x561544[_0xcbfc('0x31')]=_[_0xcbfc('0x2f')](_0x2de7fe[_0xcbfc('0x2b')],qs[_0xcbfc('0x30')](_0x28447a[_0xcbfc('0x2c')][_0xcbfc('0x30')]));_0x561544['attributes']=_0x561544[_0xcbfc('0x31')][_0xcbfc('0x32')]?_0x561544['attributes']:_0x2de7fe[_0xcbfc('0x2b')];if(_0x28447a[_0xcbfc('0x2c')][_0xcbfc('0x46')]){_0x561544['include']=[{'all':!![]}];}_0x561544=_[_0xcbfc('0x3a')]({},_0x561544,_0x28447a[_0xcbfc('0x3c')]);return db[_0xcbfc('0x3d')][_0xcbfc('0x47')](_0x561544)[_0xcbfc('0x42')](handleEntityNotFound(_0x1e14bb,null))[_0xcbfc('0x42')](respondWithResult(_0x1e14bb,null))[_0xcbfc('0x43')](handleError(_0x1e14bb,null));};exports['create']=function(_0x5a87b6,_0x237f30){return db[_0xcbfc('0x3d')][_0xcbfc('0x48')](_0x5a87b6[_0xcbfc('0x49')],{})['then'](respondWithResult(_0x237f30,0xc9))['catch'](handleError(_0x237f30,null));};exports[_0xcbfc('0x20')]=function(_0xe5c5ef,_0x12340f){if(_0xe5c5ef['body']['id']){delete _0xe5c5ef[_0xcbfc('0x49')]['id'];}return db[_0xcbfc('0x3d')][_0xcbfc('0x47')]({'where':{'id':_0xe5c5ef['params']['id']}})[_0xcbfc('0x42')](handleEntityNotFound(_0x12340f,null))[_0xcbfc('0x42')](saveUpdates(_0xe5c5ef[_0xcbfc('0x49')],null))[_0xcbfc('0x42')](respondWithResult(_0x12340f,null))[_0xcbfc('0x43')](handleError(_0x12340f,null));};exports[_0xcbfc('0x21')]=function(_0x222b58,_0x374998){return db[_0xcbfc('0x3d')][_0xcbfc('0x47')]({'where':{'id':_0x222b58['params']['id']}})[_0xcbfc('0x42')](handleEntityNotFound(_0x374998,null))[_0xcbfc('0x42')](removeEntity(_0x374998,null))[_0xcbfc('0x43')](handleError(_0x374998,null));};exports['getConfigurations']=function(_0x28ae7f,_0x1a89c1,_0x4b7038){var _0x54de8={};var _0x5ce8e3={};var _0x38db76;var _0x25e48d;return db['ZendeskAccount'][_0xcbfc('0x4a')]({'where':{'id':_0x28ae7f[_0xcbfc('0x45')]['id']}})['then'](handleEntityNotFound(_0x1a89c1,null))[_0xcbfc('0x42')](function(_0x34db13){if(_0x34db13){_0x38db76=_0x34db13;_0x5ce8e3[_0xcbfc('0x2b')]=_[_0xcbfc('0x2d')](db[_0xcbfc('0x4b')][_0xcbfc('0x28')]);_0x5ce8e3[_0xcbfc('0x2c')]=_[_0xcbfc('0x2d')](_0x28ae7f[_0xcbfc('0x2c')]);_0x5ce8e3[_0xcbfc('0x2e')]=_['intersection'](_0x5ce8e3[_0xcbfc('0x2b')],_0x5ce8e3['query']);_0x54de8['attributes']=_['intersection'](_0x5ce8e3[_0xcbfc('0x2b')],qs[_0xcbfc('0x30')](_0x28ae7f[_0xcbfc('0x2c')][_0xcbfc('0x30')]));_0x54de8[_0xcbfc('0x31')]=_0x54de8[_0xcbfc('0x31')][_0xcbfc('0x32')]?_0x54de8[_0xcbfc('0x31')]:_0x5ce8e3['model'];_0x54de8[_0xcbfc('0x35')]=qs[_0xcbfc('0x36')](_0x28ae7f[_0xcbfc('0x2c')]['sort']);_0x54de8[_0xcbfc('0x39')]=qs[_0xcbfc('0x2e')](_[_0xcbfc('0x37')](_0x28ae7f[_0xcbfc('0x2c')],_0x5ce8e3[_0xcbfc('0x2e')]));if(_0x28ae7f[_0xcbfc('0x2c')][_0xcbfc('0x38')]){_0x54de8['where']=_[_0xcbfc('0x3a')](_0x54de8['where'],{'$or':_[_0xcbfc('0x27')](_0x54de8[_0xcbfc('0x31')],function(_0x5de047){var _0x2c6b23={};_0x2c6b23[_0x5de047]={'$like':'%'+_0x28ae7f['query'][_0xcbfc('0x38')]+'%'};return _0x2c6b23;})});}_0x54de8=_[_0xcbfc('0x3a')]({},_0x54de8,_0x28ae7f[_0xcbfc('0x3c')]);return _0x38db76[_0xcbfc('0x4c')](_0x54de8);}})[_0xcbfc('0x42')](function(_0x1b2b24){if(_0x1b2b24){_0x25e48d=_0x1b2b24['length'];if(!_0x28ae7f[_0xcbfc('0x2c')][_0xcbfc('0x33')]('nolimit')){_0x54de8[_0xcbfc('0x1a')]=qs[_0xcbfc('0x1a')](_0x28ae7f[_0xcbfc('0x2c')][_0xcbfc('0x1a')]);_0x54de8[_0xcbfc('0x1b')]=qs[_0xcbfc('0x1b')](_0x28ae7f[_0xcbfc('0x2c')][_0xcbfc('0x1b')]);}return _0x38db76['getConfigurations'](_0x54de8);}})[_0xcbfc('0x42')](function(_0x3f01da){if(_0x3f01da){return _0x3f01da?{'count':_0x25e48d,'rows':_0x3f01da}:null;}})[_0xcbfc('0x42')](respondWithResult(_0x1a89c1,null))[_0xcbfc('0x43')](handleError(_0x1a89c1,null));};exports[_0xcbfc('0x4d')]=function(_0x2fb0c2,_0x209d61,_0x380539){if(_0x2fb0c2[_0xcbfc('0x49')]['id']){delete _0x2fb0c2[_0xcbfc('0x49')]['id'];}return db['ZendeskAccount'][_0xcbfc('0x4a')]({'where':{'id':_0x2fb0c2[_0xcbfc('0x45')]['id']}})['then'](handleEntityNotFound(_0x209d61,null))[_0xcbfc('0x42')](function(_0x510a43){if(_0x510a43){_0x2fb0c2['body'][_0xcbfc('0x4e')]=_0x510a43['id'];_0x2fb0c2[_0xcbfc('0x49')][_0xcbfc('0x4f')]=integrations[_0xcbfc('0x50')](_0x2fb0c2[_0xcbfc('0x49')]['channel'],_0x2fb0c2['body'][_0xcbfc('0x2a')]);_0x2fb0c2[_0xcbfc('0x49')][_0xcbfc('0x51')]=integrations[_0xcbfc('0x52')](_0x2fb0c2[_0xcbfc('0x49')]['channel'],_0x2fb0c2[_0xcbfc('0x49')][_0xcbfc('0x2a')]);return db[_0xcbfc('0x4b')]['create'](_0x2fb0c2['body'],{'include':[{'model':db['ZendeskField'],'as':_0xcbfc('0x4f')},{'model':db['ZendeskField'],'as':'Descriptions'}]});}return null;})[_0xcbfc('0x42')](respondWithResult(_0x209d61,null))['catch'](handleError(_0x209d61,null));};exports[_0xcbfc('0x53')]=function(_0x34e671,_0xed28ff,_0x461e5b){var _0x16d91a='';return db[_0xcbfc('0x3d')][_0xcbfc('0x4a')]({'where':{'id':_0x34e671[_0xcbfc('0x45')]['id']},'attributes':['id',_0xcbfc('0x54'),'password',_0xcbfc('0x55'),_0xcbfc('0x56'),_0xcbfc('0x57')]})['then'](handleEntityNotFound(_0xed28ff,null))[_0xcbfc('0x42')](function(_0x1640e9){if(_0x1640e9){_0x16d91a=_0x1640e9[_0xcbfc('0x57')];var _0x318346=_0x16d91a[_0xcbfc('0x58')](-0x1);if(_0x318346==='/'){_0x16d91a=_0x16d91a[_0xcbfc('0x59')](0x0,_0x16d91a[_0xcbfc('0x5a')](_0x318346));}var _0x562380={'method':_0xcbfc('0x5b'),'uri':util['format'](_0xcbfc('0x5c'),_0x16d91a,_0xcbfc('0x5d')),'json':!![]};switch(_0x1640e9[_0xcbfc('0x56')]){case'password':_0x562380[_0xcbfc('0x5e')]={'Authorization':util['format'](_0xcbfc('0x5f'),new Buffer(util[_0xcbfc('0x60')](_0xcbfc('0x61'),_0x1640e9[_0xcbfc('0x54')],_0x1640e9[_0xcbfc('0x62')]))[_0xcbfc('0x63')](_0xcbfc('0x64')))};break;case'token':_0x562380[_0xcbfc('0x5e')]={'Authorization':util[_0xcbfc('0x60')](_0xcbfc('0x5f'),new Buffer(util['format'](_0xcbfc('0x65'),_0x1640e9['username'],_0x1640e9[_0xcbfc('0x55')]))[_0xcbfc('0x63')](_0xcbfc('0x64')))};break;default:throw new db['Sequelize'][(_0xcbfc('0x66'))](_0xcbfc('0x67'));}return rp(_0x562380);}})['then'](function(_0xb3378d){if(_0xb3378d){var _0x58be73=[_0xcbfc('0x68'),'description',_0xcbfc('0x69'),_0xcbfc('0x6a')];_['remove'](_0xb3378d[_0xcbfc('0x5d')],function(_0x4cf2e1){return _0x58be73[_0xcbfc('0x6b')](_0x4cf2e1[_0xcbfc('0x2a')]);});return{'count':_0xb3378d[_0xcbfc('0x5d')][_0xcbfc('0x32')],'rows':_['map'](_0xb3378d[_0xcbfc('0x5d')],function(_0x4c1e0a){return{'id':_0x4c1e0a['id'],'name':_0x4c1e0a[_0xcbfc('0x6c')]>0x7?_0x4c1e0a[_0xcbfc('0x6d')]:_0x4c1e0a[_0xcbfc('0x2a')],'custom':_0x4c1e0a[_0xcbfc('0x6c')]>0x7?!![]:![],'options':_0x4c1e0a[_0xcbfc('0x6e')]?_0x4c1e0a[_0xcbfc('0x6e')]:_0x4c1e0a[_0xcbfc('0x6f')]?_0x4c1e0a[_0xcbfc('0x6f')]:[]};})};}})[_0xcbfc('0x42')](respondWithResult(_0xed28ff,null))[_0xcbfc('0x43')](function(_0x3a3b24){var _0x297513=_0x34e671[_0xcbfc('0x2c')][_0xcbfc('0x70')]?0x1f4:_0x3a3b24[_0xcbfc('0x71')]||0x1f4;logger[_0xcbfc('0x23')](_0xcbfc('0x72'),'getFields',_0x297513,JSON[_0xcbfc('0x73')](_0x3a3b24));delete _0x3a3b24['name'];if(_0x297513===0x191){_0x297513=0x190;}_0xed28ff[_0xcbfc('0x16')](_0x297513)['send'](_0x34e671[_0xcbfc('0x2c')][_0xcbfc('0x70')]?{'message':_0xcbfc('0x74'),'statusCode':_0x3a3b24[_0xcbfc('0x71')]}:_0x3a3b24);});};
\ 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