Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 2c68ba1..7fb331b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x96ab=['lodash','request-promise','ioredis','./util','../../../../config/logger','redis','defaults','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','format','Caller\x20-\x20%s','calleridname','getString','Subjects','Descriptions','<br>','Tags','name','Fields','custom_fields','mapValues','keyBy','value','%s/api/v2/tickets','remoteUri','POST','then','validateEmail','%s/api/v2/agents','length','Agent\x20found!','find','contact','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','%s/api/v2/contacts','Basic\x20%s','apiKey','toString','[HTTP]','stringify','GET','forEach','includes','type','nameField','content','string','idField','customField','push','variable','variableName','customVariable','Variable','toLowerCase','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','email','Ticket\x20created!','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','catch','outbound','recordingFormat','[OUTBOUND]','destcalleridname','destcalleridnum','error','unmanaged','lastevent','toUpperCase','The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:'];(function(_0x1cf814,_0x57c038){var _0x540f81=function(_0x79cb86){while(--_0x79cb86){_0x1cf814['push'](_0x1cf814['shift']());}};_0x540f81(++_0x57c038);}(_0x96ab,0xb2));var _0xb96a=function(_0x5098ef,_0x3f0b5d){_0x5098ef=_0x5098ef-0x0;var _0x395940=_0x96ab[_0x5098ef];return _0x395940;};'use strict';var _=require(_0xb96a('0x0'));var rp=require(_0xb96a('0x1'));var md5=require('md5');var util=require('util');var Redis=require(_0xb96a('0x2'));var intUtil=require(_0xb96a('0x3'));var config=require('../../../../config/environment');var logger=require(_0xb96a('0x4'))('freshdesk');config[_0xb96a('0x5')]=_[_0xb96a('0x6')](config[_0xb96a('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0xb96a('0x7'))(new Redis(config[_0xb96a('0x5')]));var headers={'Content-Type':_0xb96a('0x8'),'Accept':_0xb96a('0x8')};function emit(_0x55a5c2,_0xbbc6d1,_0x2fba1b){io['to'](_0x55a5c2)[_0xb96a('0x9')](_0xbbc6d1,_0x2fba1b);}function getTicket(_0x47e5e8,_0x2b047d,_0x48f438,_0xa53e27,_0x3f72b2){logger[_0xb96a('0xa')](_0xb96a('0xb'));var _0x5ca01a=_['merge']({'responder_id':_0x2b047d['id'],'requester_id':_0x48f438['id'],'name':util[_0xb96a('0xc')](_0xb96a('0xd'),_0x3f72b2[_0xb96a('0xe')]),'phone':_0x3f72b2['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xb96a('0xf')](_0xa53e27[_0xb96a('0x10')],_0x3f72b2,'\x20'),'description':intUtil[_0xb96a('0xf')](_0xa53e27[_0xb96a('0x11')],_0x3f72b2,_0xb96a('0x12')),'tags':getTags(_0xa53e27[_0xb96a('0x13')],_0xb96a('0x14'))},getCustomFields(_0xa53e27[_0xb96a('0x15')],_0x3f72b2));_0x5ca01a[_0xb96a('0x16')]=_[_0xb96a('0x17')](_[_0xb96a('0x18')](_0x5ca01a[_0xb96a('0x16')],'id'),_0xb96a('0x19'));return request({'uri':util[_0xb96a('0xc')](_0xb96a('0x1a'),_0x47e5e8[_0xb96a('0x1b')]),'method':_0xb96a('0x1c'),'body':_0x5ca01a})[_0xb96a('0x1d')](function(_0x503ba1){logger['info']('Ticket\x20created!');return _0x503ba1;});}function getUser(_0x1047ba,_0x47f125){if(intUtil[_0xb96a('0x1e')](_0x47f125)){return request({'uri':util[_0xb96a('0xc')](_0xb96a('0x1f'),_0x1047ba[_0xb96a('0x1b')]),'qs':{'email':_0x47f125}})[_0xb96a('0x1d')](function(_0x19f5f2){if(_0x19f5f2[_0xb96a('0x20')]){logger['info'](_0xb96a('0x21'));return _[_0xb96a('0x22')](_0x19f5f2,function(_0x207f9b){return _0x207f9b[_0xb96a('0x23')]['email']===_0x47f125;});}else{logger[_0xb96a('0xa')](_0xb96a('0x24'));return request({'uri':util[_0xb96a('0xc')]('%s/api/v2/agents/me',_0x1047ba[_0xb96a('0x1b')])})[_0xb96a('0x1d')](function(_0x1228c5){logger[_0xb96a('0xa')](_0xb96a('0x25'));return _0x1228c5;});}});}else{logger[_0xb96a('0xa')](_0xb96a('0x26'));return request({'uri':util['format'](_0xb96a('0x27'),_0x1047ba['remoteUri'])})['then'](function(_0x388a26){logger[_0xb96a('0xa')](_0xb96a('0x25'));return _0x388a26;});}}function getEndUser(_0x585e68,_0x5c838e,_0x56a3b6){logger[_0xb96a('0xa')]('Searching\x20enduser\x20with\x20phone',_0x56a3b6);return request({'uri':util[_0xb96a('0xc')](_0xb96a('0x28'),_0x585e68[_0xb96a('0x1b')]),'qs':{'phone':_0x56a3b6}})[_0xb96a('0x1d')](function(_0x232e2a){if(_0x232e2a['length']){logger[_0xb96a('0xa')]('Enduser\x20found!');return _['find'](_0x232e2a,{'phone':_0x56a3b6});}else{logger[_0xb96a('0xa')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0xb96a('0xc')](_0xb96a('0x28'),_0x585e68['remoteUri']),'method':_0xb96a('0x1c'),'body':{'name':_0x5c838e,'phone':_0x56a3b6}})['then'](function(_0x24f4e8){logger[_0xb96a('0xa')]('Enduser\x20created.');return _0x24f4e8;});}});}function getAuth(_0x358bce){return util[_0xb96a('0xc')](_0xb96a('0x29'),new Buffer(_0x358bce[_0xb96a('0x2a')]+':X')[_0xb96a('0x2b')]('base64'));}function request(_0x4be1b1){logger['debug'](_0xb96a('0x2c'),JSON[_0xb96a('0x2d')](_0x4be1b1));return rp(_['defaults'](_0x4be1b1,{'method':_0xb96a('0x2e'),'headers':headers,'json':!![]}));}function getTags(_0x212a8a,_0x37cf52){var _0x546e23=[];if(_0x212a8a&&_0x212a8a['length']>0x0){_0x546e23=_['map'](_0x212a8a,_0x37cf52);}return _0x546e23;}function getCustomFields(_0x57f8a6,_0x4672f0){var _0x360a50=[];var _0x42a81e={'custom_fields':[]};if(_0x57f8a6[_0xb96a('0x20')]>0x0){_[_0xb96a('0x2f')](_0x57f8a6,function(_0x14c5cb){if(_[_0xb96a('0x30')](['string','picklist'],_0x14c5cb[_0xb96a('0x31')])&&_0x14c5cb[_0xb96a('0x32')]&&!_0x14c5cb['customField']){_0x42a81e[_0x14c5cb['nameField']['toLowerCase']()]=_0x14c5cb[_0xb96a('0x33')][_0xb96a('0x2b')]();}else if(_[_0xb96a('0x30')]([_0xb96a('0x34'),'picklist'],_0x14c5cb[_0xb96a('0x31')])&&_0x14c5cb[_0xb96a('0x35')]&&_0x14c5cb[_0xb96a('0x36')]){_0x42a81e['custom_fields'][_0xb96a('0x37')]({'id':_0x14c5cb[_0xb96a('0x35')],'value':_0x14c5cb[_0xb96a('0x33')][_0xb96a('0x2b')]()});}else if(_0x14c5cb[_0xb96a('0x31')]===_0xb96a('0x38')&&_0x14c5cb[_0xb96a('0x39')]&&_0x14c5cb['idField']&&_0x14c5cb[_0xb96a('0x36')]){_0x4672f0[_0x14c5cb['variableName']]&&_0x42a81e[_0xb96a('0x16')][_0xb96a('0x37')]({'id':_0x14c5cb['idField'],'value':_0x4672f0[_0x14c5cb[_0xb96a('0x39')]][_0xb96a('0x2b')]()});}else if(_0x14c5cb['type']===_0xb96a('0x3a')&&_0x14c5cb[_0xb96a('0x3b')]&&_0x14c5cb[_0xb96a('0x3b')][_0xb96a('0x14')]&&_0x14c5cb[_0xb96a('0x35')]&&_0x14c5cb[_0xb96a('0x36')]){_0x4672f0[_0x14c5cb[_0xb96a('0x3b')][_0xb96a('0x14')][_0xb96a('0x3c')]()]&&_0x42a81e[_0xb96a('0x16')]['push']({'id':_0x14c5cb[_0xb96a('0x35')],'value':_0x4672f0[_0x14c5cb[_0xb96a('0x3b')][_0xb96a('0x14')][_0xb96a('0x3c')]()][_0xb96a('0x2b')]()});}});}return _0x42a81e;}exports['queue']=function(_0x73a04d,_0x236498,_0x2a0444,_0x5f2df9,_0x4e7d2e,_0x146726){var _0x5d1d0b,_0x1d55ea;_0x146726[_0xb96a('0x1b')]=intUtil['stripTrailingSlash'](_0x146726[_0xb96a('0x1b')]);_0x146726[_0xb96a('0x3d')]=intUtil[_0xb96a('0x3e')](_0x146726[_0xb96a('0x3d')]);if(_0x4e7d2e&&_0x4e7d2e[_0xb96a('0x3f')]){logger[_0xb96a('0xa')](_0xb96a('0x40'),_0xb96a('0x41'));_0x236498[_0xb96a('0x42')]=util['format'](_0xb96a('0x43'),_0x146726['serverUrl'],_0x236498['uniqueid'],md5(_0x236498[_0xb96a('0x44')]));}else{_0x236498[_0xb96a('0x42')]='';}headers[_0xb96a('0x45')]=getAuth(_0x146726);return getUser(_0x146726,_0x5f2df9[_0xb96a('0x46')])[_0xb96a('0x1d')](function(_0x59568f){_0x5d1d0b=_0x59568f;logger[_0xb96a('0xa')]('The\x20User\x20ID\x20is:',_0x5d1d0b['id']);return getEndUser(_0x146726,_0x236498[_0xb96a('0xe')],_0x236498['calleridnum']);})[_0xb96a('0x1d')](function(_0x1bad06){_0x1d55ea=_0x1bad06;logger[_0xb96a('0xa')]('The\x20Enduser\x20ID\x20is:',_0x1d55ea['id']);return getTicket(_0x146726,_0x5d1d0b,_0x1d55ea,_0x2a0444,_0x236498);})[_0xb96a('0x1d')](function(_0x3bb7ac){if(_0x3bb7ac&&_0x3bb7ac['id']){logger[_0xb96a('0xa')](_0xb96a('0x47'));logger['info']('The\x20Ticket\x20ID\x20is:',_0x3bb7ac['id']);logger[_0xb96a('0xa')](_0xb96a('0x40'),_0xb96a('0x48'));emit(util[_0xb96a('0xc')](_0xb96a('0x49'),_0x5f2df9[_0xb96a('0x14')]),_0xb96a('0x4a'),{'uri':util['format']('%s/helpdesk/tickets/%d',_0x146726['remoteUri'],_0x3bb7ac['id'])});}})[_0xb96a('0x4b')](function(_0x27aee1){logger['error'](_0xb96a('0x40'),JSON[_0xb96a('0x2d')](_0x27aee1));});};exports[_0xb96a('0x4c')]=function(_0x4b192b,_0x3ad108,_0x1a5270,_0x3151e8,_0x415ba0,_0x43f3f0,_0x3e0bd0){var _0x7206d8,_0x352b2a;_0x43f3f0[_0xb96a('0x1b')]=intUtil[_0xb96a('0x3e')](_0x43f3f0[_0xb96a('0x1b')]);_0x43f3f0['serverUrl']=intUtil['stripTrailingSlash'](_0x43f3f0[_0xb96a('0x3d')]);if(_0x3e0bd0&&_0x3e0bd0[_0xb96a('0x4d')]&&_0x3e0bd0['recordingFormat']!=='none'){logger[_0xb96a('0xa')](_0xb96a('0x4e'),_0xb96a('0x41'));_0x3ad108[_0xb96a('0x42')]=util[_0xb96a('0xc')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x43f3f0[_0xb96a('0x3d')],_0x3ad108[_0xb96a('0x44')],md5(_0x3ad108['uniqueid']));}headers['Authorization']=getAuth(_0x43f3f0);return getUser(_0x43f3f0,_0x3151e8['email'])[_0xb96a('0x1d')](function(_0x4eead3){_0x7206d8=_0x4eead3;logger[_0xb96a('0xa')]('The\x20User\x20ID\x20is:',_0x7206d8['id']);return getEndUser(_0x43f3f0,_0x3ad108[_0xb96a('0x4f')],_0x3ad108[_0xb96a('0x50')]);})[_0xb96a('0x1d')](function(_0x345275){_0x352b2a=_0x345275;logger['info']('The\x20Enduser\x20ID\x20is:',_0x352b2a['id']);return getTicket(_0x43f3f0,_0x7206d8,_0x352b2a,_0x1a5270,_0x3ad108);})['then'](function(_0x2e2420){if(_0x2e2420&&_0x2e2420['id']){logger[_0xb96a('0xa')](_0xb96a('0x47'));logger[_0xb96a('0xa')]('The\x20Ticket\x20ID\x20is:',_0x2e2420['id']);logger['info'](_0xb96a('0x4e'),_0xb96a('0x48'));emit(util[_0xb96a('0xc')](_0xb96a('0x49'),_0x3151e8[_0xb96a('0x14')]),_0xb96a('0x4a'),{'uri':util[_0xb96a('0xc')]('%s/helpdesk/tickets/%d',_0x43f3f0[_0xb96a('0x1b')],_0x2e2420['id'])});}})[_0xb96a('0x4b')](function(_0x3d11f5){logger[_0xb96a('0x51')]('[OUTBOUND]',JSON['stringify'](_0x3d11f5));});};exports[_0xb96a('0x52')]=function(_0x347aec,_0x58a03f,_0x53e7ff,_0x432559,_0x29fde9,_0x39242d){var _0x55c4d1,_0x22699a;_0x39242d[_0xb96a('0x1b')]=intUtil['stripTrailingSlash'](_0x39242d[_0xb96a('0x1b')]);_0x39242d[_0xb96a('0x3d')]=intUtil[_0xb96a('0x3e')](_0x39242d[_0xb96a('0x3d')]);if(_0x29fde9&&_0x29fde9[_0xb96a('0x3f')]){logger[_0xb96a('0xa')]('['+_0x58a03f[_0xb96a('0x53')][_0xb96a('0x54')]()+']',_0xb96a('0x41'));_0x58a03f[_0xb96a('0x42')]=util[_0xb96a('0xc')](_0xb96a('0x43'),_0x39242d[_0xb96a('0x3d')],_0x58a03f[_0xb96a('0x44')],md5(_0x58a03f[_0xb96a('0x44')]));}else{_0x58a03f[_0xb96a('0x42')]='';}headers[_0xb96a('0x45')]=getAuth(_0x39242d);return getUser(_0x39242d,'')['then'](function(_0x2a4e31){_0x55c4d1=_0x2a4e31;logger[_0xb96a('0xa')](_0xb96a('0x55'),_0x55c4d1['id']);return getEndUser(_0x39242d,_0x58a03f[_0xb96a('0xe')],_0x58a03f[_0xb96a('0x56')]);})[_0xb96a('0x1d')](function(_0x292053){_0x22699a=_0x292053;logger[_0xb96a('0xa')](_0xb96a('0x57'),_0x22699a['id']);return getTicket(_0x39242d,_0x55c4d1,_0x22699a,_0x53e7ff,_0x58a03f);})[_0xb96a('0x1d')](function(_0x4eaf30){if(_0x4eaf30){logger['info'](_0xb96a('0x47'));logger['info'](_0xb96a('0x58'),_0x4eaf30['id']);}})['catch'](function(_0x1819f1){logger[_0xb96a('0x51')]('['+_0x58a03f[_0xb96a('0x53')][_0xb96a('0x54')]()+']',JSON[_0xb96a('0x2d')](_0x1819f1));});};
\ No newline at end of file
+var _0x2c01=['Fields','custom_fields','mapValues','keyBy','format','remoteUri','Ticket\x20created!','validateEmail','length','Agent\x20found!','contact','email','%s/api/v2/agents/me','then','%s/api/v2/contacts','Enduser\x20found!','find','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Enduser\x20created.','Basic\x20%s','apiKey','base64','[HTTP]','GET','map','forEach','includes','string','type','nameField','toLowerCase','picklist','idField','customField','push','content','toString','variable','variableName','customVariable','Variable','name','queue','stripTrailingSlash','serverUrl','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','calleridnum','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','%s/helpdesk/tickets/%d','catch','error','stringify','outbound','recordingFormat','none','[OUTBOUND]','The\x20User\x20ID\x20is:','trigger:browser:url','unmanaged','monitor_format','lastevent','toUpperCase','lodash','request-promise','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','Caller\x20-\x20%s','calleridname','getString','Subjects','Descriptions','<br>','Tags'];(function(_0x390cea,_0x43c078){var _0x14bf80=function(_0x196f3c){while(--_0x196f3c){_0x390cea['push'](_0x390cea['shift']());}};_0x14bf80(++_0x43c078);}(_0x2c01,0xff));var _0x12c0=function(_0x18c037,_0x26dbba){_0x18c037=_0x18c037-0x0;var _0x667212=_0x2c01[_0x18c037];return _0x667212;};'use strict';var _=require(_0x12c0('0x0'));var rp=require(_0x12c0('0x1'));var md5=require(_0x12c0('0x2'));var util=require(_0x12c0('0x3'));var Redis=require(_0x12c0('0x4'));var intUtil=require(_0x12c0('0x5'));var config=require(_0x12c0('0x6'));var logger=require(_0x12c0('0x7'))(_0x12c0('0x8'));config[_0x12c0('0x9')]=_[_0x12c0('0xa')](config[_0x12c0('0x9')],{'host':_0x12c0('0xb'),'port':0x18eb});var io=require(_0x12c0('0xc'))(new Redis(config[_0x12c0('0x9')]));var headers={'Content-Type':_0x12c0('0xd'),'Accept':_0x12c0('0xd')};function emit(_0x24c85f,_0x3cfdd7,_0x8afb17){io['to'](_0x24c85f)[_0x12c0('0xe')](_0x3cfdd7,_0x8afb17);}function getTicket(_0x93152b,_0x21f363,_0x354f,_0xc80a62,_0x31a90a){logger[_0x12c0('0xf')](_0x12c0('0x10'));var _0x29ad39=_['merge']({'responder_id':_0x21f363['id'],'requester_id':_0x354f['id'],'name':util['format'](_0x12c0('0x11'),_0x31a90a[_0x12c0('0x12')]),'phone':_0x31a90a['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x12c0('0x13')](_0xc80a62[_0x12c0('0x14')],_0x31a90a,'\x20'),'description':intUtil['getString'](_0xc80a62[_0x12c0('0x15')],_0x31a90a,_0x12c0('0x16')),'tags':getTags(_0xc80a62[_0x12c0('0x17')],'name')},getCustomFields(_0xc80a62[_0x12c0('0x18')],_0x31a90a));_0x29ad39[_0x12c0('0x19')]=_[_0x12c0('0x1a')](_[_0x12c0('0x1b')](_0x29ad39[_0x12c0('0x19')],'id'),'value');return request({'uri':util[_0x12c0('0x1c')]('%s/api/v2/tickets',_0x93152b[_0x12c0('0x1d')]),'method':'POST','body':_0x29ad39})['then'](function(_0x2c17f2){logger[_0x12c0('0xf')](_0x12c0('0x1e'));return _0x2c17f2;});}function getUser(_0x4e5786,_0x2b0645){if(intUtil[_0x12c0('0x1f')](_0x2b0645)){return request({'uri':util[_0x12c0('0x1c')]('%s/api/v2/agents',_0x4e5786[_0x12c0('0x1d')]),'qs':{'email':_0x2b0645}})['then'](function(_0x3512ff){if(_0x3512ff[_0x12c0('0x20')]){logger[_0x12c0('0xf')](_0x12c0('0x21'));return _['find'](_0x3512ff,function(_0x8a035){return _0x8a035[_0x12c0('0x22')][_0x12c0('0x23')]===_0x2b0645;});}else{logger[_0x12c0('0xf')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x12c0('0x24'),_0x4e5786[_0x12c0('0x1d')])})[_0x12c0('0x25')](function(_0x261d92){logger[_0x12c0('0xf')]('Admin\x20account\x20selected.');return _0x261d92;});}});}else{logger[_0x12c0('0xf')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x24'),_0x4e5786[_0x12c0('0x1d')])})[_0x12c0('0x25')](function(_0x3feacf){logger[_0x12c0('0xf')]('Admin\x20account\x20selected.');return _0x3feacf;});}}function getEndUser(_0x3159f8,_0x5d66a2,_0x4fd91c){logger[_0x12c0('0xf')]('Searching\x20enduser\x20with\x20phone',_0x4fd91c);return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x26'),_0x3159f8[_0x12c0('0x1d')]),'qs':{'phone':_0x4fd91c}})[_0x12c0('0x25')](function(_0x8ea144){if(_0x8ea144[_0x12c0('0x20')]){logger[_0x12c0('0xf')](_0x12c0('0x27'));return _[_0x12c0('0x28')](_0x8ea144,{'phone':_0x4fd91c});}else{logger[_0x12c0('0xf')](_0x12c0('0x29'));return request({'uri':util[_0x12c0('0x1c')](_0x12c0('0x26'),_0x3159f8[_0x12c0('0x1d')]),'method':_0x12c0('0x2a'),'body':{'name':_0x5d66a2,'phone':_0x4fd91c}})[_0x12c0('0x25')](function(_0x3c47f7){logger[_0x12c0('0xf')](_0x12c0('0x2b'));return _0x3c47f7;});}});}function getAuth(_0x18a706){return util[_0x12c0('0x1c')](_0x12c0('0x2c'),new Buffer(_0x18a706[_0x12c0('0x2d')]+':X')['toString'](_0x12c0('0x2e')));}function request(_0x31d86f){logger['debug'](_0x12c0('0x2f'),JSON['stringify'](_0x31d86f));return rp(_[_0x12c0('0xa')](_0x31d86f,{'method':_0x12c0('0x30'),'headers':headers,'json':!![]}));}function getTags(_0x388170,_0x20434b){var _0x53cf06=[];if(_0x388170&&_0x388170['length']>0x0){_0x53cf06=_[_0x12c0('0x31')](_0x388170,_0x20434b);}return _0x53cf06;}function getCustomFields(_0x58bc08,_0x39d75e){var _0x3aa2ac=[];var _0x31af47={'custom_fields':[]};if(_0x58bc08[_0x12c0('0x20')]>0x0){_[_0x12c0('0x32')](_0x58bc08,function(_0x516c64){if(_[_0x12c0('0x33')]([_0x12c0('0x34'),'picklist'],_0x516c64[_0x12c0('0x35')])&&_0x516c64['nameField']&&!_0x516c64['customField']){_0x31af47[_0x516c64[_0x12c0('0x36')][_0x12c0('0x37')]()]=_0x516c64['content']['toString']();}else if(_[_0x12c0('0x33')]([_0x12c0('0x34'),_0x12c0('0x38')],_0x516c64[_0x12c0('0x35')])&&_0x516c64[_0x12c0('0x39')]&&_0x516c64[_0x12c0('0x3a')]){_0x31af47[_0x12c0('0x19')][_0x12c0('0x3b')]({'id':_0x516c64[_0x12c0('0x39')],'value':_0x516c64[_0x12c0('0x3c')][_0x12c0('0x3d')]()});}else if(_0x516c64['type']===_0x12c0('0x3e')&&_0x516c64[_0x12c0('0x3f')]&&_0x516c64[_0x12c0('0x39')]&&_0x516c64[_0x12c0('0x3a')]){_0x39d75e[_0x516c64[_0x12c0('0x3f')]]&&_0x31af47[_0x12c0('0x19')][_0x12c0('0x3b')]({'id':_0x516c64['idField'],'value':_0x39d75e[_0x516c64['variableName']][_0x12c0('0x3d')]()});}else if(_0x516c64[_0x12c0('0x35')]===_0x12c0('0x40')&&_0x516c64[_0x12c0('0x41')]&&_0x516c64[_0x12c0('0x41')][_0x12c0('0x42')]&&_0x516c64['idField']&&_0x516c64[_0x12c0('0x3a')]){_0x39d75e[_0x516c64['Variable'][_0x12c0('0x42')][_0x12c0('0x37')]()]&&_0x31af47[_0x12c0('0x19')]['push']({'id':_0x516c64[_0x12c0('0x39')],'value':_0x39d75e[_0x516c64[_0x12c0('0x41')][_0x12c0('0x42')][_0x12c0('0x37')]()][_0x12c0('0x3d')]()});}});}return _0x31af47;}exports[_0x12c0('0x43')]=function(_0x5a3214,_0x2d8ecf,_0x2709c0,_0x53007d,_0x2aba7f,_0xdb1da5){var _0x47abfa,_0x31b94c;_0xdb1da5[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0xdb1da5[_0x12c0('0x1d')]);_0xdb1da5['serverUrl']=intUtil[_0x12c0('0x44')](_0xdb1da5[_0x12c0('0x45')]);if(_0x2aba7f&&_0x2aba7f['monitor_format']){logger[_0x12c0('0xf')](_0x12c0('0x46'),_0x12c0('0x47'));_0x2d8ecf[_0x12c0('0x48')]=util[_0x12c0('0x1c')](_0x12c0('0x49'),_0xdb1da5[_0x12c0('0x45')],_0x2d8ecf[_0x12c0('0x4a')],md5(_0x2d8ecf[_0x12c0('0x4a')]));}else{_0x2d8ecf[_0x12c0('0x48')]='';}headers[_0x12c0('0x4b')]=getAuth(_0xdb1da5);return getUser(_0xdb1da5,_0x53007d[_0x12c0('0x23')])[_0x12c0('0x25')](function(_0x2a315f){_0x47abfa=_0x2a315f;logger[_0x12c0('0xf')]('The\x20User\x20ID\x20is:',_0x47abfa['id']);return getEndUser(_0xdb1da5,_0x2d8ecf[_0x12c0('0x12')],_0x2d8ecf[_0x12c0('0x4c')]);})[_0x12c0('0x25')](function(_0x25523a){_0x31b94c=_0x25523a;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x31b94c['id']);return getTicket(_0xdb1da5,_0x47abfa,_0x31b94c,_0x2709c0,_0x2d8ecf);})['then'](function(_0x596dcc){if(_0x596dcc&&_0x596dcc['id']){logger['info'](_0x12c0('0x1e'));logger['info'](_0x12c0('0x4e'),_0x596dcc['id']);logger[_0x12c0('0xf')]('[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format']('user:%s',_0x53007d[_0x12c0('0x42')]),'trigger:browser:url',{'uri':util[_0x12c0('0x1c')](_0x12c0('0x4f'),_0xdb1da5['remoteUri'],_0x596dcc['id'])});}})[_0x12c0('0x50')](function(_0x21dbc6){logger[_0x12c0('0x51')](_0x12c0('0x46'),JSON[_0x12c0('0x52')](_0x21dbc6));});};exports[_0x12c0('0x53')]=function(_0x809f40,_0x3e127e,_0xe50c3e,_0x1a5295,_0x415912,_0x20b905,_0x4497f4){var _0x4f2fa8,_0x524e84;_0x20b905[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0x20b905[_0x12c0('0x1d')]);_0x20b905[_0x12c0('0x45')]=intUtil[_0x12c0('0x44')](_0x20b905[_0x12c0('0x45')]);if(_0x4497f4&&_0x4497f4[_0x12c0('0x54')]&&_0x4497f4['recordingFormat']!==_0x12c0('0x55')){logger['info'](_0x12c0('0x56'),_0x12c0('0x47'));_0x3e127e[_0x12c0('0x48')]=util[_0x12c0('0x1c')](_0x12c0('0x49'),_0x20b905['serverUrl'],_0x3e127e[_0x12c0('0x4a')],md5(_0x3e127e[_0x12c0('0x4a')]));}headers['Authorization']=getAuth(_0x20b905);return getUser(_0x20b905,_0x1a5295['email'])[_0x12c0('0x25')](function(_0x3f5063){_0x4f2fa8=_0x3f5063;logger[_0x12c0('0xf')](_0x12c0('0x57'),_0x4f2fa8['id']);return getEndUser(_0x20b905,_0x3e127e['destcalleridname'],_0x3e127e['destcalleridnum']);})[_0x12c0('0x25')](function(_0x193c4d){_0x524e84=_0x193c4d;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x524e84['id']);return getTicket(_0x20b905,_0x4f2fa8,_0x524e84,_0xe50c3e,_0x3e127e);})[_0x12c0('0x25')](function(_0x26cc9f){if(_0x26cc9f&&_0x26cc9f['id']){logger['info'](_0x12c0('0x1e'));logger[_0x12c0('0xf')](_0x12c0('0x4e'),_0x26cc9f['id']);logger['info']('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x12c0('0x1c')]('user:%s',_0x1a5295[_0x12c0('0x42')]),_0x12c0('0x58'),{'uri':util[_0x12c0('0x1c')](_0x12c0('0x4f'),_0x20b905[_0x12c0('0x1d')],_0x26cc9f['id'])});}})[_0x12c0('0x50')](function(_0x23f8b3){logger[_0x12c0('0x51')](_0x12c0('0x56'),JSON[_0x12c0('0x52')](_0x23f8b3));});};exports[_0x12c0('0x59')]=function(_0x458e5f,_0x11627c,_0x1994b4,_0x7cad53,_0x245dc8,_0x30a362){var _0xc21361,_0x359955;_0x30a362[_0x12c0('0x1d')]=intUtil[_0x12c0('0x44')](_0x30a362[_0x12c0('0x1d')]);_0x30a362[_0x12c0('0x45')]=intUtil[_0x12c0('0x44')](_0x30a362[_0x12c0('0x45')]);if(_0x245dc8&&_0x245dc8[_0x12c0('0x5a')]){logger[_0x12c0('0xf')]('['+_0x11627c[_0x12c0('0x5b')][_0x12c0('0x5c')]()+']',_0x12c0('0x47'));_0x11627c['recordingURL']=util['format'](_0x12c0('0x49'),_0x30a362[_0x12c0('0x45')],_0x11627c[_0x12c0('0x4a')],md5(_0x11627c[_0x12c0('0x4a')]));}else{_0x11627c['recordingURL']='';}headers[_0x12c0('0x4b')]=getAuth(_0x30a362);return getUser(_0x30a362,'')['then'](function(_0x2dc651){_0xc21361=_0x2dc651;logger[_0x12c0('0xf')](_0x12c0('0x57'),_0xc21361['id']);return getEndUser(_0x30a362,_0x11627c['calleridname'],_0x11627c['calleridnum']);})[_0x12c0('0x25')](function(_0x2effce){_0x359955=_0x2effce;logger[_0x12c0('0xf')](_0x12c0('0x4d'),_0x359955['id']);return getTicket(_0x30a362,_0xc21361,_0x359955,_0x1994b4,_0x11627c);})[_0x12c0('0x25')](function(_0x3c4d65){if(_0x3c4d65){logger[_0x12c0('0xf')](_0x12c0('0x1e'));logger[_0x12c0('0xf')](_0x12c0('0x4e'),_0x3c4d65['id']);}})['catch'](function(_0x5788ac){logger[_0x12c0('0x51')]('['+_0x11627c[_0x12c0('0x5b')][_0x12c0('0x5c')]()+']',JSON[_0x12c0('0x52')](_0x5788ac));});};
\ No newline at end of file