Built motion from commit 19a84241.|2.5.34
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 6961ae9..590b6f8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2a3b=['stringify','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','user:%s','unmanaged','toUpperCase','lastevent','lodash','request-promise','md5','util','ioredis','../../../../config/environment','../../../../config/logger','redis','defaults','localhost','application/json','emit','info','Creating\x20new\x20ticket...','merge','format','calleridname','getString','Subjects','Descriptions','<br>','Tags','Fields','mapValues','keyBy','custom_fields','value','%s/api/v2/tickets','remoteUri','%s/api/v2/agents','then','length','Agent\x20found!','find','contact','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!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Enduser\x20created.','Basic\x20%s','toString','debug','GET','map','string','nameField','content','type','idField','push','variableName','customField','customVariable','Variable','name','toLowerCase','queue','stripTrailingSlash','serverUrl','monitor_format','recordingURL','uniqueid','Authorization','email','The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error'];(function(_0x2237be,_0x2ed5c1){var _0x3312ab=function(_0x448a62){while(--_0x448a62){_0x2237be['push'](_0x2237be['shift']());}};_0x3312ab(++_0x2ed5c1);}(_0x2a3b,0x176));var _0xb2a3=function(_0x16316d,_0x1618e7){_0x16316d=_0x16316d-0x0;var _0x754631=_0x2a3b[_0x16316d];return _0x754631;};'use strict';var _=require(_0xb2a3('0x0'));var rp=require(_0xb2a3('0x1'));var md5=require(_0xb2a3('0x2'));var util=require(_0xb2a3('0x3'));var Redis=require(_0xb2a3('0x4'));var intUtil=require('./util');var config=require(_0xb2a3('0x5'));var logger=require(_0xb2a3('0x6'))('freshdesk');config[_0xb2a3('0x7')]=_[_0xb2a3('0x8')](config[_0xb2a3('0x7')],{'host':_0xb2a3('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xb2a3('0x7')]));var headers={'Content-Type':_0xb2a3('0xa'),'Accept':_0xb2a3('0xa')};function emit(_0x1aad4d,_0x4bca7a,_0x54be4c){io['to'](_0x1aad4d)[_0xb2a3('0xb')](_0x4bca7a,_0x54be4c);}function getTicket(_0x3c6e02,_0xc95566,_0x450eaf,_0x1cb43c,_0x2a226e){logger[_0xb2a3('0xc')](_0xb2a3('0xd'));var _0x125198=_[_0xb2a3('0xe')]({'responder_id':_0xc95566['id'],'requester_id':_0x450eaf['id'],'name':util[_0xb2a3('0xf')]('Caller\x20-\x20%s',_0x2a226e[_0xb2a3('0x10')]),'phone':_0x2a226e['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xb2a3('0x11')](_0x1cb43c[_0xb2a3('0x12')],_0x2a226e,'\x20'),'description':intUtil['getString'](_0x1cb43c[_0xb2a3('0x13')],_0x2a226e,_0xb2a3('0x14')),'tags':getTags(_0x1cb43c[_0xb2a3('0x15')],'name')},getCustomFields(_0x1cb43c[_0xb2a3('0x16')],_0x2a226e));_0x125198['custom_fields']=_[_0xb2a3('0x17')](_[_0xb2a3('0x18')](_0x125198[_0xb2a3('0x19')],'id'),_0xb2a3('0x1a'));return request({'uri':util['format'](_0xb2a3('0x1b'),_0x3c6e02[_0xb2a3('0x1c')]),'method':'POST','body':_0x125198})['then'](function(_0x3465c0){logger[_0xb2a3('0xc')]('Ticket\x20created!');return _0x3465c0;});}function getUser(_0x4a154b,_0x51b723){if(intUtil['validateEmail'](_0x51b723)){return request({'uri':util['format'](_0xb2a3('0x1d'),_0x4a154b['remoteUri']),'qs':{'email':_0x51b723}})[_0xb2a3('0x1e')](function(_0x180ca1){if(_0x180ca1[_0xb2a3('0x1f')]){logger[_0xb2a3('0xc')](_0xb2a3('0x20'));return _[_0xb2a3('0x21')](_0x180ca1,function(_0x1d9a3f){return _0x1d9a3f[_0xb2a3('0x22')]['email']===_0x51b723;});}else{logger[_0xb2a3('0xc')](_0xb2a3('0x23'));return request({'uri':util[_0xb2a3('0xf')](_0xb2a3('0x24'),_0x4a154b['remoteUri'])})['then'](function(_0x574065){logger[_0xb2a3('0xc')](_0xb2a3('0x25'));return _0x574065;});}});}else{logger[_0xb2a3('0xc')](_0xb2a3('0x26'));return request({'uri':util[_0xb2a3('0xf')]('%s/api/v2/agents/me',_0x4a154b[_0xb2a3('0x1c')])})[_0xb2a3('0x1e')](function(_0x310be8){logger[_0xb2a3('0xc')](_0xb2a3('0x25'));return _0x310be8;});}}function getEndUser(_0x1fea91,_0x1272d4,_0x378fed){logger[_0xb2a3('0xc')](_0xb2a3('0x27'),_0x378fed);return request({'uri':util[_0xb2a3('0xf')](_0xb2a3('0x28'),_0x1fea91[_0xb2a3('0x1c')]),'qs':{'phone':_0x378fed}})[_0xb2a3('0x1e')](function(_0x5a223f){if(_0x5a223f[_0xb2a3('0x1f')]){logger[_0xb2a3('0xc')](_0xb2a3('0x29'));return _['find'](_0x5a223f,{'phone':_0x378fed});}else{logger[_0xb2a3('0xc')](_0xb2a3('0x2a'));return request({'uri':util['format'](_0xb2a3('0x28'),_0x1fea91['remoteUri']),'method':_0xb2a3('0x2b'),'body':{'name':_0x1272d4,'phone':_0x378fed}})['then'](function(_0x329a8d){logger[_0xb2a3('0xc')](_0xb2a3('0x2c'));return _0x329a8d;});}});}function getAuth(_0x499e5a){return util[_0xb2a3('0xf')](_0xb2a3('0x2d'),new Buffer(_0x499e5a['apiKey']+':X')[_0xb2a3('0x2e')]('base64'));}function request(_0x98cdc1){logger[_0xb2a3('0x2f')]('[HTTP]',JSON['stringify'](_0x98cdc1));return rp(_[_0xb2a3('0x8')](_0x98cdc1,{'method':_0xb2a3('0x30'),'headers':headers,'json':!![]}));}function getTags(_0x3beb78,_0x4ecd55){var _0x20d64c=[];if(_0x3beb78&&_0x3beb78['length']>0x0){_0x20d64c=_[_0xb2a3('0x31')](_0x3beb78,_0x4ecd55);}return _0x20d64c;}function getCustomFields(_0x349e9a,_0x52bc01){var _0x26291c=[];var _0x3ea468={'custom_fields':[]};if(_0x349e9a[_0xb2a3('0x1f')]>0x0){_['forEach'](_0x349e9a,function(_0x5d665a){if(_0x5d665a['type']===_0xb2a3('0x32')&&_0x5d665a[_0xb2a3('0x33')]&&!_0x5d665a['customField']){_0x3ea468[_0x5d665a[_0xb2a3('0x33')]['toLowerCase']()]=_0x5d665a[_0xb2a3('0x34')][_0xb2a3('0x2e')]();}else if(_0x5d665a[_0xb2a3('0x35')]===_0xb2a3('0x32')&&_0x5d665a[_0xb2a3('0x36')]&&_0x5d665a['customField']){_0x3ea468[_0xb2a3('0x19')][_0xb2a3('0x37')]({'id':_0x5d665a[_0xb2a3('0x36')],'value':_0x5d665a['content']['toString']()});}else if(_0x5d665a[_0xb2a3('0x35')]==='variable'&&_0x5d665a[_0xb2a3('0x38')]&&_0x5d665a[_0xb2a3('0x36')]&&_0x5d665a[_0xb2a3('0x39')]){_0x52bc01[_0x5d665a[_0xb2a3('0x38')]]&&_0x3ea468[_0xb2a3('0x19')]['push']({'id':_0x5d665a[_0xb2a3('0x36')],'value':_0x52bc01[_0x5d665a[_0xb2a3('0x38')]][_0xb2a3('0x2e')]()});}else if(_0x5d665a[_0xb2a3('0x35')]===_0xb2a3('0x3a')&&_0x5d665a[_0xb2a3('0x3b')]&&_0x5d665a[_0xb2a3('0x3b')]['name']&&_0x5d665a[_0xb2a3('0x36')]&&_0x5d665a[_0xb2a3('0x39')]){_0x52bc01[_0x5d665a[_0xb2a3('0x3b')][_0xb2a3('0x3c')]['toLowerCase']()]&&_0x3ea468['custom_fields'][_0xb2a3('0x37')]({'id':_0x5d665a[_0xb2a3('0x36')],'value':_0x52bc01[_0x5d665a[_0xb2a3('0x3b')]['name'][_0xb2a3('0x3d')]()][_0xb2a3('0x2e')]()});}});}return _0x3ea468;}exports[_0xb2a3('0x3e')]=function(_0x8dfa63,_0xb6afef,_0x17ad59,_0x3cf6dd,_0x4fb315,_0x44495d){var _0x3cdc56,_0x3c92b2;_0x44495d['remoteUri']=intUtil[_0xb2a3('0x3f')](_0x44495d[_0xb2a3('0x1c')]);_0x44495d[_0xb2a3('0x40')]=intUtil[_0xb2a3('0x3f')](_0x44495d[_0xb2a3('0x40')]);if(_0x4fb315&&_0x4fb315[_0xb2a3('0x41')]){logger[_0xb2a3('0xc')]('[QUEUE]','Recording\x20is\x20enabled!');_0xb6afef[_0xb2a3('0x42')]=util[_0xb2a3('0xf')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x44495d[_0xb2a3('0x40')],_0xb6afef[_0xb2a3('0x43')],md5(_0xb6afef[_0xb2a3('0x43')]));}else{_0xb6afef[_0xb2a3('0x42')]='';}headers[_0xb2a3('0x44')]=getAuth(_0x44495d);return getUser(_0x44495d,_0x3cf6dd[_0xb2a3('0x45')])[_0xb2a3('0x1e')](function(_0x1ac671){_0x3cdc56=_0x1ac671;logger[_0xb2a3('0xc')](_0xb2a3('0x46'),_0x3cdc56['id']);return getEndUser(_0x44495d,_0xb6afef[_0xb2a3('0x10')],_0xb6afef[_0xb2a3('0x47')]);})['then'](function(_0x1a6984){_0x3c92b2=_0x1a6984;logger[_0xb2a3('0xc')](_0xb2a3('0x48'),_0x3c92b2['id']);return getTicket(_0x44495d,_0x3cdc56,_0x3c92b2,_0x17ad59,_0xb6afef);})['then'](function(_0x2a7d8c){if(_0x2a7d8c&&_0x2a7d8c['id']){logger[_0xb2a3('0xc')](_0xb2a3('0x49'));logger[_0xb2a3('0xc')](_0xb2a3('0x4a'),_0x2a7d8c['id']);logger['info'](_0xb2a3('0x4b'),_0xb2a3('0x4c'));emit(util[_0xb2a3('0xf')]('user:%s',_0x3cf6dd[_0xb2a3('0x3c')]),_0xb2a3('0x4d'),{'uri':util[_0xb2a3('0xf')](_0xb2a3('0x4e'),_0x44495d[_0xb2a3('0x1c')],_0x2a7d8c['id'])});}})[_0xb2a3('0x4f')](function(_0x5156d2){logger[_0xb2a3('0x50')](_0xb2a3('0x4b'),JSON[_0xb2a3('0x51')](_0x5156d2));});};exports['outbound']=function(_0x51ccaf,_0x49942f,_0x340752,_0x222ad7,_0x15b473,_0x3702a0,_0x4ad70a){var _0x5548da,_0xa2ff4;_0x3702a0['remoteUri']=intUtil[_0xb2a3('0x3f')](_0x3702a0['remoteUri']);_0x3702a0['serverUrl']=intUtil[_0xb2a3('0x3f')](_0x3702a0[_0xb2a3('0x40')]);if(_0x4ad70a&&_0x4ad70a[_0xb2a3('0x52')]&&_0x4ad70a[_0xb2a3('0x52')]!==_0xb2a3('0x53')){logger[_0xb2a3('0xc')](_0xb2a3('0x54'),_0xb2a3('0x55'));_0x49942f[_0xb2a3('0x42')]=util[_0xb2a3('0xf')](_0xb2a3('0x56'),_0x3702a0[_0xb2a3('0x40')],_0x49942f['uniqueid'],md5(_0x49942f['uniqueid']));}headers[_0xb2a3('0x44')]=getAuth(_0x3702a0);return getUser(_0x3702a0,_0x222ad7['email'])[_0xb2a3('0x1e')](function(_0x29961c){_0x5548da=_0x29961c;logger['info']('The\x20User\x20ID\x20is:',_0x5548da['id']);return getEndUser(_0x3702a0,_0x49942f['destcalleridname'],_0x49942f['destcalleridnum']);})[_0xb2a3('0x1e')](function(_0x4bb81e){_0xa2ff4=_0x4bb81e;logger[_0xb2a3('0xc')](_0xb2a3('0x48'),_0xa2ff4['id']);return getTicket(_0x3702a0,_0x5548da,_0xa2ff4,_0x340752,_0x49942f);})[_0xb2a3('0x1e')](function(_0x7678a4){if(_0x7678a4&&_0x7678a4['id']){logger[_0xb2a3('0xc')]('Ticket\x20created!');logger['info'](_0xb2a3('0x4a'),_0x7678a4['id']);logger['info'](_0xb2a3('0x54'),_0xb2a3('0x4c'));emit(util[_0xb2a3('0xf')](_0xb2a3('0x57'),_0x222ad7[_0xb2a3('0x3c')]),_0xb2a3('0x4d'),{'uri':util[_0xb2a3('0xf')](_0xb2a3('0x4e'),_0x3702a0[_0xb2a3('0x1c')],_0x7678a4['id'])});}})[_0xb2a3('0x4f')](function(_0x2c844b){logger[_0xb2a3('0x50')](_0xb2a3('0x54'),JSON[_0xb2a3('0x51')](_0x2c844b));});};exports[_0xb2a3('0x58')]=function(_0x1fbf75,_0x34d549,_0x92cba,_0x48af77,_0x1be549,_0x4384aa){var _0x302bed,_0x3109f0;_0x4384aa[_0xb2a3('0x1c')]=intUtil[_0xb2a3('0x3f')](_0x4384aa[_0xb2a3('0x1c')]);_0x4384aa[_0xb2a3('0x40')]=intUtil['stripTrailingSlash'](_0x4384aa['serverUrl']);if(_0x1be549&&_0x1be549[_0xb2a3('0x41')]){logger[_0xb2a3('0xc')]('['+_0x34d549['lastevent'][_0xb2a3('0x59')]()+']',_0xb2a3('0x55'));_0x34d549['recordingURL']=util[_0xb2a3('0xf')](_0xb2a3('0x56'),_0x4384aa[_0xb2a3('0x40')],_0x34d549[_0xb2a3('0x43')],md5(_0x34d549['uniqueid']));}else{_0x34d549[_0xb2a3('0x42')]='';}headers['Authorization']=getAuth(_0x4384aa);return getUser(_0x4384aa,'')[_0xb2a3('0x1e')](function(_0x59e71d){_0x302bed=_0x59e71d;logger[_0xb2a3('0xc')](_0xb2a3('0x46'),_0x302bed['id']);return getEndUser(_0x4384aa,_0x34d549['calleridname'],_0x34d549[_0xb2a3('0x47')]);})[_0xb2a3('0x1e')](function(_0x39956c){_0x3109f0=_0x39956c;logger[_0xb2a3('0xc')](_0xb2a3('0x48'),_0x3109f0['id']);return getTicket(_0x4384aa,_0x302bed,_0x3109f0,_0x92cba,_0x34d549);})[_0xb2a3('0x1e')](function(_0x591974){if(_0x591974){logger['info'](_0xb2a3('0x49'));logger[_0xb2a3('0xc')]('The\x20Ticket\x20ID\x20is:',_0x591974['id']);}})[_0xb2a3('0x4f')](function(_0x5120df){logger['error']('['+_0x34d549[_0xb2a3('0x5a')][_0xb2a3('0x59')]()+']',JSON[_0xb2a3('0x51')](_0x5120df));});};
\ 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