Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index c3949c9..ac5cb76 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xab40=['../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','count','limit','Content-Range','reject','save','then','destroy','error','name','rawAttributes','fieldName','type','key','query','keys','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','map','VIRTUAL','merge','options','ZendeskAccount','include','findAll','rows','catch','show','params','includeAll','find','create','body','update','findOne','ZendeskConfiguration','order','getConfigurations','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZendeskField','getFields','username','token','authType','remoteUri','slice','lastIndexOf','format','%s/%s','ticket_fields','password','headers','Basic\x20%s','toString','base64','Sequelize','ValidationError','Unknown\x20authentication\x20type','description','assignee','remove','includes','position','title','system_field_options','custom_field_options','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','Wrong\x20credentials','eml-format','rimraf','moment','bluebird','mustache','util','path','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util'];(function(_0x543719,_0xea44b8){var _0x38bb38=function(_0x3b494a){while(--_0x3b494a){_0x543719['push'](_0x543719['shift']());}};_0x38bb38(++_0xea44b8);}(_0xab40,0xcd));var _0x0ab4=function(_0x4b3f22,_0x27cae9){_0x4b3f22=_0x4b3f22-0x0;var _0x4084c3=_0xab40[_0x4b3f22];return _0x4084c3;};'use strict';var emlformat=require(_0x0ab4('0x0'));var rimraf=require(_0x0ab4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0ab4('0x2'));var BPromise=require(_0x0ab4('0x3'));var Mustache=require(_0x0ab4('0x4'));var util=require(_0x0ab4('0x5'));var path=require(_0x0ab4('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x0ab4('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0ab4('0x8'));var squel=require(_0x0ab4('0x9'));var crypto=require(_0x0ab4('0xa'));var jsforce=require(_0x0ab4('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0ab4('0xc'));var Redis=require(_0x0ab4('0xd'));var authService=require(_0x0ab4('0xe'));var qs=require(_0x0ab4('0xf'));var as=require(_0x0ab4('0x10'));var hardwareService=require(_0x0ab4('0x11'));var logger=require(_0x0ab4('0x12'))(_0x0ab4('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0ab4('0x14'));var db=require('../../mysqldb')['db'];var integrations=require(_0x0ab4('0x15'));function respondWithStatusCode(_0x45e6fd,_0x1e7555){_0x1e7555=_0x1e7555||0xcc;return function(_0x1e2b56){if(_0x1e2b56){return _0x45e6fd[_0x0ab4('0x16')](_0x1e7555);}return _0x45e6fd[_0x0ab4('0x17')](_0x1e7555)[_0x0ab4('0x18')]();};}function respondWithResult(_0x2cc644,_0x3cb1df){_0x3cb1df=_0x3cb1df||0xc8;return function(_0x2033c8){if(_0x2033c8){return _0x2cc644[_0x0ab4('0x17')](_0x3cb1df)[_0x0ab4('0x19')](_0x2033c8);}};}function respondWithFilteredResult(_0x293e20,_0x45fad1){return function(_0x2a83a8){if(_0x2a83a8){var _0x2403db=typeof _0x45fad1[_0x0ab4('0x1a')]===_0x0ab4('0x1b')&&typeof _0x45fad1['limit']==='undefined';var _0x49634f=_0x2a83a8[_0x0ab4('0x1c')];var _0x30d5df=_0x2403db?0x0:_0x45fad1[_0x0ab4('0x1a')];var _0x53723c=_0x2403db?_0x2a83a8[_0x0ab4('0x1c')]:_0x45fad1[_0x0ab4('0x1a')]+_0x45fad1[_0x0ab4('0x1d')];var _0x31ee29;if(_0x53723c>=_0x49634f){_0x53723c=_0x49634f;_0x31ee29=0xc8;}else{_0x31ee29=0xce;}_0x293e20['status'](_0x31ee29);return _0x293e20['set'](_0x0ab4('0x1e'),_0x30d5df+'-'+_0x53723c+'/'+_0x49634f)['json'](_0x2a83a8);}return null;};}function patchUpdates(_0x2b0e29){return function(_0x30abff){try{jsonpatch['apply'](_0x30abff,_0x2b0e29,!![]);}catch(_0xacd68e){return BPromise[_0x0ab4('0x1f')](_0xacd68e);}return _0x30abff[_0x0ab4('0x20')]();};}function saveUpdates(_0x1d5c14,_0x12d06d){return function(_0x52d7d3){if(_0x52d7d3){return _0x52d7d3['update'](_0x1d5c14)[_0x0ab4('0x21')](function(_0x14087f){return _0x14087f;});}return null;};}function removeEntity(_0x392afe,_0x13c882){return function(_0x4e4b80){if(_0x4e4b80){return _0x4e4b80[_0x0ab4('0x22')]()[_0x0ab4('0x21')](function(){_0x392afe[_0x0ab4('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4c5caf,_0x176ff1){return function(_0x1c132c){if(!_0x1c132c){_0x4c5caf[_0x0ab4('0x16')](0x194);}return _0x1c132c;};}function handleError(_0x4ae515,_0x519b23){_0x519b23=_0x519b23||0x1f4;return function(_0x49c72d){logger[_0x0ab4('0x23')](_0x49c72d['stack']);if(_0x49c72d[_0x0ab4('0x24')]){delete _0x49c72d[_0x0ab4('0x24')];}_0x4ae515['status'](_0x519b23)['send'](_0x49c72d);};}exports['index']=function(_0x3d38a4,_0x183bac){var _0x1cfdad={},_0x3f61cb={},_0x25385e={'count':0x0,'rows':[]};var _0x588e0d=_['map'](db['ZendeskAccount'][_0x0ab4('0x25')],function(_0x2b66d5){return{'name':_0x2b66d5[_0x0ab4('0x26')],'type':_0x2b66d5[_0x0ab4('0x27')][_0x0ab4('0x28')]};});_0x3f61cb['model']=_['map'](_0x588e0d,_0x0ab4('0x24'));_0x3f61cb[_0x0ab4('0x29')]=_[_0x0ab4('0x2a')](_0x3d38a4['query']);_0x3f61cb['filters']=_[_0x0ab4('0x2b')](_0x3f61cb['model'],_0x3f61cb[_0x0ab4('0x29')]);_0x1cfdad[_0x0ab4('0x2c')]=_[_0x0ab4('0x2b')](_0x3f61cb[_0x0ab4('0x2d')],qs[_0x0ab4('0x2e')](_0x3d38a4[_0x0ab4('0x29')]['fields']));_0x1cfdad[_0x0ab4('0x2c')]=_0x1cfdad[_0x0ab4('0x2c')][_0x0ab4('0x2f')]?_0x1cfdad[_0x0ab4('0x2c')]:_0x3f61cb['model'];if(!_0x3d38a4['query'][_0x0ab4('0x30')](_0x0ab4('0x31'))){_0x1cfdad[_0x0ab4('0x1d')]=qs['limit'](_0x3d38a4['query']['limit']);_0x1cfdad[_0x0ab4('0x1a')]=qs[_0x0ab4('0x1a')](_0x3d38a4[_0x0ab4('0x29')]['offset']);}_0x1cfdad['order']=qs['sort'](_0x3d38a4[_0x0ab4('0x29')][_0x0ab4('0x32')]);_0x1cfdad[_0x0ab4('0x33')]=qs[_0x0ab4('0x34')](_[_0x0ab4('0x35')](_0x3d38a4[_0x0ab4('0x29')],_0x3f61cb[_0x0ab4('0x34')]),_0x588e0d);if(_0x3d38a4[_0x0ab4('0x29')][_0x0ab4('0x36')]){_0x1cfdad[_0x0ab4('0x33')]=_['merge'](_0x1cfdad[_0x0ab4('0x33')],{'$or':_[_0x0ab4('0x37')](_0x588e0d,function(_0xb6bc6a){if(_0xb6bc6a[_0x0ab4('0x27')]!==_0x0ab4('0x38')){var _0x34c74f={};_0x34c74f[_0xb6bc6a[_0x0ab4('0x24')]]={'$like':'%'+_0x3d38a4[_0x0ab4('0x29')][_0x0ab4('0x36')]+'%'};return _0x34c74f;}})});}_0x1cfdad=_[_0x0ab4('0x39')]({},_0x1cfdad,_0x3d38a4[_0x0ab4('0x3a')]);var _0x1974ce={'where':_0x1cfdad['where']};return db[_0x0ab4('0x3b')][_0x0ab4('0x1c')](_0x1974ce)[_0x0ab4('0x21')](function(_0x3acb8d){_0x25385e['count']=_0x3acb8d;if(_0x3d38a4[_0x0ab4('0x29')]['includeAll']){_0x1cfdad[_0x0ab4('0x3c')]=[{'all':!![]}];}return db[_0x0ab4('0x3b')][_0x0ab4('0x3d')](_0x1cfdad);})[_0x0ab4('0x21')](function(_0xd2293){_0x25385e[_0x0ab4('0x3e')]=_0xd2293;return _0x25385e;})['then'](respondWithFilteredResult(_0x183bac,_0x1cfdad))[_0x0ab4('0x3f')](handleError(_0x183bac,null));};exports[_0x0ab4('0x40')]=function(_0xe3df73,_0x48029f){var _0x395e0b={'raw':![],'where':{'id':_0xe3df73[_0x0ab4('0x41')]['id']}},_0xeac8ad={};_0xeac8ad[_0x0ab4('0x2d')]=_[_0x0ab4('0x2a')](db['ZendeskAccount']['rawAttributes']);_0xeac8ad['query']=_[_0x0ab4('0x2a')](_0xe3df73[_0x0ab4('0x29')]);_0xeac8ad['filters']=_[_0x0ab4('0x2b')](_0xeac8ad['model'],_0xeac8ad[_0x0ab4('0x29')]);_0x395e0b['attributes']=_[_0x0ab4('0x2b')](_0xeac8ad[_0x0ab4('0x2d')],qs[_0x0ab4('0x2e')](_0xe3df73[_0x0ab4('0x29')][_0x0ab4('0x2e')]));_0x395e0b[_0x0ab4('0x2c')]=_0x395e0b['attributes'][_0x0ab4('0x2f')]?_0x395e0b[_0x0ab4('0x2c')]:_0xeac8ad[_0x0ab4('0x2d')];if(_0xe3df73[_0x0ab4('0x29')][_0x0ab4('0x42')]){_0x395e0b[_0x0ab4('0x3c')]=[{'all':!![]}];}_0x395e0b=_['merge']({},_0x395e0b,_0xe3df73[_0x0ab4('0x3a')]);return db['ZendeskAccount'][_0x0ab4('0x43')](_0x395e0b)[_0x0ab4('0x21')](handleEntityNotFound(_0x48029f,null))[_0x0ab4('0x21')](respondWithResult(_0x48029f,null))['catch'](handleError(_0x48029f,null));};exports[_0x0ab4('0x44')]=function(_0x1fcc3b,_0x1ce096){return db[_0x0ab4('0x3b')][_0x0ab4('0x44')](_0x1fcc3b[_0x0ab4('0x45')],{})['then'](respondWithResult(_0x1ce096,0xc9))[_0x0ab4('0x3f')](handleError(_0x1ce096,null));};exports[_0x0ab4('0x46')]=function(_0x302894,_0x2801ff){if(_0x302894[_0x0ab4('0x45')]['id']){delete _0x302894[_0x0ab4('0x45')]['id'];}return db[_0x0ab4('0x3b')][_0x0ab4('0x43')]({'where':{'id':_0x302894[_0x0ab4('0x41')]['id']}})[_0x0ab4('0x21')](handleEntityNotFound(_0x2801ff,null))[_0x0ab4('0x21')](saveUpdates(_0x302894[_0x0ab4('0x45')],null))[_0x0ab4('0x21')](respondWithResult(_0x2801ff,null))['catch'](handleError(_0x2801ff,null));};exports[_0x0ab4('0x22')]=function(_0x354bc,_0x5800cc){return db[_0x0ab4('0x3b')]['find']({'where':{'id':_0x354bc['params']['id']}})[_0x0ab4('0x21')](handleEntityNotFound(_0x5800cc,null))[_0x0ab4('0x21')](removeEntity(_0x5800cc,null))[_0x0ab4('0x3f')](handleError(_0x5800cc,null));};exports['getConfigurations']=function(_0x12a2df,_0xb3bd1e,_0xeddaa1){var _0xaed2d={};var _0x30ba95={};var _0x3f20de;var _0x1eea3b;return db['ZendeskAccount'][_0x0ab4('0x47')]({'where':{'id':_0x12a2df['params']['id']}})[_0x0ab4('0x21')](handleEntityNotFound(_0xb3bd1e,null))['then'](function(_0x2597f2){if(_0x2597f2){_0x3f20de=_0x2597f2;_0x30ba95['model']=_['keys'](db[_0x0ab4('0x48')][_0x0ab4('0x25')]);_0x30ba95[_0x0ab4('0x29')]=_[_0x0ab4('0x2a')](_0x12a2df['query']);_0x30ba95[_0x0ab4('0x34')]=_[_0x0ab4('0x2b')](_0x30ba95[_0x0ab4('0x2d')],_0x30ba95[_0x0ab4('0x29')]);_0xaed2d[_0x0ab4('0x2c')]=_[_0x0ab4('0x2b')](_0x30ba95[_0x0ab4('0x2d')],qs[_0x0ab4('0x2e')](_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x2e')]));_0xaed2d[_0x0ab4('0x2c')]=_0xaed2d[_0x0ab4('0x2c')][_0x0ab4('0x2f')]?_0xaed2d[_0x0ab4('0x2c')]:_0x30ba95[_0x0ab4('0x2d')];_0xaed2d[_0x0ab4('0x49')]=qs[_0x0ab4('0x32')](_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x32')]);_0xaed2d['where']=qs[_0x0ab4('0x34')](_[_0x0ab4('0x35')](_0x12a2df[_0x0ab4('0x29')],_0x30ba95[_0x0ab4('0x34')]));if(_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x36')]){_0xaed2d[_0x0ab4('0x33')]=_[_0x0ab4('0x39')](_0xaed2d['where'],{'$or':_[_0x0ab4('0x37')](_0xaed2d[_0x0ab4('0x2c')],function(_0x54ea92){var _0x48191f={};_0x48191f[_0x54ea92]={'$like':'%'+_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x36')]+'%'};return _0x48191f;})});}_0xaed2d=_['merge']({},_0xaed2d,_0x12a2df['options']);return _0x3f20de[_0x0ab4('0x4a')](_0xaed2d);}})['then'](function(_0x597d26){if(_0x597d26){_0x1eea3b=_0x597d26[_0x0ab4('0x2f')];if(!_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x30')](_0x0ab4('0x31'))){_0xaed2d[_0x0ab4('0x1d')]=qs[_0x0ab4('0x1d')](_0x12a2df[_0x0ab4('0x29')]['limit']);_0xaed2d[_0x0ab4('0x1a')]=qs[_0x0ab4('0x1a')](_0x12a2df[_0x0ab4('0x29')][_0x0ab4('0x1a')]);}return _0x3f20de[_0x0ab4('0x4a')](_0xaed2d);}})[_0x0ab4('0x21')](function(_0x4f1847){if(_0x4f1847){return _0x4f1847?{'count':_0x1eea3b,'rows':_0x4f1847}:null;}})[_0x0ab4('0x21')](respondWithResult(_0xb3bd1e,null))[_0x0ab4('0x3f')](handleError(_0xb3bd1e,null));};exports['addConfiguration']=function(_0x66364c,_0x5b41af,_0x410198){if(_0x66364c['body']['id']){delete _0x66364c[_0x0ab4('0x45')]['id'];}return db[_0x0ab4('0x3b')][_0x0ab4('0x47')]({'where':{'id':_0x66364c[_0x0ab4('0x41')]['id']}})['then'](handleEntityNotFound(_0x5b41af,null))['then'](function(_0x10dd5b){if(_0x10dd5b){_0x66364c[_0x0ab4('0x45')]['AccountId']=_0x10dd5b['id'];_0x66364c[_0x0ab4('0x45')][_0x0ab4('0x4b')]=integrations[_0x0ab4('0x4c')](_0x66364c['body'][_0x0ab4('0x4d')],_0x66364c[_0x0ab4('0x45')][_0x0ab4('0x27')]);_0x66364c[_0x0ab4('0x45')][_0x0ab4('0x4e')]=integrations[_0x0ab4('0x4f')](_0x66364c[_0x0ab4('0x45')][_0x0ab4('0x4d')],_0x66364c['body']['type']);return db[_0x0ab4('0x48')][_0x0ab4('0x44')](_0x66364c[_0x0ab4('0x45')],{'include':[{'model':db[_0x0ab4('0x50')],'as':'Subjects'},{'model':db[_0x0ab4('0x50')],'as':'Descriptions'}]});}return null;})[_0x0ab4('0x21')](respondWithResult(_0x5b41af,null))[_0x0ab4('0x3f')](handleError(_0x5b41af,null));};exports[_0x0ab4('0x51')]=function(_0x3e5f11,_0x340129,_0x41b65f){var _0x46a008='';return db[_0x0ab4('0x3b')][_0x0ab4('0x47')]({'where':{'id':_0x3e5f11['params']['id']},'attributes':['id',_0x0ab4('0x52'),'password',_0x0ab4('0x53'),_0x0ab4('0x54'),_0x0ab4('0x55')]})[_0x0ab4('0x21')](handleEntityNotFound(_0x340129,null))[_0x0ab4('0x21')](function(_0x32282c){if(_0x32282c){_0x46a008=_0x32282c[_0x0ab4('0x55')];var _0xa3a87c=_0x46a008[_0x0ab4('0x56')](-0x1);if(_0xa3a87c==='/'){_0x46a008=_0x46a008['substring'](0x0,_0x46a008[_0x0ab4('0x57')](_0xa3a87c));}var _0x9b1a87={'method':'GET','uri':util[_0x0ab4('0x58')](_0x0ab4('0x59'),_0x46a008,_0x0ab4('0x5a')),'json':!![]};switch(_0x32282c['authType']){case _0x0ab4('0x5b'):_0x9b1a87[_0x0ab4('0x5c')]={'Authorization':util[_0x0ab4('0x58')](_0x0ab4('0x5d'),new Buffer(util['format']('%s:%s',_0x32282c[_0x0ab4('0x52')],_0x32282c[_0x0ab4('0x5b')]))[_0x0ab4('0x5e')](_0x0ab4('0x5f')))};break;case'token':_0x9b1a87[_0x0ab4('0x5c')]={'Authorization':util[_0x0ab4('0x58')](_0x0ab4('0x5d'),new Buffer(util['format']('%s/token:%s',_0x32282c[_0x0ab4('0x52')],_0x32282c[_0x0ab4('0x53')]))[_0x0ab4('0x5e')](_0x0ab4('0x5f')))};break;default:throw new db[(_0x0ab4('0x60'))][(_0x0ab4('0x61'))](_0x0ab4('0x62'));}return rp(_0x9b1a87);}})['then'](function(_0xe18f04){if(_0xe18f04){var _0x57ed73=['subject',_0x0ab4('0x63'),'group',_0x0ab4('0x64')];_[_0x0ab4('0x65')](_0xe18f04[_0x0ab4('0x5a')],function(_0x368573){return _0x57ed73[_0x0ab4('0x66')](_0x368573['type']);});return{'count':_0xe18f04['ticket_fields'][_0x0ab4('0x2f')],'rows':_[_0x0ab4('0x37')](_0xe18f04['ticket_fields'],function(_0x550cc5){return{'id':_0x550cc5['id'],'name':_0x550cc5[_0x0ab4('0x67')]>0x7?_0x550cc5[_0x0ab4('0x68')]:_0x550cc5['type'],'custom':_0x550cc5[_0x0ab4('0x67')]>0x7?!![]:![],'options':_0x550cc5[_0x0ab4('0x69')]?_0x550cc5[_0x0ab4('0x69')]:_0x550cc5['custom_field_options']?_0x550cc5[_0x0ab4('0x6a')]:[]};})};}})[_0x0ab4('0x21')](respondWithResult(_0x340129,null))[_0x0ab4('0x3f')](function(_0x1be1b9){var _0x4f745e=_0x3e5f11[_0x0ab4('0x29')][_0x0ab4('0x6b')]?0x1f4:_0x1be1b9[_0x0ab4('0x6c')]||0x1f4;logger[_0x0ab4('0x23')](_0x0ab4('0x6d'),_0x0ab4('0x51'),_0x4f745e,JSON[_0x0ab4('0x6e')](_0x1be1b9));delete _0x1be1b9[_0x0ab4('0x24')];if(_0x4f745e===0x191){_0x4f745e=0x190;}_0x340129[_0x0ab4('0x17')](_0x4f745e)[_0x0ab4('0x6f')](_0x3e5f11['query'][_0x0ab4('0x6b')]?{'message':_0x0ab4('0x70'),'statusCode':_0x1be1b9[_0x0ab4('0x6c')]}:_0x1be1b9);});};
\ No newline at end of file
+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