Built motion from commit 14588770.|2.5.38
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index e70ea4d..0f9b0fe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x05c7=['calleridname','calleridnum','getString','Subjects','Descriptions','<br>','name','Fields','keyBy','custom_fields','value','%s/api/v2/tickets','remoteUri','then','info','Ticket\x20created!','validateEmail','%s/api/v2/agents','length','find','contact','%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','Basic\x20%s','toString','base64','[HTTP]','stringify','defaults','GET','forEach','includes','string','picklist','type','nameField','idField','customField','content','variable','variableName','push','customVariable','Variable','toLowerCase','queue','serverUrl','stripTrailingSlash','monitor_format','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','Authorization','email','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','%s/helpdesk/tickets/%d','catch','outbound','recordingFormat','[OUTBOUND]','Recording\x20is\x20enabled!','uniqueid','destcalleridname','trigger:browser:url','error','unmanaged','toUpperCase','lastevent','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','redis','localhost','application/json','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s'];(function(_0x59e862,_0x477bf2){var _0x1a25ee=function(_0xc61e64){while(--_0xc61e64){_0x59e862['push'](_0x59e862['shift']());}};_0x1a25ee(++_0x477bf2);}(_0x05c7,0x162));var _0x705c=function(_0x309ee3,_0x26c85f){_0x309ee3=_0x309ee3-0x0;var _0x2268e0=_0x05c7[_0x309ee3];return _0x2268e0;};'use strict';var _=require('lodash');var rp=require('request-promise');var md5=require(_0x705c('0x0'));var util=require(_0x705c('0x1'));var Redis=require(_0x705c('0x2'));var intUtil=require(_0x705c('0x3'));var config=require(_0x705c('0x4'));var logger=require(_0x705c('0x5'))(_0x705c('0x6'));config[_0x705c('0x7')]=_['defaults'](config[_0x705c('0x7')],{'host':_0x705c('0x8'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x705c('0x7')]));var headers={'Content-Type':_0x705c('0x9'),'Accept':'application/json'};function emit(_0x439c9e,_0x235850,_0x3fa9b3){io['to'](_0x439c9e)['emit'](_0x235850,_0x3fa9b3);}function getTicket(_0x370db8,_0x5434db,_0xf39764,_0x160e1e,_0x2ddbed){logger['info'](_0x705c('0xa'));var _0x4b92c9=_[_0x705c('0xb')]({'responder_id':_0x5434db['id'],'requester_id':_0xf39764['id'],'name':util[_0x705c('0xc')](_0x705c('0xd'),_0x2ddbed[_0x705c('0xe')]),'phone':_0x2ddbed[_0x705c('0xf')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x705c('0x10')](_0x160e1e[_0x705c('0x11')],_0x2ddbed,'\x20'),'description':intUtil[_0x705c('0x10')](_0x160e1e[_0x705c('0x12')],_0x2ddbed,_0x705c('0x13')),'tags':getTags(_0x160e1e['Tags'],_0x705c('0x14'))},getCustomFields(_0x160e1e[_0x705c('0x15')],_0x2ddbed));_0x4b92c9['custom_fields']=_['mapValues'](_[_0x705c('0x16')](_0x4b92c9[_0x705c('0x17')],'id'),_0x705c('0x18'));return request({'uri':util[_0x705c('0xc')](_0x705c('0x19'),_0x370db8[_0x705c('0x1a')]),'method':'POST','body':_0x4b92c9})[_0x705c('0x1b')](function(_0x203107){logger[_0x705c('0x1c')](_0x705c('0x1d'));return _0x203107;});}function getUser(_0x4aa842,_0x53d984){if(intUtil[_0x705c('0x1e')](_0x53d984)){return request({'uri':util[_0x705c('0xc')](_0x705c('0x1f'),_0x4aa842[_0x705c('0x1a')]),'qs':{'email':_0x53d984}})['then'](function(_0xd3d3bb){if(_0xd3d3bb[_0x705c('0x20')]){logger[_0x705c('0x1c')]('Agent\x20found!');return _[_0x705c('0x21')](_0xd3d3bb,function(_0x5b5cb4){return _0x5b5cb4[_0x705c('0x22')]['email']===_0x53d984;});}else{logger[_0x705c('0x1c')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x705c('0x23'),_0x4aa842[_0x705c('0x1a')])})['then'](function(_0x1cec58){logger[_0x705c('0x1c')](_0x705c('0x24'));return _0x1cec58;});}});}else{logger[_0x705c('0x1c')](_0x705c('0x25'));return request({'uri':util['format'](_0x705c('0x23'),_0x4aa842[_0x705c('0x1a')])})[_0x705c('0x1b')](function(_0x326ba5){logger[_0x705c('0x1c')](_0x705c('0x24'));return _0x326ba5;});}}function getEndUser(_0x16e2d7,_0x1e0990,_0xebd0fc){logger[_0x705c('0x1c')](_0x705c('0x26'),_0xebd0fc);return request({'uri':util[_0x705c('0xc')](_0x705c('0x27'),_0x16e2d7[_0x705c('0x1a')]),'qs':{'phone':_0xebd0fc}})[_0x705c('0x1b')](function(_0x57ac4f){if(_0x57ac4f['length']){logger['info'](_0x705c('0x28'));return _[_0x705c('0x21')](_0x57ac4f,{'phone':_0xebd0fc});}else{logger['info'](_0x705c('0x29'));return request({'uri':util[_0x705c('0xc')](_0x705c('0x27'),_0x16e2d7[_0x705c('0x1a')]),'method':_0x705c('0x2a'),'body':{'name':_0x1e0990,'phone':_0xebd0fc}})[_0x705c('0x1b')](function(_0x42b2a8){logger[_0x705c('0x1c')]('Enduser\x20created.');return _0x42b2a8;});}});}function getAuth(_0x3c15cb){return util[_0x705c('0xc')](_0x705c('0x2b'),new Buffer(_0x3c15cb['apiKey']+':X')[_0x705c('0x2c')](_0x705c('0x2d')));}function request(_0x4630c0){logger['debug'](_0x705c('0x2e'),JSON[_0x705c('0x2f')](_0x4630c0));return rp(_[_0x705c('0x30')](_0x4630c0,{'method':_0x705c('0x31'),'headers':headers,'json':!![]}));}function getTags(_0x48fe55,_0x1cbf8d){var _0x5acaea=[];if(_0x48fe55&&_0x48fe55[_0x705c('0x20')]>0x0){_0x5acaea=_['map'](_0x48fe55,_0x1cbf8d);}return _0x5acaea;}function getCustomFields(_0x518746,_0x113391){var _0x393581=[];var _0x1ba888={'custom_fields':[]};if(_0x518746[_0x705c('0x20')]>0x0){_[_0x705c('0x32')](_0x518746,function(_0x4de52b){if(_[_0x705c('0x33')]([_0x705c('0x34'),_0x705c('0x35')],_0x4de52b[_0x705c('0x36')])&&_0x4de52b[_0x705c('0x37')]&&!_0x4de52b['customField']){_0x1ba888[_0x4de52b[_0x705c('0x37')]['toLowerCase']()]=_0x4de52b['content'][_0x705c('0x2c')]();}else if(_['includes'](['string',_0x705c('0x35')],_0x4de52b[_0x705c('0x36')])&&_0x4de52b[_0x705c('0x38')]&&_0x4de52b[_0x705c('0x39')]){_0x1ba888[_0x705c('0x17')]['push']({'id':_0x4de52b['idField'],'value':_0x4de52b[_0x705c('0x3a')]['toString']()});}else if(_0x4de52b[_0x705c('0x36')]===_0x705c('0x3b')&&_0x4de52b[_0x705c('0x3c')]&&_0x4de52b[_0x705c('0x38')]&&_0x4de52b[_0x705c('0x39')]){_0x113391[_0x4de52b['variableName']]&&_0x1ba888[_0x705c('0x17')][_0x705c('0x3d')]({'id':_0x4de52b[_0x705c('0x38')],'value':_0x113391[_0x4de52b['variableName']][_0x705c('0x2c')]()});}else if(_0x4de52b['type']===_0x705c('0x3e')&&_0x4de52b[_0x705c('0x3f')]&&_0x4de52b['Variable'][_0x705c('0x14')]&&_0x4de52b[_0x705c('0x38')]&&_0x4de52b[_0x705c('0x39')]){_0x113391[_0x4de52b[_0x705c('0x3f')]['name'][_0x705c('0x40')]()]&&_0x1ba888[_0x705c('0x17')]['push']({'id':_0x4de52b[_0x705c('0x38')],'value':_0x113391[_0x4de52b['Variable']['name'][_0x705c('0x40')]()][_0x705c('0x2c')]()});}});}return _0x1ba888;}exports[_0x705c('0x41')]=function(_0x11b1f5,_0x51dc26,_0x158318,_0x1ae75e,_0x2c1099,_0xa695b5){var _0x487340,_0x4aab8a;_0xa695b5[_0x705c('0x1a')]=intUtil['stripTrailingSlash'](_0xa695b5['remoteUri']);_0xa695b5[_0x705c('0x42')]=intUtil[_0x705c('0x43')](_0xa695b5[_0x705c('0x42')]);if(_0x2c1099&&_0x2c1099[_0x705c('0x44')]){logger[_0x705c('0x1c')]('[QUEUE]','Recording\x20is\x20enabled!');_0x51dc26[_0x705c('0x45')]=util['format'](_0x705c('0x46'),_0xa695b5[_0x705c('0x42')],_0x51dc26['uniqueid'],md5(_0x51dc26['uniqueid']));}else{_0x51dc26[_0x705c('0x45')]='';}headers[_0x705c('0x47')]=getAuth(_0xa695b5);return getUser(_0xa695b5,_0x1ae75e[_0x705c('0x48')])[_0x705c('0x1b')](function(_0x287718){_0x487340=_0x287718;logger[_0x705c('0x1c')](_0x705c('0x49'),_0x487340['id']);return getEndUser(_0xa695b5,_0x51dc26[_0x705c('0xe')],_0x51dc26[_0x705c('0xf')]);})[_0x705c('0x1b')](function(_0x3cd743){_0x4aab8a=_0x3cd743;logger[_0x705c('0x1c')](_0x705c('0x4a'),_0x4aab8a['id']);return getTicket(_0xa695b5,_0x487340,_0x4aab8a,_0x158318,_0x51dc26);})[_0x705c('0x1b')](function(_0x2c62f1){if(_0x2c62f1&&_0x2c62f1['id']){logger[_0x705c('0x1c')]('Ticket\x20created!');logger['info'](_0x705c('0x4b'),_0x2c62f1['id']);logger[_0x705c('0x1c')](_0x705c('0x4c'),_0x705c('0x4d'));emit(util[_0x705c('0xc')](_0x705c('0x4e'),_0x1ae75e[_0x705c('0x14')]),'trigger:browser:url',{'uri':util[_0x705c('0xc')](_0x705c('0x4f'),_0xa695b5[_0x705c('0x1a')],_0x2c62f1['id'])});}})[_0x705c('0x50')](function(_0x59ee17){logger['error']('[QUEUE]',JSON[_0x705c('0x2f')](_0x59ee17));});};exports[_0x705c('0x51')]=function(_0x3470ab,_0x91a427,_0x2cf479,_0x9c5cc6,_0x125f0f,_0x345ce9,_0x76e7cc){var _0x21ee49,_0x525b03;_0x345ce9[_0x705c('0x1a')]=intUtil[_0x705c('0x43')](_0x345ce9['remoteUri']);_0x345ce9['serverUrl']=intUtil[_0x705c('0x43')](_0x345ce9[_0x705c('0x42')]);if(_0x76e7cc&&_0x76e7cc[_0x705c('0x52')]&&_0x76e7cc[_0x705c('0x52')]!=='none'){logger['info'](_0x705c('0x53'),_0x705c('0x54'));_0x91a427[_0x705c('0x45')]=util[_0x705c('0xc')](_0x705c('0x46'),_0x345ce9['serverUrl'],_0x91a427[_0x705c('0x55')],md5(_0x91a427[_0x705c('0x55')]));}headers[_0x705c('0x47')]=getAuth(_0x345ce9);return getUser(_0x345ce9,_0x9c5cc6[_0x705c('0x48')])[_0x705c('0x1b')](function(_0x35e72a){_0x21ee49=_0x35e72a;logger['info'](_0x705c('0x49'),_0x21ee49['id']);return getEndUser(_0x345ce9,_0x91a427[_0x705c('0x56')],_0x91a427['destcalleridnum']);})[_0x705c('0x1b')](function(_0x40fc7c){_0x525b03=_0x40fc7c;logger['info']('The\x20Enduser\x20ID\x20is:',_0x525b03['id']);return getTicket(_0x345ce9,_0x21ee49,_0x525b03,_0x2cf479,_0x91a427);})['then'](function(_0x176cdc){if(_0x176cdc&&_0x176cdc['id']){logger['info'](_0x705c('0x1d'));logger[_0x705c('0x1c')](_0x705c('0x4b'),_0x176cdc['id']);logger[_0x705c('0x1c')]('[OUTBOUND]',_0x705c('0x4d'));emit(util[_0x705c('0xc')]('user:%s',_0x9c5cc6[_0x705c('0x14')]),_0x705c('0x57'),{'uri':util[_0x705c('0xc')](_0x705c('0x4f'),_0x345ce9[_0x705c('0x1a')],_0x176cdc['id'])});}})['catch'](function(_0x48e67f){logger[_0x705c('0x58')](_0x705c('0x53'),JSON['stringify'](_0x48e67f));});};exports[_0x705c('0x59')]=function(_0x2a5a11,_0x121028,_0x2f490b,_0x3a8b2c,_0x513d7c,_0xa32651){var _0x15a88c,_0x35cebb;_0xa32651['remoteUri']=intUtil[_0x705c('0x43')](_0xa32651[_0x705c('0x1a')]);_0xa32651[_0x705c('0x42')]=intUtil['stripTrailingSlash'](_0xa32651[_0x705c('0x42')]);if(_0x513d7c&&_0x513d7c[_0x705c('0x44')]){logger[_0x705c('0x1c')]('['+_0x121028['lastevent'][_0x705c('0x5a')]()+']',_0x705c('0x54'));_0x121028['recordingURL']=util[_0x705c('0xc')](_0x705c('0x46'),_0xa32651[_0x705c('0x42')],_0x121028[_0x705c('0x55')],md5(_0x121028[_0x705c('0x55')]));}else{_0x121028[_0x705c('0x45')]='';}headers[_0x705c('0x47')]=getAuth(_0xa32651);return getUser(_0xa32651,'')[_0x705c('0x1b')](function(_0x2d4c4a){_0x15a88c=_0x2d4c4a;logger[_0x705c('0x1c')]('The\x20User\x20ID\x20is:',_0x15a88c['id']);return getEndUser(_0xa32651,_0x121028[_0x705c('0xe')],_0x121028[_0x705c('0xf')]);})[_0x705c('0x1b')](function(_0x496b98){_0x35cebb=_0x496b98;logger[_0x705c('0x1c')](_0x705c('0x4a'),_0x35cebb['id']);return getTicket(_0xa32651,_0x15a88c,_0x35cebb,_0x2f490b,_0x121028);})[_0x705c('0x1b')](function(_0x540f26){if(_0x540f26){logger[_0x705c('0x1c')](_0x705c('0x1d'));logger[_0x705c('0x1c')](_0x705c('0x4b'),_0x540f26['id']);}})[_0x705c('0x50')](function(_0x355d3a){logger[_0x705c('0x58')]('['+_0x121028[_0x705c('0x5b')][_0x705c('0x5a')]()+']',JSON[_0x705c('0x2f')](_0x355d3a));});};
\ No newline at end of file
+var _0x5844=['Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','base64','debug','[HTTP]','stringify','GET','map','forEach','type','customField','toLowerCase','toString','includes','string','push','idField','variable','variableName','customVariable','Variable','queue','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','uniqueid','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','recordingFormat','none','[OUTBOUND]','Authorization','destcalleridname','destcalleridnum','toUpperCase','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','lastevent','lodash','request-promise','md5','ioredis','./util','../../../../config/logger','freshdesk','redis','defaults','localhost','application/json','emit','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridname','calleridnum','getString','Subjects','Descriptions','<br>','Tags','name','Fields','mapValues','keyBy','custom_fields','%s/api/v2/tickets','remoteUri','POST','info','Ticket\x20created!','validateEmail','%s/api/v2/agents','then','length','find','contact','email','%s/api/v2/agents/me','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.'];(function(_0x40a045,_0x516f0e){var _0x1a687c=function(_0x48c9fe){while(--_0x48c9fe){_0x40a045['push'](_0x40a045['shift']());}};_0x1a687c(++_0x516f0e);}(_0x5844,0x141));var _0x4584=function(_0x4bf0e5,_0x5e0954){_0x4bf0e5=_0x4bf0e5-0x0;var _0x16cd41=_0x5844[_0x4bf0e5];return _0x16cd41;};'use strict';var _=require(_0x4584('0x0'));var rp=require(_0x4584('0x1'));var md5=require(_0x4584('0x2'));var util=require('util');var Redis=require(_0x4584('0x3'));var intUtil=require(_0x4584('0x4'));var config=require('../../../../config/environment');var logger=require(_0x4584('0x5'))(_0x4584('0x6'));config[_0x4584('0x7')]=_[_0x4584('0x8')](config[_0x4584('0x7')],{'host':_0x4584('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x4584('0x7')]));var headers={'Content-Type':'application/json','Accept':_0x4584('0xa')};function emit(_0x50f6a5,_0x119cac,_0x404f86){io['to'](_0x50f6a5)[_0x4584('0xb')](_0x119cac,_0x404f86);}function getTicket(_0x4aeba2,_0x48d513,_0x1b1183,_0x266167,_0x503f4e){logger['info'](_0x4584('0xc'));var _0x18b494=_[_0x4584('0xd')]({'responder_id':_0x48d513['id'],'requester_id':_0x1b1183['id'],'name':util[_0x4584('0xe')](_0x4584('0xf'),_0x503f4e[_0x4584('0x10')]),'phone':_0x503f4e[_0x4584('0x11')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x4584('0x12')](_0x266167[_0x4584('0x13')],_0x503f4e,'\x20'),'description':intUtil['getString'](_0x266167[_0x4584('0x14')],_0x503f4e,_0x4584('0x15')),'tags':getTags(_0x266167[_0x4584('0x16')],_0x4584('0x17'))},getCustomFields(_0x266167[_0x4584('0x18')],_0x503f4e));_0x18b494['custom_fields']=_[_0x4584('0x19')](_[_0x4584('0x1a')](_0x18b494[_0x4584('0x1b')],'id'),'value');return request({'uri':util[_0x4584('0xe')](_0x4584('0x1c'),_0x4aeba2[_0x4584('0x1d')]),'method':_0x4584('0x1e'),'body':_0x18b494})['then'](function(_0x2513db){logger[_0x4584('0x1f')](_0x4584('0x20'));return _0x2513db;});}function getUser(_0x348f7d,_0x4de179){if(intUtil[_0x4584('0x21')](_0x4de179)){return request({'uri':util[_0x4584('0xe')](_0x4584('0x22'),_0x348f7d['remoteUri']),'qs':{'email':_0x4de179}})[_0x4584('0x23')](function(_0x189ff0){if(_0x189ff0[_0x4584('0x24')]){logger[_0x4584('0x1f')]('Agent\x20found!');return _[_0x4584('0x25')](_0x189ff0,function(_0x6d89d9){return _0x6d89d9[_0x4584('0x26')][_0x4584('0x27')]===_0x4de179;});}else{logger[_0x4584('0x1f')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x4584('0x28'),_0x348f7d[_0x4584('0x1d')])})[_0x4584('0x23')](function(_0x44f8a7){logger[_0x4584('0x1f')]('Admin\x20account\x20selected.');return _0x44f8a7;});}});}else{logger['info'](_0x4584('0x29'));return request({'uri':util[_0x4584('0xe')](_0x4584('0x28'),_0x348f7d[_0x4584('0x1d')])})[_0x4584('0x23')](function(_0x5d1dbd){logger['info'](_0x4584('0x2a'));return _0x5d1dbd;});}}function getEndUser(_0x3fed48,_0x263a5d,_0x35179a){logger['info'](_0x4584('0x2b'),_0x35179a);return request({'uri':util['format'](_0x4584('0x2c'),_0x3fed48['remoteUri']),'qs':{'phone':_0x35179a}})[_0x4584('0x23')](function(_0x341b60){if(_0x341b60[_0x4584('0x24')]){logger[_0x4584('0x1f')](_0x4584('0x2d'));return _[_0x4584('0x25')](_0x341b60,{'phone':_0x35179a});}else{logger[_0x4584('0x1f')](_0x4584('0x2e'));return request({'uri':util[_0x4584('0xe')](_0x4584('0x2c'),_0x3fed48[_0x4584('0x1d')]),'method':_0x4584('0x1e'),'body':{'name':_0x263a5d,'phone':_0x35179a}})[_0x4584('0x23')](function(_0xfac315){logger[_0x4584('0x1f')]('Enduser\x20created.');return _0xfac315;});}});}function getAuth(_0x5065ce){return util['format']('Basic\x20%s',new Buffer(_0x5065ce['apiKey']+':X')['toString'](_0x4584('0x2f')));}function request(_0x3bc3f7){logger[_0x4584('0x30')](_0x4584('0x31'),JSON[_0x4584('0x32')](_0x3bc3f7));return rp(_['defaults'](_0x3bc3f7,{'method':_0x4584('0x33'),'headers':headers,'json':!![]}));}function getTags(_0x11160d,_0x3d5ec3){var _0x141e77=[];if(_0x11160d&&_0x11160d[_0x4584('0x24')]>0x0){_0x141e77=_[_0x4584('0x34')](_0x11160d,_0x3d5ec3);}return _0x141e77;}function getCustomFields(_0x2e6bbe,_0x45da03){var _0x21c82a=[];var _0x47c05c={'custom_fields':[]};if(_0x2e6bbe[_0x4584('0x24')]>0x0){_[_0x4584('0x35')](_0x2e6bbe,function(_0x1c9f3c){if(_['includes'](['string','picklist'],_0x1c9f3c[_0x4584('0x36')])&&_0x1c9f3c['nameField']&&!_0x1c9f3c[_0x4584('0x37')]){_0x47c05c[_0x1c9f3c['nameField'][_0x4584('0x38')]()]=_0x1c9f3c['content'][_0x4584('0x39')]();}else if(_[_0x4584('0x3a')]([_0x4584('0x3b'),'picklist'],_0x1c9f3c[_0x4584('0x36')])&&_0x1c9f3c['idField']&&_0x1c9f3c[_0x4584('0x37')]){_0x47c05c[_0x4584('0x1b')][_0x4584('0x3c')]({'id':_0x1c9f3c[_0x4584('0x3d')],'value':_0x1c9f3c['content'][_0x4584('0x39')]()});}else if(_0x1c9f3c['type']===_0x4584('0x3e')&&_0x1c9f3c[_0x4584('0x3f')]&&_0x1c9f3c[_0x4584('0x3d')]&&_0x1c9f3c['customField']){_0x45da03[_0x1c9f3c[_0x4584('0x3f')]]&&_0x47c05c[_0x4584('0x1b')]['push']({'id':_0x1c9f3c[_0x4584('0x3d')],'value':_0x45da03[_0x1c9f3c[_0x4584('0x3f')]][_0x4584('0x39')]()});}else if(_0x1c9f3c[_0x4584('0x36')]===_0x4584('0x40')&&_0x1c9f3c['Variable']&&_0x1c9f3c[_0x4584('0x41')][_0x4584('0x17')]&&_0x1c9f3c[_0x4584('0x3d')]&&_0x1c9f3c[_0x4584('0x37')]){_0x45da03[_0x1c9f3c[_0x4584('0x41')][_0x4584('0x17')][_0x4584('0x38')]()]&&_0x47c05c[_0x4584('0x1b')]['push']({'id':_0x1c9f3c['idField'],'value':_0x45da03[_0x1c9f3c['Variable']['name']['toLowerCase']()][_0x4584('0x39')]()});}});}return _0x47c05c;}exports[_0x4584('0x42')]=function(_0x2b43a0,_0x54f039,_0x143887,_0x560510,_0x2e6d1b,_0x2f2309){var _0x4e5c74,_0x3525c7;_0x2f2309[_0x4584('0x1d')]=intUtil['stripTrailingSlash'](_0x2f2309[_0x4584('0x1d')]);_0x2f2309[_0x4584('0x43')]=intUtil[_0x4584('0x44')](_0x2f2309[_0x4584('0x43')]);if(_0x2e6d1b&&_0x2e6d1b[_0x4584('0x45')]){logger[_0x4584('0x1f')](_0x4584('0x46'),_0x4584('0x47'));_0x54f039[_0x4584('0x48')]=util['format']('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x2f2309['serverUrl'],_0x54f039[_0x4584('0x49')],md5(_0x54f039[_0x4584('0x49')]));}else{_0x54f039[_0x4584('0x48')]='';}headers['Authorization']=getAuth(_0x2f2309);return getUser(_0x2f2309,_0x560510[_0x4584('0x27')])[_0x4584('0x23')](function(_0x51a555){_0x4e5c74=_0x51a555;logger[_0x4584('0x1f')](_0x4584('0x4a'),_0x4e5c74['id']);return getEndUser(_0x2f2309,_0x54f039[_0x4584('0x10')],_0x54f039[_0x4584('0x11')]);})[_0x4584('0x23')](function(_0x427e43){_0x3525c7=_0x427e43;logger[_0x4584('0x1f')](_0x4584('0x4b'),_0x3525c7['id']);return getTicket(_0x2f2309,_0x4e5c74,_0x3525c7,_0x143887,_0x54f039);})['then'](function(_0x278d16){if(_0x278d16&&_0x278d16['id']){logger['info'](_0x4584('0x20'));logger['info'](_0x4584('0x4c'),_0x278d16['id']);logger[_0x4584('0x1f')](_0x4584('0x46'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x4584('0xe')](_0x4584('0x4d'),_0x560510[_0x4584('0x17')]),_0x4584('0x4e'),{'uri':util[_0x4584('0xe')](_0x4584('0x4f'),_0x2f2309[_0x4584('0x1d')],_0x278d16['id'])});}})[_0x4584('0x50')](function(_0x3dd5a9){logger[_0x4584('0x51')]('[QUEUE]',JSON[_0x4584('0x32')](_0x3dd5a9));});};exports['outbound']=function(_0x1c4882,_0x3fe4f3,_0x568490,_0x9d9a05,_0x21ca37,_0x42f763,_0x588337){var _0x4829c1,_0x25fe9f;_0x42f763['remoteUri']=intUtil[_0x4584('0x44')](_0x42f763[_0x4584('0x1d')]);_0x42f763[_0x4584('0x43')]=intUtil['stripTrailingSlash'](_0x42f763['serverUrl']);if(_0x588337&&_0x588337[_0x4584('0x52')]&&_0x588337[_0x4584('0x52')]!==_0x4584('0x53')){logger[_0x4584('0x1f')](_0x4584('0x54'),'Recording\x20is\x20enabled!');_0x3fe4f3['recordingURL']=util[_0x4584('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x42f763[_0x4584('0x43')],_0x3fe4f3[_0x4584('0x49')],md5(_0x3fe4f3[_0x4584('0x49')]));}headers[_0x4584('0x55')]=getAuth(_0x42f763);return getUser(_0x42f763,_0x9d9a05['email'])[_0x4584('0x23')](function(_0x42f9ca){_0x4829c1=_0x42f9ca;logger[_0x4584('0x1f')](_0x4584('0x4a'),_0x4829c1['id']);return getEndUser(_0x42f763,_0x3fe4f3[_0x4584('0x56')],_0x3fe4f3[_0x4584('0x57')]);})[_0x4584('0x23')](function(_0x40cb59){_0x25fe9f=_0x40cb59;logger[_0x4584('0x1f')](_0x4584('0x4b'),_0x25fe9f['id']);return getTicket(_0x42f763,_0x4829c1,_0x25fe9f,_0x568490,_0x3fe4f3);})[_0x4584('0x23')](function(_0x1cafcd){if(_0x1cafcd&&_0x1cafcd['id']){logger['info'](_0x4584('0x20'));logger['info']('The\x20Ticket\x20ID\x20is:',_0x1cafcd['id']);logger[_0x4584('0x1f')](_0x4584('0x54'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x4584('0xe')]('user:%s',_0x9d9a05[_0x4584('0x17')]),_0x4584('0x4e'),{'uri':util[_0x4584('0xe')](_0x4584('0x4f'),_0x42f763['remoteUri'],_0x1cafcd['id'])});}})[_0x4584('0x50')](function(_0x3fa0df){logger[_0x4584('0x51')](_0x4584('0x54'),JSON[_0x4584('0x32')](_0x3fa0df));});};exports['unmanaged']=function(_0x6ceae2,_0x5f25e8,_0x181616,_0x16fc53,_0xabe1c0,_0x37c44a){var _0x7fd2d5,_0x55c600;_0x37c44a['remoteUri']=intUtil[_0x4584('0x44')](_0x37c44a[_0x4584('0x1d')]);_0x37c44a[_0x4584('0x43')]=intUtil[_0x4584('0x44')](_0x37c44a['serverUrl']);if(_0xabe1c0&&_0xabe1c0[_0x4584('0x45')]){logger['info']('['+_0x5f25e8['lastevent'][_0x4584('0x58')]()+']',_0x4584('0x47'));_0x5f25e8[_0x4584('0x48')]=util[_0x4584('0xe')](_0x4584('0x59'),_0x37c44a['serverUrl'],_0x5f25e8[_0x4584('0x49')],md5(_0x5f25e8['uniqueid']));}else{_0x5f25e8[_0x4584('0x48')]='';}headers[_0x4584('0x55')]=getAuth(_0x37c44a);return getUser(_0x37c44a,'')[_0x4584('0x23')](function(_0x275afa){_0x7fd2d5=_0x275afa;logger[_0x4584('0x1f')](_0x4584('0x4a'),_0x7fd2d5['id']);return getEndUser(_0x37c44a,_0x5f25e8[_0x4584('0x10')],_0x5f25e8[_0x4584('0x11')]);})['then'](function(_0x35e62d){_0x55c600=_0x35e62d;logger[_0x4584('0x1f')](_0x4584('0x4b'),_0x55c600['id']);return getTicket(_0x37c44a,_0x7fd2d5,_0x55c600,_0x181616,_0x5f25e8);})['then'](function(_0x319fe9){if(_0x319fe9){logger['info'](_0x4584('0x20'));logger['info'](_0x4584('0x4c'),_0x319fe9['id']);}})[_0x4584('0x50')](function(_0x506416){logger[_0x4584('0x51')]('['+_0x5f25e8[_0x4584('0x5a')][_0x4584('0x58')]()+']',JSON[_0x4584('0x32')](_0x506416));});};
\ No newline at end of file