Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 74c73ec..8e32d83 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbaf0=['getFields','username','password','token','remoteUri','slice','substring','lastIndexOf','GET','ticket_fields','authType','headers','format','Basic\x20%s','%s:%s','base64','%s/token:%s','toString','Sequelize','ValidationError','Unknown\x20authentication\x20type','subject','description','group','assignee','remove','position','title','system_field_options','custom_field_options','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','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','jayson/promise','client','http','request','then','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','stack','name','send','map','ZendeskAccount','fieldName','key','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','type','includeAll','include','findAll','rows','params','keys','rawAttributes','options','find','body','getConfigurations','findOne','pick','nolimit','addConfiguration','Subjects','channel','Descriptions','getDescriptions','ZendeskField'];(function(_0xc98d2d,_0x10be63){var _0x3d39fb=function(_0x10b5e4){while(--_0x10b5e4){_0xc98d2d['push'](_0xc98d2d['shift']());}};_0x3d39fb(++_0x10be63);}(_0xbaf0,0x12a));var _0x0baf=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0xbaf0[_0x3947c9];return _0x2e7871;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x0baf('0x0'));var rimraf=require(_0x0baf('0x1'));var zipdir=require(_0x0baf('0x2'));var jsonpatch=require(_0x0baf('0x3'));var rp=require(_0x0baf('0x4'));var moment=require(_0x0baf('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x0baf('0x6'));var util=require(_0x0baf('0x7'));var path=require(_0x0baf('0x8'));var sox=require(_0x0baf('0x9'));var csv=require(_0x0baf('0xa'));var ejs=require(_0x0baf('0xb'));var fs=require('fs');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'));var jayson=require(_0x0baf('0x1c'));var client=jayson[_0x0baf('0x1d')][_0x0baf('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x5a0583,_0x2ab33e,_0x49e44b,_0x1c76a8){return new BPromise(function(_0x1f50c3,_0x7fbf67){var _0x2bc381=_0x1c76a8||client;return _0x2bc381[_0x0baf('0x1f')](_0x5a0583,_0x49e44b)[_0x0baf('0x20')](function(_0x4f80a8){logger['info'](_0x0baf('0x21'),_0x2ab33e,_0x0baf('0x22'));logger[_0x0baf('0x23')](_0x0baf('0x24'),_0x2ab33e,_0x0baf('0x22'),JSON[_0x0baf('0x25')](_0x4f80a8));if(_0x4f80a8['error']){if(_0x4f80a8[_0x0baf('0x26')][_0x0baf('0x27')]===0x1f4){logger[_0x0baf('0x26')](_0x0baf('0x21'),_0x2ab33e,_0x4f80a8[_0x0baf('0x26')][_0x0baf('0x28')]);return _0x7fbf67(_0x4f80a8['error']['message']);}logger[_0x0baf('0x26')](_0x0baf('0x21'),_0x2ab33e,_0x4f80a8[_0x0baf('0x26')][_0x0baf('0x28')]);return _0x1f50c3(_0x4f80a8[_0x0baf('0x26')][_0x0baf('0x28')]);}else{logger[_0x0baf('0x29')](_0x0baf('0x21'),_0x2ab33e,_0x0baf('0x22'));_0x1f50c3(_0x4f80a8[_0x0baf('0x2a')]['message']);}})[_0x0baf('0x2b')](function(_0x482522){logger[_0x0baf('0x26')]('ZendeskAccount,\x20%s,\x20%s',_0x2ab33e,_0x482522);_0x7fbf67(_0x482522);});});}function respondWithStatusCode(_0x4de74c,_0x2ef0aa){_0x2ef0aa=_0x2ef0aa||0xcc;return function(_0x48a0e9){if(_0x48a0e9){return _0x4de74c['sendStatus'](_0x2ef0aa);}return _0x4de74c[_0x0baf('0x2c')](_0x2ef0aa)[_0x0baf('0x2d')]();};}function respondWithResult(_0x34e264,_0x19d9fd){_0x19d9fd=_0x19d9fd||0xc8;return function(_0x3a1ba1){if(_0x3a1ba1){return _0x34e264['status'](_0x19d9fd)[_0x0baf('0x2e')](_0x3a1ba1);}};}function respondWithFilteredResult(_0x4681c5,_0x1ca35a){return function(_0x366e71){if(_0x366e71){var _0x3843b8=_0x366e71[_0x0baf('0x2f')],_0x3b9b31=_0x1ca35a[_0x0baf('0x30')],_0x453525=_0x1ca35a[_0x0baf('0x30')]+_0x1ca35a[_0x0baf('0x31')],_0x549fd0;if(_0x453525>=_0x3843b8){_0x453525=_0x3843b8;_0x549fd0=0xc8;}else{_0x549fd0=0xce;}_0x4681c5['status'](_0x549fd0);return _0x4681c5[_0x0baf('0x32')](_0x0baf('0x33'),_0x3b9b31+'-'+_0x453525+'/'+_0x3843b8)['json'](_0x366e71);}return null;};}function patchUpdates(_0x44ec31){return function(_0x32e4fb){try{jsonpatch[_0x0baf('0x34')](_0x32e4fb,_0x44ec31,!![]);}catch(_0xb4dbb1){return BPromise[_0x0baf('0x35')](_0xb4dbb1);}return _0x32e4fb[_0x0baf('0x36')]();};}function saveUpdates(_0x213a6a,_0x57476f){return function(_0xe92c2c){if(_0xe92c2c){return _0xe92c2c[_0x0baf('0x37')](_0x213a6a)[_0x0baf('0x20')](function(_0x3ed995){return _0x3ed995;});}return null;};}function removeEntity(_0x24ecee,_0x275ea1){return function(_0x2fc983){if(_0x2fc983){return _0x2fc983[_0x0baf('0x38')]()[_0x0baf('0x20')](function(){_0x24ecee[_0x0baf('0x2c')](0xcc)[_0x0baf('0x2d')]();});}};}function handleEntityNotFound(_0x165d14,_0x45294a){return function(_0x3a3353){if(!_0x3a3353){_0x165d14['sendStatus'](0x194);}return _0x3a3353;};}function handleError(_0x2fd426,_0x53ae1d){_0x53ae1d=_0x53ae1d||0x1f4;return function(_0x1aa474){logger[_0x0baf('0x26')](_0x1aa474[_0x0baf('0x39')]);if(_0x1aa474[_0x0baf('0x3a')]){delete _0x1aa474['name'];}_0x2fd426[_0x0baf('0x2c')](_0x53ae1d)[_0x0baf('0x3b')](_0x1aa474);};}exports['index']=function(_0x23d890,_0x2447c2){var _0x62a2ed={},_0xbaa9a7={},_0x1f60bd={'count':0x0,'rows':[]};var _0x1b0991=_[_0x0baf('0x3c')](db[_0x0baf('0x3d')]['rawAttributes'],function(_0x7e765b){return{'name':_0x7e765b[_0x0baf('0x3e')],'type':_0x7e765b['type'][_0x0baf('0x3f')]};});_0xbaa9a7['model']=_['map'](_0x1b0991,_0x0baf('0x3a'));_0xbaa9a7[_0x0baf('0x40')]=_['keys'](_0x23d890['query']);_0xbaa9a7[_0x0baf('0x41')]=_[_0x0baf('0x42')](_0xbaa9a7[_0x0baf('0x43')],_0xbaa9a7[_0x0baf('0x40')]);_0x62a2ed[_0x0baf('0x44')]=_[_0x0baf('0x42')](_0xbaa9a7[_0x0baf('0x43')],qs[_0x0baf('0x45')](_0x23d890[_0x0baf('0x40')][_0x0baf('0x45')]));_0x62a2ed[_0x0baf('0x44')]=_0x62a2ed[_0x0baf('0x44')][_0x0baf('0x46')]?_0x62a2ed[_0x0baf('0x44')]:_0xbaa9a7['model'];if(!_0x23d890[_0x0baf('0x40')][_0x0baf('0x47')]('nolimit')){_0x62a2ed[_0x0baf('0x31')]=qs[_0x0baf('0x31')](_0x23d890[_0x0baf('0x40')][_0x0baf('0x31')]);_0x62a2ed[_0x0baf('0x30')]=qs[_0x0baf('0x30')](_0x23d890['query'][_0x0baf('0x30')]);}_0x62a2ed[_0x0baf('0x48')]=qs['sort'](_0x23d890[_0x0baf('0x40')][_0x0baf('0x49')]);_0x62a2ed[_0x0baf('0x4a')]=qs[_0x0baf('0x41')](_['pick'](_0x23d890[_0x0baf('0x40')],_0xbaa9a7[_0x0baf('0x41')]),_0x1b0991);if(_0x23d890[_0x0baf('0x40')][_0x0baf('0x4b')]){_0x62a2ed[_0x0baf('0x4a')]=_[_0x0baf('0x4c')](_0x62a2ed[_0x0baf('0x4a')],{'$or':_[_0x0baf('0x3c')](_0x1b0991,function(_0xce1bf0){if(_0xce1bf0[_0x0baf('0x4d')]!=='VIRTUAL'){var _0x2a2a7c={};_0x2a2a7c[_0xce1bf0[_0x0baf('0x3a')]]={'$like':'%'+_0x23d890[_0x0baf('0x40')][_0x0baf('0x4b')]+'%'};return _0x2a2a7c;}})});}_0x62a2ed=_[_0x0baf('0x4c')]({},_0x62a2ed,_0x23d890['options']);var _0x1e7364={'where':_0x62a2ed[_0x0baf('0x4a')]};return db[_0x0baf('0x3d')][_0x0baf('0x2f')](_0x1e7364)[_0x0baf('0x20')](function(_0x54ed41){_0x1f60bd[_0x0baf('0x2f')]=_0x54ed41;if(_0x23d890[_0x0baf('0x40')][_0x0baf('0x4e')]){_0x62a2ed[_0x0baf('0x4f')]=[{'all':!![]}];}return db[_0x0baf('0x3d')][_0x0baf('0x50')](_0x62a2ed);})[_0x0baf('0x20')](function(_0x5679d9){_0x1f60bd[_0x0baf('0x51')]=_0x5679d9;return _0x1f60bd;})[_0x0baf('0x20')](respondWithFilteredResult(_0x2447c2,_0x62a2ed))[_0x0baf('0x2b')](handleError(_0x2447c2,null));};exports['show']=function(_0x3c9de3,_0x2222b6){var _0x10fa62={'raw':![],'where':{'id':_0x3c9de3[_0x0baf('0x52')]['id']}},_0x3fabec={};_0x3fabec[_0x0baf('0x43')]=_[_0x0baf('0x53')](db['ZendeskAccount'][_0x0baf('0x54')]);_0x3fabec[_0x0baf('0x40')]=_[_0x0baf('0x53')](_0x3c9de3[_0x0baf('0x40')]);_0x3fabec[_0x0baf('0x41')]=_[_0x0baf('0x42')](_0x3fabec[_0x0baf('0x43')],_0x3fabec[_0x0baf('0x40')]);_0x10fa62[_0x0baf('0x44')]=_[_0x0baf('0x42')](_0x3fabec[_0x0baf('0x43')],qs['fields'](_0x3c9de3['query'][_0x0baf('0x45')]));_0x10fa62[_0x0baf('0x44')]=_0x10fa62[_0x0baf('0x44')][_0x0baf('0x46')]?_0x10fa62[_0x0baf('0x44')]:_0x3fabec[_0x0baf('0x43')];if(_0x3c9de3[_0x0baf('0x40')]['includeAll']){_0x10fa62[_0x0baf('0x4f')]=[{'all':!![]}];}_0x10fa62=_[_0x0baf('0x4c')]({},_0x10fa62,_0x3c9de3[_0x0baf('0x55')]);return db[_0x0baf('0x3d')][_0x0baf('0x56')](_0x10fa62)[_0x0baf('0x20')](handleEntityNotFound(_0x2222b6,null))['then'](respondWithResult(_0x2222b6,null))[_0x0baf('0x2b')](handleError(_0x2222b6,null));};exports['create']=function(_0x151741,_0x59f732){return db[_0x0baf('0x3d')]['create'](_0x151741[_0x0baf('0x57')],{})['then'](respondWithResult(_0x59f732,0xc9))[_0x0baf('0x2b')](handleError(_0x59f732,null));};exports[_0x0baf('0x37')]=function(_0x411c1f,_0x4520d1){if(_0x411c1f[_0x0baf('0x57')]['id']){delete _0x411c1f['body']['id'];}return db[_0x0baf('0x3d')][_0x0baf('0x56')]({'where':{'id':_0x411c1f[_0x0baf('0x52')]['id']}})[_0x0baf('0x20')](handleEntityNotFound(_0x4520d1,null))[_0x0baf('0x20')](saveUpdates(_0x411c1f[_0x0baf('0x57')],null))['then'](respondWithResult(_0x4520d1,null))[_0x0baf('0x2b')](handleError(_0x4520d1,null));};exports[_0x0baf('0x38')]=function(_0x315cbf,_0xabafaa){return db[_0x0baf('0x3d')][_0x0baf('0x56')]({'where':{'id':_0x315cbf[_0x0baf('0x52')]['id']}})['then'](handleEntityNotFound(_0xabafaa,null))['then'](removeEntity(_0xabafaa,null))[_0x0baf('0x2b')](handleError(_0xabafaa,null));};exports[_0x0baf('0x58')]=function(_0x371a3d,_0x337d94,_0x3128aa){var _0x35221e={};var _0xaa4293={};var _0x14a667;var _0x3d9a32;return db['ZendeskAccount'][_0x0baf('0x59')]({'where':{'id':_0x371a3d[_0x0baf('0x52')]['id']}})[_0x0baf('0x20')](handleEntityNotFound(_0x337d94,null))[_0x0baf('0x20')](function(_0x2024e2){if(_0x2024e2){_0x14a667=_0x2024e2;_0xaa4293[_0x0baf('0x43')]=_[_0x0baf('0x53')](db['ZendeskConfiguration'][_0x0baf('0x54')]);_0xaa4293[_0x0baf('0x40')]=_[_0x0baf('0x53')](_0x371a3d[_0x0baf('0x40')]);_0xaa4293[_0x0baf('0x41')]=_[_0x0baf('0x42')](_0xaa4293[_0x0baf('0x43')],_0xaa4293[_0x0baf('0x40')]);_0x35221e['attributes']=_[_0x0baf('0x42')](_0xaa4293['model'],qs[_0x0baf('0x45')](_0x371a3d['query']['fields']));_0x35221e[_0x0baf('0x44')]=_0x35221e['attributes'][_0x0baf('0x46')]?_0x35221e[_0x0baf('0x44')]:_0xaa4293['model'];_0x35221e[_0x0baf('0x48')]=qs[_0x0baf('0x49')](_0x371a3d[_0x0baf('0x40')]['sort']);_0x35221e['where']=qs[_0x0baf('0x41')](_[_0x0baf('0x5a')](_0x371a3d[_0x0baf('0x40')],_0xaa4293[_0x0baf('0x41')]));if(_0x371a3d[_0x0baf('0x40')]['filter']){_0x35221e[_0x0baf('0x4a')]=_['merge'](_0x35221e['where'],{'$or':_['map'](_0x35221e[_0x0baf('0x44')],function(_0x58a366){var _0x4946d4={};_0x4946d4[_0x58a366]={'$like':'%'+_0x371a3d[_0x0baf('0x40')][_0x0baf('0x4b')]+'%'};return _0x4946d4;})});}_0x35221e=_[_0x0baf('0x4c')]({},_0x35221e,_0x371a3d[_0x0baf('0x55')]);return _0x14a667[_0x0baf('0x58')](_0x35221e);}})[_0x0baf('0x20')](function(_0x4c05d6){if(_0x4c05d6){_0x3d9a32=_0x4c05d6[_0x0baf('0x46')];if(!_0x371a3d[_0x0baf('0x40')][_0x0baf('0x47')](_0x0baf('0x5b'))){_0x35221e[_0x0baf('0x31')]=qs[_0x0baf('0x31')](_0x371a3d['query'][_0x0baf('0x31')]);_0x35221e[_0x0baf('0x30')]=qs[_0x0baf('0x30')](_0x371a3d['query'][_0x0baf('0x30')]);}return _0x14a667[_0x0baf('0x58')](_0x35221e);}})[_0x0baf('0x20')](function(_0x2c20fe){if(_0x2c20fe){return _0x2c20fe?{'count':_0x3d9a32,'rows':_0x2c20fe}:null;}})[_0x0baf('0x20')](respondWithResult(_0x337d94,null))[_0x0baf('0x2b')](handleError(_0x337d94,null));};exports[_0x0baf('0x5c')]=function(_0x5874cc,_0x54353a,_0x4b7caa){if(_0x5874cc[_0x0baf('0x57')]['id']){delete _0x5874cc[_0x0baf('0x57')]['id'];}return db[_0x0baf('0x3d')][_0x0baf('0x59')]({'where':{'id':_0x5874cc[_0x0baf('0x52')]['id']}})[_0x0baf('0x20')](handleEntityNotFound(_0x54353a,null))['then'](function(_0x591ea6){if(_0x591ea6){_0x5874cc[_0x0baf('0x57')]['AccountId']=_0x591ea6['id'];_0x5874cc[_0x0baf('0x57')][_0x0baf('0x5d')]=integrations['getSubjects'](_0x5874cc[_0x0baf('0x57')][_0x0baf('0x5e')],_0x5874cc[_0x0baf('0x57')][_0x0baf('0x4d')]);_0x5874cc[_0x0baf('0x57')][_0x0baf('0x5f')]=integrations[_0x0baf('0x60')](_0x5874cc[_0x0baf('0x57')][_0x0baf('0x5e')],_0x5874cc['body']['type']);return db['ZendeskConfiguration']['create'](_0x5874cc['body'],{'include':[{'model':db[_0x0baf('0x61')],'as':_0x0baf('0x5d')},{'model':db[_0x0baf('0x61')],'as':_0x0baf('0x5f')}]});}return null;})['then'](respondWithResult(_0x54353a,null))[_0x0baf('0x2b')](handleError(_0x54353a,null));};exports[_0x0baf('0x62')]=function(_0x58caee,_0x4b2226,_0x43aecd){var _0x175f8b='';return db[_0x0baf('0x3d')][_0x0baf('0x59')]({'where':{'id':_0x58caee[_0x0baf('0x52')]['id']},'attributes':['id',_0x0baf('0x63'),_0x0baf('0x64'),_0x0baf('0x65'),'authType',_0x0baf('0x66')]})[_0x0baf('0x20')](handleEntityNotFound(_0x4b2226,null))['then'](function(_0xa82961){if(_0xa82961){_0x175f8b=_0xa82961[_0x0baf('0x66')];var _0x538f24=_0x175f8b[_0x0baf('0x67')](-0x1);if(_0x538f24==='/'){_0x175f8b=_0x175f8b[_0x0baf('0x68')](0x0,_0x175f8b[_0x0baf('0x69')](_0x538f24));}var _0x2baede={'method':_0x0baf('0x6a'),'uri':util['format']('%s/%s',_0x175f8b,_0x0baf('0x6b')),'json':!![]};switch(_0xa82961[_0x0baf('0x6c')]){case'password':_0x2baede[_0x0baf('0x6d')]={'Authorization':util[_0x0baf('0x6e')](_0x0baf('0x6f'),new Buffer(util['format'](_0x0baf('0x70'),_0xa82961[_0x0baf('0x63')],_0xa82961[_0x0baf('0x64')]))['toString'](_0x0baf('0x71')))};break;case'token':_0x2baede[_0x0baf('0x6d')]={'Authorization':util[_0x0baf('0x6e')](_0x0baf('0x6f'),new Buffer(util[_0x0baf('0x6e')](_0x0baf('0x72'),_0xa82961['username'],_0xa82961[_0x0baf('0x65')]))[_0x0baf('0x73')]('base64'))};break;default:throw new db[(_0x0baf('0x74'))][(_0x0baf('0x75'))](_0x0baf('0x76'));}return rp(_0x2baede);}})[_0x0baf('0x20')](function(_0x1cbbcc){if(_0x1cbbcc){var _0x250df2=[_0x0baf('0x77'),_0x0baf('0x78'),_0x0baf('0x79'),_0x0baf('0x7a')];_[_0x0baf('0x7b')](_0x1cbbcc[_0x0baf('0x6b')],function(_0x5985f9){return _0x250df2['includes'](_0x5985f9[_0x0baf('0x4d')]);});return{'count':_0x1cbbcc[_0x0baf('0x6b')][_0x0baf('0x46')],'rows':_['map'](_0x1cbbcc['ticket_fields'],function(_0x3f9b17){return{'id':_0x3f9b17['id'],'name':_0x3f9b17[_0x0baf('0x7c')]>0x7?_0x3f9b17[_0x0baf('0x7d')]:_0x3f9b17[_0x0baf('0x4d')],'custom':_0x3f9b17[_0x0baf('0x7c')]>0x7?!![]:![],'options':_0x3f9b17[_0x0baf('0x7e')]?_0x3f9b17[_0x0baf('0x7e')]:_0x3f9b17[_0x0baf('0x7f')]?_0x3f9b17[_0x0baf('0x7f')]:[]};})};}})['then'](respondWithResult(_0x4b2226,null))[_0x0baf('0x2b')](function(_0x1eb835){var _0x1897b7=_0x58caee[_0x0baf('0x40')]['test']?0x1f4:_0x1eb835['statusCode']||0x1f4;logger['error'](_0x0baf('0x80'),_0x0baf('0x62'),_0x1897b7,JSON['stringify'](_0x1eb835));delete _0x1eb835['name'];if(_0x1897b7===0x191){_0x1897b7=0x190;}_0x4b2226[_0x0baf('0x2c')](_0x1897b7)[_0x0baf('0x3b')](_0x58caee['query'][_0x0baf('0x81')]?{'message':_0x0baf('0x82'),'statusCode':_0x1eb835[_0x0baf('0x83')]}:_0x1eb835);});};
\ No newline at end of file
+var _0xe6d7=['getConfigurations','findOne','ZendeskConfiguration','hasOwnProperty','addConfiguration','AccountId','getSubjects','channel','Descriptions','getDescriptions','ZendeskField','username','authType','remoteUri','slice','substring','format','%s/%s','ticket_fields','headers','Basic\x20%s','password','toString','base64','%s/token:%s','token','Sequelize','Unknown\x20authentication\x20type','subject','description','group','remove','includes','position','title','system_field_options','custom_field_options','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','send','Wrong\x20credentials','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../components/integrations/configuration','jayson/promise','client','http','then','ZendeskAccount,\x20%s,\x20%s','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','offset','limit','Content-Range','apply','reject','save','update','stack','name','index','map','rawAttributes','fieldName','type','key','model','intersection','query','fields','attributes','length','nolimit','order','sort','where','filters','pick','VIRTUAL','filter','options','ZendeskAccount','count','rows','show','params','keys','includeAll','include','merge','find','create','body','destroy'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xe6d7,0x1ae));var _0x7e6d=function(_0x43014f,_0x108442){_0x43014f=_0x43014f-0x0;var _0x200ff0=_0xe6d7[_0x43014f];return _0x200ff0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x7e6d('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x7e6d('0x1'));var jsonpatch=require(_0x7e6d('0x2'));var rp=require(_0x7e6d('0x3'));var moment=require(_0x7e6d('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x7e6d('0x5'));var util=require('util');var path=require('path');var sox=require(_0x7e6d('0x6'));var csv=require(_0x7e6d('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x7e6d('0x8'));var squel=require(_0x7e6d('0x9'));var crypto=require(_0x7e6d('0xa'));var jsforce=require(_0x7e6d('0xb'));var deskjs=require(_0x7e6d('0xc'));var toCsv=require(_0x7e6d('0x7'));var querystring=require(_0x7e6d('0xd'));var Papa=require(_0x7e6d('0xe'));var Redis=require(_0x7e6d('0xf'));var authService=require(_0x7e6d('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x7e6d('0x11'));var hardwareService=require(_0x7e6d('0x12'));var logger=require(_0x7e6d('0x13'))(_0x7e6d('0x14'));var utils=require('../../config/utils');var config=require(_0x7e6d('0x15'));var licenseUtil=require(_0x7e6d('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0x7e6d('0x17'));var jayson=require(_0x7e6d('0x18'));var client=jayson[_0x7e6d('0x19')][_0x7e6d('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x154045,_0x2bab2e,_0x38c3e4,_0x28b9b8){return new BPromise(function(_0x3b93ad,_0x2a610c){var _0x5cad83=_0x28b9b8||client;return _0x5cad83['request'](_0x154045,_0x38c3e4)[_0x7e6d('0x1b')](function(_0x265a56){logger['info'](_0x7e6d('0x1c'),_0x2bab2e,'request\x20sent');logger[_0x7e6d('0x1d')](_0x7e6d('0x1e'),_0x2bab2e,_0x7e6d('0x1f'),JSON[_0x7e6d('0x20')](_0x265a56));if(_0x265a56['error']){if(_0x265a56[_0x7e6d('0x21')][_0x7e6d('0x22')]===0x1f4){logger['error'](_0x7e6d('0x1c'),_0x2bab2e,_0x265a56[_0x7e6d('0x21')][_0x7e6d('0x23')]);return _0x2a610c(_0x265a56[_0x7e6d('0x21')]['message']);}logger[_0x7e6d('0x21')](_0x7e6d('0x1c'),_0x2bab2e,_0x265a56[_0x7e6d('0x21')]['message']);return _0x3b93ad(_0x265a56[_0x7e6d('0x21')][_0x7e6d('0x23')]);}else{logger[_0x7e6d('0x24')](_0x7e6d('0x1c'),_0x2bab2e,'request\x20sent');_0x3b93ad(_0x265a56[_0x7e6d('0x25')][_0x7e6d('0x23')]);}})[_0x7e6d('0x26')](function(_0x5d8908){logger[_0x7e6d('0x21')](_0x7e6d('0x1c'),_0x2bab2e,_0x5d8908);_0x2a610c(_0x5d8908);});});}function respondWithStatusCode(_0x29aa87,_0x188739){_0x188739=_0x188739||0xcc;return function(_0x1e90a7){if(_0x1e90a7){return _0x29aa87[_0x7e6d('0x27')](_0x188739);}return _0x29aa87[_0x7e6d('0x28')](_0x188739)[_0x7e6d('0x29')]();};}function respondWithResult(_0x37c4f3,_0x23dafe){_0x23dafe=_0x23dafe||0xc8;return function(_0x3c7b36){if(_0x3c7b36){return _0x37c4f3[_0x7e6d('0x28')](_0x23dafe)[_0x7e6d('0x2a')](_0x3c7b36);}};}function respondWithFilteredResult(_0x249e7f,_0x1004f4){return function(_0x2997d4){if(_0x2997d4){var _0x5e507d=_0x2997d4['count'],_0x5a23ab=_0x1004f4[_0x7e6d('0x2b')],_0x477394=_0x1004f4[_0x7e6d('0x2b')]+_0x1004f4[_0x7e6d('0x2c')],_0x31977d;if(_0x477394>=_0x5e507d){_0x477394=_0x5e507d;_0x31977d=0xc8;}else{_0x31977d=0xce;}_0x249e7f[_0x7e6d('0x28')](_0x31977d);return _0x249e7f['set'](_0x7e6d('0x2d'),_0x5a23ab+'-'+_0x477394+'/'+_0x5e507d)[_0x7e6d('0x2a')](_0x2997d4);}return null;};}function patchUpdates(_0x3f1a6b){return function(_0x42341d){try{jsonpatch[_0x7e6d('0x2e')](_0x42341d,_0x3f1a6b,!![]);}catch(_0x31f642){return BPromise[_0x7e6d('0x2f')](_0x31f642);}return _0x42341d[_0x7e6d('0x30')]();};}function saveUpdates(_0x38ccdf,_0x5b79ea){return function(_0x5f05f8){if(_0x5f05f8){return _0x5f05f8[_0x7e6d('0x31')](_0x38ccdf)[_0x7e6d('0x1b')](function(_0x587108){return _0x587108;});}return null;};}function removeEntity(_0x56599c,_0x2acac9){return function(_0x3ac54d){if(_0x3ac54d){return _0x3ac54d['destroy']()['then'](function(){_0x56599c['status'](0xcc)[_0x7e6d('0x29')]();});}};}function handleEntityNotFound(_0x297439,_0x27ac77){return function(_0x2084e9){if(!_0x2084e9){_0x297439[_0x7e6d('0x27')](0x194);}return _0x2084e9;};}function handleError(_0xbadd1f,_0x4c61d6){_0x4c61d6=_0x4c61d6||0x1f4;return function(_0x5d6278){logger[_0x7e6d('0x21')](_0x5d6278[_0x7e6d('0x32')]);if(_0x5d6278[_0x7e6d('0x33')]){delete _0x5d6278['name'];}_0xbadd1f[_0x7e6d('0x28')](_0x4c61d6)['send'](_0x5d6278);};}exports[_0x7e6d('0x34')]=function(_0x3cdba7,_0x3c3e59){var _0x10c545={},_0x34133e={},_0x338f68={'count':0x0,'rows':[]};var _0x18781f=_[_0x7e6d('0x35')](db['ZendeskAccount'][_0x7e6d('0x36')],function(_0x386e01){return{'name':_0x386e01[_0x7e6d('0x37')],'type':_0x386e01[_0x7e6d('0x38')][_0x7e6d('0x39')]};});_0x34133e[_0x7e6d('0x3a')]=_['map'](_0x18781f,_0x7e6d('0x33'));_0x34133e['query']=_['keys'](_0x3cdba7['query']);_0x34133e['filters']=_[_0x7e6d('0x3b')](_0x34133e[_0x7e6d('0x3a')],_0x34133e[_0x7e6d('0x3c')]);_0x10c545['attributes']=_[_0x7e6d('0x3b')](_0x34133e[_0x7e6d('0x3a')],qs['fields'](_0x3cdba7['query'][_0x7e6d('0x3d')]));_0x10c545[_0x7e6d('0x3e')]=_0x10c545[_0x7e6d('0x3e')][_0x7e6d('0x3f')]?_0x10c545[_0x7e6d('0x3e')]:_0x34133e[_0x7e6d('0x3a')];if(!_0x3cdba7['query']['hasOwnProperty'](_0x7e6d('0x40'))){_0x10c545[_0x7e6d('0x2c')]=qs[_0x7e6d('0x2c')](_0x3cdba7[_0x7e6d('0x3c')][_0x7e6d('0x2c')]);_0x10c545[_0x7e6d('0x2b')]=qs['offset'](_0x3cdba7['query'][_0x7e6d('0x2b')]);}_0x10c545[_0x7e6d('0x41')]=qs['sort'](_0x3cdba7['query'][_0x7e6d('0x42')]);_0x10c545[_0x7e6d('0x43')]=qs[_0x7e6d('0x44')](_[_0x7e6d('0x45')](_0x3cdba7[_0x7e6d('0x3c')],_0x34133e[_0x7e6d('0x44')]),_0x18781f);if(_0x3cdba7[_0x7e6d('0x3c')]['filter']){_0x10c545[_0x7e6d('0x43')]=_['merge'](_0x10c545[_0x7e6d('0x43')],{'$or':_[_0x7e6d('0x35')](_0x18781f,function(_0xc7f155){if(_0xc7f155['type']!==_0x7e6d('0x46')){var _0x462dde={};_0x462dde[_0xc7f155[_0x7e6d('0x33')]]={'$like':'%'+_0x3cdba7[_0x7e6d('0x3c')][_0x7e6d('0x47')]+'%'};return _0x462dde;}})});}_0x10c545=_['merge']({},_0x10c545,_0x3cdba7[_0x7e6d('0x48')]);var _0x592800={'where':_0x10c545['where']};return db[_0x7e6d('0x49')]['count'](_0x592800)[_0x7e6d('0x1b')](function(_0x48109c){_0x338f68[_0x7e6d('0x4a')]=_0x48109c;if(_0x3cdba7[_0x7e6d('0x3c')]['includeAll']){_0x10c545['include']=[{'all':!![]}];}return db[_0x7e6d('0x49')]['findAll'](_0x10c545);})[_0x7e6d('0x1b')](function(_0x206489){_0x338f68[_0x7e6d('0x4b')]=_0x206489;return _0x338f68;})['then'](respondWithFilteredResult(_0x3c3e59,_0x10c545))[_0x7e6d('0x26')](handleError(_0x3c3e59,null));};exports[_0x7e6d('0x4c')]=function(_0x48e561,_0x1de7cb){var _0x633991={'raw':![],'where':{'id':_0x48e561[_0x7e6d('0x4d')]['id']}},_0x3f2c0d={};_0x3f2c0d[_0x7e6d('0x3a')]=_[_0x7e6d('0x4e')](db['ZendeskAccount'][_0x7e6d('0x36')]);_0x3f2c0d[_0x7e6d('0x3c')]=_[_0x7e6d('0x4e')](_0x48e561[_0x7e6d('0x3c')]);_0x3f2c0d['filters']=_['intersection'](_0x3f2c0d[_0x7e6d('0x3a')],_0x3f2c0d[_0x7e6d('0x3c')]);_0x633991[_0x7e6d('0x3e')]=_['intersection'](_0x3f2c0d[_0x7e6d('0x3a')],qs[_0x7e6d('0x3d')](_0x48e561[_0x7e6d('0x3c')]['fields']));_0x633991[_0x7e6d('0x3e')]=_0x633991['attributes']['length']?_0x633991[_0x7e6d('0x3e')]:_0x3f2c0d[_0x7e6d('0x3a')];if(_0x48e561[_0x7e6d('0x3c')][_0x7e6d('0x4f')]){_0x633991[_0x7e6d('0x50')]=[{'all':!![]}];}_0x633991=_[_0x7e6d('0x51')]({},_0x633991,_0x48e561['options']);return db[_0x7e6d('0x49')][_0x7e6d('0x52')](_0x633991)[_0x7e6d('0x1b')](handleEntityNotFound(_0x1de7cb,null))[_0x7e6d('0x1b')](respondWithResult(_0x1de7cb,null))['catch'](handleError(_0x1de7cb,null));};exports[_0x7e6d('0x53')]=function(_0x3497b3,_0x1e3293){return db[_0x7e6d('0x49')][_0x7e6d('0x53')](_0x3497b3[_0x7e6d('0x54')],{})['then'](respondWithResult(_0x1e3293,0xc9))[_0x7e6d('0x26')](handleError(_0x1e3293,null));};exports[_0x7e6d('0x31')]=function(_0x1a729c,_0x5a4c45){if(_0x1a729c[_0x7e6d('0x54')]['id']){delete _0x1a729c[_0x7e6d('0x54')]['id'];}return db[_0x7e6d('0x49')][_0x7e6d('0x52')]({'where':{'id':_0x1a729c['params']['id']}})[_0x7e6d('0x1b')](handleEntityNotFound(_0x5a4c45,null))[_0x7e6d('0x1b')](saveUpdates(_0x1a729c['body'],null))[_0x7e6d('0x1b')](respondWithResult(_0x5a4c45,null))[_0x7e6d('0x26')](handleError(_0x5a4c45,null));};exports[_0x7e6d('0x55')]=function(_0x5b1ced,_0x19188b){return db[_0x7e6d('0x49')][_0x7e6d('0x52')]({'where':{'id':_0x5b1ced['params']['id']}})[_0x7e6d('0x1b')](handleEntityNotFound(_0x19188b,null))[_0x7e6d('0x1b')](removeEntity(_0x19188b,null))['catch'](handleError(_0x19188b,null));};exports[_0x7e6d('0x56')]=function(_0x62a15e,_0x18632c,_0x3232d4){var _0x245b4b={};var _0xb71d53={};var _0x22dae4;var _0x32b15a;return db[_0x7e6d('0x49')][_0x7e6d('0x57')]({'where':{'id':_0x62a15e['params']['id']}})[_0x7e6d('0x1b')](handleEntityNotFound(_0x18632c,null))[_0x7e6d('0x1b')](function(_0xa486ae){if(_0xa486ae){_0x22dae4=_0xa486ae;_0xb71d53['model']=_[_0x7e6d('0x4e')](db[_0x7e6d('0x58')]['rawAttributes']);_0xb71d53[_0x7e6d('0x3c')]=_[_0x7e6d('0x4e')](_0x62a15e[_0x7e6d('0x3c')]);_0xb71d53[_0x7e6d('0x44')]=_[_0x7e6d('0x3b')](_0xb71d53[_0x7e6d('0x3a')],_0xb71d53['query']);_0x245b4b[_0x7e6d('0x3e')]=_['intersection'](_0xb71d53[_0x7e6d('0x3a')],qs[_0x7e6d('0x3d')](_0x62a15e[_0x7e6d('0x3c')][_0x7e6d('0x3d')]));_0x245b4b['attributes']=_0x245b4b[_0x7e6d('0x3e')][_0x7e6d('0x3f')]?_0x245b4b[_0x7e6d('0x3e')]:_0xb71d53['model'];_0x245b4b[_0x7e6d('0x41')]=qs['sort'](_0x62a15e['query'][_0x7e6d('0x42')]);_0x245b4b[_0x7e6d('0x43')]=qs['filters'](_[_0x7e6d('0x45')](_0x62a15e[_0x7e6d('0x3c')],_0xb71d53[_0x7e6d('0x44')]));if(_0x62a15e[_0x7e6d('0x3c')][_0x7e6d('0x47')]){_0x245b4b[_0x7e6d('0x43')]=_[_0x7e6d('0x51')](_0x245b4b[_0x7e6d('0x43')],{'$or':_[_0x7e6d('0x35')](_0x245b4b[_0x7e6d('0x3e')],function(_0x4313ae){var _0x1fcec1={};_0x1fcec1[_0x4313ae]={'$like':'%'+_0x62a15e[_0x7e6d('0x3c')]['filter']+'%'};return _0x1fcec1;})});}_0x245b4b=_[_0x7e6d('0x51')]({},_0x245b4b,_0x62a15e[_0x7e6d('0x48')]);return _0x22dae4[_0x7e6d('0x56')](_0x245b4b);}})[_0x7e6d('0x1b')](function(_0x30b983){if(_0x30b983){_0x32b15a=_0x30b983['length'];if(!_0x62a15e[_0x7e6d('0x3c')][_0x7e6d('0x59')]('nolimit')){_0x245b4b[_0x7e6d('0x2c')]=qs[_0x7e6d('0x2c')](_0x62a15e['query']['limit']);_0x245b4b[_0x7e6d('0x2b')]=qs[_0x7e6d('0x2b')](_0x62a15e[_0x7e6d('0x3c')]['offset']);}return _0x22dae4['getConfigurations'](_0x245b4b);}})[_0x7e6d('0x1b')](function(_0x27ac69){if(_0x27ac69){return _0x27ac69?{'count':_0x32b15a,'rows':_0x27ac69}:null;}})[_0x7e6d('0x1b')](respondWithResult(_0x18632c,null))[_0x7e6d('0x26')](handleError(_0x18632c,null));};exports[_0x7e6d('0x5a')]=function(_0x4c36b8,_0x1a3640,_0x2659ed){if(_0x4c36b8[_0x7e6d('0x54')]['id']){delete _0x4c36b8[_0x7e6d('0x54')]['id'];}return db[_0x7e6d('0x49')][_0x7e6d('0x57')]({'where':{'id':_0x4c36b8[_0x7e6d('0x4d')]['id']}})[_0x7e6d('0x1b')](handleEntityNotFound(_0x1a3640,null))['then'](function(_0xf235e0){if(_0xf235e0){_0x4c36b8[_0x7e6d('0x54')][_0x7e6d('0x5b')]=_0xf235e0['id'];_0x4c36b8['body']['Subjects']=integrations[_0x7e6d('0x5c')](_0x4c36b8[_0x7e6d('0x54')][_0x7e6d('0x5d')],_0x4c36b8[_0x7e6d('0x54')][_0x7e6d('0x38')]);_0x4c36b8['body'][_0x7e6d('0x5e')]=integrations[_0x7e6d('0x5f')](_0x4c36b8['body'][_0x7e6d('0x5d')],_0x4c36b8[_0x7e6d('0x54')][_0x7e6d('0x38')]);return db[_0x7e6d('0x58')][_0x7e6d('0x53')](_0x4c36b8[_0x7e6d('0x54')],{'include':[{'model':db[_0x7e6d('0x60')],'as':'Subjects'},{'model':db[_0x7e6d('0x60')],'as':'Descriptions'}]});}return null;})[_0x7e6d('0x1b')](respondWithResult(_0x1a3640,null))[_0x7e6d('0x26')](handleError(_0x1a3640,null));};exports['getFields']=function(_0x48dbbc,_0x418b67,_0x5dedbe){var _0x42f968='';return db['ZendeskAccount'][_0x7e6d('0x57')]({'where':{'id':_0x48dbbc[_0x7e6d('0x4d')]['id']},'attributes':['id',_0x7e6d('0x61'),'password','token',_0x7e6d('0x62'),_0x7e6d('0x63')]})['then'](handleEntityNotFound(_0x418b67,null))[_0x7e6d('0x1b')](function(_0x18e430){if(_0x18e430){_0x42f968=_0x18e430[_0x7e6d('0x63')];var _0x4cfab6=_0x42f968[_0x7e6d('0x64')](-0x1);if(_0x4cfab6==='/'){_0x42f968=_0x42f968[_0x7e6d('0x65')](0x0,_0x42f968['lastIndexOf'](_0x4cfab6));}var _0x2ad9b1={'method':'GET','uri':util[_0x7e6d('0x66')](_0x7e6d('0x67'),_0x42f968,_0x7e6d('0x68')),'json':!![]};switch(_0x18e430[_0x7e6d('0x62')]){case'password':_0x2ad9b1[_0x7e6d('0x69')]={'Authorization':util[_0x7e6d('0x66')](_0x7e6d('0x6a'),new Buffer(util[_0x7e6d('0x66')]('%s:%s',_0x18e430[_0x7e6d('0x61')],_0x18e430[_0x7e6d('0x6b')]))[_0x7e6d('0x6c')](_0x7e6d('0x6d')))};break;case'token':_0x2ad9b1[_0x7e6d('0x69')]={'Authorization':util[_0x7e6d('0x66')](_0x7e6d('0x6a'),new Buffer(util[_0x7e6d('0x66')](_0x7e6d('0x6e'),_0x18e430['username'],_0x18e430[_0x7e6d('0x6f')]))[_0x7e6d('0x6c')]('base64'))};break;default:throw new db[(_0x7e6d('0x70'))]['ValidationError'](_0x7e6d('0x71'));}return rp(_0x2ad9b1);}})['then'](function(_0x3d22e1){if(_0x3d22e1){var _0x1f83fa=[_0x7e6d('0x72'),_0x7e6d('0x73'),_0x7e6d('0x74'),'assignee'];_[_0x7e6d('0x75')](_0x3d22e1[_0x7e6d('0x68')],function(_0x31e632){return _0x1f83fa[_0x7e6d('0x76')](_0x31e632[_0x7e6d('0x38')]);});return{'count':_0x3d22e1[_0x7e6d('0x68')][_0x7e6d('0x3f')],'rows':_[_0x7e6d('0x35')](_0x3d22e1['ticket_fields'],function(_0x29422c){return{'id':_0x29422c['id'],'name':_0x29422c[_0x7e6d('0x77')]>0x7?_0x29422c[_0x7e6d('0x78')]:_0x29422c['type'],'custom':_0x29422c['position']>0x7?!![]:![],'options':_0x29422c[_0x7e6d('0x79')]?_0x29422c[_0x7e6d('0x79')]:_0x29422c[_0x7e6d('0x7a')]?_0x29422c[_0x7e6d('0x7a')]:[]};})};}})[_0x7e6d('0x1b')](respondWithResult(_0x418b67,null))['catch'](function(_0x2d9b5e){var _0x32e563=_0x48dbbc['query'][_0x7e6d('0x7b')]?0x1f4:_0x2d9b5e[_0x7e6d('0x7c')]||0x1f4;logger['error'](_0x7e6d('0x7d'),_0x7e6d('0x7e'),_0x32e563,JSON[_0x7e6d('0x20')](_0x2d9b5e));delete _0x2d9b5e[_0x7e6d('0x33')];if(_0x32e563===0x191){_0x32e563=0x190;}_0x418b67[_0x7e6d('0x28')](_0x32e563)[_0x7e6d('0x7f')](_0x48dbbc[_0x7e6d('0x3c')][_0x7e6d('0x7b')]?{'message':_0x7e6d('0x80'),'statusCode':_0x2d9b5e['statusCode']}:_0x2d9b5e);});};
\ No newline at end of file