Built motion from commit d69f4380.|2.6.29
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index f4ec166..8ec8725 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x671f=['customVariable','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','recordingURL','The\x20User\x20ID\x20is:','calleridname','The\x20Ticket\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','outbound','recordingFormat','[OUTBOUND]','Recording\x20is\x20enabled!','unmanaged','lastevent','The\x20Enduser\x20ID\x20is:','toUpperCase','request-promise','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','defaults','application/json','emit','info','Creating\x20new\x20ticket...','merge','Caller\x20-\x20%s','calleridnum','getString','Descriptions','<br>','Tags','name','Fields','custom_fields','keyBy','value','format','remoteUri','Ticket\x20created!','validateEmail','%s/api/v2/agents','length','Agent\x20found!','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','then','%s/api/v2/agents/me','Admin\x20account\x20selected.','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20created.','Basic\x20%s','toString','base64','debug','[HTTP]','stringify','GET','map','forEach','string','picklist','type','nameField','customField','toLowerCase','content','idField','push','variable','variableName'];(function(_0x4de22e,_0x4891db){var _0x51f11e=function(_0x175c6e){while(--_0x175c6e){_0x4de22e['push'](_0x4de22e['shift']());}};_0x51f11e(++_0x4891db);}(_0x671f,0xcf));var _0xf671=function(_0x2e7170,_0x187736){_0x2e7170=_0x2e7170-0x0;var _0x36f675=_0x671f[_0x2e7170];return _0x36f675;};'use strict';var _=require('lodash');var rp=require(_0xf671('0x0'));var md5=require(_0xf671('0x1'));var util=require(_0xf671('0x2'));var Redis=require(_0xf671('0x3'));var intUtil=require(_0xf671('0x4'));var config=require(_0xf671('0x5'));var logger=require(_0xf671('0x6'))(_0xf671('0x7'));config[_0xf671('0x8')]=_[_0xf671('0x9')](config[_0xf671('0x8')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf671('0x8')]));var headers={'Content-Type':'application/json','Accept':_0xf671('0xa')};function emit(_0x1721a2,_0x8e981d,_0x49ef68){io['to'](_0x1721a2)[_0xf671('0xb')](_0x8e981d,_0x49ef68);}function getTicket(_0x160c65,_0x306c66,_0xfd0b11,_0x5c7e39,_0x530d77){logger[_0xf671('0xc')](_0xf671('0xd'));var _0x40b2a5=_[_0xf671('0xe')]({'responder_id':_0x306c66['id'],'requester_id':_0xfd0b11['id'],'name':util['format'](_0xf671('0xf'),_0x530d77['calleridname']),'phone':_0x530d77[_0xf671('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xf671('0x11')](_0x5c7e39['Subjects'],_0x530d77,'\x20'),'description':intUtil[_0xf671('0x11')](_0x5c7e39[_0xf671('0x12')],_0x530d77,_0xf671('0x13')),'tags':getTags(_0x5c7e39[_0xf671('0x14')],_0xf671('0x15'))},getCustomFields(_0x5c7e39[_0xf671('0x16')],_0x530d77));_0x40b2a5[_0xf671('0x17')]=_['mapValues'](_[_0xf671('0x18')](_0x40b2a5[_0xf671('0x17')],'id'),_0xf671('0x19'));return request({'uri':util[_0xf671('0x1a')]('%s/api/v2/tickets',_0x160c65[_0xf671('0x1b')]),'method':'POST','body':_0x40b2a5})['then'](function(_0x5a6807){logger[_0xf671('0xc')](_0xf671('0x1c'));return _0x5a6807;});}function getUser(_0x48abbd,_0x435f94){if(intUtil[_0xf671('0x1d')](_0x435f94)){return request({'uri':util['format'](_0xf671('0x1e'),_0x48abbd['remoteUri']),'qs':{'email':_0x435f94}})['then'](function(_0xd1a60f){if(_0xd1a60f[_0xf671('0x1f')]){logger[_0xf671('0xc')](_0xf671('0x20'));return _[_0xf671('0x21')](_0xd1a60f,function(_0x5c1604){return _0x5c1604[_0xf671('0x22')][_0xf671('0x23')]===_0x435f94;});}else{logger[_0xf671('0xc')](_0xf671('0x24'));return request({'uri':util[_0xf671('0x1a')]('%s/api/v2/agents/me',_0x48abbd['remoteUri'])})[_0xf671('0x25')](function(_0x48d7df){logger[_0xf671('0xc')]('Admin\x20account\x20selected.');return _0x48d7df;});}});}else{logger[_0xf671('0xc')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0xf671('0x26'),_0x48abbd[_0xf671('0x1b')])})[_0xf671('0x25')](function(_0x30c7d6){logger[_0xf671('0xc')](_0xf671('0x27'));return _0x30c7d6;});}}function getEndUser(_0x7dcaa5,_0x5b3db2,_0x39be40){logger[_0xf671('0xc')]('Searching\x20enduser\x20with\x20phone',_0x39be40);return request({'uri':util['format'](_0xf671('0x28'),_0x7dcaa5['remoteUri']),'qs':{'phone':_0x39be40}})[_0xf671('0x25')](function(_0x2fb32c){if(_0x2fb32c['length']){logger[_0xf671('0xc')](_0xf671('0x29'));return _[_0xf671('0x21')](_0x2fb32c,{'phone':_0x39be40});}else{logger[_0xf671('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util['format'](_0xf671('0x28'),_0x7dcaa5[_0xf671('0x1b')]),'method':'POST','body':{'name':_0x5b3db2,'phone':_0x39be40}})['then'](function(_0x5c4b62){logger[_0xf671('0xc')](_0xf671('0x2a'));return _0x5c4b62;});}});}function getAuth(_0xf5da00){return util[_0xf671('0x1a')](_0xf671('0x2b'),new Buffer(_0xf5da00['apiKey']+':X')[_0xf671('0x2c')](_0xf671('0x2d')));}function request(_0x167a9b){logger[_0xf671('0x2e')](_0xf671('0x2f'),JSON[_0xf671('0x30')](_0x167a9b));return rp(_['defaults'](_0x167a9b,{'method':_0xf671('0x31'),'headers':headers,'json':!![]}));}function getTags(_0x3763ee,_0x4d439f){var _0x5d7ee3=[];if(_0x3763ee&&_0x3763ee[_0xf671('0x1f')]>0x0){_0x5d7ee3=_[_0xf671('0x32')](_0x3763ee,_0x4d439f);}return _0x5d7ee3;}function getCustomFields(_0x1e65b6,_0x203771){var _0x244f21=[];var _0x499a38={'custom_fields':[]};if(_0x1e65b6['length']>0x0){_[_0xf671('0x33')](_0x1e65b6,function(_0x1278eb){if(_['includes']([_0xf671('0x34'),_0xf671('0x35')],_0x1278eb[_0xf671('0x36')])&&_0x1278eb[_0xf671('0x37')]&&!_0x1278eb[_0xf671('0x38')]){_0x499a38[_0x1278eb['nameField'][_0xf671('0x39')]()]=_0x1278eb[_0xf671('0x3a')]['toString']();}else if(_['includes']([_0xf671('0x34'),_0xf671('0x35')],_0x1278eb[_0xf671('0x36')])&&_0x1278eb[_0xf671('0x3b')]&&_0x1278eb[_0xf671('0x38')]){_0x499a38[_0xf671('0x17')][_0xf671('0x3c')]({'id':_0x1278eb[_0xf671('0x3b')],'value':_0x1278eb['content'][_0xf671('0x2c')]()});}else if(_0x1278eb[_0xf671('0x36')]===_0xf671('0x3d')&&_0x1278eb[_0xf671('0x3e')]&&_0x1278eb[_0xf671('0x3b')]&&_0x1278eb[_0xf671('0x38')]){_0x203771[_0x1278eb['variableName']]&&_0x499a38['custom_fields'][_0xf671('0x3c')]({'id':_0x1278eb[_0xf671('0x3b')],'value':_0x203771[_0x1278eb[_0xf671('0x3e')]]['toString']()});}else if(_0x1278eb['type']===_0xf671('0x3f')&&_0x1278eb[_0xf671('0x40')]&&_0x1278eb[_0xf671('0x40')][_0xf671('0x15')]&&_0x1278eb[_0xf671('0x3b')]&&_0x1278eb[_0xf671('0x38')]){_0x203771[_0x1278eb[_0xf671('0x40')]['name'][_0xf671('0x39')]()]&&_0x499a38['custom_fields']['push']({'id':_0x1278eb['idField'],'value':_0x203771[_0x1278eb[_0xf671('0x40')][_0xf671('0x15')][_0xf671('0x39')]()][_0xf671('0x2c')]()});}});}return _0x499a38;}exports[_0xf671('0x41')]=function(_0x132394,_0x2923f7,_0x2da5c2,_0x1c79ea,_0x185c5c,_0xa8dc20){var _0x44e7a2,_0x54b78e;_0xa8dc20[_0xf671('0x1b')]=intUtil[_0xf671('0x42')](_0xa8dc20['remoteUri']);_0xa8dc20['serverUrl']=intUtil[_0xf671('0x42')](_0xa8dc20[_0xf671('0x43')]);if(_0x185c5c&&_0x185c5c[_0xf671('0x44')]){logger[_0xf671('0xc')](_0xf671('0x45'),'Recording\x20is\x20enabled!');_0x2923f7['recordingURL']=util['format'](_0xf671('0x46'),_0xa8dc20['serverUrl'],_0x2923f7[_0xf671('0x47')],md5(_0x2923f7[_0xf671('0x47')]));}else{_0x2923f7[_0xf671('0x48')]='';}headers['Authorization']=getAuth(_0xa8dc20);return getUser(_0xa8dc20,_0x1c79ea[_0xf671('0x23')])[_0xf671('0x25')](function(_0x2c7778){_0x44e7a2=_0x2c7778;logger[_0xf671('0xc')](_0xf671('0x49'),_0x44e7a2['id']);return getEndUser(_0xa8dc20,_0x2923f7[_0xf671('0x4a')],_0x2923f7[_0xf671('0x10')]);})[_0xf671('0x25')](function(_0x16f97c){_0x54b78e=_0x16f97c;logger[_0xf671('0xc')]('The\x20Enduser\x20ID\x20is:',_0x54b78e['id']);return getTicket(_0xa8dc20,_0x44e7a2,_0x54b78e,_0x2da5c2,_0x2923f7);})[_0xf671('0x25')](function(_0x1a0130){if(_0x1a0130&&_0x1a0130['id']){logger['info'](_0xf671('0x1c'));logger[_0xf671('0xc')](_0xf671('0x4b'),_0x1a0130['id']);logger['info'](_0xf671('0x45'),_0xf671('0x4c'));emit(util['format'](_0xf671('0x4d'),_0x1c79ea['name']),_0xf671('0x4e'),{'uri':util[_0xf671('0x1a')](_0xf671('0x4f'),_0xa8dc20[_0xf671('0x1b')],_0x1a0130['id'])});}})[_0xf671('0x50')](function(_0x37d351){logger[_0xf671('0x51')]('[QUEUE]',JSON['stringify'](_0x37d351));});};exports[_0xf671('0x52')]=function(_0x234c3e,_0x251ec5,_0x518a9f,_0x1da416,_0x313eb2,_0x3111a0,_0x3ebcca){var _0x40795a,_0x4fb328;_0x3111a0[_0xf671('0x1b')]=intUtil[_0xf671('0x42')](_0x3111a0[_0xf671('0x1b')]);_0x3111a0[_0xf671('0x43')]=intUtil[_0xf671('0x42')](_0x3111a0[_0xf671('0x43')]);if(_0x3ebcca&&_0x3ebcca[_0xf671('0x53')]&&_0x3ebcca[_0xf671('0x53')]!=='none'){logger[_0xf671('0xc')](_0xf671('0x54'),_0xf671('0x55'));_0x251ec5[_0xf671('0x48')]=util[_0xf671('0x1a')](_0xf671('0x46'),_0x3111a0[_0xf671('0x43')],_0x251ec5[_0xf671('0x47')],md5(_0x251ec5[_0xf671('0x47')]));}headers['Authorization']=getAuth(_0x3111a0);return getUser(_0x3111a0,_0x1da416[_0xf671('0x23')])[_0xf671('0x25')](function(_0x5c0be4){_0x40795a=_0x5c0be4;logger[_0xf671('0xc')]('The\x20User\x20ID\x20is:',_0x40795a['id']);return getEndUser(_0x3111a0,_0x251ec5['destcalleridname'],_0x251ec5['destcalleridnum']);})[_0xf671('0x25')](function(_0x43bc4c){_0x4fb328=_0x43bc4c;logger['info']('The\x20Enduser\x20ID\x20is:',_0x4fb328['id']);return getTicket(_0x3111a0,_0x40795a,_0x4fb328,_0x518a9f,_0x251ec5);})[_0xf671('0x25')](function(_0x31e75f){if(_0x31e75f&&_0x31e75f['id']){logger['info']('Ticket\x20created!');logger[_0xf671('0xc')](_0xf671('0x4b'),_0x31e75f['id']);logger[_0xf671('0xc')](_0xf671('0x54'),_0xf671('0x4c'));emit(util[_0xf671('0x1a')](_0xf671('0x4d'),_0x1da416[_0xf671('0x15')]),_0xf671('0x4e'),{'uri':util['format'](_0xf671('0x4f'),_0x3111a0[_0xf671('0x1b')],_0x31e75f['id'])});}})[_0xf671('0x50')](function(_0x148df6){logger[_0xf671('0x51')]('[OUTBOUND]',JSON[_0xf671('0x30')](_0x148df6));});};exports[_0xf671('0x56')]=function(_0xeecf93,_0x423bc7,_0x46d6a9,_0x153caa,_0x21230e,_0x381372){var _0x2b81a1,_0x45b0c7;_0x381372[_0xf671('0x1b')]=intUtil[_0xf671('0x42')](_0x381372[_0xf671('0x1b')]);_0x381372[_0xf671('0x43')]=intUtil['stripTrailingSlash'](_0x381372['serverUrl']);if(_0x21230e&&_0x21230e[_0xf671('0x44')]){logger[_0xf671('0xc')]('['+_0x423bc7[_0xf671('0x57')]['toUpperCase']()+']',_0xf671('0x55'));_0x423bc7[_0xf671('0x48')]=util[_0xf671('0x1a')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x381372[_0xf671('0x43')],_0x423bc7['uniqueid'],md5(_0x423bc7[_0xf671('0x47')]));}else{_0x423bc7['recordingURL']='';}headers['Authorization']=getAuth(_0x381372);return getUser(_0x381372,'')[_0xf671('0x25')](function(_0x31ee88){_0x2b81a1=_0x31ee88;logger[_0xf671('0xc')](_0xf671('0x49'),_0x2b81a1['id']);return getEndUser(_0x381372,_0x423bc7[_0xf671('0x4a')],_0x423bc7['calleridnum']);})[_0xf671('0x25')](function(_0x1f0648){_0x45b0c7=_0x1f0648;logger[_0xf671('0xc')](_0xf671('0x58'),_0x45b0c7['id']);return getTicket(_0x381372,_0x2b81a1,_0x45b0c7,_0x46d6a9,_0x423bc7);})['then'](function(_0x3f9036){if(_0x3f9036){logger[_0xf671('0xc')](_0xf671('0x1c'));logger[_0xf671('0xc')](_0xf671('0x4b'),_0x3f9036['id']);}})[_0xf671('0x50')](function(_0x4ba7cf){logger[_0xf671('0x51')]('['+_0x423bc7[_0xf671('0x57')][_0xf671('0x59')]()+']',JSON[_0xf671('0x30')](_0x4ba7cf));});};
\ No newline at end of file
+var _0xf8f3=['util','ioredis','./util','../../../../config/environment','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','emit','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridnum','getString','Descriptions','<br>','Tags','Fields','custom_fields','value','remoteUri','info','validateEmail','%s/api/v2/agents','Agent\x20found!','find','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Admin\x20account\x20selected.','then','%s/api/v2/contacts','length','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Enduser\x20created.','base64','debug','[HTTP]','stringify','GET','map','forEach','includes','string','picklist','type','nameField','customField','toLowerCase','content','idField','toString','variable','variableName','customVariable','Variable','name','push','queue','stripTrailingSlash','serverUrl','monitor_format','Recording\x20is\x20enabled!','uniqueid','Authorization','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','[QUEUE]','%s/helpdesk/tickets/%d','catch','error','recordingFormat','none','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','destcalleridnum','[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','toUpperCase','recordingURL','calleridname','lodash','request-promise','md5'];(function(_0x26df48,_0x22aa50){var _0x209047=function(_0x1d068b){while(--_0x1d068b){_0x26df48['push'](_0x26df48['shift']());}};_0x209047(++_0x22aa50);}(_0xf8f3,0xb1));var _0x3f8f=function(_0x4f22c8,_0x5c5252){_0x4f22c8=_0x4f22c8-0x0;var _0x516ef5=_0xf8f3[_0x4f22c8];return _0x516ef5;};'use strict';var _=require(_0x3f8f('0x0'));var rp=require(_0x3f8f('0x1'));var md5=require(_0x3f8f('0x2'));var util=require(_0x3f8f('0x3'));var Redis=require(_0x3f8f('0x4'));var intUtil=require(_0x3f8f('0x5'));var config=require(_0x3f8f('0x6'));var logger=require('../../../../config/logger')(_0x3f8f('0x7'));config[_0x3f8f('0x8')]=_[_0x3f8f('0x9')](config[_0x3f8f('0x8')],{'host':_0x3f8f('0xa'),'port':0x18eb});var io=require(_0x3f8f('0xb'))(new Redis(config['redis']));var headers={'Content-Type':'application/json','Accept':_0x3f8f('0xc')};function emit(_0x4e6225,_0xec1da7,_0x26c036){io['to'](_0x4e6225)[_0x3f8f('0xd')](_0xec1da7,_0x26c036);}function getTicket(_0x277dd0,_0xb964e7,_0x4be6ff,_0x4621c4,_0x168920){logger['info'](_0x3f8f('0xe'));var _0x56d77c=_[_0x3f8f('0xf')]({'responder_id':_0xb964e7['id'],'requester_id':_0x4be6ff['id'],'name':util[_0x3f8f('0x10')](_0x3f8f('0x11'),_0x168920['calleridname']),'phone':_0x168920[_0x3f8f('0x12')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0x4621c4['Subjects'],_0x168920,'\x20'),'description':intUtil[_0x3f8f('0x13')](_0x4621c4[_0x3f8f('0x14')],_0x168920,_0x3f8f('0x15')),'tags':getTags(_0x4621c4[_0x3f8f('0x16')],'name')},getCustomFields(_0x4621c4[_0x3f8f('0x17')],_0x168920));_0x56d77c[_0x3f8f('0x18')]=_['mapValues'](_['keyBy'](_0x56d77c['custom_fields'],'id'),_0x3f8f('0x19'));return request({'uri':util[_0x3f8f('0x10')]('%s/api/v2/tickets',_0x277dd0[_0x3f8f('0x1a')]),'method':'POST','body':_0x56d77c})['then'](function(_0x22cb18){logger[_0x3f8f('0x1b')]('Ticket\x20created!');return _0x22cb18;});}function getUser(_0x8ee1f6,_0x259515){if(intUtil[_0x3f8f('0x1c')](_0x259515)){return request({'uri':util[_0x3f8f('0x10')](_0x3f8f('0x1d'),_0x8ee1f6['remoteUri']),'qs':{'email':_0x259515}})['then'](function(_0x349e9c){if(_0x349e9c['length']){logger[_0x3f8f('0x1b')](_0x3f8f('0x1e'));return _[_0x3f8f('0x1f')](_0x349e9c,function(_0x35cc15){return _0x35cc15['contact'][_0x3f8f('0x20')]===_0x259515;});}else{logger[_0x3f8f('0x1b')](_0x3f8f('0x21'));return request({'uri':util[_0x3f8f('0x10')](_0x3f8f('0x22'),_0x8ee1f6['remoteUri'])})['then'](function(_0x561a88){logger[_0x3f8f('0x1b')](_0x3f8f('0x23'));return _0x561a88;});}});}else{logger[_0x3f8f('0x1b')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x3f8f('0x22'),_0x8ee1f6[_0x3f8f('0x1a')])})[_0x3f8f('0x24')](function(_0x13c261){logger[_0x3f8f('0x1b')](_0x3f8f('0x23'));return _0x13c261;});}}function getEndUser(_0x569f42,_0x524876,_0x527953){logger['info']('Searching\x20enduser\x20with\x20phone',_0x527953);return request({'uri':util[_0x3f8f('0x10')](_0x3f8f('0x25'),_0x569f42['remoteUri']),'qs':{'phone':_0x527953}})['then'](function(_0x352b32){if(_0x352b32[_0x3f8f('0x26')]){logger[_0x3f8f('0x1b')](_0x3f8f('0x27'));return _['find'](_0x352b32,{'phone':_0x527953});}else{logger['info'](_0x3f8f('0x28'));return request({'uri':util[_0x3f8f('0x10')]('%s/api/v2/contacts',_0x569f42[_0x3f8f('0x1a')]),'method':_0x3f8f('0x29'),'body':{'name':_0x524876,'phone':_0x527953}})[_0x3f8f('0x24')](function(_0x3b7779){logger[_0x3f8f('0x1b')](_0x3f8f('0x2a'));return _0x3b7779;});}});}function getAuth(_0x42f27d){return util['format']('Basic\x20%s',new Buffer(_0x42f27d['apiKey']+':X')['toString'](_0x3f8f('0x2b')));}function request(_0x10f151){logger[_0x3f8f('0x2c')](_0x3f8f('0x2d'),JSON[_0x3f8f('0x2e')](_0x10f151));return rp(_[_0x3f8f('0x9')](_0x10f151,{'method':_0x3f8f('0x2f'),'headers':headers,'json':!![]}));}function getTags(_0x27ce0d,_0x1f54f5){var _0x2567ce=[];if(_0x27ce0d&&_0x27ce0d[_0x3f8f('0x26')]>0x0){_0x2567ce=_[_0x3f8f('0x30')](_0x27ce0d,_0x1f54f5);}return _0x2567ce;}function getCustomFields(_0x9ffd73,_0x16f8cc){var _0x1b0d68=[];var _0x2d5da5={'custom_fields':[]};if(_0x9ffd73[_0x3f8f('0x26')]>0x0){_[_0x3f8f('0x31')](_0x9ffd73,function(_0x46ab89){if(_[_0x3f8f('0x32')]([_0x3f8f('0x33'),_0x3f8f('0x34')],_0x46ab89[_0x3f8f('0x35')])&&_0x46ab89[_0x3f8f('0x36')]&&!_0x46ab89[_0x3f8f('0x37')]){_0x2d5da5[_0x46ab89[_0x3f8f('0x36')][_0x3f8f('0x38')]()]=_0x46ab89[_0x3f8f('0x39')]['toString']();}else if(_[_0x3f8f('0x32')]([_0x3f8f('0x33'),_0x3f8f('0x34')],_0x46ab89[_0x3f8f('0x35')])&&_0x46ab89[_0x3f8f('0x3a')]&&_0x46ab89[_0x3f8f('0x37')]){_0x2d5da5['custom_fields']['push']({'id':_0x46ab89[_0x3f8f('0x3a')],'value':_0x46ab89[_0x3f8f('0x39')][_0x3f8f('0x3b')]()});}else if(_0x46ab89[_0x3f8f('0x35')]===_0x3f8f('0x3c')&&_0x46ab89[_0x3f8f('0x3d')]&&_0x46ab89[_0x3f8f('0x3a')]&&_0x46ab89['customField']){_0x16f8cc[_0x46ab89[_0x3f8f('0x3d')]]&&_0x2d5da5[_0x3f8f('0x18')]['push']({'id':_0x46ab89[_0x3f8f('0x3a')],'value':_0x16f8cc[_0x46ab89[_0x3f8f('0x3d')]][_0x3f8f('0x3b')]()});}else if(_0x46ab89[_0x3f8f('0x35')]===_0x3f8f('0x3e')&&_0x46ab89[_0x3f8f('0x3f')]&&_0x46ab89[_0x3f8f('0x3f')][_0x3f8f('0x40')]&&_0x46ab89['idField']&&_0x46ab89['customField']){_0x16f8cc[_0x46ab89[_0x3f8f('0x3f')][_0x3f8f('0x40')][_0x3f8f('0x38')]()]&&_0x2d5da5[_0x3f8f('0x18')][_0x3f8f('0x41')]({'id':_0x46ab89['idField'],'value':_0x16f8cc[_0x46ab89['Variable'][_0x3f8f('0x40')][_0x3f8f('0x38')]()][_0x3f8f('0x3b')]()});}});}return _0x2d5da5;}exports[_0x3f8f('0x42')]=function(_0x25c89f,_0x107518,_0x3eb467,_0x526450,_0x4634b2,_0x2205c7){var _0x27bdb6,_0x178bb5;_0x2205c7[_0x3f8f('0x1a')]=intUtil[_0x3f8f('0x43')](_0x2205c7[_0x3f8f('0x1a')]);_0x2205c7['serverUrl']=intUtil[_0x3f8f('0x43')](_0x2205c7[_0x3f8f('0x44')]);if(_0x4634b2&&_0x4634b2[_0x3f8f('0x45')]){logger[_0x3f8f('0x1b')]('[QUEUE]',_0x3f8f('0x46'));_0x107518['recordingURL']=util['format']('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x2205c7[_0x3f8f('0x44')],_0x107518[_0x3f8f('0x47')],md5(_0x107518[_0x3f8f('0x47')]));}else{_0x107518['recordingURL']='';}headers[_0x3f8f('0x48')]=getAuth(_0x2205c7);return getUser(_0x2205c7,_0x526450['email'])[_0x3f8f('0x24')](function(_0xc7ed3a){_0x27bdb6=_0xc7ed3a;logger[_0x3f8f('0x1b')](_0x3f8f('0x49'),_0x27bdb6['id']);return getEndUser(_0x2205c7,_0x107518['calleridname'],_0x107518['calleridnum']);})[_0x3f8f('0x24')](function(_0x260208){_0x178bb5=_0x260208;logger[_0x3f8f('0x1b')](_0x3f8f('0x4a'),_0x178bb5['id']);return getTicket(_0x2205c7,_0x27bdb6,_0x178bb5,_0x3eb467,_0x107518);})[_0x3f8f('0x24')](function(_0x362ef4){if(_0x362ef4&&_0x362ef4['id']){logger[_0x3f8f('0x1b')](_0x3f8f('0x4b'));logger['info'](_0x3f8f('0x4c'),_0x362ef4['id']);logger[_0x3f8f('0x1b')](_0x3f8f('0x4d'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format']('user:%s',_0x526450[_0x3f8f('0x40')]),'trigger:browser:url',{'uri':util[_0x3f8f('0x10')](_0x3f8f('0x4e'),_0x2205c7[_0x3f8f('0x1a')],_0x362ef4['id'])});}})[_0x3f8f('0x4f')](function(_0x38719b){logger[_0x3f8f('0x50')]('[QUEUE]',JSON[_0x3f8f('0x2e')](_0x38719b));});};exports['outbound']=function(_0xaeecbb,_0x46f5a9,_0x46870b,_0x20dbb8,_0x5d189a,_0x5b4293,_0x4467a9){var _0x1aeaf8,_0x2cbf93;_0x5b4293[_0x3f8f('0x1a')]=intUtil[_0x3f8f('0x43')](_0x5b4293[_0x3f8f('0x1a')]);_0x5b4293['serverUrl']=intUtil[_0x3f8f('0x43')](_0x5b4293[_0x3f8f('0x44')]);if(_0x4467a9&&_0x4467a9['recordingFormat']&&_0x4467a9[_0x3f8f('0x51')]!==_0x3f8f('0x52')){logger[_0x3f8f('0x1b')]('[OUTBOUND]',_0x3f8f('0x46'));_0x46f5a9['recordingURL']=util[_0x3f8f('0x10')](_0x3f8f('0x53'),_0x5b4293[_0x3f8f('0x44')],_0x46f5a9[_0x3f8f('0x47')],md5(_0x46f5a9[_0x3f8f('0x47')]));}headers[_0x3f8f('0x48')]=getAuth(_0x5b4293);return getUser(_0x5b4293,_0x20dbb8[_0x3f8f('0x20')])[_0x3f8f('0x24')](function(_0x460fda){_0x1aeaf8=_0x460fda;logger[_0x3f8f('0x1b')](_0x3f8f('0x49'),_0x1aeaf8['id']);return getEndUser(_0x5b4293,_0x46f5a9['destcalleridname'],_0x46f5a9[_0x3f8f('0x54')]);})[_0x3f8f('0x24')](function(_0x432999){_0x2cbf93=_0x432999;logger[_0x3f8f('0x1b')](_0x3f8f('0x4a'),_0x2cbf93['id']);return getTicket(_0x5b4293,_0x1aeaf8,_0x2cbf93,_0x46870b,_0x46f5a9);})[_0x3f8f('0x24')](function(_0x1eb6f9){if(_0x1eb6f9&&_0x1eb6f9['id']){logger['info'](_0x3f8f('0x4b'));logger['info'](_0x3f8f('0x4c'),_0x1eb6f9['id']);logger[_0x3f8f('0x1b')](_0x3f8f('0x55'),_0x3f8f('0x56'));emit(util[_0x3f8f('0x10')]('user:%s',_0x20dbb8[_0x3f8f('0x40')]),'trigger:browser:url',{'uri':util[_0x3f8f('0x10')](_0x3f8f('0x4e'),_0x5b4293[_0x3f8f('0x1a')],_0x1eb6f9['id'])});}})[_0x3f8f('0x4f')](function(_0x1aff67){logger[_0x3f8f('0x50')](_0x3f8f('0x55'),JSON[_0x3f8f('0x2e')](_0x1aff67));});};exports['unmanaged']=function(_0x5813d2,_0x31b52f,_0x207f22,_0x383dd0,_0x387b58,_0x403898){var _0x354385,_0x233d74;_0x403898[_0x3f8f('0x1a')]=intUtil[_0x3f8f('0x43')](_0x403898['remoteUri']);_0x403898['serverUrl']=intUtil[_0x3f8f('0x43')](_0x403898['serverUrl']);if(_0x387b58&&_0x387b58[_0x3f8f('0x45')]){logger[_0x3f8f('0x1b')]('['+_0x31b52f['lastevent'][_0x3f8f('0x57')]()+']',_0x3f8f('0x46'));_0x31b52f[_0x3f8f('0x58')]=util[_0x3f8f('0x10')](_0x3f8f('0x53'),_0x403898[_0x3f8f('0x44')],_0x31b52f['uniqueid'],md5(_0x31b52f[_0x3f8f('0x47')]));}else{_0x31b52f[_0x3f8f('0x58')]='';}headers[_0x3f8f('0x48')]=getAuth(_0x403898);return getUser(_0x403898,'')[_0x3f8f('0x24')](function(_0x1da657){_0x354385=_0x1da657;logger[_0x3f8f('0x1b')]('The\x20User\x20ID\x20is:',_0x354385['id']);return getEndUser(_0x403898,_0x31b52f[_0x3f8f('0x59')],_0x31b52f[_0x3f8f('0x12')]);})[_0x3f8f('0x24')](function(_0x3ed6a0){_0x233d74=_0x3ed6a0;logger[_0x3f8f('0x1b')](_0x3f8f('0x4a'),_0x233d74['id']);return getTicket(_0x403898,_0x354385,_0x233d74,_0x207f22,_0x31b52f);})[_0x3f8f('0x24')](function(_0x1297c5){if(_0x1297c5){logger[_0x3f8f('0x1b')](_0x3f8f('0x4b'));logger['info'](_0x3f8f('0x4c'),_0x1297c5['id']);}})[_0x3f8f('0x4f')](function(_0x377122){logger[_0x3f8f('0x50')]('['+_0x31b52f['lastevent'][_0x3f8f('0x57')]()+']',JSON[_0x3f8f('0x2e')](_0x377122));});};
\ No newline at end of file