Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 61db38c..7fb331b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4a37=['nameField','toLowerCase','includes','push','content','type','variable','idField','variableName','customVariable','Variable','name','stripTrailingSlash','serverUrl','[QUEUE]','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','recordingURL','Authorization','The\x20User\x20ID\x20is:','calleridname','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','recordingFormat','none','[OUTBOUND]','destcalleridnum','The\x20Enduser\x20ID\x20is:','unmanaged','monitor_format','lastevent','toUpperCase','calleridnum','lodash','request-promise','md5','util','ioredis','../../../../config/logger','freshdesk','defaults','redis','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','merge','format','getString','Subjects','Descriptions','custom_fields','mapValues','keyBy','%s/api/v2/tickets','remoteUri','then','validateEmail','length','Agent\x20found!','find','contact','email','%s/api/v2/agents/me','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','Enduser\x20found!','POST','Enduser\x20created.','Basic\x20%s','toString','base64','debug','stringify','GET','string','picklist','customField'];(function(_0x35ac2d,_0x324c0c){var _0x43e260=function(_0x5e0c29){while(--_0x5e0c29){_0x35ac2d['push'](_0x35ac2d['shift']());}};_0x43e260(++_0x324c0c);}(_0x4a37,0x1d0));var _0x74a3=function(_0x1bff3b,_0x23c495){_0x1bff3b=_0x1bff3b-0x0;var _0x58ce2a=_0x4a37[_0x1bff3b];return _0x58ce2a;};'use strict';var _=require(_0x74a3('0x0'));var rp=require(_0x74a3('0x1'));var md5=require(_0x74a3('0x2'));var util=require(_0x74a3('0x3'));var Redis=require(_0x74a3('0x4'));var intUtil=require('./util');var config=require('../../../../config/environment');var logger=require(_0x74a3('0x5'))(_0x74a3('0x6'));config['redis']=_[_0x74a3('0x7')](config[_0x74a3('0x8')],{'host':'localhost','port':0x18eb});var io=require(_0x74a3('0x9'))(new Redis(config['redis']));var headers={'Content-Type':_0x74a3('0xa'),'Accept':_0x74a3('0xa')};function emit(_0x176299,_0x3611fd,_0x3ad7b9){io['to'](_0x176299)[_0x74a3('0xb')](_0x3611fd,_0x3ad7b9);}function getTicket(_0x9e4493,_0x3a66db,_0x30dae6,_0x2e930b,_0x58b124){logger[_0x74a3('0xc')](_0x74a3('0xd'));var _0x4ff7d1=_[_0x74a3('0xe')]({'responder_id':_0x3a66db['id'],'requester_id':_0x30dae6['id'],'name':util[_0x74a3('0xf')]('Caller\x20-\x20%s',_0x58b124['calleridname']),'phone':_0x58b124['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x74a3('0x10')](_0x2e930b[_0x74a3('0x11')],_0x58b124,'\x20'),'description':intUtil[_0x74a3('0x10')](_0x2e930b[_0x74a3('0x12')],_0x58b124,'<br>'),'tags':getTags(_0x2e930b['Tags'],'name')},getCustomFields(_0x2e930b['Fields'],_0x58b124));_0x4ff7d1[_0x74a3('0x13')]=_[_0x74a3('0x14')](_[_0x74a3('0x15')](_0x4ff7d1[_0x74a3('0x13')],'id'),'value');return request({'uri':util[_0x74a3('0xf')](_0x74a3('0x16'),_0x9e4493[_0x74a3('0x17')]),'method':'POST','body':_0x4ff7d1})[_0x74a3('0x18')](function(_0x976811){logger[_0x74a3('0xc')]('Ticket\x20created!');return _0x976811;});}function getUser(_0x1d2532,_0x2512e2){if(intUtil[_0x74a3('0x19')](_0x2512e2)){return request({'uri':util['format']('%s/api/v2/agents',_0x1d2532['remoteUri']),'qs':{'email':_0x2512e2}})[_0x74a3('0x18')](function(_0x44b576){if(_0x44b576[_0x74a3('0x1a')]){logger[_0x74a3('0xc')](_0x74a3('0x1b'));return _[_0x74a3('0x1c')](_0x44b576,function(_0x5e0b37){return _0x5e0b37[_0x74a3('0x1d')][_0x74a3('0x1e')]===_0x2512e2;});}else{logger[_0x74a3('0xc')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x74a3('0xf')](_0x74a3('0x1f'),_0x1d2532[_0x74a3('0x17')])})[_0x74a3('0x18')](function(_0x29e196){logger[_0x74a3('0xc')](_0x74a3('0x20'));return _0x29e196;});}});}else{logger['info']('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x74a3('0xf')](_0x74a3('0x1f'),_0x1d2532[_0x74a3('0x17')])})[_0x74a3('0x18')](function(_0x29f5d8){logger[_0x74a3('0xc')](_0x74a3('0x20'));return _0x29f5d8;});}}function getEndUser(_0x1d8ef6,_0x4875eb,_0x4cba0a){logger['info'](_0x74a3('0x21'),_0x4cba0a);return request({'uri':util[_0x74a3('0xf')]('%s/api/v2/contacts',_0x1d8ef6[_0x74a3('0x17')]),'qs':{'phone':_0x4cba0a}})[_0x74a3('0x18')](function(_0x1fccc5){if(_0x1fccc5[_0x74a3('0x1a')]){logger[_0x74a3('0xc')](_0x74a3('0x22'));return _[_0x74a3('0x1c')](_0x1fccc5,{'phone':_0x4cba0a});}else{logger[_0x74a3('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0x74a3('0xf')]('%s/api/v2/contacts',_0x1d8ef6['remoteUri']),'method':_0x74a3('0x23'),'body':{'name':_0x4875eb,'phone':_0x4cba0a}})[_0x74a3('0x18')](function(_0x332f55){logger[_0x74a3('0xc')](_0x74a3('0x24'));return _0x332f55;});}});}function getAuth(_0x54846e){return util[_0x74a3('0xf')](_0x74a3('0x25'),new Buffer(_0x54846e['apiKey']+':X')[_0x74a3('0x26')](_0x74a3('0x27')));}function request(_0x27ed86){logger[_0x74a3('0x28')]('[HTTP]',JSON[_0x74a3('0x29')](_0x27ed86));return rp(_[_0x74a3('0x7')](_0x27ed86,{'method':_0x74a3('0x2a'),'headers':headers,'json':!![]}));}function getTags(_0x5df5eb,_0x3a2ea6){var _0x32899c=[];if(_0x5df5eb&&_0x5df5eb[_0x74a3('0x1a')]>0x0){_0x32899c=_['map'](_0x5df5eb,_0x3a2ea6);}return _0x32899c;}function getCustomFields(_0x12c14e,_0x5ad13d){var _0x47c2a2=[];var _0xb101e0={'custom_fields':[]};if(_0x12c14e[_0x74a3('0x1a')]>0x0){_['forEach'](_0x12c14e,function(_0x4384c4){if(_['includes']([_0x74a3('0x2b'),_0x74a3('0x2c')],_0x4384c4['type'])&&_0x4384c4['nameField']&&!_0x4384c4[_0x74a3('0x2d')]){_0xb101e0[_0x4384c4[_0x74a3('0x2e')][_0x74a3('0x2f')]()]=_0x4384c4['content']['toString']();}else if(_[_0x74a3('0x30')](['string',_0x74a3('0x2c')],_0x4384c4['type'])&&_0x4384c4['idField']&&_0x4384c4['customField']){_0xb101e0[_0x74a3('0x13')][_0x74a3('0x31')]({'id':_0x4384c4['idField'],'value':_0x4384c4[_0x74a3('0x32')]['toString']()});}else if(_0x4384c4[_0x74a3('0x33')]===_0x74a3('0x34')&&_0x4384c4['variableName']&&_0x4384c4[_0x74a3('0x35')]&&_0x4384c4['customField']){_0x5ad13d[_0x4384c4[_0x74a3('0x36')]]&&_0xb101e0[_0x74a3('0x13')][_0x74a3('0x31')]({'id':_0x4384c4[_0x74a3('0x35')],'value':_0x5ad13d[_0x4384c4[_0x74a3('0x36')]][_0x74a3('0x26')]()});}else if(_0x4384c4[_0x74a3('0x33')]===_0x74a3('0x37')&&_0x4384c4[_0x74a3('0x38')]&&_0x4384c4['Variable'][_0x74a3('0x39')]&&_0x4384c4[_0x74a3('0x35')]&&_0x4384c4['customField']){_0x5ad13d[_0x4384c4[_0x74a3('0x38')]['name'][_0x74a3('0x2f')]()]&&_0xb101e0[_0x74a3('0x13')]['push']({'id':_0x4384c4[_0x74a3('0x35')],'value':_0x5ad13d[_0x4384c4[_0x74a3('0x38')][_0x74a3('0x39')][_0x74a3('0x2f')]()][_0x74a3('0x26')]()});}});}return _0xb101e0;}exports['queue']=function(_0x504f1a,_0x49f3c6,_0x35dc39,_0x11250f,_0x4f6477,_0x248b84){var _0x5f14fb,_0x3247dd;_0x248b84[_0x74a3('0x17')]=intUtil[_0x74a3('0x3a')](_0x248b84[_0x74a3('0x17')]);_0x248b84[_0x74a3('0x3b')]=intUtil[_0x74a3('0x3a')](_0x248b84[_0x74a3('0x3b')]);if(_0x4f6477&&_0x4f6477['monitor_format']){logger[_0x74a3('0xc')](_0x74a3('0x3c'),_0x74a3('0x3d'));_0x49f3c6['recordingURL']=util[_0x74a3('0xf')](_0x74a3('0x3e'),_0x248b84['serverUrl'],_0x49f3c6[_0x74a3('0x3f')],md5(_0x49f3c6[_0x74a3('0x3f')]));}else{_0x49f3c6[_0x74a3('0x40')]='';}headers[_0x74a3('0x41')]=getAuth(_0x248b84);return getUser(_0x248b84,_0x11250f[_0x74a3('0x1e')])[_0x74a3('0x18')](function(_0xdb6538){_0x5f14fb=_0xdb6538;logger['info'](_0x74a3('0x42'),_0x5f14fb['id']);return getEndUser(_0x248b84,_0x49f3c6[_0x74a3('0x43')],_0x49f3c6['calleridnum']);})[_0x74a3('0x18')](function(_0x289e5c){_0x3247dd=_0x289e5c;logger[_0x74a3('0xc')]('The\x20Enduser\x20ID\x20is:',_0x3247dd['id']);return getTicket(_0x248b84,_0x5f14fb,_0x3247dd,_0x35dc39,_0x49f3c6);})[_0x74a3('0x18')](function(_0x17f9bb){if(_0x17f9bb&&_0x17f9bb['id']){logger['info'](_0x74a3('0x44'));logger[_0x74a3('0xc')](_0x74a3('0x45'),_0x17f9bb['id']);logger[_0x74a3('0xc')](_0x74a3('0x3c'),_0x74a3('0x46'));emit(util[_0x74a3('0xf')]('user:%s',_0x11250f[_0x74a3('0x39')]),_0x74a3('0x47'),{'uri':util['format'](_0x74a3('0x48'),_0x248b84[_0x74a3('0x17')],_0x17f9bb['id'])});}})[_0x74a3('0x49')](function(_0x3e7815){logger[_0x74a3('0x4a')]('[QUEUE]',JSON[_0x74a3('0x29')](_0x3e7815));});};exports['outbound']=function(_0x2b8a47,_0x392062,_0x77d554,_0x428d31,_0x5b7de4,_0x418da6,_0x39be26){var _0x28d017,_0x43dac3;_0x418da6[_0x74a3('0x17')]=intUtil[_0x74a3('0x3a')](_0x418da6[_0x74a3('0x17')]);_0x418da6['serverUrl']=intUtil[_0x74a3('0x3a')](_0x418da6[_0x74a3('0x3b')]);if(_0x39be26&&_0x39be26['recordingFormat']&&_0x39be26[_0x74a3('0x4b')]!==_0x74a3('0x4c')){logger[_0x74a3('0xc')](_0x74a3('0x4d'),_0x74a3('0x3d'));_0x392062[_0x74a3('0x40')]=util['format'](_0x74a3('0x3e'),_0x418da6[_0x74a3('0x3b')],_0x392062[_0x74a3('0x3f')],md5(_0x392062[_0x74a3('0x3f')]));}headers[_0x74a3('0x41')]=getAuth(_0x418da6);return getUser(_0x418da6,_0x428d31['email'])[_0x74a3('0x18')](function(_0x20e89c){_0x28d017=_0x20e89c;logger[_0x74a3('0xc')](_0x74a3('0x42'),_0x28d017['id']);return getEndUser(_0x418da6,_0x392062['destcalleridname'],_0x392062[_0x74a3('0x4e')]);})[_0x74a3('0x18')](function(_0x3eb1b0){_0x43dac3=_0x3eb1b0;logger[_0x74a3('0xc')](_0x74a3('0x4f'),_0x43dac3['id']);return getTicket(_0x418da6,_0x28d017,_0x43dac3,_0x77d554,_0x392062);})['then'](function(_0x323b89){if(_0x323b89&&_0x323b89['id']){logger[_0x74a3('0xc')](_0x74a3('0x44'));logger[_0x74a3('0xc')](_0x74a3('0x45'),_0x323b89['id']);logger[_0x74a3('0xc')](_0x74a3('0x4d'),_0x74a3('0x46'));emit(util[_0x74a3('0xf')]('user:%s',_0x428d31['name']),'trigger:browser:url',{'uri':util[_0x74a3('0xf')](_0x74a3('0x48'),_0x418da6[_0x74a3('0x17')],_0x323b89['id'])});}})[_0x74a3('0x49')](function(_0xa6aa2a){logger[_0x74a3('0x4a')](_0x74a3('0x4d'),JSON['stringify'](_0xa6aa2a));});};exports[_0x74a3('0x50')]=function(_0x50b6b4,_0x5a74a6,_0x37616f,_0x5556fb,_0xa741d0,_0x17c647){var _0x3ea431,_0x2750a3;_0x17c647[_0x74a3('0x17')]=intUtil[_0x74a3('0x3a')](_0x17c647[_0x74a3('0x17')]);_0x17c647['serverUrl']=intUtil[_0x74a3('0x3a')](_0x17c647[_0x74a3('0x3b')]);if(_0xa741d0&&_0xa741d0[_0x74a3('0x51')]){logger['info']('['+_0x5a74a6[_0x74a3('0x52')][_0x74a3('0x53')]()+']','Recording\x20is\x20enabled!');_0x5a74a6['recordingURL']=util['format'](_0x74a3('0x3e'),_0x17c647['serverUrl'],_0x5a74a6[_0x74a3('0x3f')],md5(_0x5a74a6[_0x74a3('0x3f')]));}else{_0x5a74a6[_0x74a3('0x40')]='';}headers['Authorization']=getAuth(_0x17c647);return getUser(_0x17c647,'')['then'](function(_0x5e3aae){_0x3ea431=_0x5e3aae;logger[_0x74a3('0xc')](_0x74a3('0x42'),_0x3ea431['id']);return getEndUser(_0x17c647,_0x5a74a6['calleridname'],_0x5a74a6[_0x74a3('0x54')]);})[_0x74a3('0x18')](function(_0x580346){_0x2750a3=_0x580346;logger[_0x74a3('0xc')](_0x74a3('0x4f'),_0x2750a3['id']);return getTicket(_0x17c647,_0x3ea431,_0x2750a3,_0x37616f,_0x5a74a6);})[_0x74a3('0x18')](function(_0x36450f){if(_0x36450f){logger[_0x74a3('0xc')](_0x74a3('0x44'));logger[_0x74a3('0xc')](_0x74a3('0x45'),_0x36450f['id']);}})[_0x74a3('0x49')](function(_0x50774a){logger['error']('['+_0x5a74a6[_0x74a3('0x52')]['toUpperCase']()+']',JSON[_0x74a3('0x29')](_0x50774a));});};
\ 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