Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index 054c6e6..74c73ec 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf17f=['Subjects','channel','Descriptions','getDescriptions','ZendeskField','getFields','username','password','remoteUri','lastIndexOf','GET','format','ticket_fields','Basic\x20%s','%s:%s','toString','token','%s/token:%s','base64','Sequelize','Unknown\x20authentication\x20type','subject','description','group','assignee','remove','includes','position','title','system_field_options','custom_field_options','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','html-pdf','eml-format','rimraf','fast-json-patch','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','../../components/integrations/configuration','jayson/promise','http','request','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','end','name','index','ZendeskAccount','rawAttributes','fieldName','type','map','query','filters','intersection','model','attributes','fields','length','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','keys','find','create','body','getConfigurations','findOne','ZendeskConfiguration','hasOwnProperty','AccountId'];(function(_0x3162a2,_0x4ff99d){var _0x59a65a=function(_0x2b256c){while(--_0x2b256c){_0x3162a2['push'](_0x3162a2['shift']());}};_0x59a65a(++_0x4ff99d);}(_0xf17f,0x113));var _0xff17=function(_0x4cee82,_0x208e67){_0x4cee82=_0x4cee82-0x0;var _0x200c1d=_0xf17f[_0x4cee82];return _0x200c1d;};'use strict';var pdf=require(_0xff17('0x0'));var emlformat=require(_0xff17('0x1'));var rimraf=require(_0xff17('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xff17('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xff17('0x4'));var Mustache=require(_0xff17('0x5'));var util=require(_0xff17('0x6'));var path=require(_0xff17('0x7'));var sox=require('sox');var csv=require(_0xff17('0x8'));var ejs=require(_0xff17('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xff17('0xa'));var crypto=require(_0xff17('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xff17('0xc'));var toCsv=require(_0xff17('0x8'));var querystring=require(_0xff17('0xd'));var Papa=require('papaparse');var Redis=require(_0xff17('0xe'));var authService=require(_0xff17('0xf'));var qs=require(_0xff17('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xff17('0x11'));var logger=require(_0xff17('0x12'))(_0xff17('0x13'));var utils=require(_0xff17('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xff17('0x15'))['db'];var integrations=require(_0xff17('0x16'));var jayson=require(_0xff17('0x17'));var client=jayson['client'][_0xff17('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x40e5fb,_0x54904a,_0x2c5a13,_0x4218bc){return new BPromise(function(_0x4e3435,_0x5721de){var _0x53f625=_0x4218bc||client;return _0x53f625[_0xff17('0x19')](_0x40e5fb,_0x2c5a13)['then'](function(_0x2f501a){logger[_0xff17('0x1a')](_0xff17('0x1b'),_0x54904a,_0xff17('0x1c'));logger[_0xff17('0x1d')]('ZendeskAccount,\x20%s,\x20%s,\x20%s',_0x54904a,_0xff17('0x1c'),JSON[_0xff17('0x1e')](_0x2f501a));if(_0x2f501a[_0xff17('0x1f')]){if(_0x2f501a['error']['code']===0x1f4){logger[_0xff17('0x1f')](_0xff17('0x1b'),_0x54904a,_0x2f501a[_0xff17('0x1f')]['message']);return _0x5721de(_0x2f501a['error']['message']);}logger['error'](_0xff17('0x1b'),_0x54904a,_0x2f501a['error'][_0xff17('0x20')]);return _0x4e3435(_0x2f501a[_0xff17('0x1f')][_0xff17('0x20')]);}else{logger['info'](_0xff17('0x1b'),_0x54904a,_0xff17('0x1c'));_0x4e3435(_0x2f501a['result']['message']);}})[_0xff17('0x21')](function(_0x237b49){logger[_0xff17('0x1f')]('ZendeskAccount,\x20%s,\x20%s',_0x54904a,_0x237b49);_0x5721de(_0x237b49);});});}function respondWithStatusCode(_0x594018,_0x20f5f3){_0x20f5f3=_0x20f5f3||0xcc;return function(_0xecd4cb){if(_0xecd4cb){return _0x594018[_0xff17('0x22')](_0x20f5f3);}return _0x594018[_0xff17('0x23')](_0x20f5f3)['end']();};}function respondWithResult(_0x10cd49,_0x3904bb){_0x3904bb=_0x3904bb||0xc8;return function(_0x5ad4df){if(_0x5ad4df){return _0x10cd49[_0xff17('0x23')](_0x3904bb)[_0xff17('0x24')](_0x5ad4df);}};}function respondWithFilteredResult(_0x509d30,_0x301511){return function(_0x512f7b){if(_0x512f7b){var _0x57513e=_0x512f7b[_0xff17('0x25')],_0x5cf3a5=_0x301511[_0xff17('0x26')],_0x4138e3=_0x301511[_0xff17('0x26')]+_0x301511[_0xff17('0x27')],_0x182dd7;if(_0x4138e3>=_0x57513e){_0x4138e3=_0x57513e;_0x182dd7=0xc8;}else{_0x182dd7=0xce;}_0x509d30[_0xff17('0x23')](_0x182dd7);return _0x509d30[_0xff17('0x28')](_0xff17('0x29'),_0x5cf3a5+'-'+_0x4138e3+'/'+_0x57513e)[_0xff17('0x24')](_0x512f7b);}return null;};}function patchUpdates(_0x52f588){return function(_0x37b5d0){try{jsonpatch[_0xff17('0x2a')](_0x37b5d0,_0x52f588,!![]);}catch(_0x2fe2bc){return BPromise[_0xff17('0x2b')](_0x2fe2bc);}return _0x37b5d0[_0xff17('0x2c')]();};}function saveUpdates(_0x164be8,_0x45b124){return function(_0x3dc73c){if(_0x3dc73c){return _0x3dc73c[_0xff17('0x2d')](_0x164be8)[_0xff17('0x2e')](function(_0x1b8dd0){return _0x1b8dd0;});}return null;};}function removeEntity(_0x2223ae,_0x8be4c7){return function(_0x1f3c3e){if(_0x1f3c3e){return _0x1f3c3e[_0xff17('0x2f')]()[_0xff17('0x2e')](function(){_0x2223ae[_0xff17('0x23')](0xcc)[_0xff17('0x30')]();});}};}function handleEntityNotFound(_0x3abebf,_0x3de4e8){return function(_0x58e0e6){if(!_0x58e0e6){_0x3abebf[_0xff17('0x22')](0x194);}return _0x58e0e6;};}function handleError(_0x596dee,_0x3a8345){_0x3a8345=_0x3a8345||0x1f4;return function(_0x4c57d7){logger['error'](_0x4c57d7['stack']);if(_0x4c57d7['name']){delete _0x4c57d7[_0xff17('0x31')];}_0x596dee[_0xff17('0x23')](_0x3a8345)['send'](_0x4c57d7);};}exports[_0xff17('0x32')]=function(_0x4073ba,_0x5e6504){var _0x3cbadd={},_0x1e30b2={},_0x3fe045={'count':0x0,'rows':[]};var _0x4daa4e=_['map'](db[_0xff17('0x33')][_0xff17('0x34')],function(_0x43a562){return{'name':_0x43a562[_0xff17('0x35')],'type':_0x43a562[_0xff17('0x36')]['key']};});_0x1e30b2['model']=_[_0xff17('0x37')](_0x4daa4e,'name');_0x1e30b2[_0xff17('0x38')]=_['keys'](_0x4073ba[_0xff17('0x38')]);_0x1e30b2[_0xff17('0x39')]=_[_0xff17('0x3a')](_0x1e30b2[_0xff17('0x3b')],_0x1e30b2[_0xff17('0x38')]);_0x3cbadd[_0xff17('0x3c')]=_['intersection'](_0x1e30b2[_0xff17('0x3b')],qs[_0xff17('0x3d')](_0x4073ba['query'][_0xff17('0x3d')]));_0x3cbadd[_0xff17('0x3c')]=_0x3cbadd[_0xff17('0x3c')][_0xff17('0x3e')]?_0x3cbadd[_0xff17('0x3c')]:_0x1e30b2['model'];if(!_0x4073ba['query']['hasOwnProperty']('nolimit')){_0x3cbadd[_0xff17('0x27')]=qs[_0xff17('0x27')](_0x4073ba[_0xff17('0x38')]['limit']);_0x3cbadd['offset']=qs[_0xff17('0x26')](_0x4073ba[_0xff17('0x38')]['offset']);}_0x3cbadd[_0xff17('0x3f')]=qs[_0xff17('0x40')](_0x4073ba[_0xff17('0x38')][_0xff17('0x40')]);_0x3cbadd[_0xff17('0x41')]=qs[_0xff17('0x39')](_[_0xff17('0x42')](_0x4073ba[_0xff17('0x38')],_0x1e30b2['filters']),_0x4daa4e);if(_0x4073ba[_0xff17('0x38')][_0xff17('0x43')]){_0x3cbadd[_0xff17('0x41')]=_[_0xff17('0x44')](_0x3cbadd[_0xff17('0x41')],{'$or':_[_0xff17('0x37')](_0x4daa4e,function(_0x2ece1f){if(_0x2ece1f['type']!==_0xff17('0x45')){var _0x5deb36={};_0x5deb36[_0x2ece1f['name']]={'$like':'%'+_0x4073ba[_0xff17('0x38')][_0xff17('0x43')]+'%'};return _0x5deb36;}})});}_0x3cbadd=_[_0xff17('0x44')]({},_0x3cbadd,_0x4073ba[_0xff17('0x46')]);var _0x34fba1={'where':_0x3cbadd[_0xff17('0x41')]};return db['ZendeskAccount'][_0xff17('0x25')](_0x34fba1)[_0xff17('0x2e')](function(_0x332e83){_0x3fe045['count']=_0x332e83;if(_0x4073ba['query'][_0xff17('0x47')]){_0x3cbadd[_0xff17('0x48')]=[{'all':!![]}];}return db[_0xff17('0x33')][_0xff17('0x49')](_0x3cbadd);})[_0xff17('0x2e')](function(_0x3e1728){_0x3fe045[_0xff17('0x4a')]=_0x3e1728;return _0x3fe045;})[_0xff17('0x2e')](respondWithFilteredResult(_0x5e6504,_0x3cbadd))['catch'](handleError(_0x5e6504,null));};exports['show']=function(_0x460802,_0x1c7b18){var _0xb31f23={'raw':![],'where':{'id':_0x460802[_0xff17('0x4b')]['id']}},_0x39974f={};_0x39974f['model']=_[_0xff17('0x4c')](db[_0xff17('0x33')][_0xff17('0x34')]);_0x39974f[_0xff17('0x38')]=_[_0xff17('0x4c')](_0x460802['query']);_0x39974f[_0xff17('0x39')]=_[_0xff17('0x3a')](_0x39974f[_0xff17('0x3b')],_0x39974f[_0xff17('0x38')]);_0xb31f23['attributes']=_[_0xff17('0x3a')](_0x39974f[_0xff17('0x3b')],qs[_0xff17('0x3d')](_0x460802[_0xff17('0x38')]['fields']));_0xb31f23[_0xff17('0x3c')]=_0xb31f23[_0xff17('0x3c')][_0xff17('0x3e')]?_0xb31f23['attributes']:_0x39974f[_0xff17('0x3b')];if(_0x460802['query']['includeAll']){_0xb31f23[_0xff17('0x48')]=[{'all':!![]}];}_0xb31f23=_['merge']({},_0xb31f23,_0x460802[_0xff17('0x46')]);return db[_0xff17('0x33')][_0xff17('0x4d')](_0xb31f23)[_0xff17('0x2e')](handleEntityNotFound(_0x1c7b18,null))[_0xff17('0x2e')](respondWithResult(_0x1c7b18,null))[_0xff17('0x21')](handleError(_0x1c7b18,null));};exports[_0xff17('0x4e')]=function(_0x1f4ba6,_0x59c793){return db[_0xff17('0x33')]['create'](_0x1f4ba6[_0xff17('0x4f')],{})['then'](respondWithResult(_0x59c793,0xc9))[_0xff17('0x21')](handleError(_0x59c793,null));};exports[_0xff17('0x2d')]=function(_0x2ba59c,_0x4d189a){if(_0x2ba59c[_0xff17('0x4f')]['id']){delete _0x2ba59c[_0xff17('0x4f')]['id'];}return db[_0xff17('0x33')][_0xff17('0x4d')]({'where':{'id':_0x2ba59c[_0xff17('0x4b')]['id']}})['then'](handleEntityNotFound(_0x4d189a,null))['then'](saveUpdates(_0x2ba59c[_0xff17('0x4f')],null))[_0xff17('0x2e')](respondWithResult(_0x4d189a,null))[_0xff17('0x21')](handleError(_0x4d189a,null));};exports[_0xff17('0x2f')]=function(_0x4b1ae8,_0x4be3ba){return db[_0xff17('0x33')]['find']({'where':{'id':_0x4b1ae8['params']['id']}})[_0xff17('0x2e')](handleEntityNotFound(_0x4be3ba,null))['then'](removeEntity(_0x4be3ba,null))[_0xff17('0x21')](handleError(_0x4be3ba,null));};exports[_0xff17('0x50')]=function(_0x2d1cf6,_0x41df03,_0x3a2c1e){var _0x3e4dce={};var _0xd071ea={};var _0xafec42;var _0x26615a;return db[_0xff17('0x33')][_0xff17('0x51')]({'where':{'id':_0x2d1cf6['params']['id']}})[_0xff17('0x2e')](handleEntityNotFound(_0x41df03,null))[_0xff17('0x2e')](function(_0x4e3ae7){if(_0x4e3ae7){_0xafec42=_0x4e3ae7;_0xd071ea[_0xff17('0x3b')]=_['keys'](db[_0xff17('0x52')][_0xff17('0x34')]);_0xd071ea[_0xff17('0x38')]=_['keys'](_0x2d1cf6[_0xff17('0x38')]);_0xd071ea[_0xff17('0x39')]=_[_0xff17('0x3a')](_0xd071ea[_0xff17('0x3b')],_0xd071ea[_0xff17('0x38')]);_0x3e4dce['attributes']=_[_0xff17('0x3a')](_0xd071ea[_0xff17('0x3b')],qs[_0xff17('0x3d')](_0x2d1cf6[_0xff17('0x38')][_0xff17('0x3d')]));_0x3e4dce[_0xff17('0x3c')]=_0x3e4dce['attributes']['length']?_0x3e4dce[_0xff17('0x3c')]:_0xd071ea[_0xff17('0x3b')];_0x3e4dce[_0xff17('0x3f')]=qs[_0xff17('0x40')](_0x2d1cf6[_0xff17('0x38')][_0xff17('0x40')]);_0x3e4dce[_0xff17('0x41')]=qs[_0xff17('0x39')](_[_0xff17('0x42')](_0x2d1cf6[_0xff17('0x38')],_0xd071ea[_0xff17('0x39')]));if(_0x2d1cf6[_0xff17('0x38')][_0xff17('0x43')]){_0x3e4dce['where']=_['merge'](_0x3e4dce[_0xff17('0x41')],{'$or':_['map'](_0x3e4dce[_0xff17('0x3c')],function(_0x24f617){var _0x44f8fe={};_0x44f8fe[_0x24f617]={'$like':'%'+_0x2d1cf6[_0xff17('0x38')]['filter']+'%'};return _0x44f8fe;})});}_0x3e4dce=_['merge']({},_0x3e4dce,_0x2d1cf6[_0xff17('0x46')]);return _0xafec42[_0xff17('0x50')](_0x3e4dce);}})['then'](function(_0x1adbc5){if(_0x1adbc5){_0x26615a=_0x1adbc5['length'];if(!_0x2d1cf6[_0xff17('0x38')][_0xff17('0x53')]('nolimit')){_0x3e4dce[_0xff17('0x27')]=qs[_0xff17('0x27')](_0x2d1cf6[_0xff17('0x38')][_0xff17('0x27')]);_0x3e4dce[_0xff17('0x26')]=qs['offset'](_0x2d1cf6['query']['offset']);}return _0xafec42['getConfigurations'](_0x3e4dce);}})[_0xff17('0x2e')](function(_0x53ec10){if(_0x53ec10){return _0x53ec10?{'count':_0x26615a,'rows':_0x53ec10}:null;}})['then'](respondWithResult(_0x41df03,null))[_0xff17('0x21')](handleError(_0x41df03,null));};exports['addConfiguration']=function(_0x2d6233,_0x27c96f,_0x11deaa){if(_0x2d6233['body']['id']){delete _0x2d6233[_0xff17('0x4f')]['id'];}return db[_0xff17('0x33')][_0xff17('0x51')]({'where':{'id':_0x2d6233['params']['id']}})[_0xff17('0x2e')](handleEntityNotFound(_0x27c96f,null))['then'](function(_0x4598dd){if(_0x4598dd){_0x2d6233[_0xff17('0x4f')][_0xff17('0x54')]=_0x4598dd['id'];_0x2d6233[_0xff17('0x4f')][_0xff17('0x55')]=integrations['getSubjects'](_0x2d6233['body'][_0xff17('0x56')],_0x2d6233[_0xff17('0x4f')][_0xff17('0x36')]);_0x2d6233[_0xff17('0x4f')][_0xff17('0x57')]=integrations[_0xff17('0x58')](_0x2d6233[_0xff17('0x4f')][_0xff17('0x56')],_0x2d6233[_0xff17('0x4f')][_0xff17('0x36')]);return db['ZendeskConfiguration']['create'](_0x2d6233[_0xff17('0x4f')],{'include':[{'model':db[_0xff17('0x59')],'as':_0xff17('0x55')},{'model':db['ZendeskField'],'as':_0xff17('0x57')}]});}return null;})['then'](respondWithResult(_0x27c96f,null))[_0xff17('0x21')](handleError(_0x27c96f,null));};exports[_0xff17('0x5a')]=function(_0x31b943,_0x2b0f7f,_0x413a11){var _0x19ff36='';return db[_0xff17('0x33')][_0xff17('0x51')]({'where':{'id':_0x31b943['params']['id']},'attributes':['id',_0xff17('0x5b'),_0xff17('0x5c'),'token','authType',_0xff17('0x5d')]})[_0xff17('0x2e')](handleEntityNotFound(_0x2b0f7f,null))['then'](function(_0x41464e){if(_0x41464e){_0x19ff36=_0x41464e[_0xff17('0x5d')];var _0x3787e6=_0x19ff36['slice'](-0x1);if(_0x3787e6==='/'){_0x19ff36=_0x19ff36['substring'](0x0,_0x19ff36[_0xff17('0x5e')](_0x3787e6));}var _0x54e97d={'method':_0xff17('0x5f'),'uri':util[_0xff17('0x60')]('%s/%s',_0x19ff36,_0xff17('0x61')),'json':!![]};switch(_0x41464e['authType']){case _0xff17('0x5c'):_0x54e97d['headers']={'Authorization':util[_0xff17('0x60')](_0xff17('0x62'),new Buffer(util[_0xff17('0x60')](_0xff17('0x63'),_0x41464e[_0xff17('0x5b')],_0x41464e[_0xff17('0x5c')]))[_0xff17('0x64')]('base64'))};break;case _0xff17('0x65'):_0x54e97d['headers']={'Authorization':util[_0xff17('0x60')](_0xff17('0x62'),new Buffer(util[_0xff17('0x60')](_0xff17('0x66'),_0x41464e[_0xff17('0x5b')],_0x41464e[_0xff17('0x65')]))[_0xff17('0x64')](_0xff17('0x67')))};break;default:throw new db[(_0xff17('0x68'))]['ValidationError'](_0xff17('0x69'));}return rp(_0x54e97d);}})['then'](function(_0x5a2b26){if(_0x5a2b26){var _0x33298b=[_0xff17('0x6a'),_0xff17('0x6b'),_0xff17('0x6c'),_0xff17('0x6d')];_[_0xff17('0x6e')](_0x5a2b26[_0xff17('0x61')],function(_0x5e82a2){return _0x33298b[_0xff17('0x6f')](_0x5e82a2['type']);});return{'count':_0x5a2b26[_0xff17('0x61')][_0xff17('0x3e')],'rows':_[_0xff17('0x37')](_0x5a2b26['ticket_fields'],function(_0x21d19f){return{'id':_0x21d19f['id'],'name':_0x21d19f[_0xff17('0x70')]>0x7?_0x21d19f[_0xff17('0x71')]:_0x21d19f['type'],'custom':_0x21d19f[_0xff17('0x70')]>0x7?!![]:![],'options':_0x21d19f[_0xff17('0x72')]?_0x21d19f[_0xff17('0x72')]:_0x21d19f[_0xff17('0x73')]?_0x21d19f[_0xff17('0x73')]:[]};})};}})['then'](respondWithResult(_0x2b0f7f,null))[_0xff17('0x21')](function(_0x5eaa42){var _0x22a51c=_0x31b943[_0xff17('0x38')][_0xff17('0x74')]?0x1f4:_0x5eaa42[_0xff17('0x75')]||0x1f4;logger[_0xff17('0x1f')](_0xff17('0x76'),_0xff17('0x5a'),_0x22a51c,JSON[_0xff17('0x1e')](_0x5eaa42));delete _0x5eaa42['name'];if(_0x22a51c===0x191){_0x22a51c=0x190;}_0x2b0f7f[_0xff17('0x23')](_0x22a51c)['send'](_0x31b943[_0xff17('0x38')]['test']?{'message':_0xff17('0x77'),'statusCode':_0x5eaa42[_0xff17('0x75')]}:_0x5eaa42);});};
\ No newline at end of file
+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