Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index e0ff798..590b6f8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3d5c=['%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','calleridname','The\x20Ticket\x20ID\x20is:','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','outbound','stripTrailingSlash','recordingFormat','[OUTBOUND]','Recording\x20is\x20enabled!','The\x20User\x20ID\x20is:','destcalleridname','The\x20Enduser\x20ID\x20is:','unmanaged','lastevent','toUpperCase','lodash','md5','util','./util','../../../../config/logger','freshdesk','redis','localhost','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridnum','getString','Subjects','Descriptions','<br>','Tags','Fields','custom_fields','mapValues','keyBy','value','%s/api/v2/tickets','remoteUri','Ticket\x20created!','validateEmail','find','email','%s/api/v2/agents/me','then','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','length','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Enduser\x20created.','Basic\x20%s','toString','base64','debug','[HTTP]','stringify','defaults','GET','map','forEach','type','string','nameField','toLowerCase','content','idField','customField','push','variable','variableName','customVariable','Variable','name','queue','serverUrl','monitor_format','[QUEUE]','recordingURL'];(function(_0xdad237,_0x361a1d){var _0x15c575=function(_0x8db2f6){while(--_0x8db2f6){_0xdad237['push'](_0xdad237['shift']());}};_0x15c575(++_0x361a1d);}(_0x3d5c,0x6f));var _0xc3d5=function(_0x1e7517,_0x4b03c9){_0x1e7517=_0x1e7517-0x0;var _0x522f4c=_0x3d5c[_0x1e7517];return _0x522f4c;};'use strict';var _=require(_0xc3d5('0x0'));var rp=require('request-promise');var md5=require(_0xc3d5('0x1'));var util=require(_0xc3d5('0x2'));var Redis=require('ioredis');var intUtil=require(_0xc3d5('0x3'));var config=require('../../../../config/environment');var logger=require(_0xc3d5('0x4'))(_0xc3d5('0x5'));config['redis']=_['defaults'](config[_0xc3d5('0x6')],{'host':_0xc3d5('0x7'),'port':0x18eb});var io=require(_0xc3d5('0x8'))(new Redis(config[_0xc3d5('0x6')]));var headers={'Content-Type':_0xc3d5('0x9'),'Accept':'application/json'};function emit(_0x4e0050,_0x327b0c,_0x2b8fe6){io['to'](_0x4e0050)[_0xc3d5('0xa')](_0x327b0c,_0x2b8fe6);}function getTicket(_0x3cd58b,_0x5480ed,_0x3182fe,_0x137bdf,_0x4b30b4){logger[_0xc3d5('0xb')](_0xc3d5('0xc'));var _0x12e99f=_[_0xc3d5('0xd')]({'responder_id':_0x5480ed['id'],'requester_id':_0x3182fe['id'],'name':util[_0xc3d5('0xe')](_0xc3d5('0xf'),_0x4b30b4['calleridname']),'phone':_0x4b30b4[_0xc3d5('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xc3d5('0x11')](_0x137bdf[_0xc3d5('0x12')],_0x4b30b4,'\x20'),'description':intUtil['getString'](_0x137bdf[_0xc3d5('0x13')],_0x4b30b4,_0xc3d5('0x14')),'tags':getTags(_0x137bdf[_0xc3d5('0x15')],'name')},getCustomFields(_0x137bdf[_0xc3d5('0x16')],_0x4b30b4));_0x12e99f[_0xc3d5('0x17')]=_[_0xc3d5('0x18')](_[_0xc3d5('0x19')](_0x12e99f[_0xc3d5('0x17')],'id'),_0xc3d5('0x1a'));return request({'uri':util['format'](_0xc3d5('0x1b'),_0x3cd58b[_0xc3d5('0x1c')]),'method':'POST','body':_0x12e99f})['then'](function(_0x555a4f){logger['info'](_0xc3d5('0x1d'));return _0x555a4f;});}function getUser(_0x38417e,_0x2400b5){if(intUtil[_0xc3d5('0x1e')](_0x2400b5)){return request({'uri':util[_0xc3d5('0xe')]('%s/api/v2/agents',_0x38417e[_0xc3d5('0x1c')]),'qs':{'email':_0x2400b5}})['then'](function(_0x321f8c){if(_0x321f8c['length']){logger['info']('Agent\x20found!');return _[_0xc3d5('0x1f')](_0x321f8c,function(_0x42aa70){return _0x42aa70['contact'][_0xc3d5('0x20')]===_0x2400b5;});}else{logger['info']('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0xc3d5('0x21'),_0x38417e[_0xc3d5('0x1c')])})['then'](function(_0x199389){logger['info']('Admin\x20account\x20selected.');return _0x199389;});}});}else{logger[_0xc3d5('0xb')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0xc3d5('0xe')]('%s/api/v2/agents/me',_0x38417e[_0xc3d5('0x1c')])})[_0xc3d5('0x22')](function(_0x5db414){logger[_0xc3d5('0xb')](_0xc3d5('0x23'));return _0x5db414;});}}function getEndUser(_0x9f9e27,_0x2d5c12,_0x4a9564){logger[_0xc3d5('0xb')](_0xc3d5('0x24'),_0x4a9564);return request({'uri':util[_0xc3d5('0xe')]('%s/api/v2/contacts',_0x9f9e27[_0xc3d5('0x1c')]),'qs':{'phone':_0x4a9564}})['then'](function(_0x2cf2c1){if(_0x2cf2c1[_0xc3d5('0x25')]){logger['info']('Enduser\x20found!');return _[_0xc3d5('0x1f')](_0x2cf2c1,{'phone':_0x4a9564});}else{logger['info'](_0xc3d5('0x26'));return request({'uri':util[_0xc3d5('0xe')]('%s/api/v2/contacts',_0x9f9e27[_0xc3d5('0x1c')]),'method':_0xc3d5('0x27'),'body':{'name':_0x2d5c12,'phone':_0x4a9564}})[_0xc3d5('0x22')](function(_0x12e551){logger[_0xc3d5('0xb')](_0xc3d5('0x28'));return _0x12e551;});}});}function getAuth(_0xf86e03){return util['format'](_0xc3d5('0x29'),new Buffer(_0xf86e03['apiKey']+':X')[_0xc3d5('0x2a')](_0xc3d5('0x2b')));}function request(_0x313b1f){logger[_0xc3d5('0x2c')](_0xc3d5('0x2d'),JSON[_0xc3d5('0x2e')](_0x313b1f));return rp(_[_0xc3d5('0x2f')](_0x313b1f,{'method':_0xc3d5('0x30'),'headers':headers,'json':!![]}));}function getTags(_0x2acfbf,_0xffe0a2){var _0x97a7f=[];if(_0x2acfbf&&_0x2acfbf[_0xc3d5('0x25')]>0x0){_0x97a7f=_[_0xc3d5('0x31')](_0x2acfbf,_0xffe0a2);}return _0x97a7f;}function getCustomFields(_0x5328f9,_0x131a78){var _0x5b713c=[];var _0x5015bc={'custom_fields':[]};if(_0x5328f9[_0xc3d5('0x25')]>0x0){_[_0xc3d5('0x32')](_0x5328f9,function(_0x31bd51){if(_0x31bd51[_0xc3d5('0x33')]===_0xc3d5('0x34')&&_0x31bd51[_0xc3d5('0x35')]&&!_0x31bd51['customField']){_0x5015bc[_0x31bd51[_0xc3d5('0x35')][_0xc3d5('0x36')]()]=_0x31bd51[_0xc3d5('0x37')][_0xc3d5('0x2a')]();}else if(_0x31bd51['type']===_0xc3d5('0x34')&&_0x31bd51[_0xc3d5('0x38')]&&_0x31bd51[_0xc3d5('0x39')]){_0x5015bc['custom_fields'][_0xc3d5('0x3a')]({'id':_0x31bd51[_0xc3d5('0x38')],'value':_0x31bd51[_0xc3d5('0x37')][_0xc3d5('0x2a')]()});}else if(_0x31bd51[_0xc3d5('0x33')]===_0xc3d5('0x3b')&&_0x31bd51[_0xc3d5('0x3c')]&&_0x31bd51[_0xc3d5('0x38')]&&_0x31bd51[_0xc3d5('0x39')]){_0x131a78[_0x31bd51[_0xc3d5('0x3c')]]&&_0x5015bc[_0xc3d5('0x17')]['push']({'id':_0x31bd51['idField'],'value':_0x131a78[_0x31bd51[_0xc3d5('0x3c')]][_0xc3d5('0x2a')]()});}else if(_0x31bd51[_0xc3d5('0x33')]===_0xc3d5('0x3d')&&_0x31bd51[_0xc3d5('0x3e')]&&_0x31bd51['Variable']['name']&&_0x31bd51['idField']&&_0x31bd51['customField']){_0x131a78[_0x31bd51[_0xc3d5('0x3e')][_0xc3d5('0x3f')][_0xc3d5('0x36')]()]&&_0x5015bc[_0xc3d5('0x17')][_0xc3d5('0x3a')]({'id':_0x31bd51[_0xc3d5('0x38')],'value':_0x131a78[_0x31bd51[_0xc3d5('0x3e')][_0xc3d5('0x3f')]['toLowerCase']()][_0xc3d5('0x2a')]()});}});}return _0x5015bc;}exports[_0xc3d5('0x40')]=function(_0x97bd10,_0x4f00c2,_0x4253f5,_0x4e34a0,_0x4e9e0a,_0x34b904){var _0xad2d8f,_0xcb8280;_0x34b904[_0xc3d5('0x1c')]=intUtil['stripTrailingSlash'](_0x34b904[_0xc3d5('0x1c')]);_0x34b904[_0xc3d5('0x41')]=intUtil['stripTrailingSlash'](_0x34b904['serverUrl']);if(_0x4e9e0a&&_0x4e9e0a[_0xc3d5('0x42')]){logger['info'](_0xc3d5('0x43'),'Recording\x20is\x20enabled!');_0x4f00c2[_0xc3d5('0x44')]=util[_0xc3d5('0xe')](_0xc3d5('0x45'),_0x34b904['serverUrl'],_0x4f00c2[_0xc3d5('0x46')],md5(_0x4f00c2[_0xc3d5('0x46')]));}else{_0x4f00c2['recordingURL']='';}headers[_0xc3d5('0x47')]=getAuth(_0x34b904);return getUser(_0x34b904,_0x4e34a0['email'])['then'](function(_0x32382e){_0xad2d8f=_0x32382e;logger[_0xc3d5('0xb')]('The\x20User\x20ID\x20is:',_0xad2d8f['id']);return getEndUser(_0x34b904,_0x4f00c2[_0xc3d5('0x48')],_0x4f00c2[_0xc3d5('0x10')]);})[_0xc3d5('0x22')](function(_0x2a66af){_0xcb8280=_0x2a66af;logger[_0xc3d5('0xb')]('The\x20Enduser\x20ID\x20is:',_0xcb8280['id']);return getTicket(_0x34b904,_0xad2d8f,_0xcb8280,_0x4253f5,_0x4f00c2);})[_0xc3d5('0x22')](function(_0x554bb3){if(_0x554bb3&&_0x554bb3['id']){logger[_0xc3d5('0xb')](_0xc3d5('0x1d'));logger['info'](_0xc3d5('0x49'),_0x554bb3['id']);logger[_0xc3d5('0xb')](_0xc3d5('0x43'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xc3d5('0xe')](_0xc3d5('0x4a'),_0x4e34a0['name']),_0xc3d5('0x4b'),{'uri':util[_0xc3d5('0xe')](_0xc3d5('0x4c'),_0x34b904[_0xc3d5('0x1c')],_0x554bb3['id'])});}})[_0xc3d5('0x4d')](function(_0x1e055b){logger[_0xc3d5('0x4e')](_0xc3d5('0x43'),JSON[_0xc3d5('0x2e')](_0x1e055b));});};exports[_0xc3d5('0x4f')]=function(_0x6e660f,_0x5386b5,_0x38f2af,_0xbb4836,_0x18cd32,_0xcf3c96,_0x18e680){var _0xd10d6f,_0x149219;_0xcf3c96[_0xc3d5('0x1c')]=intUtil['stripTrailingSlash'](_0xcf3c96[_0xc3d5('0x1c')]);_0xcf3c96[_0xc3d5('0x41')]=intUtil[_0xc3d5('0x50')](_0xcf3c96[_0xc3d5('0x41')]);if(_0x18e680&&_0x18e680[_0xc3d5('0x51')]&&_0x18e680[_0xc3d5('0x51')]!=='none'){logger[_0xc3d5('0xb')](_0xc3d5('0x52'),_0xc3d5('0x53'));_0x5386b5[_0xc3d5('0x44')]=util[_0xc3d5('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0xcf3c96[_0xc3d5('0x41')],_0x5386b5[_0xc3d5('0x46')],md5(_0x5386b5['uniqueid']));}headers[_0xc3d5('0x47')]=getAuth(_0xcf3c96);return getUser(_0xcf3c96,_0xbb4836[_0xc3d5('0x20')])['then'](function(_0x35d1f6){_0xd10d6f=_0x35d1f6;logger[_0xc3d5('0xb')](_0xc3d5('0x54'),_0xd10d6f['id']);return getEndUser(_0xcf3c96,_0x5386b5[_0xc3d5('0x55')],_0x5386b5['destcalleridnum']);})[_0xc3d5('0x22')](function(_0x3341d6){_0x149219=_0x3341d6;logger[_0xc3d5('0xb')](_0xc3d5('0x56'),_0x149219['id']);return getTicket(_0xcf3c96,_0xd10d6f,_0x149219,_0x38f2af,_0x5386b5);})[_0xc3d5('0x22')](function(_0x57b5ba){if(_0x57b5ba&&_0x57b5ba['id']){logger['info'](_0xc3d5('0x1d'));logger[_0xc3d5('0xb')](_0xc3d5('0x49'),_0x57b5ba['id']);logger[_0xc3d5('0xb')]('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xc3d5('0xe')]('user:%s',_0xbb4836['name']),_0xc3d5('0x4b'),{'uri':util[_0xc3d5('0xe')]('%s/helpdesk/tickets/%d',_0xcf3c96[_0xc3d5('0x1c')],_0x57b5ba['id'])});}})[_0xc3d5('0x4d')](function(_0xf1b560){logger[_0xc3d5('0x4e')](_0xc3d5('0x52'),JSON[_0xc3d5('0x2e')](_0xf1b560));});};exports[_0xc3d5('0x57')]=function(_0x5becfb,_0x2c60f7,_0x418d41,_0x2c3691,_0x1dbe1c,_0xbc7398){var _0x38a1b4,_0x1c1709;_0xbc7398['remoteUri']=intUtil[_0xc3d5('0x50')](_0xbc7398['remoteUri']);_0xbc7398[_0xc3d5('0x41')]=intUtil[_0xc3d5('0x50')](_0xbc7398[_0xc3d5('0x41')]);if(_0x1dbe1c&&_0x1dbe1c[_0xc3d5('0x42')]){logger[_0xc3d5('0xb')]('['+_0x2c60f7[_0xc3d5('0x58')][_0xc3d5('0x59')]()+']',_0xc3d5('0x53'));_0x2c60f7[_0xc3d5('0x44')]=util[_0xc3d5('0xe')](_0xc3d5('0x45'),_0xbc7398[_0xc3d5('0x41')],_0x2c60f7['uniqueid'],md5(_0x2c60f7['uniqueid']));}else{_0x2c60f7[_0xc3d5('0x44')]='';}headers['Authorization']=getAuth(_0xbc7398);return getUser(_0xbc7398,'')['then'](function(_0x54eaa1){_0x38a1b4=_0x54eaa1;logger['info'](_0xc3d5('0x54'),_0x38a1b4['id']);return getEndUser(_0xbc7398,_0x2c60f7[_0xc3d5('0x48')],_0x2c60f7['calleridnum']);})[_0xc3d5('0x22')](function(_0x12ab53){_0x1c1709=_0x12ab53;logger[_0xc3d5('0xb')](_0xc3d5('0x56'),_0x1c1709['id']);return getTicket(_0xbc7398,_0x38a1b4,_0x1c1709,_0x418d41,_0x2c60f7);})[_0xc3d5('0x22')](function(_0x1dcce1){if(_0x1dcce1){logger[_0xc3d5('0xb')](_0xc3d5('0x1d'));logger[_0xc3d5('0xb')](_0xc3d5('0x49'),_0x1dcce1['id']);}})[_0xc3d5('0x4d')](function(_0x40fc23){logger[_0xc3d5('0x4e')]('['+_0x2c60f7[_0xc3d5('0x58')][_0xc3d5('0x59')]()+']',JSON[_0xc3d5('0x2e')](_0x40fc23));});};
\ No newline at end of file
+var _0x70f6=['mapValues','value','%s/api/v2/tickets','remoteUri','POST','then','validateEmail','%s/api/v2/agents','length','Agent\x20found!','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20found!','Basic\x20%s','apiKey','toString','base64','stringify','defaults','GET','map','forEach','includes','string','picklist','type','nameField','customField','toLowerCase','content','idField','variable','variableName','push','customVariable','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','recordingURL','Authorization','The\x20User\x20ID\x20is:','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','user:%s','%s/helpdesk/tickets/%d','error','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','destcalleridname','trigger:browser:url','catch','unmanaged','lastevent','toUpperCase','The\x20Enduser\x20ID\x20is:','request-promise','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','localhost','socket.io-emitter','application/json','info','merge','format','Caller\x20-\x20%s','calleridname','calleridnum','getString','Descriptions','<br>','Tags','name','Fields','custom_fields'];(function(_0x3d4876,_0x366386){var _0x58ca9d=function(_0x5bd045){while(--_0x5bd045){_0x3d4876['push'](_0x3d4876['shift']());}};_0x58ca9d(++_0x366386);}(_0x70f6,0x101));var _0x670f=function(_0x4f32de,_0x5bd4a){_0x4f32de=_0x4f32de-0x0;var _0x149821=_0x70f6[_0x4f32de];return _0x149821;};'use strict';var _=require('lodash');var rp=require(_0x670f('0x0'));var md5=require(_0x670f('0x1'));var util=require(_0x670f('0x2'));var Redis=require(_0x670f('0x3'));var intUtil=require(_0x670f('0x4'));var config=require(_0x670f('0x5'));var logger=require(_0x670f('0x6'))(_0x670f('0x7'));config['redis']=_['defaults'](config[_0x670f('0x8')],{'host':_0x670f('0x9'),'port':0x18eb});var io=require(_0x670f('0xa'))(new Redis(config[_0x670f('0x8')]));var headers={'Content-Type':'application/json','Accept':_0x670f('0xb')};function emit(_0x54d67c,_0x5cafc8,_0x16cafd){io['to'](_0x54d67c)['emit'](_0x5cafc8,_0x16cafd);}function getTicket(_0x81f4ed,_0x80b44f,_0x4964dc,_0x568e14,_0x11f668){logger[_0x670f('0xc')]('Creating\x20new\x20ticket...');var _0x49d9f0=_[_0x670f('0xd')]({'responder_id':_0x80b44f['id'],'requester_id':_0x4964dc['id'],'name':util[_0x670f('0xe')](_0x670f('0xf'),_0x11f668[_0x670f('0x10')]),'phone':_0x11f668[_0x670f('0x11')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0x568e14['Subjects'],_0x11f668,'\x20'),'description':intUtil[_0x670f('0x12')](_0x568e14[_0x670f('0x13')],_0x11f668,_0x670f('0x14')),'tags':getTags(_0x568e14[_0x670f('0x15')],_0x670f('0x16'))},getCustomFields(_0x568e14[_0x670f('0x17')],_0x11f668));_0x49d9f0[_0x670f('0x18')]=_[_0x670f('0x19')](_['keyBy'](_0x49d9f0[_0x670f('0x18')],'id'),_0x670f('0x1a'));return request({'uri':util[_0x670f('0xe')](_0x670f('0x1b'),_0x81f4ed[_0x670f('0x1c')]),'method':_0x670f('0x1d'),'body':_0x49d9f0})[_0x670f('0x1e')](function(_0x3f512e){logger[_0x670f('0xc')]('Ticket\x20created!');return _0x3f512e;});}function getUser(_0x2f12cc,_0x34cf89){if(intUtil[_0x670f('0x1f')](_0x34cf89)){return request({'uri':util[_0x670f('0xe')](_0x670f('0x20'),_0x2f12cc[_0x670f('0x1c')]),'qs':{'email':_0x34cf89}})['then'](function(_0x320e4e){if(_0x320e4e[_0x670f('0x21')]){logger['info'](_0x670f('0x22'));return _[_0x670f('0x23')](_0x320e4e,function(_0x472603){return _0x472603[_0x670f('0x24')][_0x670f('0x25')]===_0x34cf89;});}else{logger['info'](_0x670f('0x26'));return request({'uri':util[_0x670f('0xe')](_0x670f('0x27'),_0x2f12cc['remoteUri'])})[_0x670f('0x1e')](function(_0x5ac16e){logger[_0x670f('0xc')](_0x670f('0x28'));return _0x5ac16e;});}});}else{logger['info'](_0x670f('0x29'));return request({'uri':util[_0x670f('0xe')](_0x670f('0x27'),_0x2f12cc[_0x670f('0x1c')])})[_0x670f('0x1e')](function(_0x25085e){logger[_0x670f('0xc')]('Admin\x20account\x20selected.');return _0x25085e;});}}function getEndUser(_0x49c5f9,_0x2e5dcb,_0x20a022){logger[_0x670f('0xc')](_0x670f('0x2a'),_0x20a022);return request({'uri':util[_0x670f('0xe')](_0x670f('0x2b'),_0x49c5f9['remoteUri']),'qs':{'phone':_0x20a022}})[_0x670f('0x1e')](function(_0x176d87){if(_0x176d87[_0x670f('0x21')]){logger[_0x670f('0xc')](_0x670f('0x2c'));return _[_0x670f('0x23')](_0x176d87,{'phone':_0x20a022});}else{logger[_0x670f('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0x670f('0xe')](_0x670f('0x2b'),_0x49c5f9[_0x670f('0x1c')]),'method':_0x670f('0x1d'),'body':{'name':_0x2e5dcb,'phone':_0x20a022}})[_0x670f('0x1e')](function(_0x177216){logger[_0x670f('0xc')]('Enduser\x20created.');return _0x177216;});}});}function getAuth(_0x3bc88e){return util['format'](_0x670f('0x2d'),new Buffer(_0x3bc88e[_0x670f('0x2e')]+':X')[_0x670f('0x2f')](_0x670f('0x30')));}function request(_0x3342f3){logger['debug']('[HTTP]',JSON[_0x670f('0x31')](_0x3342f3));return rp(_[_0x670f('0x32')](_0x3342f3,{'method':_0x670f('0x33'),'headers':headers,'json':!![]}));}function getTags(_0x481e4b,_0x3ec580){var _0x3b9304=[];if(_0x481e4b&&_0x481e4b[_0x670f('0x21')]>0x0){_0x3b9304=_[_0x670f('0x34')](_0x481e4b,_0x3ec580);}return _0x3b9304;}function getCustomFields(_0x49b85b,_0x4d6dbb){var _0x56ce28=[];var _0x3562be={'custom_fields':[]};if(_0x49b85b['length']>0x0){_[_0x670f('0x35')](_0x49b85b,function(_0x3af5a5){if(_[_0x670f('0x36')]([_0x670f('0x37'),_0x670f('0x38')],_0x3af5a5[_0x670f('0x39')])&&_0x3af5a5[_0x670f('0x3a')]&&!_0x3af5a5[_0x670f('0x3b')]){_0x3562be[_0x3af5a5['nameField'][_0x670f('0x3c')]()]=_0x3af5a5[_0x670f('0x3d')]['toString']();}else if(_['includes']([_0x670f('0x37'),'picklist'],_0x3af5a5[_0x670f('0x39')])&&_0x3af5a5[_0x670f('0x3e')]&&_0x3af5a5['customField']){_0x3562be['custom_fields']['push']({'id':_0x3af5a5[_0x670f('0x3e')],'value':_0x3af5a5[_0x670f('0x3d')]['toString']()});}else if(_0x3af5a5[_0x670f('0x39')]===_0x670f('0x3f')&&_0x3af5a5[_0x670f('0x40')]&&_0x3af5a5[_0x670f('0x3e')]&&_0x3af5a5[_0x670f('0x3b')]){_0x4d6dbb[_0x3af5a5['variableName']]&&_0x3562be[_0x670f('0x18')][_0x670f('0x41')]({'id':_0x3af5a5[_0x670f('0x3e')],'value':_0x4d6dbb[_0x3af5a5['variableName']][_0x670f('0x2f')]()});}else if(_0x3af5a5['type']===_0x670f('0x42')&&_0x3af5a5[_0x670f('0x43')]&&_0x3af5a5['Variable'][_0x670f('0x16')]&&_0x3af5a5[_0x670f('0x3e')]&&_0x3af5a5['customField']){_0x4d6dbb[_0x3af5a5[_0x670f('0x43')][_0x670f('0x16')][_0x670f('0x3c')]()]&&_0x3562be[_0x670f('0x18')][_0x670f('0x41')]({'id':_0x3af5a5[_0x670f('0x3e')],'value':_0x4d6dbb[_0x3af5a5[_0x670f('0x43')]['name']['toLowerCase']()][_0x670f('0x2f')]()});}});}return _0x3562be;}exports[_0x670f('0x44')]=function(_0x29c660,_0x1a0fed,_0x5f42f0,_0x4e45b9,_0x230975,_0x4f19ff){var _0x4bdd2f,_0x2d7553;_0x4f19ff[_0x670f('0x1c')]=intUtil[_0x670f('0x45')](_0x4f19ff[_0x670f('0x1c')]);_0x4f19ff[_0x670f('0x46')]=intUtil[_0x670f('0x45')](_0x4f19ff[_0x670f('0x46')]);if(_0x230975&&_0x230975[_0x670f('0x47')]){logger[_0x670f('0xc')](_0x670f('0x48'),'Recording\x20is\x20enabled!');_0x1a0fed['recordingURL']=util['format'](_0x670f('0x49'),_0x4f19ff[_0x670f('0x46')],_0x1a0fed['uniqueid'],md5(_0x1a0fed[_0x670f('0x4a')]));}else{_0x1a0fed[_0x670f('0x4b')]='';}headers[_0x670f('0x4c')]=getAuth(_0x4f19ff);return getUser(_0x4f19ff,_0x4e45b9['email'])['then'](function(_0x1f785a){_0x4bdd2f=_0x1f785a;logger['info'](_0x670f('0x4d'),_0x4bdd2f['id']);return getEndUser(_0x4f19ff,_0x1a0fed[_0x670f('0x10')],_0x1a0fed[_0x670f('0x11')]);})[_0x670f('0x1e')](function(_0x3e1088){_0x2d7553=_0x3e1088;logger['info']('The\x20Enduser\x20ID\x20is:',_0x2d7553['id']);return getTicket(_0x4f19ff,_0x4bdd2f,_0x2d7553,_0x5f42f0,_0x1a0fed);})[_0x670f('0x1e')](function(_0x5a4147){if(_0x5a4147&&_0x5a4147['id']){logger[_0x670f('0xc')](_0x670f('0x4e'));logger[_0x670f('0xc')](_0x670f('0x4f'),_0x5a4147['id']);logger[_0x670f('0xc')](_0x670f('0x48'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x670f('0xe')](_0x670f('0x50'),_0x4e45b9[_0x670f('0x16')]),'trigger:browser:url',{'uri':util[_0x670f('0xe')](_0x670f('0x51'),_0x4f19ff['remoteUri'],_0x5a4147['id'])});}})['catch'](function(_0x264d3c){logger[_0x670f('0x52')]('[QUEUE]',JSON[_0x670f('0x31')](_0x264d3c));});};exports['outbound']=function(_0x1349e9,_0x3c40b9,_0x3ddaea,_0x5bf1d8,_0x4fda2c,_0x2697c7,_0xc49b21){var _0x2af036,_0x34b7bd;_0x2697c7['remoteUri']=intUtil[_0x670f('0x45')](_0x2697c7[_0x670f('0x1c')]);_0x2697c7['serverUrl']=intUtil['stripTrailingSlash'](_0x2697c7[_0x670f('0x46')]);if(_0xc49b21&&_0xc49b21[_0x670f('0x53')]&&_0xc49b21[_0x670f('0x53')]!==_0x670f('0x54')){logger[_0x670f('0xc')](_0x670f('0x55'),_0x670f('0x56'));_0x3c40b9[_0x670f('0x4b')]=util[_0x670f('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x2697c7[_0x670f('0x46')],_0x3c40b9[_0x670f('0x4a')],md5(_0x3c40b9[_0x670f('0x4a')]));}headers[_0x670f('0x4c')]=getAuth(_0x2697c7);return getUser(_0x2697c7,_0x5bf1d8[_0x670f('0x25')])[_0x670f('0x1e')](function(_0x57a14a){_0x2af036=_0x57a14a;logger[_0x670f('0xc')]('The\x20User\x20ID\x20is:',_0x2af036['id']);return getEndUser(_0x2697c7,_0x3c40b9[_0x670f('0x57')],_0x3c40b9['destcalleridnum']);})['then'](function(_0x9c0ef3){_0x34b7bd=_0x9c0ef3;logger[_0x670f('0xc')]('The\x20Enduser\x20ID\x20is:',_0x34b7bd['id']);return getTicket(_0x2697c7,_0x2af036,_0x34b7bd,_0x3ddaea,_0x3c40b9);})['then'](function(_0x177be9){if(_0x177be9&&_0x177be9['id']){logger[_0x670f('0xc')]('Ticket\x20created!');logger['info'](_0x670f('0x4f'),_0x177be9['id']);logger['info']('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format'](_0x670f('0x50'),_0x5bf1d8[_0x670f('0x16')]),_0x670f('0x58'),{'uri':util[_0x670f('0xe')](_0x670f('0x51'),_0x2697c7[_0x670f('0x1c')],_0x177be9['id'])});}})[_0x670f('0x59')](function(_0x5ce1be){logger[_0x670f('0x52')](_0x670f('0x55'),JSON[_0x670f('0x31')](_0x5ce1be));});};exports[_0x670f('0x5a')]=function(_0xda01ef,_0x59e0ad,_0x4a603a,_0x3eb088,_0x39d926,_0xb8cdef){var _0xfd0440,_0x435e1b;_0xb8cdef[_0x670f('0x1c')]=intUtil[_0x670f('0x45')](_0xb8cdef['remoteUri']);_0xb8cdef[_0x670f('0x46')]=intUtil[_0x670f('0x45')](_0xb8cdef[_0x670f('0x46')]);if(_0x39d926&&_0x39d926[_0x670f('0x47')]){logger[_0x670f('0xc')]('['+_0x59e0ad[_0x670f('0x5b')][_0x670f('0x5c')]()+']',_0x670f('0x56'));_0x59e0ad[_0x670f('0x4b')]=util[_0x670f('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0xb8cdef['serverUrl'],_0x59e0ad[_0x670f('0x4a')],md5(_0x59e0ad[_0x670f('0x4a')]));}else{_0x59e0ad[_0x670f('0x4b')]='';}headers[_0x670f('0x4c')]=getAuth(_0xb8cdef);return getUser(_0xb8cdef,'')[_0x670f('0x1e')](function(_0x51de89){_0xfd0440=_0x51de89;logger['info'](_0x670f('0x4d'),_0xfd0440['id']);return getEndUser(_0xb8cdef,_0x59e0ad[_0x670f('0x10')],_0x59e0ad[_0x670f('0x11')]);})[_0x670f('0x1e')](function(_0x40007b){_0x435e1b=_0x40007b;logger[_0x670f('0xc')](_0x670f('0x5d'),_0x435e1b['id']);return getTicket(_0xb8cdef,_0xfd0440,_0x435e1b,_0x4a603a,_0x59e0ad);})[_0x670f('0x1e')](function(_0x3c5c09){if(_0x3c5c09){logger['info'](_0x670f('0x4e'));logger['info']('The\x20Ticket\x20ID\x20is:',_0x3c5c09['id']);}})['catch'](function(_0x4c9e45){logger[_0x670f('0x52')]('['+_0x59e0ad[_0x670f('0x5b')]['toUpperCase']()+']',JSON['stringify'](_0x4c9e45));});};
\ No newline at end of file