Built motion from commit fda31434.|2.5.44
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 94e7988..0ac5b4f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1f52=['name','Fields','mapValues','keyBy','custom_fields','value','format','remoteUri','then','Ticket\x20created!','validateEmail','length','find','contact','email','%s/api/v2/agents/me','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Basic\x20%s','apiKey','toString','base64','debug','[HTTP]','GET','forEach','includes','string','picklist','nameField','customField','content','type','idField','push','variable','variableName','Variable','toLowerCase','queue','stripTrailingSlash','serverUrl','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','[QUEUE]','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','recordingFormat','none','[OUTBOUND]','destcalleridname','stringify','unmanaged','monitor_format','lastevent','toUpperCase','recordingURL','lodash','request-promise','md5','util','ioredis','../../../../config/environment','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','info','Creating\x20new\x20ticket...','merge','Caller\x20-\x20%s','calleridname','calleridnum','getString','Descriptions','<br>'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x1f52,0xf9));var _0x21f5=function(_0x2509be,_0x5c9173){_0x2509be=_0x2509be-0x0;var _0x2f2f00=_0x1f52[_0x2509be];return _0x2f2f00;};'use strict';var _=require(_0x21f5('0x0'));var rp=require(_0x21f5('0x1'));var md5=require(_0x21f5('0x2'));var util=require(_0x21f5('0x3'));var Redis=require(_0x21f5('0x4'));var intUtil=require('./util');var config=require(_0x21f5('0x5'));var logger=require('../../../../config/logger')(_0x21f5('0x6'));config[_0x21f5('0x7')]=_[_0x21f5('0x8')](config[_0x21f5('0x7')],{'host':_0x21f5('0x9'),'port':0x18eb});var io=require(_0x21f5('0xa'))(new Redis(config[_0x21f5('0x7')]));var headers={'Content-Type':_0x21f5('0xb'),'Accept':_0x21f5('0xb')};function emit(_0x4ce1b6,_0x4aaf73,_0x3ba8de){io['to'](_0x4ce1b6)['emit'](_0x4aaf73,_0x3ba8de);}function getTicket(_0x39b637,_0x19a46d,_0x57e76b,_0x58e76a,_0x39cceb){logger[_0x21f5('0xc')](_0x21f5('0xd'));var _0x2fe2e1=_[_0x21f5('0xe')]({'responder_id':_0x19a46d['id'],'requester_id':_0x57e76b['id'],'name':util['format'](_0x21f5('0xf'),_0x39cceb[_0x21f5('0x10')]),'phone':_0x39cceb[_0x21f5('0x11')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0x58e76a['Subjects'],_0x39cceb,'\x20'),'description':intUtil[_0x21f5('0x12')](_0x58e76a[_0x21f5('0x13')],_0x39cceb,_0x21f5('0x14')),'tags':getTags(_0x58e76a['Tags'],_0x21f5('0x15'))},getCustomFields(_0x58e76a[_0x21f5('0x16')],_0x39cceb));_0x2fe2e1['custom_fields']=_[_0x21f5('0x17')](_[_0x21f5('0x18')](_0x2fe2e1[_0x21f5('0x19')],'id'),_0x21f5('0x1a'));return request({'uri':util[_0x21f5('0x1b')]('%s/api/v2/tickets',_0x39b637[_0x21f5('0x1c')]),'method':'POST','body':_0x2fe2e1})[_0x21f5('0x1d')](function(_0x14e993){logger[_0x21f5('0xc')](_0x21f5('0x1e'));return _0x14e993;});}function getUser(_0x3f4bc3,_0x1c6a94){if(intUtil[_0x21f5('0x1f')](_0x1c6a94)){return request({'uri':util[_0x21f5('0x1b')]('%s/api/v2/agents',_0x3f4bc3[_0x21f5('0x1c')]),'qs':{'email':_0x1c6a94}})['then'](function(_0x14abd4){if(_0x14abd4[_0x21f5('0x20')]){logger[_0x21f5('0xc')]('Agent\x20found!');return _[_0x21f5('0x21')](_0x14abd4,function(_0x3033b6){return _0x3033b6[_0x21f5('0x22')][_0x21f5('0x23')]===_0x1c6a94;});}else{logger['info']('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x21f5('0x1b')](_0x21f5('0x24'),_0x3f4bc3[_0x21f5('0x1c')])})[_0x21f5('0x1d')](function(_0x250801){logger[_0x21f5('0xc')](_0x21f5('0x25'));return _0x250801;});}});}else{logger[_0x21f5('0xc')](_0x21f5('0x26'));return request({'uri':util[_0x21f5('0x1b')](_0x21f5('0x24'),_0x3f4bc3['remoteUri'])})[_0x21f5('0x1d')](function(_0x1db8d2){logger[_0x21f5('0xc')](_0x21f5('0x25'));return _0x1db8d2;});}}function getEndUser(_0x1ea397,_0x5364d1,_0x32a8a1){logger[_0x21f5('0xc')]('Searching\x20enduser\x20with\x20phone',_0x32a8a1);return request({'uri':util[_0x21f5('0x1b')](_0x21f5('0x27'),_0x1ea397['remoteUri']),'qs':{'phone':_0x32a8a1}})[_0x21f5('0x1d')](function(_0xed4a10){if(_0xed4a10[_0x21f5('0x20')]){logger['info'](_0x21f5('0x28'));return _[_0x21f5('0x21')](_0xed4a10,{'phone':_0x32a8a1});}else{logger[_0x21f5('0xc')](_0x21f5('0x29'));return request({'uri':util['format'](_0x21f5('0x27'),_0x1ea397[_0x21f5('0x1c')]),'method':_0x21f5('0x2a'),'body':{'name':_0x5364d1,'phone':_0x32a8a1}})[_0x21f5('0x1d')](function(_0x143407){logger[_0x21f5('0xc')]('Enduser\x20created.');return _0x143407;});}});}function getAuth(_0x8f759b){return util[_0x21f5('0x1b')](_0x21f5('0x2b'),new Buffer(_0x8f759b[_0x21f5('0x2c')]+':X')[_0x21f5('0x2d')](_0x21f5('0x2e')));}function request(_0x25e84b){logger[_0x21f5('0x2f')](_0x21f5('0x30'),JSON['stringify'](_0x25e84b));return rp(_[_0x21f5('0x8')](_0x25e84b,{'method':_0x21f5('0x31'),'headers':headers,'json':!![]}));}function getTags(_0x18504e,_0x12d071){var _0x1e11ec=[];if(_0x18504e&&_0x18504e[_0x21f5('0x20')]>0x0){_0x1e11ec=_['map'](_0x18504e,_0x12d071);}return _0x1e11ec;}function getCustomFields(_0x1ff412,_0x1ba62c){var _0x462f66=[];var _0x43dec1={'custom_fields':[]};if(_0x1ff412[_0x21f5('0x20')]>0x0){_[_0x21f5('0x32')](_0x1ff412,function(_0x1cae35){if(_[_0x21f5('0x33')]([_0x21f5('0x34'),_0x21f5('0x35')],_0x1cae35['type'])&&_0x1cae35[_0x21f5('0x36')]&&!_0x1cae35[_0x21f5('0x37')]){_0x43dec1[_0x1cae35[_0x21f5('0x36')]['toLowerCase']()]=_0x1cae35[_0x21f5('0x38')]['toString']();}else if(_[_0x21f5('0x33')](['string',_0x21f5('0x35')],_0x1cae35[_0x21f5('0x39')])&&_0x1cae35[_0x21f5('0x3a')]&&_0x1cae35[_0x21f5('0x37')]){_0x43dec1[_0x21f5('0x19')][_0x21f5('0x3b')]({'id':_0x1cae35[_0x21f5('0x3a')],'value':_0x1cae35[_0x21f5('0x38')][_0x21f5('0x2d')]()});}else if(_0x1cae35[_0x21f5('0x39')]===_0x21f5('0x3c')&&_0x1cae35[_0x21f5('0x3d')]&&_0x1cae35['idField']&&_0x1cae35[_0x21f5('0x37')]){_0x1ba62c[_0x1cae35[_0x21f5('0x3d')]]&&_0x43dec1[_0x21f5('0x19')][_0x21f5('0x3b')]({'id':_0x1cae35[_0x21f5('0x3a')],'value':_0x1ba62c[_0x1cae35[_0x21f5('0x3d')]][_0x21f5('0x2d')]()});}else if(_0x1cae35[_0x21f5('0x39')]==='customVariable'&&_0x1cae35[_0x21f5('0x3e')]&&_0x1cae35['Variable'][_0x21f5('0x15')]&&_0x1cae35[_0x21f5('0x3a')]&&_0x1cae35[_0x21f5('0x37')]){_0x1ba62c[_0x1cae35['Variable']['name'][_0x21f5('0x3f')]()]&&_0x43dec1[_0x21f5('0x19')][_0x21f5('0x3b')]({'id':_0x1cae35[_0x21f5('0x3a')],'value':_0x1ba62c[_0x1cae35[_0x21f5('0x3e')][_0x21f5('0x15')][_0x21f5('0x3f')]()][_0x21f5('0x2d')]()});}});}return _0x43dec1;}exports[_0x21f5('0x40')]=function(_0x1de4eb,_0x1f7e85,_0x13d270,_0x33545b,_0x109632,_0x1e39d1){var _0x48470e,_0x495fe4;_0x1e39d1[_0x21f5('0x1c')]=intUtil[_0x21f5('0x41')](_0x1e39d1['remoteUri']);_0x1e39d1[_0x21f5('0x42')]=intUtil[_0x21f5('0x41')](_0x1e39d1[_0x21f5('0x42')]);if(_0x109632&&_0x109632['monitor_format']){logger[_0x21f5('0xc')]('[QUEUE]',_0x21f5('0x43'));_0x1f7e85['recordingURL']=util[_0x21f5('0x1b')](_0x21f5('0x44'),_0x1e39d1[_0x21f5('0x42')],_0x1f7e85['uniqueid'],md5(_0x1f7e85[_0x21f5('0x45')]));}else{_0x1f7e85['recordingURL']='';}headers[_0x21f5('0x46')]=getAuth(_0x1e39d1);return getUser(_0x1e39d1,_0x33545b[_0x21f5('0x23')])[_0x21f5('0x1d')](function(_0x3cce38){_0x48470e=_0x3cce38;logger[_0x21f5('0xc')](_0x21f5('0x47'),_0x48470e['id']);return getEndUser(_0x1e39d1,_0x1f7e85[_0x21f5('0x10')],_0x1f7e85[_0x21f5('0x11')]);})[_0x21f5('0x1d')](function(_0x522f26){_0x495fe4=_0x522f26;logger[_0x21f5('0xc')](_0x21f5('0x48'),_0x495fe4['id']);return getTicket(_0x1e39d1,_0x48470e,_0x495fe4,_0x13d270,_0x1f7e85);})['then'](function(_0x456507){if(_0x456507&&_0x456507['id']){logger['info'](_0x21f5('0x1e'));logger[_0x21f5('0xc')](_0x21f5('0x49'),_0x456507['id']);logger[_0x21f5('0xc')](_0x21f5('0x4a'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x21f5('0x1b')](_0x21f5('0x4b'),_0x33545b['name']),_0x21f5('0x4c'),{'uri':util['format'](_0x21f5('0x4d'),_0x1e39d1[_0x21f5('0x1c')],_0x456507['id'])});}})[_0x21f5('0x4e')](function(_0x149d08){logger[_0x21f5('0x4f')](_0x21f5('0x4a'),JSON['stringify'](_0x149d08));});};exports['outbound']=function(_0x19cf3f,_0x36547f,_0x155553,_0x3672ce,_0x3d6750,_0x48b44b,_0x57901b){var _0x5b07b2,_0x56b449;_0x48b44b[_0x21f5('0x1c')]=intUtil[_0x21f5('0x41')](_0x48b44b[_0x21f5('0x1c')]);_0x48b44b[_0x21f5('0x42')]=intUtil[_0x21f5('0x41')](_0x48b44b[_0x21f5('0x42')]);if(_0x57901b&&_0x57901b['recordingFormat']&&_0x57901b[_0x21f5('0x50')]!==_0x21f5('0x51')){logger[_0x21f5('0xc')](_0x21f5('0x52'),'Recording\x20is\x20enabled!');_0x36547f['recordingURL']=util[_0x21f5('0x1b')](_0x21f5('0x44'),_0x48b44b[_0x21f5('0x42')],_0x36547f['uniqueid'],md5(_0x36547f['uniqueid']));}headers[_0x21f5('0x46')]=getAuth(_0x48b44b);return getUser(_0x48b44b,_0x3672ce[_0x21f5('0x23')])[_0x21f5('0x1d')](function(_0x127d3e){_0x5b07b2=_0x127d3e;logger['info']('The\x20User\x20ID\x20is:',_0x5b07b2['id']);return getEndUser(_0x48b44b,_0x36547f[_0x21f5('0x53')],_0x36547f['destcalleridnum']);})[_0x21f5('0x1d')](function(_0x414216){_0x56b449=_0x414216;logger['info'](_0x21f5('0x48'),_0x56b449['id']);return getTicket(_0x48b44b,_0x5b07b2,_0x56b449,_0x155553,_0x36547f);})[_0x21f5('0x1d')](function(_0x45d8ac){if(_0x45d8ac&&_0x45d8ac['id']){logger[_0x21f5('0xc')](_0x21f5('0x1e'));logger['info'](_0x21f5('0x49'),_0x45d8ac['id']);logger['info'](_0x21f5('0x52'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x21f5('0x1b')](_0x21f5('0x4b'),_0x3672ce[_0x21f5('0x15')]),_0x21f5('0x4c'),{'uri':util['format']('%s/helpdesk/tickets/%d',_0x48b44b[_0x21f5('0x1c')],_0x45d8ac['id'])});}})['catch'](function(_0x55d195){logger[_0x21f5('0x4f')]('[OUTBOUND]',JSON[_0x21f5('0x54')](_0x55d195));});};exports[_0x21f5('0x55')]=function(_0x34ec14,_0x4b83df,_0x51ad2c,_0x17801c,_0x407812,_0x18efcc){var _0x594974,_0x46d623;_0x18efcc[_0x21f5('0x1c')]=intUtil['stripTrailingSlash'](_0x18efcc[_0x21f5('0x1c')]);_0x18efcc[_0x21f5('0x42')]=intUtil['stripTrailingSlash'](_0x18efcc[_0x21f5('0x42')]);if(_0x407812&&_0x407812[_0x21f5('0x56')]){logger[_0x21f5('0xc')]('['+_0x4b83df[_0x21f5('0x57')][_0x21f5('0x58')]()+']','Recording\x20is\x20enabled!');_0x4b83df[_0x21f5('0x59')]=util['format'](_0x21f5('0x44'),_0x18efcc[_0x21f5('0x42')],_0x4b83df[_0x21f5('0x45')],md5(_0x4b83df[_0x21f5('0x45')]));}else{_0x4b83df[_0x21f5('0x59')]='';}headers[_0x21f5('0x46')]=getAuth(_0x18efcc);return getUser(_0x18efcc,'')[_0x21f5('0x1d')](function(_0x5b0f8c){_0x594974=_0x5b0f8c;logger[_0x21f5('0xc')]('The\x20User\x20ID\x20is:',_0x594974['id']);return getEndUser(_0x18efcc,_0x4b83df['calleridname'],_0x4b83df[_0x21f5('0x11')]);})[_0x21f5('0x1d')](function(_0x5ec974){_0x46d623=_0x5ec974;logger[_0x21f5('0xc')](_0x21f5('0x48'),_0x46d623['id']);return getTicket(_0x18efcc,_0x594974,_0x46d623,_0x51ad2c,_0x4b83df);})[_0x21f5('0x1d')](function(_0x18ddd6){if(_0x18ddd6){logger[_0x21f5('0xc')]('Ticket\x20created!');logger[_0x21f5('0xc')](_0x21f5('0x49'),_0x18ddd6['id']);}})[_0x21f5('0x4e')](function(_0x4fd27d){logger['error']('['+_0x4b83df[_0x21f5('0x57')][_0x21f5('0x58')]()+']',JSON[_0x21f5('0x54')](_0x4fd27d));});};
\ No newline at end of file
+var _0x73f2=['debug','[HTTP]','GET','map','includes','string','type','toLowerCase','picklist','idField','customField','push','content','variableName','customVariable','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','Authorization','The\x20User\x20ID\x20is:','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','%s/helpdesk/tickets/%d','catch','stringify','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','destcalleridname','destcalleridnum','user:%s','error','unmanaged','toUpperCase','lastevent','lodash','md5','util','../../../../config/environment','../../../../config/logger','defaults','redis','localhost','info','Creating\x20new\x20ticket...','merge','format','calleridname','calleridnum','getString','Subjects','Descriptions','<br>','Tags','name','Fields','custom_fields','mapValues','keyBy','value','remoteUri','POST','Ticket\x20created!','validateEmail','length','find','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','then','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20created.','toString'];(function(_0xd8f7bd,_0x45dc8c){var _0x1bd5ee=function(_0x20498e){while(--_0x20498e){_0xd8f7bd['push'](_0xd8f7bd['shift']());}};_0x1bd5ee(++_0x45dc8c);}(_0x73f2,0x128));var _0x273f=function(_0x47d1a8,_0x58fd59){_0x47d1a8=_0x47d1a8-0x0;var _0x5807f9=_0x73f2[_0x47d1a8];return _0x5807f9;};'use strict';var _=require(_0x273f('0x0'));var rp=require('request-promise');var md5=require(_0x273f('0x1'));var util=require(_0x273f('0x2'));var Redis=require('ioredis');var intUtil=require('./util');var config=require(_0x273f('0x3'));var logger=require(_0x273f('0x4'))('freshdesk');config['redis']=_[_0x273f('0x5')](config[_0x273f('0x6')],{'host':_0x273f('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x273f('0x6')]));var headers={'Content-Type':'application/json','Accept':'application/json'};function emit(_0xaee0ae,_0x45b425,_0x356c41){io['to'](_0xaee0ae)['emit'](_0x45b425,_0x356c41);}function getTicket(_0x5e9bfd,_0x5bca67,_0x4c25d2,_0x24f0e5,_0x9fde01){logger[_0x273f('0x8')](_0x273f('0x9'));var _0x5a01f2=_[_0x273f('0xa')]({'responder_id':_0x5bca67['id'],'requester_id':_0x4c25d2['id'],'name':util[_0x273f('0xb')]('Caller\x20-\x20%s',_0x9fde01[_0x273f('0xc')]),'phone':_0x9fde01[_0x273f('0xd')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x273f('0xe')](_0x24f0e5[_0x273f('0xf')],_0x9fde01,'\x20'),'description':intUtil[_0x273f('0xe')](_0x24f0e5[_0x273f('0x10')],_0x9fde01,_0x273f('0x11')),'tags':getTags(_0x24f0e5[_0x273f('0x12')],_0x273f('0x13'))},getCustomFields(_0x24f0e5[_0x273f('0x14')],_0x9fde01));_0x5a01f2[_0x273f('0x15')]=_[_0x273f('0x16')](_[_0x273f('0x17')](_0x5a01f2[_0x273f('0x15')],'id'),_0x273f('0x18'));return request({'uri':util[_0x273f('0xb')]('%s/api/v2/tickets',_0x5e9bfd[_0x273f('0x19')]),'method':_0x273f('0x1a'),'body':_0x5a01f2})['then'](function(_0x342954){logger['info'](_0x273f('0x1b'));return _0x342954;});}function getUser(_0x27a23c,_0x2c32e6){if(intUtil[_0x273f('0x1c')](_0x2c32e6)){return request({'uri':util['format']('%s/api/v2/agents',_0x27a23c['remoteUri']),'qs':{'email':_0x2c32e6}})['then'](function(_0x2e6c35){if(_0x2e6c35[_0x273f('0x1d')]){logger[_0x273f('0x8')]('Agent\x20found!');return _[_0x273f('0x1e')](_0x2e6c35,function(_0x61a2e8){return _0x61a2e8['contact'][_0x273f('0x1f')]===_0x2c32e6;});}else{logger[_0x273f('0x8')](_0x273f('0x20'));return request({'uri':util[_0x273f('0xb')](_0x273f('0x21'),_0x27a23c['remoteUri'])})[_0x273f('0x22')](function(_0x2d335a){logger[_0x273f('0x8')](_0x273f('0x23'));return _0x2d335a;});}});}else{logger[_0x273f('0x8')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format'](_0x273f('0x21'),_0x27a23c['remoteUri'])})[_0x273f('0x22')](function(_0x34d9ef){logger['info'](_0x273f('0x23'));return _0x34d9ef;});}}function getEndUser(_0x15f082,_0x17fed7,_0x2c7005){logger[_0x273f('0x8')](_0x273f('0x24'),_0x2c7005);return request({'uri':util[_0x273f('0xb')](_0x273f('0x25'),_0x15f082['remoteUri']),'qs':{'phone':_0x2c7005}})[_0x273f('0x22')](function(_0x17574a){if(_0x17574a[_0x273f('0x1d')]){logger[_0x273f('0x8')]('Enduser\x20found!');return _[_0x273f('0x1e')](_0x17574a,{'phone':_0x2c7005});}else{logger[_0x273f('0x8')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0x273f('0xb')]('%s/api/v2/contacts',_0x15f082['remoteUri']),'method':'POST','body':{'name':_0x17fed7,'phone':_0x2c7005}})[_0x273f('0x22')](function(_0x23d609){logger[_0x273f('0x8')](_0x273f('0x26'));return _0x23d609;});}});}function getAuth(_0x684872){return util[_0x273f('0xb')]('Basic\x20%s',new Buffer(_0x684872['apiKey']+':X')[_0x273f('0x27')]('base64'));}function request(_0x36ec9e){logger[_0x273f('0x28')](_0x273f('0x29'),JSON['stringify'](_0x36ec9e));return rp(_[_0x273f('0x5')](_0x36ec9e,{'method':_0x273f('0x2a'),'headers':headers,'json':!![]}));}function getTags(_0x335fa6,_0x2a228c){var _0x37cbe7=[];if(_0x335fa6&&_0x335fa6[_0x273f('0x1d')]>0x0){_0x37cbe7=_[_0x273f('0x2b')](_0x335fa6,_0x2a228c);}return _0x37cbe7;}function getCustomFields(_0x19d181,_0x3dc1b4){var _0x4b75ef=[];var _0x57b654={'custom_fields':[]};if(_0x19d181[_0x273f('0x1d')]>0x0){_['forEach'](_0x19d181,function(_0x16e483){if(_[_0x273f('0x2c')]([_0x273f('0x2d'),'picklist'],_0x16e483[_0x273f('0x2e')])&&_0x16e483['nameField']&&!_0x16e483['customField']){_0x57b654[_0x16e483['nameField'][_0x273f('0x2f')]()]=_0x16e483['content'][_0x273f('0x27')]();}else if(_['includes']([_0x273f('0x2d'),_0x273f('0x30')],_0x16e483['type'])&&_0x16e483[_0x273f('0x31')]&&_0x16e483[_0x273f('0x32')]){_0x57b654['custom_fields'][_0x273f('0x33')]({'id':_0x16e483['idField'],'value':_0x16e483[_0x273f('0x34')]['toString']()});}else if(_0x16e483[_0x273f('0x2e')]==='variable'&&_0x16e483[_0x273f('0x35')]&&_0x16e483['idField']&&_0x16e483[_0x273f('0x32')]){_0x3dc1b4[_0x16e483[_0x273f('0x35')]]&&_0x57b654['custom_fields']['push']({'id':_0x16e483[_0x273f('0x31')],'value':_0x3dc1b4[_0x16e483[_0x273f('0x35')]]['toString']()});}else if(_0x16e483[_0x273f('0x2e')]===_0x273f('0x36')&&_0x16e483['Variable']&&_0x16e483[_0x273f('0x37')]['name']&&_0x16e483[_0x273f('0x31')]&&_0x16e483[_0x273f('0x32')]){_0x3dc1b4[_0x16e483[_0x273f('0x37')]['name'][_0x273f('0x2f')]()]&&_0x57b654[_0x273f('0x15')][_0x273f('0x33')]({'id':_0x16e483[_0x273f('0x31')],'value':_0x3dc1b4[_0x16e483[_0x273f('0x37')][_0x273f('0x13')]['toLowerCase']()][_0x273f('0x27')]()});}});}return _0x57b654;}exports[_0x273f('0x38')]=function(_0x5b5d14,_0xb5b677,_0x5dd509,_0x4d8a38,_0x1b6525,_0x27c4d3){var _0x2ef82d,_0x4f25ac;_0x27c4d3[_0x273f('0x19')]=intUtil[_0x273f('0x39')](_0x27c4d3[_0x273f('0x19')]);_0x27c4d3[_0x273f('0x3a')]=intUtil[_0x273f('0x39')](_0x27c4d3[_0x273f('0x3a')]);if(_0x1b6525&&_0x1b6525[_0x273f('0x3b')]){logger[_0x273f('0x8')]('[QUEUE]','Recording\x20is\x20enabled!');_0xb5b677['recordingURL']=util[_0x273f('0xb')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x27c4d3[_0x273f('0x3a')],_0xb5b677['uniqueid'],md5(_0xb5b677['uniqueid']));}else{_0xb5b677['recordingURL']='';}headers[_0x273f('0x3c')]=getAuth(_0x27c4d3);return getUser(_0x27c4d3,_0x4d8a38[_0x273f('0x1f')])[_0x273f('0x22')](function(_0xb222a2){_0x2ef82d=_0xb222a2;logger['info'](_0x273f('0x3d'),_0x2ef82d['id']);return getEndUser(_0x27c4d3,_0xb5b677[_0x273f('0xc')],_0xb5b677[_0x273f('0xd')]);})[_0x273f('0x22')](function(_0x907800){_0x4f25ac=_0x907800;logger['info'](_0x273f('0x3e'),_0x4f25ac['id']);return getTicket(_0x27c4d3,_0x2ef82d,_0x4f25ac,_0x5dd509,_0xb5b677);})['then'](function(_0x6760f6){if(_0x6760f6&&_0x6760f6['id']){logger[_0x273f('0x8')](_0x273f('0x1b'));logger[_0x273f('0x8')](_0x273f('0x3f'),_0x6760f6['id']);logger[_0x273f('0x8')](_0x273f('0x40'),_0x273f('0x41'));emit(util['format']('user:%s',_0x4d8a38['name']),_0x273f('0x42'),{'uri':util[_0x273f('0xb')](_0x273f('0x43'),_0x27c4d3[_0x273f('0x19')],_0x6760f6['id'])});}})[_0x273f('0x44')](function(_0x4aa4fa){logger['error'](_0x273f('0x40'),JSON[_0x273f('0x45')](_0x4aa4fa));});};exports['outbound']=function(_0x56d333,_0x52a702,_0x51d0da,_0x4e957e,_0x3ad663,_0xfb7198,_0xb77824){var _0x2b7eb0,_0x40bf88;_0xfb7198['remoteUri']=intUtil['stripTrailingSlash'](_0xfb7198[_0x273f('0x19')]);_0xfb7198[_0x273f('0x3a')]=intUtil[_0x273f('0x39')](_0xfb7198[_0x273f('0x3a')]);if(_0xb77824&&_0xb77824[_0x273f('0x46')]&&_0xb77824[_0x273f('0x46')]!==_0x273f('0x47')){logger[_0x273f('0x8')](_0x273f('0x48'),_0x273f('0x49'));_0x52a702[_0x273f('0x4a')]=util[_0x273f('0xb')](_0x273f('0x4b'),_0xfb7198[_0x273f('0x3a')],_0x52a702[_0x273f('0x4c')],md5(_0x52a702[_0x273f('0x4c')]));}headers[_0x273f('0x3c')]=getAuth(_0xfb7198);return getUser(_0xfb7198,_0x4e957e['email'])[_0x273f('0x22')](function(_0x576655){_0x2b7eb0=_0x576655;logger[_0x273f('0x8')]('The\x20User\x20ID\x20is:',_0x2b7eb0['id']);return getEndUser(_0xfb7198,_0x52a702[_0x273f('0x4d')],_0x52a702[_0x273f('0x4e')]);})[_0x273f('0x22')](function(_0x4b189b){_0x40bf88=_0x4b189b;logger['info'](_0x273f('0x3e'),_0x40bf88['id']);return getTicket(_0xfb7198,_0x2b7eb0,_0x40bf88,_0x51d0da,_0x52a702);})[_0x273f('0x22')](function(_0x290910){if(_0x290910&&_0x290910['id']){logger[_0x273f('0x8')](_0x273f('0x1b'));logger[_0x273f('0x8')]('The\x20Ticket\x20ID\x20is:',_0x290910['id']);logger[_0x273f('0x8')](_0x273f('0x48'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format'](_0x273f('0x4f'),_0x4e957e[_0x273f('0x13')]),'trigger:browser:url',{'uri':util[_0x273f('0xb')](_0x273f('0x43'),_0xfb7198[_0x273f('0x19')],_0x290910['id'])});}})[_0x273f('0x44')](function(_0x221023){logger[_0x273f('0x50')](_0x273f('0x48'),JSON[_0x273f('0x45')](_0x221023));});};exports[_0x273f('0x51')]=function(_0x57fed5,_0x2ce2b3,_0x5e5180,_0x30a974,_0x558191,_0x1a797f){var _0x308228,_0x9e5ada;_0x1a797f[_0x273f('0x19')]=intUtil[_0x273f('0x39')](_0x1a797f[_0x273f('0x19')]);_0x1a797f[_0x273f('0x3a')]=intUtil[_0x273f('0x39')](_0x1a797f[_0x273f('0x3a')]);if(_0x558191&&_0x558191[_0x273f('0x3b')]){logger['info']('['+_0x2ce2b3['lastevent'][_0x273f('0x52')]()+']','Recording\x20is\x20enabled!');_0x2ce2b3[_0x273f('0x4a')]=util[_0x273f('0xb')](_0x273f('0x4b'),_0x1a797f[_0x273f('0x3a')],_0x2ce2b3[_0x273f('0x4c')],md5(_0x2ce2b3['uniqueid']));}else{_0x2ce2b3[_0x273f('0x4a')]='';}headers[_0x273f('0x3c')]=getAuth(_0x1a797f);return getUser(_0x1a797f,'')[_0x273f('0x22')](function(_0x45cc48){_0x308228=_0x45cc48;logger[_0x273f('0x8')]('The\x20User\x20ID\x20is:',_0x308228['id']);return getEndUser(_0x1a797f,_0x2ce2b3['calleridname'],_0x2ce2b3['calleridnum']);})[_0x273f('0x22')](function(_0x161d3f){_0x9e5ada=_0x161d3f;logger[_0x273f('0x8')](_0x273f('0x3e'),_0x9e5ada['id']);return getTicket(_0x1a797f,_0x308228,_0x9e5ada,_0x5e5180,_0x2ce2b3);})[_0x273f('0x22')](function(_0x5d2b02){if(_0x5d2b02){logger[_0x273f('0x8')](_0x273f('0x1b'));logger[_0x273f('0x8')]('The\x20Ticket\x20ID\x20is:',_0x5d2b02['id']);}})[_0x273f('0x44')](function(_0x4274a1){logger['error']('['+_0x2ce2b3[_0x273f('0x53')][_0x273f('0x52')]()+']',JSON['stringify'](_0x4274a1));});};
\ No newline at end of file