Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index bef6ff3..f97a712 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x745f=['trigger:browser:url','error','monitor_format','lastevent','toUpperCase','The\x20User\x20ID\x20is:','lodash','request-promise','util','ioredis','./util','../../../../config/environment','freshdesk','defaults','socket.io-emitter','redis','application/json','emit','Caller\x20-\x20%s','calleridname','calleridnum','getString','<br>','Tags','custom_fields','mapValues','value','POST','then','info','Ticket\x20created!','validateEmail','format','%s/api/v2/agents','remoteUri','length','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Admin\x20account\x20selected.','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Basic\x20%s','toString','base64','debug','GET','forEach','type','string','nameField','customField','toLowerCase','idField','content','variable','variableName','push','customVariable','Variable','name','queue','stripTrailingSlash','serverUrl','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','%s/helpdesk/tickets/%d','catch','stringify','outbound','recordingFormat','none','[OUTBOUND]','destcalleridnum','user:%s'];(function(_0x58c20f,_0x4cdb1b){var _0x3b0318=function(_0x36fa84){while(--_0x36fa84){_0x58c20f['push'](_0x58c20f['shift']());}};_0x3b0318(++_0x4cdb1b);}(_0x745f,0x1af));var _0xf745=function(_0xe69bf1,_0x487cbc){_0xe69bf1=_0xe69bf1-0x0;var _0x1259d1=_0x745f[_0xe69bf1];return _0x1259d1;};'use strict';var _=require(_0xf745('0x0'));var rp=require(_0xf745('0x1'));var md5=require('md5');var util=require(_0xf745('0x2'));var Redis=require(_0xf745('0x3'));var intUtil=require(_0xf745('0x4'));var config=require(_0xf745('0x5'));var logger=require('../../../../config/logger')(_0xf745('0x6'));config['redis']=_[_0xf745('0x7')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0xf745('0x8'))(new Redis(config[_0xf745('0x9')]));var headers={'Content-Type':_0xf745('0xa'),'Accept':_0xf745('0xa')};function emit(_0xe3df5e,_0x3027c9,_0x49fb99){io['to'](_0xe3df5e)[_0xf745('0xb')](_0x3027c9,_0x49fb99);}function getTicket(_0x7f6572,_0x2d6eae,_0x51cc71,_0xf593bc,_0x9a812d){logger['info']('Creating\x20new\x20ticket...');var _0x44d908=_['merge']({'responder_id':_0x2d6eae['id'],'requester_id':_0x51cc71['id'],'name':util['format'](_0xf745('0xc'),_0x9a812d[_0xf745('0xd')]),'phone':_0x9a812d[_0xf745('0xe')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0xf593bc['Subjects'],_0x9a812d,'\x20'),'description':intUtil[_0xf745('0xf')](_0xf593bc['Descriptions'],_0x9a812d,_0xf745('0x10')),'tags':getTags(_0xf593bc[_0xf745('0x11')],'name')},getCustomFields(_0xf593bc['Fields'],_0x9a812d));_0x44d908[_0xf745('0x12')]=_[_0xf745('0x13')](_['keyBy'](_0x44d908[_0xf745('0x12')],'id'),_0xf745('0x14'));return request({'uri':util['format']('%s/api/v2/tickets',_0x7f6572['remoteUri']),'method':_0xf745('0x15'),'body':_0x44d908})[_0xf745('0x16')](function(_0x42ba68){logger[_0xf745('0x17')](_0xf745('0x18'));return _0x42ba68;});}function getUser(_0x35386f,_0x5c47d6){if(intUtil[_0xf745('0x19')](_0x5c47d6)){return request({'uri':util[_0xf745('0x1a')](_0xf745('0x1b'),_0x35386f[_0xf745('0x1c')]),'qs':{'email':_0x5c47d6}})[_0xf745('0x16')](function(_0x93a3b0){if(_0x93a3b0[_0xf745('0x1d')]){logger['info']('Agent\x20found!');return _[_0xf745('0x1e')](_0x93a3b0,function(_0x2b6119){return _0x2b6119[_0xf745('0x1f')][_0xf745('0x20')]===_0x5c47d6;});}else{logger['info'](_0xf745('0x21'));return request({'uri':util['format']('%s/api/v2/agents/me',_0x35386f[_0xf745('0x1c')])})[_0xf745('0x16')](function(_0x1b0b0f){logger[_0xf745('0x17')]('Admin\x20account\x20selected.');return _0x1b0b0f;});}});}else{logger[_0xf745('0x17')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0xf745('0x1a')](_0xf745('0x22'),_0x35386f[_0xf745('0x1c')])})[_0xf745('0x16')](function(_0x29e3f8){logger[_0xf745('0x17')](_0xf745('0x23'));return _0x29e3f8;});}}function getEndUser(_0x2bea51,_0x16ba6b,_0x3d9278){logger[_0xf745('0x17')]('Searching\x20enduser\x20with\x20phone',_0x3d9278);return request({'uri':util['format'](_0xf745('0x24'),_0x2bea51['remoteUri']),'qs':{'phone':_0x3d9278}})['then'](function(_0x1a97bd){if(_0x1a97bd['length']){logger['info'](_0xf745('0x25'));return _[_0xf745('0x1e')](_0x1a97bd,{'phone':_0x3d9278});}else{logger[_0xf745('0x17')](_0xf745('0x26'));return request({'uri':util[_0xf745('0x1a')]('%s/api/v2/contacts',_0x2bea51[_0xf745('0x1c')]),'method':'POST','body':{'name':_0x16ba6b,'phone':_0x3d9278}})[_0xf745('0x16')](function(_0x3861a5){logger['info']('Enduser\x20created.');return _0x3861a5;});}});}function getAuth(_0x1b73de){return util['format'](_0xf745('0x27'),new Buffer(_0x1b73de['apiKey']+':X')[_0xf745('0x28')](_0xf745('0x29')));}function request(_0x14c028){logger[_0xf745('0x2a')]('[HTTP]',JSON['stringify'](_0x14c028));return rp(_['defaults'](_0x14c028,{'method':_0xf745('0x2b'),'headers':headers,'json':!![]}));}function getTags(_0x118670,_0x1d32cb){var _0x57b332=[];if(_0x118670&&_0x118670[_0xf745('0x1d')]>0x0){_0x57b332=_['map'](_0x118670,_0x1d32cb);}return _0x57b332;}function getCustomFields(_0x275e2b,_0x11d697){var _0x5d68f8=[];var _0x48d8aa={'custom_fields':[]};if(_0x275e2b[_0xf745('0x1d')]>0x0){_[_0xf745('0x2c')](_0x275e2b,function(_0x468113){if(_0x468113[_0xf745('0x2d')]===_0xf745('0x2e')&&_0x468113[_0xf745('0x2f')]&&!_0x468113[_0xf745('0x30')]){_0x48d8aa[_0x468113[_0xf745('0x2f')][_0xf745('0x31')]()]=_0x468113['content']['toString']();}else if(_0x468113['type']==='string'&&_0x468113[_0xf745('0x32')]&&_0x468113[_0xf745('0x30')]){_0x48d8aa[_0xf745('0x12')]['push']({'id':_0x468113[_0xf745('0x32')],'value':_0x468113[_0xf745('0x33')]['toString']()});}else if(_0x468113[_0xf745('0x2d')]===_0xf745('0x34')&&_0x468113['variableName']&&_0x468113[_0xf745('0x32')]&&_0x468113['customField']){_0x11d697[_0x468113[_0xf745('0x35')]]&&_0x48d8aa['custom_fields'][_0xf745('0x36')]({'id':_0x468113[_0xf745('0x32')],'value':_0x11d697[_0x468113[_0xf745('0x35')]][_0xf745('0x28')]()});}else if(_0x468113['type']===_0xf745('0x37')&&_0x468113[_0xf745('0x38')]&&_0x468113[_0xf745('0x38')][_0xf745('0x39')]&&_0x468113[_0xf745('0x32')]&&_0x468113[_0xf745('0x30')]){_0x11d697[_0x468113['Variable'][_0xf745('0x39')][_0xf745('0x31')]()]&&_0x48d8aa['custom_fields'][_0xf745('0x36')]({'id':_0x468113[_0xf745('0x32')],'value':_0x11d697[_0x468113['Variable'][_0xf745('0x39')][_0xf745('0x31')]()][_0xf745('0x28')]()});}});}return _0x48d8aa;}exports[_0xf745('0x3a')]=function(_0x51686c,_0xa246de,_0x5dd344,_0x58c447,_0x17561c,_0x42919d){var _0x4926ac,_0x49cbe5;_0x42919d[_0xf745('0x1c')]=intUtil[_0xf745('0x3b')](_0x42919d[_0xf745('0x1c')]);_0x42919d[_0xf745('0x3c')]=intUtil[_0xf745('0x3b')](_0x42919d[_0xf745('0x3c')]);if(_0x17561c&&_0x17561c['monitor_format']){logger[_0xf745('0x17')](_0xf745('0x3d'),_0xf745('0x3e'));_0xa246de[_0xf745('0x3f')]=util[_0xf745('0x1a')](_0xf745('0x40'),_0x42919d[_0xf745('0x3c')],_0xa246de[_0xf745('0x41')],md5(_0xa246de[_0xf745('0x41')]));}else{_0xa246de[_0xf745('0x3f')]='';}headers[_0xf745('0x42')]=getAuth(_0x42919d);return getUser(_0x42919d,_0x58c447[_0xf745('0x20')])[_0xf745('0x16')](function(_0x24b215){_0x4926ac=_0x24b215;logger[_0xf745('0x17')]('The\x20User\x20ID\x20is:',_0x4926ac['id']);return getEndUser(_0x42919d,_0xa246de[_0xf745('0xd')],_0xa246de['calleridnum']);})[_0xf745('0x16')](function(_0xf19217){_0x49cbe5=_0xf19217;logger['info'](_0xf745('0x43'),_0x49cbe5['id']);return getTicket(_0x42919d,_0x4926ac,_0x49cbe5,_0x5dd344,_0xa246de);})[_0xf745('0x16')](function(_0x15a2d5){if(_0x15a2d5&&_0x15a2d5['id']){logger[_0xf745('0x17')]('Ticket\x20created!');logger[_0xf745('0x17')](_0xf745('0x44'),_0x15a2d5['id']);logger[_0xf745('0x17')](_0xf745('0x3d'),_0xf745('0x45'));emit(util[_0xf745('0x1a')]('user:%s',_0x58c447[_0xf745('0x39')]),'trigger:browser:url',{'uri':util[_0xf745('0x1a')](_0xf745('0x46'),_0x42919d['remoteUri'],_0x15a2d5['id'])});}})[_0xf745('0x47')](function(_0x58634c){logger['error'](_0xf745('0x3d'),JSON[_0xf745('0x48')](_0x58634c));});};exports[_0xf745('0x49')]=function(_0x263e7c,_0x491172,_0x5b6e7d,_0x370af0,_0x30f0b6,_0x240204,_0x29d287){var _0x442fa8,_0x4d61ee;_0x240204[_0xf745('0x1c')]=intUtil[_0xf745('0x3b')](_0x240204[_0xf745('0x1c')]);_0x240204['serverUrl']=intUtil[_0xf745('0x3b')](_0x240204['serverUrl']);if(_0x29d287&&_0x29d287[_0xf745('0x4a')]&&_0x29d287[_0xf745('0x4a')]!==_0xf745('0x4b')){logger['info'](_0xf745('0x4c'),_0xf745('0x3e'));_0x491172['recordingURL']=util['format'](_0xf745('0x40'),_0x240204[_0xf745('0x3c')],_0x491172['uniqueid'],md5(_0x491172[_0xf745('0x41')]));}headers[_0xf745('0x42')]=getAuth(_0x240204);return getUser(_0x240204,_0x370af0['email'])[_0xf745('0x16')](function(_0x4900be){_0x442fa8=_0x4900be;logger[_0xf745('0x17')]('The\x20User\x20ID\x20is:',_0x442fa8['id']);return getEndUser(_0x240204,_0x491172['destcalleridname'],_0x491172[_0xf745('0x4d')]);})[_0xf745('0x16')](function(_0x571011){_0x4d61ee=_0x571011;logger[_0xf745('0x17')](_0xf745('0x43'),_0x4d61ee['id']);return getTicket(_0x240204,_0x442fa8,_0x4d61ee,_0x5b6e7d,_0x491172);})[_0xf745('0x16')](function(_0x358719){if(_0x358719&&_0x358719['id']){logger['info'](_0xf745('0x18'));logger[_0xf745('0x17')](_0xf745('0x44'),_0x358719['id']);logger[_0xf745('0x17')](_0xf745('0x4c'),_0xf745('0x45'));emit(util[_0xf745('0x1a')](_0xf745('0x4e'),_0x370af0[_0xf745('0x39')]),_0xf745('0x4f'),{'uri':util[_0xf745('0x1a')](_0xf745('0x46'),_0x240204[_0xf745('0x1c')],_0x358719['id'])});}})['catch'](function(_0x5b0ad9){logger[_0xf745('0x50')](_0xf745('0x4c'),JSON[_0xf745('0x48')](_0x5b0ad9));});};exports['unmanaged']=function(_0xf973be,_0x22d6f2,_0x5c2d02,_0xe33e3,_0x480425,_0x2cd138){var _0x512485,_0x4fb00e;_0x2cd138[_0xf745('0x1c')]=intUtil[_0xf745('0x3b')](_0x2cd138[_0xf745('0x1c')]);_0x2cd138[_0xf745('0x3c')]=intUtil[_0xf745('0x3b')](_0x2cd138[_0xf745('0x3c')]);if(_0x480425&&_0x480425[_0xf745('0x51')]){logger['info']('['+_0x22d6f2[_0xf745('0x52')][_0xf745('0x53')]()+']',_0xf745('0x3e'));_0x22d6f2['recordingURL']=util[_0xf745('0x1a')](_0xf745('0x40'),_0x2cd138[_0xf745('0x3c')],_0x22d6f2[_0xf745('0x41')],md5(_0x22d6f2[_0xf745('0x41')]));}else{_0x22d6f2['recordingURL']='';}headers['Authorization']=getAuth(_0x2cd138);return getUser(_0x2cd138,'')[_0xf745('0x16')](function(_0x57e810){_0x512485=_0x57e810;logger[_0xf745('0x17')](_0xf745('0x54'),_0x512485['id']);return getEndUser(_0x2cd138,_0x22d6f2['calleridname'],_0x22d6f2['calleridnum']);})[_0xf745('0x16')](function(_0x43ba41){_0x4fb00e=_0x43ba41;logger[_0xf745('0x17')](_0xf745('0x43'),_0x4fb00e['id']);return getTicket(_0x2cd138,_0x512485,_0x4fb00e,_0x5c2d02,_0x22d6f2);})[_0xf745('0x16')](function(_0x531642){if(_0x531642){logger[_0xf745('0x17')]('Ticket\x20created!');logger[_0xf745('0x17')]('The\x20Ticket\x20ID\x20is:',_0x531642['id']);}})[_0xf745('0x47')](function(_0x139cdf){logger[_0xf745('0x50')]('['+_0x22d6f2[_0xf745('0x52')][_0xf745('0x53')]()+']',JSON[_0xf745('0x48')](_0x139cdf));});};
\ No newline at end of file
+var _0xa3c1=['The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','%s/helpdesk/tickets/%d','catch','error','stringify','outbound','recordingFormat','none','[OUTBOUND]','destcalleridname','destcalleridnum','The\x20Ticket\x20ID\x20is:','trigger:browser:url','unmanaged','toUpperCase','lastevent','lodash','ioredis','./util','../../../../config/environment','../../../../config/logger','redis','defaults','localhost','socket.io-emitter','application/json','info','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridname','getString','Descriptions','Tags','name','mapValues','keyBy','custom_fields','value','Ticket\x20created!','then','length','Agent\x20found!','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','remoteUri','Admin\x20account\x20selected.','Enduser\x20found!','find','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','%s/api/v2/contacts','POST','Enduser\x20created.','Basic\x20%s','apiKey','toString','base64','[HTTP]','GET','map','forEach','type','string','nameField','customField','toLowerCase','content','push','idField','variable','variableName','customVariable','Variable','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization'];(function(_0x2c022a,_0x1ea7ba){var _0x422073=function(_0x12c051){while(--_0x12c051){_0x2c022a['push'](_0x2c022a['shift']());}};_0x422073(++_0x1ea7ba);}(_0xa3c1,0x11f));var _0x1a3c=function(_0x520e5c,_0x52e863){_0x520e5c=_0x520e5c-0x0;var _0x482f94=_0xa3c1[_0x520e5c];return _0x482f94;};'use strict';var _=require(_0x1a3c('0x0'));var rp=require('request-promise');var md5=require('md5');var util=require('util');var Redis=require(_0x1a3c('0x1'));var intUtil=require(_0x1a3c('0x2'));var config=require(_0x1a3c('0x3'));var logger=require(_0x1a3c('0x4'))('freshdesk');config[_0x1a3c('0x5')]=_[_0x1a3c('0x6')](config[_0x1a3c('0x5')],{'host':_0x1a3c('0x7'),'port':0x18eb});var io=require(_0x1a3c('0x8'))(new Redis(config[_0x1a3c('0x5')]));var headers={'Content-Type':_0x1a3c('0x9'),'Accept':_0x1a3c('0x9')};function emit(_0x2c7434,_0x536ba6,_0x35cf4d){io['to'](_0x2c7434)['emit'](_0x536ba6,_0x35cf4d);}function getTicket(_0x48ac53,_0x2c0a25,_0x3d72c1,_0x14fede,_0x1019a6){logger[_0x1a3c('0xa')](_0x1a3c('0xb'));var _0x147ea2=_[_0x1a3c('0xc')]({'responder_id':_0x2c0a25['id'],'requester_id':_0x3d72c1['id'],'name':util[_0x1a3c('0xd')](_0x1a3c('0xe'),_0x1019a6[_0x1a3c('0xf')]),'phone':_0x1019a6['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x1a3c('0x10')](_0x14fede['Subjects'],_0x1019a6,'\x20'),'description':intUtil[_0x1a3c('0x10')](_0x14fede[_0x1a3c('0x11')],_0x1019a6,'<br>'),'tags':getTags(_0x14fede[_0x1a3c('0x12')],_0x1a3c('0x13'))},getCustomFields(_0x14fede['Fields'],_0x1019a6));_0x147ea2['custom_fields']=_[_0x1a3c('0x14')](_[_0x1a3c('0x15')](_0x147ea2[_0x1a3c('0x16')],'id'),_0x1a3c('0x17'));return request({'uri':util['format']('%s/api/v2/tickets',_0x48ac53['remoteUri']),'method':'POST','body':_0x147ea2})['then'](function(_0x34db6e){logger['info'](_0x1a3c('0x18'));return _0x34db6e;});}function getUser(_0x4114f6,_0x2872e6){if(intUtil['validateEmail'](_0x2872e6)){return request({'uri':util[_0x1a3c('0xd')]('%s/api/v2/agents',_0x4114f6['remoteUri']),'qs':{'email':_0x2872e6}})[_0x1a3c('0x19')](function(_0x21f95f){if(_0x21f95f[_0x1a3c('0x1a')]){logger[_0x1a3c('0xa')](_0x1a3c('0x1b'));return _['find'](_0x21f95f,function(_0x22de6c){return _0x22de6c[_0x1a3c('0x1c')][_0x1a3c('0x1d')]===_0x2872e6;});}else{logger[_0x1a3c('0xa')](_0x1a3c('0x1e'));return request({'uri':util['format'](_0x1a3c('0x1f'),_0x4114f6[_0x1a3c('0x20')])})[_0x1a3c('0x19')](function(_0x18c095){logger[_0x1a3c('0xa')](_0x1a3c('0x21'));return _0x18c095;});}});}else{logger[_0x1a3c('0xa')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x1a3c('0xd')](_0x1a3c('0x1f'),_0x4114f6[_0x1a3c('0x20')])})['then'](function(_0x371546){logger[_0x1a3c('0xa')](_0x1a3c('0x21'));return _0x371546;});}}function getEndUser(_0x88a00c,_0x1f57e3,_0xe41ce9){logger[_0x1a3c('0xa')]('Searching\x20enduser\x20with\x20phone',_0xe41ce9);return request({'uri':util['format']('%s/api/v2/contacts',_0x88a00c[_0x1a3c('0x20')]),'qs':{'phone':_0xe41ce9}})[_0x1a3c('0x19')](function(_0x5d3907){if(_0x5d3907['length']){logger[_0x1a3c('0xa')](_0x1a3c('0x22'));return _[_0x1a3c('0x23')](_0x5d3907,{'phone':_0xe41ce9});}else{logger[_0x1a3c('0xa')](_0x1a3c('0x24'));return request({'uri':util[_0x1a3c('0xd')](_0x1a3c('0x25'),_0x88a00c['remoteUri']),'method':_0x1a3c('0x26'),'body':{'name':_0x1f57e3,'phone':_0xe41ce9}})[_0x1a3c('0x19')](function(_0x17c08f){logger[_0x1a3c('0xa')](_0x1a3c('0x27'));return _0x17c08f;});}});}function getAuth(_0x3ff017){return util['format'](_0x1a3c('0x28'),new Buffer(_0x3ff017[_0x1a3c('0x29')]+':X')[_0x1a3c('0x2a')](_0x1a3c('0x2b')));}function request(_0x3441c4){logger['debug'](_0x1a3c('0x2c'),JSON['stringify'](_0x3441c4));return rp(_[_0x1a3c('0x6')](_0x3441c4,{'method':_0x1a3c('0x2d'),'headers':headers,'json':!![]}));}function getTags(_0x2f0a59,_0x571160){var _0x1001aa=[];if(_0x2f0a59&&_0x2f0a59['length']>0x0){_0x1001aa=_[_0x1a3c('0x2e')](_0x2f0a59,_0x571160);}return _0x1001aa;}function getCustomFields(_0x29e708,_0x35c195){var _0x4f2372=[];var _0x2cac43={'custom_fields':[]};if(_0x29e708['length']>0x0){_[_0x1a3c('0x2f')](_0x29e708,function(_0x23ac3d){if(_0x23ac3d[_0x1a3c('0x30')]===_0x1a3c('0x31')&&_0x23ac3d[_0x1a3c('0x32')]&&!_0x23ac3d[_0x1a3c('0x33')]){_0x2cac43[_0x23ac3d['nameField'][_0x1a3c('0x34')]()]=_0x23ac3d[_0x1a3c('0x35')][_0x1a3c('0x2a')]();}else if(_0x23ac3d[_0x1a3c('0x30')]===_0x1a3c('0x31')&&_0x23ac3d['idField']&&_0x23ac3d[_0x1a3c('0x33')]){_0x2cac43[_0x1a3c('0x16')][_0x1a3c('0x36')]({'id':_0x23ac3d[_0x1a3c('0x37')],'value':_0x23ac3d[_0x1a3c('0x35')][_0x1a3c('0x2a')]()});}else if(_0x23ac3d[_0x1a3c('0x30')]===_0x1a3c('0x38')&&_0x23ac3d['variableName']&&_0x23ac3d['idField']&&_0x23ac3d[_0x1a3c('0x33')]){_0x35c195[_0x23ac3d[_0x1a3c('0x39')]]&&_0x2cac43[_0x1a3c('0x16')][_0x1a3c('0x36')]({'id':_0x23ac3d['idField'],'value':_0x35c195[_0x23ac3d[_0x1a3c('0x39')]][_0x1a3c('0x2a')]()});}else if(_0x23ac3d[_0x1a3c('0x30')]===_0x1a3c('0x3a')&&_0x23ac3d[_0x1a3c('0x3b')]&&_0x23ac3d[_0x1a3c('0x3b')][_0x1a3c('0x13')]&&_0x23ac3d[_0x1a3c('0x37')]&&_0x23ac3d['customField']){_0x35c195[_0x23ac3d[_0x1a3c('0x3b')][_0x1a3c('0x13')][_0x1a3c('0x34')]()]&&_0x2cac43[_0x1a3c('0x16')][_0x1a3c('0x36')]({'id':_0x23ac3d['idField'],'value':_0x35c195[_0x23ac3d[_0x1a3c('0x3b')][_0x1a3c('0x13')][_0x1a3c('0x34')]()][_0x1a3c('0x2a')]()});}});}return _0x2cac43;}exports['queue']=function(_0x34be04,_0x52c3b9,_0x3548f9,_0x25d446,_0x2806a6,_0x741ba3){var _0x435ae3,_0xe83664;_0x741ba3[_0x1a3c('0x20')]=intUtil[_0x1a3c('0x3c')](_0x741ba3[_0x1a3c('0x20')]);_0x741ba3[_0x1a3c('0x3d')]=intUtil[_0x1a3c('0x3c')](_0x741ba3[_0x1a3c('0x3d')]);if(_0x2806a6&&_0x2806a6[_0x1a3c('0x3e')]){logger['info'](_0x1a3c('0x3f'),_0x1a3c('0x40'));_0x52c3b9[_0x1a3c('0x41')]=util['format'](_0x1a3c('0x42'),_0x741ba3[_0x1a3c('0x3d')],_0x52c3b9[_0x1a3c('0x43')],md5(_0x52c3b9['uniqueid']));}else{_0x52c3b9[_0x1a3c('0x41')]='';}headers[_0x1a3c('0x44')]=getAuth(_0x741ba3);return getUser(_0x741ba3,_0x25d446[_0x1a3c('0x1d')])['then'](function(_0xf677c3){_0x435ae3=_0xf677c3;logger[_0x1a3c('0xa')](_0x1a3c('0x45'),_0x435ae3['id']);return getEndUser(_0x741ba3,_0x52c3b9[_0x1a3c('0xf')],_0x52c3b9[_0x1a3c('0x46')]);})[_0x1a3c('0x19')](function(_0x5c2e7e){_0xe83664=_0x5c2e7e;logger['info'](_0x1a3c('0x47'),_0xe83664['id']);return getTicket(_0x741ba3,_0x435ae3,_0xe83664,_0x3548f9,_0x52c3b9);})[_0x1a3c('0x19')](function(_0x529a45){if(_0x529a45&&_0x529a45['id']){logger[_0x1a3c('0xa')](_0x1a3c('0x18'));logger['info']('The\x20Ticket\x20ID\x20is:',_0x529a45['id']);logger[_0x1a3c('0xa')](_0x1a3c('0x3f'),_0x1a3c('0x48'));emit(util[_0x1a3c('0xd')](_0x1a3c('0x49'),_0x25d446[_0x1a3c('0x13')]),'trigger:browser:url',{'uri':util[_0x1a3c('0xd')](_0x1a3c('0x4a'),_0x741ba3[_0x1a3c('0x20')],_0x529a45['id'])});}})[_0x1a3c('0x4b')](function(_0xa12d3a){logger[_0x1a3c('0x4c')](_0x1a3c('0x3f'),JSON[_0x1a3c('0x4d')](_0xa12d3a));});};exports[_0x1a3c('0x4e')]=function(_0xa9825b,_0x1be53c,_0x14dab4,_0x4cb90d,_0x3b3f07,_0x2137bc,_0x2a748b){var _0x4d418d,_0x72656c;_0x2137bc[_0x1a3c('0x20')]=intUtil[_0x1a3c('0x3c')](_0x2137bc[_0x1a3c('0x20')]);_0x2137bc[_0x1a3c('0x3d')]=intUtil['stripTrailingSlash'](_0x2137bc[_0x1a3c('0x3d')]);if(_0x2a748b&&_0x2a748b[_0x1a3c('0x4f')]&&_0x2a748b['recordingFormat']!==_0x1a3c('0x50')){logger[_0x1a3c('0xa')](_0x1a3c('0x51'),'Recording\x20is\x20enabled!');_0x1be53c[_0x1a3c('0x41')]=util['format']('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x2137bc[_0x1a3c('0x3d')],_0x1be53c[_0x1a3c('0x43')],md5(_0x1be53c[_0x1a3c('0x43')]));}headers[_0x1a3c('0x44')]=getAuth(_0x2137bc);return getUser(_0x2137bc,_0x4cb90d['email'])[_0x1a3c('0x19')](function(_0x2318c5){_0x4d418d=_0x2318c5;logger[_0x1a3c('0xa')](_0x1a3c('0x45'),_0x4d418d['id']);return getEndUser(_0x2137bc,_0x1be53c[_0x1a3c('0x52')],_0x1be53c[_0x1a3c('0x53')]);})[_0x1a3c('0x19')](function(_0x54f17e){_0x72656c=_0x54f17e;logger['info'](_0x1a3c('0x47'),_0x72656c['id']);return getTicket(_0x2137bc,_0x4d418d,_0x72656c,_0x14dab4,_0x1be53c);})[_0x1a3c('0x19')](function(_0x35b229){if(_0x35b229&&_0x35b229['id']){logger['info']('Ticket\x20created!');logger[_0x1a3c('0xa')](_0x1a3c('0x54'),_0x35b229['id']);logger[_0x1a3c('0xa')](_0x1a3c('0x51'),_0x1a3c('0x48'));emit(util['format'](_0x1a3c('0x49'),_0x4cb90d[_0x1a3c('0x13')]),_0x1a3c('0x55'),{'uri':util[_0x1a3c('0xd')]('%s/helpdesk/tickets/%d',_0x2137bc[_0x1a3c('0x20')],_0x35b229['id'])});}})['catch'](function(_0x1e2692){logger['error']('[OUTBOUND]',JSON[_0x1a3c('0x4d')](_0x1e2692));});};exports[_0x1a3c('0x56')]=function(_0x46b8b6,_0x58036d,_0x1af80d,_0x1c67f4,_0x233cbf,_0x7ba0bc){var _0x224797,_0x472e41;_0x7ba0bc[_0x1a3c('0x20')]=intUtil[_0x1a3c('0x3c')](_0x7ba0bc[_0x1a3c('0x20')]);_0x7ba0bc[_0x1a3c('0x3d')]=intUtil['stripTrailingSlash'](_0x7ba0bc[_0x1a3c('0x3d')]);if(_0x233cbf&&_0x233cbf['monitor_format']){logger[_0x1a3c('0xa')]('['+_0x58036d['lastevent'][_0x1a3c('0x57')]()+']','Recording\x20is\x20enabled!');_0x58036d[_0x1a3c('0x41')]=util[_0x1a3c('0xd')](_0x1a3c('0x42'),_0x7ba0bc[_0x1a3c('0x3d')],_0x58036d['uniqueid'],md5(_0x58036d[_0x1a3c('0x43')]));}else{_0x58036d[_0x1a3c('0x41')]='';}headers[_0x1a3c('0x44')]=getAuth(_0x7ba0bc);return getUser(_0x7ba0bc,'')[_0x1a3c('0x19')](function(_0x24ca01){_0x224797=_0x24ca01;logger['info'](_0x1a3c('0x45'),_0x224797['id']);return getEndUser(_0x7ba0bc,_0x58036d[_0x1a3c('0xf')],_0x58036d[_0x1a3c('0x46')]);})['then'](function(_0x5af7c6){_0x472e41=_0x5af7c6;logger[_0x1a3c('0xa')](_0x1a3c('0x47'),_0x472e41['id']);return getTicket(_0x7ba0bc,_0x224797,_0x472e41,_0x1af80d,_0x58036d);})[_0x1a3c('0x19')](function(_0x467e59){if(_0x467e59){logger['info'](_0x1a3c('0x18'));logger[_0x1a3c('0xa')](_0x1a3c('0x54'),_0x467e59['id']);}})['catch'](function(_0x4e1a5b){logger[_0x1a3c('0x4c')]('['+_0x58036d[_0x1a3c('0x58')]['toUpperCase']()+']',JSON[_0x1a3c('0x4d')](_0x4e1a5b));});};
\ No newline at end of file