Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / services / ami / trigger / integration / zendesk.js
index 6e8c2ba..8a6df4a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xea0a=['GET','map','forEach','string','nameField','toLowerCase','content','toString','idField','customField','variable','variableName','custom_fields','type','customVariable','Variable','push','queue','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','serverUrl','uniqueid','recordingURL','Authorization','email','The\x20User\x20ID\x20is:','calleridname','calleridnum','The\x20Enduser\x20ID\x20is:','integrationTab','Displaying\x20ticket\x20to\x20agent...','%s/channels/voice/agents/%d/tickets/%d/display.json','newTab','user:%s','trigger:browser:url','%s/agent/tickets/%s','error','catch','[QUEUE]\x20Error\x20running\x20Zendesk\x20integration','inspect','recordingFormat','none','[OUTBOUND]','destcalleridname','destcalleridnum','The\x20Ticket\x20ID\x20is:','replace','/api/v2','Zendesk\x20account\x20type\x20not\x20recognized','[OUTBOUND]\x20Error\x20running\x20Zendesk\x20integration','unmanaged','lastevent','toUpperCase','\x20Error\x20running\x20Zendesk\x20integration','lodash','request-promise','md5','util','ioredis','../../../../config/environment','../../../../config/logger','zendesk','redis','defaults','localhost','socket.io-emitter','emit','application/json','info','format','POST','Tags','name','Subjects','getString','Descriptions','then','Ticket\x20created!','ticket','validateEmail','Getting\x20agent\x20with\x20email','%s/search.json','count','find','results','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/users/me.json','Admin\x20account\x20selected.','user','remoteUri','Searching\x20enduser\x20with\x20phone','length','first','end-user','Caller\x20-\x20%s','Enduser\x20created.','%s:%s','password','authType','token','Basic\x20%s','base64','debug','stringify'];(function(_0x5a79ba,_0x380948){var _0x572dbf=function(_0x265419){while(--_0x265419){_0x5a79ba['push'](_0x5a79ba['shift']());}};_0x572dbf(++_0x380948);}(_0xea0a,0x10f));var _0xaea0=function(_0x13c4a6,_0x4041d9){_0x13c4a6=_0x13c4a6-0x0;var _0x5b1eeb=_0xea0a[_0x13c4a6];return _0x5b1eeb;};'use strict';var _=require(_0xaea0('0x0'));var rp=require(_0xaea0('0x1'));var md5=require(_0xaea0('0x2'));var util=require(_0xaea0('0x3'));var Redis=require(_0xaea0('0x4'));var intUtil=require('./util');var config=require(_0xaea0('0x5'));var logger=require(_0xaea0('0x6'))(_0xaea0('0x7'));config[_0xaea0('0x8')]=_[_0xaea0('0x9')](config[_0xaea0('0x8')],{'host':_0xaea0('0xa'),'port':0x18eb});var io=require(_0xaea0('0xb'))(new Redis(config[_0xaea0('0x8')]));function emit(_0x1faa43,_0x12ac3e,_0x2265ed){io['to'](_0x1faa43)[_0xaea0('0xc')](_0x12ac3e,_0x2265ed);}var headers={'Content-Type':_0xaea0('0xd'),'Accept':'application/json'};function getTicket(_0x2cefd1,_0xab2519,_0x1ba4ad,_0x22b2cb,_0x48ba70){logger[_0xaea0('0xe')]('Creating\x20new\x20ticket...');return request({'uri':util[_0xaea0('0xf')]('%s/tickets.json',_0x2cefd1['remoteUri']),'method':_0xaea0('0x10'),'body':{'ticket':_['merge']({'requester_id':_0x1ba4ad['id'],'submitter_id':_0xab2519?_0xab2519['id']:undefined,'assignee_id':_0xab2519?_0xab2519['id']:undefined,'tags':getTags(_0x22b2cb[_0xaea0('0x11')],_0xaea0('0x12')),'subject':intUtil['getString'](_0x22b2cb[_0xaea0('0x13')],_0x48ba70,'\x20'),'description':intUtil[_0xaea0('0x14')](_0x22b2cb[_0xaea0('0x15')],_0x48ba70,'\x0a'),'comment':{'public':![],'body':intUtil['getString'](_0x22b2cb[_0xaea0('0x15')],_0x48ba70,'\x0a')}},getCustomFields(_0x22b2cb['Fields'],_0x48ba70))}})[_0xaea0('0x16')](function(_0x191702){logger[_0xaea0('0xe')](_0xaea0('0x17'));return _0x191702[_0xaea0('0x18')];});}function getUser(_0x2c3873,_0x142d52){if(intUtil[_0xaea0('0x19')](_0x142d52)){logger[_0xaea0('0xe')](_0xaea0('0x1a'),_0x142d52);return request({'uri':util[_0xaea0('0xf')](_0xaea0('0x1b'),_0x2c3873['remoteUri']),'qs':{'query':util[_0xaea0('0xf')]('type:user\x20role:agent\x20email:%s',_0x142d52)}})[_0xaea0('0x16')](function(_0x599218){if(_0x599218[_0xaea0('0x1c')]){logger[_0xaea0('0xe')]('Agent\x20found!');return _[_0xaea0('0x1d')](_0x599218[_0xaea0('0x1e')],{'email':_0x142d52,'role':'agent'});}else{logger[_0xaea0('0xe')](_0xaea0('0x1f'));return request({'uri':util[_0xaea0('0xf')](_0xaea0('0x20'),_0x2c3873['remoteUri'])})[_0xaea0('0x16')](function(_0x6091c7){logger[_0xaea0('0xe')](_0xaea0('0x21'));return _0x6091c7[_0xaea0('0x22')];});}});}else{logger[_0xaea0('0xe')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0xaea0('0xf')](_0xaea0('0x20'),_0x2c3873[_0xaea0('0x23')])})['then'](function(_0x526323){logger['info'](_0xaea0('0x21'));return _0x526323[_0xaea0('0x22')];});}}function getEndUser(_0x3ba09b,_0x5634ac,_0x40d1a2){logger[_0xaea0('0xe')](_0xaea0('0x24'),_0x40d1a2);return request({'uri':util['format'](_0xaea0('0x1b'),_0x3ba09b[_0xaea0('0x23')]),'qs':{'query':util['format']('type:user\x20role:end-user\x20phone:%s',_0x40d1a2)}})[_0xaea0('0x16')](function(_0x1c428d){var _0x699619;if(_0x1c428d['results'][_0xaea0('0x25')]){_0x1c428d[_0xaea0('0x1e')]=_['filter'](_0x1c428d['results'],{'suspended':![],'role':'end-user'});if(_0x1c428d[_0xaea0('0x1e')][_0xaea0('0x25')]){_0x699619=_[_0xaea0('0x26')](_0x1c428d[_0xaea0('0x1e')]);}}if(_0x699619){logger['info']('Enduser\x20found!');return _0x699619;}else{logger[_0xaea0('0xe')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0xaea0('0xf')]('%s/users.json',_0x3ba09b[_0xaea0('0x23')]),'method':_0xaea0('0x10'),'body':{'user':{'role':_0xaea0('0x27'),'name':util[_0xaea0('0xf')](_0xaea0('0x28'),_0x5634ac||_0x40d1a2),'phone':_0x40d1a2}}})[_0xaea0('0x16')](function(_0x35365c){logger[_0xaea0('0xe')](_0xaea0('0x29'));return _0x35365c[_0xaea0('0x22')];});}});}function getAuth(_0x52cd03){var _0x541509;if(_0x52cd03['authType']==='password'){_0x541509=util[_0xaea0('0xf')](_0xaea0('0x2a'),_0x52cd03['username'],_0x52cd03[_0xaea0('0x2b')]);}else if(_0x52cd03[_0xaea0('0x2c')]===_0xaea0('0x2d')){_0x541509=util['format']('%s/token:%s',_0x52cd03['username'],_0x52cd03[_0xaea0('0x2d')]);}return util[_0xaea0('0xf')](_0xaea0('0x2e'),new Buffer(_0x541509)['toString'](_0xaea0('0x2f')));}function request(_0x18e18f){logger[_0xaea0('0x30')]('[HTTP]',JSON[_0xaea0('0x31')](_0x18e18f));return rp(_[_0xaea0('0x9')](_0x18e18f,{'method':_0xaea0('0x32'),'headers':headers,'json':!![]}));}function getTags(_0x1081c4,_0x19f2c3){var _0x44a496=[];if(_0x1081c4&&_0x1081c4[_0xaea0('0x25')]>0x0){_0x44a496=_[_0xaea0('0x33')](_0x1081c4,_0x19f2c3);}return _0x44a496;}function getCustomFields(_0x5e4566,_0x1a07e9){var _0x447934=[];var _0x569cce={'custom_fields':[]};if(_0x5e4566[_0xaea0('0x25')]>0x0){_[_0xaea0('0x34')](_0x5e4566,function(_0x15f9e1){if(_0x15f9e1['type']===_0xaea0('0x35')&&_0x15f9e1[_0xaea0('0x36')]&&!_0x15f9e1['customField']){_0x569cce[_0x15f9e1['nameField'][_0xaea0('0x37')]()]=_0x15f9e1[_0xaea0('0x38')][_0xaea0('0x39')]();}else if(_0x15f9e1['type']===_0xaea0('0x35')&&_0x15f9e1[_0xaea0('0x3a')]&&_0x15f9e1[_0xaea0('0x3b')]){_0x569cce['custom_fields']['push']({'id':_0x15f9e1[_0xaea0('0x3a')],'value':_0x15f9e1[_0xaea0('0x38')][_0xaea0('0x39')]()});}else if(_0x15f9e1['type']===_0xaea0('0x3c')&&_0x15f9e1[_0xaea0('0x3d')]&&_0x15f9e1['idField']&&_0x15f9e1[_0xaea0('0x3b')]){_0x1a07e9[_0x15f9e1[_0xaea0('0x3d')]]&&_0x569cce[_0xaea0('0x3e')]['push']({'id':_0x15f9e1[_0xaea0('0x3a')],'value':_0x1a07e9[_0x15f9e1['variableName']][_0xaea0('0x39')]()});}else if(_0x15f9e1[_0xaea0('0x3f')]===_0xaea0('0x40')&&_0x15f9e1[_0xaea0('0x41')]&&_0x15f9e1[_0xaea0('0x41')][_0xaea0('0x12')]&&_0x15f9e1['idField']&&_0x15f9e1[_0xaea0('0x3b')]){_0x1a07e9[_0x15f9e1[_0xaea0('0x41')][_0xaea0('0x12')][_0xaea0('0x37')]()]&&_0x569cce[_0xaea0('0x3e')][_0xaea0('0x42')]({'id':_0x15f9e1[_0xaea0('0x3a')],'value':_0x1a07e9[_0x15f9e1[_0xaea0('0x41')][_0xaea0('0x12')][_0xaea0('0x37')]()][_0xaea0('0x39')]()});}});}return _0x569cce;}exports[_0xaea0('0x43')]=function(_0x16f2b9,_0x525923,_0x2ec96d,_0x3b80c9,_0x331166,_0x38d945){var _0x2e5734,_0x1de274;_0x38d945[_0xaea0('0x23')]=intUtil[_0xaea0('0x44')](_0x38d945['remoteUri']);_0x38d945['serverUrl']=intUtil['stripTrailingSlash'](_0x38d945['serverUrl']);if(_0x331166&&_0x331166[_0xaea0('0x45')]){logger['info'](_0xaea0('0x46'),_0xaea0('0x47'));_0x525923['recordingURL']=util[_0xaea0('0xf')](_0xaea0('0x48'),_0x38d945[_0xaea0('0x49')],_0x525923[_0xaea0('0x4a')],md5(_0x525923[_0xaea0('0x4a')]));}else{_0x525923[_0xaea0('0x4b')]='';}headers[_0xaea0('0x4c')]=getAuth(_0x38d945);return getUser(_0x38d945,_0x3b80c9[_0xaea0('0x4d')])[_0xaea0('0x16')](function(_0xe51cd7){_0x2e5734=_0xe51cd7;logger[_0xaea0('0xe')](_0xaea0('0x4e'),_0x2e5734['id']);return getEndUser(_0x38d945,_0x525923[_0xaea0('0x4f')],_0x525923[_0xaea0('0x50')]);})[_0xaea0('0x16')](function(_0x2dacc2){_0x1de274=_0x2dacc2;logger[_0xaea0('0xe')](_0xaea0('0x51'),_0x1de274['id']);return getTicket(_0x38d945,_0x2e5734,_0x1de274,_0x2ec96d,_0x525923);})['then'](function(_0x43307b){if(_0x43307b){logger['info']('The\x20Ticket\x20ID\x20is:',_0x43307b['id']);switch(_0x38d945[_0xaea0('0x3f')]){case _0xaea0('0x52'):logger[_0xaea0('0xe')](_0xaea0('0x46'),_0xaea0('0x53'));return request({'uri':util[_0xaea0('0xf')](_0xaea0('0x54'),_0x38d945[_0xaea0('0x23')],_0x2e5734['id'],_0x43307b['id']),'method':_0xaea0('0x10')});case _0xaea0('0x55'):logger[_0xaea0('0xe')]('[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xaea0('0xf')](_0xaea0('0x56'),_0x3b80c9['name']),_0xaea0('0x57'),{'uri':util[_0xaea0('0xf')](_0xaea0('0x58'),_0x38d945[_0xaea0('0x23')]['replace']('/api/v2',''),_0x43307b['id'])});break;default:logger[_0xaea0('0x59')](_0xaea0('0x46'),'Zendesk\x20account\x20type\x20not\x20recognized');}}})[_0xaea0('0x5a')](function(_0x3bc5d1){logger['error'](_0xaea0('0x5b'),util[_0xaea0('0x5c')](_0x3bc5d1,{'showHidden':!![],'depth':null}));});};exports['outbound']=function(_0x1889fc,_0x44b7bb,_0x2e05e4,_0x3ea69c,_0x500fe3,_0x5a221f,_0x6473cb){var _0x551dcc,_0x220004;_0x5a221f[_0xaea0('0x23')]=intUtil['stripTrailingSlash'](_0x5a221f[_0xaea0('0x23')]);_0x5a221f[_0xaea0('0x49')]=intUtil[_0xaea0('0x44')](_0x5a221f[_0xaea0('0x49')]);if(_0x6473cb&&_0x6473cb['recordingFormat']&&_0x6473cb[_0xaea0('0x5d')]!==_0xaea0('0x5e')){logger[_0xaea0('0xe')](_0xaea0('0x5f'),_0xaea0('0x47'));_0x44b7bb['recordingURL']=util[_0xaea0('0xf')](_0xaea0('0x48'),_0x5a221f[_0xaea0('0x49')],_0x44b7bb[_0xaea0('0x4a')],md5(_0x44b7bb[_0xaea0('0x4a')]));}headers[_0xaea0('0x4c')]=getAuth(_0x5a221f);return getUser(_0x5a221f,_0x3ea69c[_0xaea0('0x4d')])[_0xaea0('0x16')](function(_0x350351){_0x551dcc=_0x350351;logger['info'](_0xaea0('0x4e'),_0x551dcc['id']);return getEndUser(_0x5a221f,_0x44b7bb[_0xaea0('0x60')],_0x44b7bb[_0xaea0('0x61')]);})[_0xaea0('0x16')](function(_0x48a705){_0x220004=_0x48a705;logger[_0xaea0('0xe')](_0xaea0('0x51'),_0x220004['id']);return getTicket(_0x5a221f,_0x551dcc,_0x220004,_0x2e05e4,_0x44b7bb);})[_0xaea0('0x16')](function(_0x3b1a2a){if(_0x3b1a2a){logger[_0xaea0('0xe')](_0xaea0('0x62'),_0x3b1a2a['id']);switch(_0x5a221f[_0xaea0('0x3f')]){case _0xaea0('0x52'):logger[_0xaea0('0xe')]('[OUTBOUND]',_0xaea0('0x53'));return request({'uri':util[_0xaea0('0xf')]('%s/channels/voice/agents/%d/tickets/%d/display.json',_0x5a221f[_0xaea0('0x23')],_0x551dcc['id'],_0x3b1a2a['id']),'method':'POST'});case _0xaea0('0x55'):logger[_0xaea0('0xe')](_0xaea0('0x5f'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xaea0('0xf')]('user:%s',_0x3ea69c['name']),_0xaea0('0x57'),{'uri':util['format'](_0xaea0('0x58'),_0x5a221f[_0xaea0('0x23')][_0xaea0('0x63')](_0xaea0('0x64'),''),_0x3b1a2a['id'])});break;default:logger['error']('[OUTBOUND]',_0xaea0('0x65'));}}})['catch'](function(_0x5e89f2){logger[_0xaea0('0x59')](_0xaea0('0x66'),util[_0xaea0('0x5c')](_0x5e89f2,{'showHidden':!![],'depth':null}));});};exports[_0xaea0('0x67')]=function(_0x20b323,_0x44d5d4,_0x506496,_0x164bd8,_0x353190,_0x1b705e){var _0x580fa7,_0x526b34;_0x1b705e[_0xaea0('0x23')]=intUtil[_0xaea0('0x44')](_0x1b705e[_0xaea0('0x23')]);_0x1b705e['serverUrl']=intUtil[_0xaea0('0x44')](_0x1b705e[_0xaea0('0x49')]);if(_0x353190&&_0x353190[_0xaea0('0x45')]){logger[_0xaea0('0xe')]('['+_0x44d5d4[_0xaea0('0x68')]['toUpperCase']()+']',_0xaea0('0x47'));_0x44d5d4[_0xaea0('0x4b')]=util[_0xaea0('0xf')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x1b705e[_0xaea0('0x49')],_0x44d5d4['uniqueid'],md5(_0x44d5d4[_0xaea0('0x4a')]));}else{_0x44d5d4[_0xaea0('0x4b')]='';}headers['Authorization']=getAuth(_0x1b705e);return getUser(_0x1b705e)[_0xaea0('0x16')](function(_0x268e38){_0x580fa7=_0x268e38;logger[_0xaea0('0xe')](_0xaea0('0x4e'),_0x580fa7['id']);return getEndUser(_0x1b705e,_0x44d5d4[_0xaea0('0x4f')],_0x44d5d4[_0xaea0('0x50')]);})[_0xaea0('0x16')](function(_0x826691){_0x526b34=_0x826691;logger['info'](_0xaea0('0x51'),_0x526b34['id']);return getTicket(_0x1b705e,_0x580fa7,_0x526b34,_0x506496,_0x44d5d4);})[_0xaea0('0x16')](function(_0xc94952){if(_0xc94952){logger['info']('The\x20Ticket\x20ID\x20is:',_0xc94952['id']);}})[_0xaea0('0x5a')](function(_0x4474ba){logger[_0xaea0('0x59')]('['+_0x44d5d4[_0xaea0('0x68')][_0xaea0('0x69')]()+']'+_0xaea0('0x6a'),util[_0xaea0('0x5c')](_0x4474ba,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0xfcb7=['%s/tickets.json','remoteUri','POST','merge','Tags','name','getString','Subjects','Descriptions','Fields','then','info','Ticket\x20created!','ticket','validateEmail','Getting\x20agent\x20with\x20email','%s/search.json','type:user\x20role:agent\x20email:%s','count','Agent\x20found!','agent','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/users/me.json','Admin\x20account\x20selected.','user','Searching\x20enduser\x20with\x20phone','type:user\x20role:end-user\x20phone:%s','length','results','first','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','%s/users.json','end-user','Caller\x20-\x20%s','Enduser\x20created.','password','username','authType','token','%s/token:%s','Basic\x20%s','toString','base64','debug','[HTTP]','stringify','GET','map','forEach','string','picklist','type','nameField','toLowerCase','content','includes','idField','custom_fields','push','variable','variableName','customField','customVariable','Variable','serverUrl','monitor_format','[QUEUE]','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','email','The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','integrationTab','Displaying\x20ticket\x20to\x20agent...','%s/channels/voice/agents/%d/tickets/%d/display.json','newTab','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','error','catch','[QUEUE]\x20Error\x20running\x20Zendesk\x20integration','inspect','outbound','stripTrailingSlash','recordingFormat','none','Recording\x20is\x20enabled!','[OUTBOUND]','%s/agent/tickets/%s','replace','/api/v2','Zendesk\x20account\x20type\x20not\x20recognized','[OUTBOUND]\x20Error\x20running\x20Zendesk\x20integration','lastevent','calleridname','\x20Error\x20running\x20Zendesk\x20integration','request-promise','md5','util','ioredis','./util','../../../../config/logger','zendesk','redis','defaults','localhost','socket.io-emitter','application/json','Creating\x20new\x20ticket...','format'];(function(_0x21b016,_0xc19ac0){var _0x19f268=function(_0x1c60de){while(--_0x1c60de){_0x21b016['push'](_0x21b016['shift']());}};_0x19f268(++_0xc19ac0);}(_0xfcb7,0x14b));var _0x7fcb=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xfcb7[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var rp=require(_0x7fcb('0x0'));var md5=require(_0x7fcb('0x1'));var util=require(_0x7fcb('0x2'));var Redis=require(_0x7fcb('0x3'));var intUtil=require(_0x7fcb('0x4'));var config=require('../../../../config/environment');var logger=require(_0x7fcb('0x5'))(_0x7fcb('0x6'));config[_0x7fcb('0x7')]=_[_0x7fcb('0x8')](config[_0x7fcb('0x7')],{'host':_0x7fcb('0x9'),'port':0x18eb});var io=require(_0x7fcb('0xa'))(new Redis(config[_0x7fcb('0x7')]));function emit(_0x183480,_0x2440a5,_0x1d5dd9){io['to'](_0x183480)['emit'](_0x2440a5,_0x1d5dd9);}var headers={'Content-Type':'application/json','Accept':_0x7fcb('0xb')};function getTicket(_0x4596a6,_0x339f2d,_0x416972,_0x5d768e,_0x1cdbac){logger['info'](_0x7fcb('0xc'));return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0xe'),_0x4596a6[_0x7fcb('0xf')]),'method':_0x7fcb('0x10'),'body':{'ticket':_[_0x7fcb('0x11')]({'requester_id':_0x416972['id'],'submitter_id':_0x339f2d?_0x339f2d['id']:undefined,'assignee_id':_0x339f2d?_0x339f2d['id']:undefined,'tags':getTags(_0x5d768e[_0x7fcb('0x12')],_0x7fcb('0x13')),'subject':intUtil[_0x7fcb('0x14')](_0x5d768e[_0x7fcb('0x15')],_0x1cdbac,'\x20'),'description':intUtil[_0x7fcb('0x14')](_0x5d768e[_0x7fcb('0x16')],_0x1cdbac,'\x0a'),'comment':{'public':![],'body':intUtil['getString'](_0x5d768e[_0x7fcb('0x16')],_0x1cdbac,'\x0a')}},getCustomFields(_0x5d768e[_0x7fcb('0x17')],_0x1cdbac))}})[_0x7fcb('0x18')](function(_0x4e4ee4){logger[_0x7fcb('0x19')](_0x7fcb('0x1a'));return _0x4e4ee4[_0x7fcb('0x1b')];});}function getUser(_0x138048,_0xad4b93){if(intUtil[_0x7fcb('0x1c')](_0xad4b93)){logger['info'](_0x7fcb('0x1d'),_0xad4b93);return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0x1e'),_0x138048[_0x7fcb('0xf')]),'qs':{'query':util[_0x7fcb('0xd')](_0x7fcb('0x1f'),_0xad4b93)}})[_0x7fcb('0x18')](function(_0x35e030){if(_0x35e030[_0x7fcb('0x20')]){logger['info'](_0x7fcb('0x21'));return _['find'](_0x35e030['results'],{'email':_0xad4b93,'role':_0x7fcb('0x22')});}else{logger[_0x7fcb('0x19')](_0x7fcb('0x23'));return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0x24'),_0x138048[_0x7fcb('0xf')])})[_0x7fcb('0x18')](function(_0x4cc5b0){logger[_0x7fcb('0x19')](_0x7fcb('0x25'));return _0x4cc5b0[_0x7fcb('0x26')];});}});}else{logger[_0x7fcb('0x19')](_0x7fcb('0x23'));return request({'uri':util[_0x7fcb('0xd')]('%s/users/me.json',_0x138048[_0x7fcb('0xf')])})['then'](function(_0x3efd7c){logger[_0x7fcb('0x19')](_0x7fcb('0x25'));return _0x3efd7c[_0x7fcb('0x26')];});}}function getEndUser(_0x41808c,_0x3d0527,_0x2ab0bb){logger['info'](_0x7fcb('0x27'),_0x2ab0bb);return request({'uri':util['format'](_0x7fcb('0x1e'),_0x41808c[_0x7fcb('0xf')]),'qs':{'query':util[_0x7fcb('0xd')](_0x7fcb('0x28'),_0x2ab0bb)}})[_0x7fcb('0x18')](function(_0x2fd90d){var _0x3d4657;if(_0x2fd90d['results'][_0x7fcb('0x29')]){_0x2fd90d[_0x7fcb('0x2a')]=_['filter'](_0x2fd90d['results'],{'suspended':![],'role':'end-user'});if(_0x2fd90d['results'][_0x7fcb('0x29')]){_0x3d4657=_[_0x7fcb('0x2b')](_0x2fd90d['results']);}}if(_0x3d4657){logger[_0x7fcb('0x19')](_0x7fcb('0x2c'));return _0x3d4657;}else{logger['info'](_0x7fcb('0x2d'));return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0x2e'),_0x41808c[_0x7fcb('0xf')]),'method':_0x7fcb('0x10'),'body':{'user':{'role':_0x7fcb('0x2f'),'name':util[_0x7fcb('0xd')](_0x7fcb('0x30'),_0x3d0527||_0x2ab0bb),'phone':_0x2ab0bb}}})['then'](function(_0x4c849f){logger[_0x7fcb('0x19')](_0x7fcb('0x31'));return _0x4c849f['user'];});}});}function getAuth(_0x185d80){var _0x39941b;if(_0x185d80['authType']===_0x7fcb('0x32')){_0x39941b=util[_0x7fcb('0xd')]('%s:%s',_0x185d80[_0x7fcb('0x33')],_0x185d80['password']);}else if(_0x185d80[_0x7fcb('0x34')]===_0x7fcb('0x35')){_0x39941b=util[_0x7fcb('0xd')](_0x7fcb('0x36'),_0x185d80['username'],_0x185d80[_0x7fcb('0x35')]);}return util[_0x7fcb('0xd')](_0x7fcb('0x37'),new Buffer(_0x39941b)[_0x7fcb('0x38')](_0x7fcb('0x39')));}function request(_0x192258){logger[_0x7fcb('0x3a')](_0x7fcb('0x3b'),JSON[_0x7fcb('0x3c')](_0x192258));return rp(_[_0x7fcb('0x8')](_0x192258,{'method':_0x7fcb('0x3d'),'headers':headers,'json':!![]}));}function getTags(_0x99e419,_0x2f3736){var _0x4c1e1b=[];if(_0x99e419&&_0x99e419[_0x7fcb('0x29')]>0x0){_0x4c1e1b=_[_0x7fcb('0x3e')](_0x99e419,_0x2f3736);}return _0x4c1e1b;}function getCustomFields(_0x116295,_0x2d141c){var _0x19e6e3=[];var _0x2f9743={'custom_fields':[]};if(_0x116295[_0x7fcb('0x29')]>0x0){_[_0x7fcb('0x3f')](_0x116295,function(_0x30bf07){if(_['includes']([_0x7fcb('0x40'),_0x7fcb('0x41')],_0x30bf07[_0x7fcb('0x42')])&&_0x30bf07[_0x7fcb('0x43')]&&!_0x30bf07['customField']){_0x2f9743[_0x30bf07[_0x7fcb('0x43')][_0x7fcb('0x44')]()]=_0x30bf07[_0x7fcb('0x45')][_0x7fcb('0x38')]();}else if(_[_0x7fcb('0x46')]([_0x7fcb('0x40'),'picklist'],_0x30bf07['type'])&&_0x30bf07[_0x7fcb('0x47')]&&_0x30bf07['customField']){_0x2f9743[_0x7fcb('0x48')][_0x7fcb('0x49')]({'id':_0x30bf07['idField'],'value':_0x30bf07[_0x7fcb('0x45')]['toString']()});}else if(_0x30bf07[_0x7fcb('0x42')]===_0x7fcb('0x4a')&&_0x30bf07[_0x7fcb('0x4b')]&&_0x30bf07[_0x7fcb('0x47')]&&_0x30bf07[_0x7fcb('0x4c')]){_0x2d141c[_0x30bf07[_0x7fcb('0x4b')]]&&_0x2f9743[_0x7fcb('0x48')]['push']({'id':_0x30bf07['idField'],'value':_0x2d141c[_0x30bf07[_0x7fcb('0x4b')]]['toString']()});}else if(_0x30bf07['type']===_0x7fcb('0x4d')&&_0x30bf07[_0x7fcb('0x4e')]&&_0x30bf07[_0x7fcb('0x4e')][_0x7fcb('0x13')]&&_0x30bf07[_0x7fcb('0x47')]&&_0x30bf07[_0x7fcb('0x4c')]){_0x2d141c[_0x30bf07[_0x7fcb('0x4e')][_0x7fcb('0x13')]['toLowerCase']()]&&_0x2f9743['custom_fields'][_0x7fcb('0x49')]({'id':_0x30bf07[_0x7fcb('0x47')],'value':_0x2d141c[_0x30bf07[_0x7fcb('0x4e')][_0x7fcb('0x13')][_0x7fcb('0x44')]()][_0x7fcb('0x38')]()});}});}return _0x2f9743;}exports['queue']=function(_0x46af7c,_0x2560bb,_0x5192e0,_0x32834f,_0x499796,_0x52b691){var _0x34d55e,_0x552f53;_0x52b691['remoteUri']=intUtil['stripTrailingSlash'](_0x52b691[_0x7fcb('0xf')]);_0x52b691['serverUrl']=intUtil['stripTrailingSlash'](_0x52b691[_0x7fcb('0x4f')]);if(_0x499796&&_0x499796[_0x7fcb('0x50')]){logger[_0x7fcb('0x19')](_0x7fcb('0x51'),'Recording\x20is\x20enabled!');_0x2560bb[_0x7fcb('0x52')]=util[_0x7fcb('0xd')](_0x7fcb('0x53'),_0x52b691['serverUrl'],_0x2560bb[_0x7fcb('0x54')],md5(_0x2560bb[_0x7fcb('0x54')]));}else{_0x2560bb['recordingURL']='';}headers[_0x7fcb('0x55')]=getAuth(_0x52b691);return getUser(_0x52b691,_0x32834f[_0x7fcb('0x56')])[_0x7fcb('0x18')](function(_0x35dc9e){_0x34d55e=_0x35dc9e;logger[_0x7fcb('0x19')](_0x7fcb('0x57'),_0x34d55e['id']);return getEndUser(_0x52b691,_0x2560bb['calleridname'],_0x2560bb[_0x7fcb('0x58')]);})[_0x7fcb('0x18')](function(_0x27eaf8){_0x552f53=_0x27eaf8;logger[_0x7fcb('0x19')](_0x7fcb('0x59'),_0x552f53['id']);return getTicket(_0x52b691,_0x34d55e,_0x552f53,_0x5192e0,_0x2560bb);})['then'](function(_0x516eb0){if(_0x516eb0){logger[_0x7fcb('0x19')](_0x7fcb('0x5a'),_0x516eb0['id']);switch(_0x52b691['type']){case _0x7fcb('0x5b'):logger[_0x7fcb('0x19')](_0x7fcb('0x51'),_0x7fcb('0x5c'));return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0x5d'),_0x52b691[_0x7fcb('0xf')],_0x34d55e['id'],_0x516eb0['id']),'method':_0x7fcb('0x10')});case _0x7fcb('0x5e'):logger[_0x7fcb('0x19')](_0x7fcb('0x51'),_0x7fcb('0x5f'));emit(util[_0x7fcb('0xd')](_0x7fcb('0x60'),_0x32834f['name']),'trigger:browser:url',{'uri':util[_0x7fcb('0xd')]('%s/agent/tickets/%s',_0x52b691[_0x7fcb('0xf')]['replace']('/api/v2',''),_0x516eb0['id'])});break;default:logger[_0x7fcb('0x61')](_0x7fcb('0x51'),'Zendesk\x20account\x20type\x20not\x20recognized');}}})[_0x7fcb('0x62')](function(_0x4ba0a4){logger[_0x7fcb('0x61')](_0x7fcb('0x63'),util[_0x7fcb('0x64')](_0x4ba0a4,{'showHidden':!![],'depth':null}));});};exports[_0x7fcb('0x65')]=function(_0x2e9001,_0x2d0ac8,_0x33f2c7,_0x122827,_0x28997f,_0x19ac29,_0x3536e2){var _0x4d9af7,_0x931c86;_0x19ac29['remoteUri']=intUtil[_0x7fcb('0x66')](_0x19ac29[_0x7fcb('0xf')]);_0x19ac29[_0x7fcb('0x4f')]=intUtil[_0x7fcb('0x66')](_0x19ac29[_0x7fcb('0x4f')]);if(_0x3536e2&&_0x3536e2[_0x7fcb('0x67')]&&_0x3536e2[_0x7fcb('0x67')]!==_0x7fcb('0x68')){logger[_0x7fcb('0x19')]('[OUTBOUND]',_0x7fcb('0x69'));_0x2d0ac8[_0x7fcb('0x52')]=util[_0x7fcb('0xd')](_0x7fcb('0x53'),_0x19ac29['serverUrl'],_0x2d0ac8[_0x7fcb('0x54')],md5(_0x2d0ac8[_0x7fcb('0x54')]));}headers[_0x7fcb('0x55')]=getAuth(_0x19ac29);return getUser(_0x19ac29,_0x122827['email'])[_0x7fcb('0x18')](function(_0xf025f7){_0x4d9af7=_0xf025f7;logger['info']('The\x20User\x20ID\x20is:',_0x4d9af7['id']);return getEndUser(_0x19ac29,_0x2d0ac8['destcalleridname'],_0x2d0ac8['destcalleridnum']);})[_0x7fcb('0x18')](function(_0x1b8975){_0x931c86=_0x1b8975;logger['info'](_0x7fcb('0x59'),_0x931c86['id']);return getTicket(_0x19ac29,_0x4d9af7,_0x931c86,_0x33f2c7,_0x2d0ac8);})[_0x7fcb('0x18')](function(_0x19b558){if(_0x19b558){logger[_0x7fcb('0x19')](_0x7fcb('0x5a'),_0x19b558['id']);switch(_0x19ac29[_0x7fcb('0x42')]){case _0x7fcb('0x5b'):logger[_0x7fcb('0x19')](_0x7fcb('0x6a'),_0x7fcb('0x5c'));return request({'uri':util[_0x7fcb('0xd')](_0x7fcb('0x5d'),_0x19ac29[_0x7fcb('0xf')],_0x4d9af7['id'],_0x19b558['id']),'method':_0x7fcb('0x10')});case _0x7fcb('0x5e'):logger[_0x7fcb('0x19')]('[OUTBOUND]',_0x7fcb('0x5f'));emit(util['format'](_0x7fcb('0x60'),_0x122827['name']),'trigger:browser:url',{'uri':util[_0x7fcb('0xd')](_0x7fcb('0x6b'),_0x19ac29[_0x7fcb('0xf')][_0x7fcb('0x6c')](_0x7fcb('0x6d'),''),_0x19b558['id'])});break;default:logger['error']('[OUTBOUND]',_0x7fcb('0x6e'));}}})['catch'](function(_0x3ef45c){logger[_0x7fcb('0x61')](_0x7fcb('0x6f'),util[_0x7fcb('0x64')](_0x3ef45c,{'showHidden':!![],'depth':null}));});};exports['unmanaged']=function(_0x4fb6e0,_0x274564,_0x479fef,_0x6ccdc5,_0x46a7a8,_0x4aa961){var _0x442912,_0x45a138;_0x4aa961[_0x7fcb('0xf')]=intUtil[_0x7fcb('0x66')](_0x4aa961[_0x7fcb('0xf')]);_0x4aa961[_0x7fcb('0x4f')]=intUtil['stripTrailingSlash'](_0x4aa961[_0x7fcb('0x4f')]);if(_0x46a7a8&&_0x46a7a8['monitor_format']){logger[_0x7fcb('0x19')]('['+_0x274564[_0x7fcb('0x70')]['toUpperCase']()+']',_0x7fcb('0x69'));_0x274564[_0x7fcb('0x52')]=util[_0x7fcb('0xd')](_0x7fcb('0x53'),_0x4aa961[_0x7fcb('0x4f')],_0x274564[_0x7fcb('0x54')],md5(_0x274564[_0x7fcb('0x54')]));}else{_0x274564[_0x7fcb('0x52')]='';}headers['Authorization']=getAuth(_0x4aa961);return getUser(_0x4aa961)[_0x7fcb('0x18')](function(_0x3697d3){_0x442912=_0x3697d3;logger[_0x7fcb('0x19')](_0x7fcb('0x57'),_0x442912['id']);return getEndUser(_0x4aa961,_0x274564[_0x7fcb('0x71')],_0x274564['calleridnum']);})[_0x7fcb('0x18')](function(_0x3f2825){_0x45a138=_0x3f2825;logger[_0x7fcb('0x19')](_0x7fcb('0x59'),_0x45a138['id']);return getTicket(_0x4aa961,_0x442912,_0x45a138,_0x479fef,_0x274564);})['then'](function(_0x37ed04){if(_0x37ed04){logger['info'](_0x7fcb('0x5a'),_0x37ed04['id']);}})[_0x7fcb('0x62')](function(_0x4321e1){logger['error']('['+_0x274564[_0x7fcb('0x70')]['toUpperCase']()+']'+_0x7fcb('0x72'),util[_0x7fcb('0x64')](_0x4321e1,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file