Built motion from commit e0fa946e.|2.6.5
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index f9a2fb9..1a88226 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0159=['Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','Subjects','getString','Descriptions','<br>','Tags','name','Fields','mapValues','keyBy','custom_fields','%s/api/v2/tickets','POST','Ticket\x20created!','%s/api/v2/agents','remoteUri','then','length','find','email','%s/api/v2/agents/me','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20found!','Basic\x20%s','apiKey','debug','[HTTP]','stringify','GET','map','forEach','type','nameField','content','toString','idField','customField','push','variable','variableName','customVariable','Variable','toLowerCase','queue','stripTrailingSlash','serverUrl','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','recordingURL','The\x20User\x20ID\x20is:','calleridname','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','recordingFormat','none','Authorization','destcalleridname','destcalleridnum','[OUTBOUND]','monitor_format','lastevent','toUpperCase','calleridnum','lodash','util','ioredis','./util','../../../../config/environment','../../../../config/logger','redis','defaults','localhost','socket.io-emitter','application/json','emit','info'];(function(_0x45b072,_0x550fac){var _0x1f3aac=function(_0xd9f3c6){while(--_0xd9f3c6){_0x45b072['push'](_0x45b072['shift']());}};_0x1f3aac(++_0x550fac);}(_0x0159,0xa7));var _0x9015=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0159[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x9015('0x0'));var rp=require('request-promise');var md5=require('md5');var util=require(_0x9015('0x1'));var Redis=require(_0x9015('0x2'));var intUtil=require(_0x9015('0x3'));var config=require(_0x9015('0x4'));var logger=require(_0x9015('0x5'))('freshdesk');config[_0x9015('0x6')]=_[_0x9015('0x7')](config[_0x9015('0x6')],{'host':_0x9015('0x8'),'port':0x18eb});var io=require(_0x9015('0x9'))(new Redis(config['redis']));var headers={'Content-Type':_0x9015('0xa'),'Accept':_0x9015('0xa')};function emit(_0xefa4d5,_0x236b28,_0x104722){io['to'](_0xefa4d5)[_0x9015('0xb')](_0x236b28,_0x104722);}function getTicket(_0x2b1c08,_0x2e25c3,_0x5101b3,_0xcecf8e,_0x5411a5){logger[_0x9015('0xc')](_0x9015('0xd'));var _0x34d39f=_[_0x9015('0xe')]({'responder_id':_0x2e25c3['id'],'requester_id':_0x5101b3['id'],'name':util[_0x9015('0xf')](_0x9015('0x10'),_0x5411a5['calleridname']),'phone':_0x5411a5['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0xcecf8e[_0x9015('0x11')],_0x5411a5,'\x20'),'description':intUtil[_0x9015('0x12')](_0xcecf8e[_0x9015('0x13')],_0x5411a5,_0x9015('0x14')),'tags':getTags(_0xcecf8e[_0x9015('0x15')],_0x9015('0x16'))},getCustomFields(_0xcecf8e[_0x9015('0x17')],_0x5411a5));_0x34d39f['custom_fields']=_[_0x9015('0x18')](_[_0x9015('0x19')](_0x34d39f[_0x9015('0x1a')],'id'),'value');return request({'uri':util[_0x9015('0xf')](_0x9015('0x1b'),_0x2b1c08['remoteUri']),'method':_0x9015('0x1c'),'body':_0x34d39f})['then'](function(_0x5c4dbe){logger[_0x9015('0xc')](_0x9015('0x1d'));return _0x5c4dbe;});}function getUser(_0x5d6871,_0x29ef35){if(intUtil['validateEmail'](_0x29ef35)){return request({'uri':util['format'](_0x9015('0x1e'),_0x5d6871[_0x9015('0x1f')]),'qs':{'email':_0x29ef35}})[_0x9015('0x20')](function(_0x260a72){if(_0x260a72[_0x9015('0x21')]){logger['info']('Agent\x20found!');return _[_0x9015('0x22')](_0x260a72,function(_0x35f2e0){return _0x35f2e0['contact'][_0x9015('0x23')]===_0x29ef35;});}else{logger[_0x9015('0xc')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x9015('0xf')](_0x9015('0x24'),_0x5d6871[_0x9015('0x1f')])})[_0x9015('0x20')](function(_0x13d9d0){logger[_0x9015('0xc')]('Admin\x20account\x20selected.');return _0x13d9d0;});}});}else{logger[_0x9015('0xc')](_0x9015('0x25'));return request({'uri':util[_0x9015('0xf')](_0x9015('0x24'),_0x5d6871['remoteUri'])})[_0x9015('0x20')](function(_0x546b27){logger[_0x9015('0xc')](_0x9015('0x26'));return _0x546b27;});}}function getEndUser(_0x4bbc3a,_0x3cb77c,_0x529f1c){logger[_0x9015('0xc')](_0x9015('0x27'),_0x529f1c);return request({'uri':util[_0x9015('0xf')](_0x9015('0x28'),_0x4bbc3a[_0x9015('0x1f')]),'qs':{'phone':_0x529f1c}})[_0x9015('0x20')](function(_0xc3f4a3){if(_0xc3f4a3['length']){logger[_0x9015('0xc')](_0x9015('0x29'));return _['find'](_0xc3f4a3,{'phone':_0x529f1c});}else{logger[_0x9015('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util['format'](_0x9015('0x28'),_0x4bbc3a['remoteUri']),'method':_0x9015('0x1c'),'body':{'name':_0x3cb77c,'phone':_0x529f1c}})[_0x9015('0x20')](function(_0x3af34a){logger[_0x9015('0xc')]('Enduser\x20created.');return _0x3af34a;});}});}function getAuth(_0x5a29ba){return util[_0x9015('0xf')](_0x9015('0x2a'),new Buffer(_0x5a29ba[_0x9015('0x2b')]+':X')['toString']('base64'));}function request(_0x51bfd2){logger[_0x9015('0x2c')](_0x9015('0x2d'),JSON[_0x9015('0x2e')](_0x51bfd2));return rp(_[_0x9015('0x7')](_0x51bfd2,{'method':_0x9015('0x2f'),'headers':headers,'json':!![]}));}function getTags(_0x3feafb,_0x2d8738){var _0x78f4bc=[];if(_0x3feafb&&_0x3feafb['length']>0x0){_0x78f4bc=_[_0x9015('0x30')](_0x3feafb,_0x2d8738);}return _0x78f4bc;}function getCustomFields(_0x2d3e1c,_0x2138d8){var _0x565d1a=[];var _0x448552={'custom_fields':[]};if(_0x2d3e1c[_0x9015('0x21')]>0x0){_[_0x9015('0x31')](_0x2d3e1c,function(_0x4762b1){if(_0x4762b1[_0x9015('0x32')]==='string'&&_0x4762b1[_0x9015('0x33')]&&!_0x4762b1['customField']){_0x448552[_0x4762b1['nameField']['toLowerCase']()]=_0x4762b1[_0x9015('0x34')][_0x9015('0x35')]();}else if(_0x4762b1[_0x9015('0x32')]==='string'&&_0x4762b1[_0x9015('0x36')]&&_0x4762b1[_0x9015('0x37')]){_0x448552[_0x9015('0x1a')][_0x9015('0x38')]({'id':_0x4762b1['idField'],'value':_0x4762b1[_0x9015('0x34')][_0x9015('0x35')]()});}else if(_0x4762b1['type']===_0x9015('0x39')&&_0x4762b1[_0x9015('0x3a')]&&_0x4762b1['idField']&&_0x4762b1[_0x9015('0x37')]){_0x2138d8[_0x4762b1[_0x9015('0x3a')]]&&_0x448552[_0x9015('0x1a')][_0x9015('0x38')]({'id':_0x4762b1[_0x9015('0x36')],'value':_0x2138d8[_0x4762b1[_0x9015('0x3a')]]['toString']()});}else if(_0x4762b1[_0x9015('0x32')]===_0x9015('0x3b')&&_0x4762b1[_0x9015('0x3c')]&&_0x4762b1[_0x9015('0x3c')]['name']&&_0x4762b1[_0x9015('0x36')]&&_0x4762b1['customField']){_0x2138d8[_0x4762b1[_0x9015('0x3c')]['name'][_0x9015('0x3d')]()]&&_0x448552[_0x9015('0x1a')][_0x9015('0x38')]({'id':_0x4762b1['idField'],'value':_0x2138d8[_0x4762b1['Variable'][_0x9015('0x16')]['toLowerCase']()][_0x9015('0x35')]()});}});}return _0x448552;}exports[_0x9015('0x3e')]=function(_0x21a638,_0x5e7931,_0x3a5843,_0x14ed04,_0x5f4844,_0x20af21){var _0xde3ea9,_0x17942f;_0x20af21['remoteUri']=intUtil[_0x9015('0x3f')](_0x20af21[_0x9015('0x1f')]);_0x20af21['serverUrl']=intUtil[_0x9015('0x3f')](_0x20af21[_0x9015('0x40')]);if(_0x5f4844&&_0x5f4844['monitor_format']){logger[_0x9015('0xc')]('[QUEUE]',_0x9015('0x41'));_0x5e7931['recordingURL']=util[_0x9015('0xf')](_0x9015('0x42'),_0x20af21[_0x9015('0x40')],_0x5e7931[_0x9015('0x43')],md5(_0x5e7931[_0x9015('0x43')]));}else{_0x5e7931[_0x9015('0x44')]='';}headers['Authorization']=getAuth(_0x20af21);return getUser(_0x20af21,_0x14ed04['email'])[_0x9015('0x20')](function(_0x2ea5a1){_0xde3ea9=_0x2ea5a1;logger['info'](_0x9015('0x45'),_0xde3ea9['id']);return getEndUser(_0x20af21,_0x5e7931[_0x9015('0x46')],_0x5e7931['calleridnum']);})[_0x9015('0x20')](function(_0x19f9ba){_0x17942f=_0x19f9ba;logger[_0x9015('0xc')](_0x9015('0x47'),_0x17942f['id']);return getTicket(_0x20af21,_0xde3ea9,_0x17942f,_0x3a5843,_0x5e7931);})[_0x9015('0x20')](function(_0x39e6fc){if(_0x39e6fc&&_0x39e6fc['id']){logger[_0x9015('0xc')]('Ticket\x20created!');logger[_0x9015('0xc')](_0x9015('0x48'),_0x39e6fc['id']);logger[_0x9015('0xc')](_0x9015('0x49'),_0x9015('0x4a'));emit(util[_0x9015('0xf')](_0x9015('0x4b'),_0x14ed04['name']),_0x9015('0x4c'),{'uri':util[_0x9015('0xf')](_0x9015('0x4d'),_0x20af21[_0x9015('0x1f')],_0x39e6fc['id'])});}})[_0x9015('0x4e')](function(_0x41e775){logger[_0x9015('0x4f')](_0x9015('0x49'),JSON[_0x9015('0x2e')](_0x41e775));});};exports['outbound']=function(_0x2600ad,_0x54a18a,_0x54b31a,_0x26df21,_0x541ba0,_0x1cb40e,_0x15a338){var _0x3ad073,_0x2baf85;_0x1cb40e[_0x9015('0x1f')]=intUtil[_0x9015('0x3f')](_0x1cb40e[_0x9015('0x1f')]);_0x1cb40e['serverUrl']=intUtil[_0x9015('0x3f')](_0x1cb40e[_0x9015('0x40')]);if(_0x15a338&&_0x15a338[_0x9015('0x50')]&&_0x15a338[_0x9015('0x50')]!==_0x9015('0x51')){logger[_0x9015('0xc')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x54a18a[_0x9015('0x44')]=util[_0x9015('0xf')](_0x9015('0x42'),_0x1cb40e[_0x9015('0x40')],_0x54a18a[_0x9015('0x43')],md5(_0x54a18a['uniqueid']));}headers[_0x9015('0x52')]=getAuth(_0x1cb40e);return getUser(_0x1cb40e,_0x26df21[_0x9015('0x23')])[_0x9015('0x20')](function(_0x4212de){_0x3ad073=_0x4212de;logger[_0x9015('0xc')](_0x9015('0x45'),_0x3ad073['id']);return getEndUser(_0x1cb40e,_0x54a18a[_0x9015('0x53')],_0x54a18a[_0x9015('0x54')]);})['then'](function(_0x5b026b){_0x2baf85=_0x5b026b;logger[_0x9015('0xc')](_0x9015('0x47'),_0x2baf85['id']);return getTicket(_0x1cb40e,_0x3ad073,_0x2baf85,_0x54b31a,_0x54a18a);})[_0x9015('0x20')](function(_0x14c1a4){if(_0x14c1a4&&_0x14c1a4['id']){logger['info'](_0x9015('0x1d'));logger[_0x9015('0xc')]('The\x20Ticket\x20ID\x20is:',_0x14c1a4['id']);logger[_0x9015('0xc')](_0x9015('0x55'),_0x9015('0x4a'));emit(util[_0x9015('0xf')](_0x9015('0x4b'),_0x26df21[_0x9015('0x16')]),_0x9015('0x4c'),{'uri':util[_0x9015('0xf')](_0x9015('0x4d'),_0x1cb40e[_0x9015('0x1f')],_0x14c1a4['id'])});}})[_0x9015('0x4e')](function(_0x548900){logger[_0x9015('0x4f')](_0x9015('0x55'),JSON[_0x9015('0x2e')](_0x548900));});};exports['unmanaged']=function(_0xcfab41,_0x11ceca,_0x54038f,_0x4ae10d,_0x24c359,_0x37da6c){var _0x2f710e,_0x57f009;_0x37da6c[_0x9015('0x1f')]=intUtil[_0x9015('0x3f')](_0x37da6c[_0x9015('0x1f')]);_0x37da6c[_0x9015('0x40')]=intUtil['stripTrailingSlash'](_0x37da6c[_0x9015('0x40')]);if(_0x24c359&&_0x24c359[_0x9015('0x56')]){logger[_0x9015('0xc')]('['+_0x11ceca[_0x9015('0x57')][_0x9015('0x58')]()+']',_0x9015('0x41'));_0x11ceca[_0x9015('0x44')]=util[_0x9015('0xf')](_0x9015('0x42'),_0x37da6c[_0x9015('0x40')],_0x11ceca[_0x9015('0x43')],md5(_0x11ceca[_0x9015('0x43')]));}else{_0x11ceca['recordingURL']='';}headers[_0x9015('0x52')]=getAuth(_0x37da6c);return getUser(_0x37da6c,'')['then'](function(_0x74f17){_0x2f710e=_0x74f17;logger[_0x9015('0xc')]('The\x20User\x20ID\x20is:',_0x2f710e['id']);return getEndUser(_0x37da6c,_0x11ceca[_0x9015('0x46')],_0x11ceca[_0x9015('0x59')]);})[_0x9015('0x20')](function(_0x5c180c){_0x57f009=_0x5c180c;logger['info'](_0x9015('0x47'),_0x57f009['id']);return getTicket(_0x37da6c,_0x2f710e,_0x57f009,_0x54038f,_0x11ceca);})[_0x9015('0x20')](function(_0x3ff5fa){if(_0x3ff5fa){logger[_0x9015('0xc')](_0x9015('0x1d'));logger[_0x9015('0xc')]('The\x20Ticket\x20ID\x20is:',_0x3ff5fa['id']);}})['catch'](function(_0x3df17f){logger[_0x9015('0x4f')]('['+_0x11ceca[_0x9015('0x57')][_0x9015('0x58')]()+']',JSON[_0x9015('0x2e')](_0x3df17f));});};
\ No newline at end of file
+var _0x5d0d=['mapValues','keyBy','%s/api/v2/tickets','remoteUri','POST','then','%s/api/v2/agents','find','contact','email','%s/api/v2/agents/me','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','%s/api/v2/contacts','length','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Enduser\x20created.','Basic\x20%s','apiKey','toString','base64','debug','GET','map','string','type','nameField','customField','toLowerCase','content','picklist','idField','variableName','push','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','recordingURL','uniqueid','Authorization','The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','Ticket\x20created!','The\x20Ticket\x20ID\x20is:','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','error','stringify','outbound','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','destcalleridname','destcalleridnum','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','catch','unmanaged','lastevent','toUpperCase','lodash','md5','util','ioredis','./util','../../../../config/environment','../../../../config/logger','freshdesk','defaults','localhost','socket.io-emitter','redis','application/json','emit','info','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridname','getString','Subjects','<br>','name','Fields','custom_fields'];(function(_0x307e50,_0x35f0c2){var _0x352074=function(_0x36db65){while(--_0x36db65){_0x307e50['push'](_0x307e50['shift']());}};_0x352074(++_0x35f0c2);}(_0x5d0d,0x1b7));var _0xd5d0=function(_0x1b4b23,_0x5dd6d6){_0x1b4b23=_0x1b4b23-0x0;var _0x2a325b=_0x5d0d[_0x1b4b23];return _0x2a325b;};'use strict';var _=require(_0xd5d0('0x0'));var rp=require('request-promise');var md5=require(_0xd5d0('0x1'));var util=require(_0xd5d0('0x2'));var Redis=require(_0xd5d0('0x3'));var intUtil=require(_0xd5d0('0x4'));var config=require(_0xd5d0('0x5'));var logger=require(_0xd5d0('0x6'))(_0xd5d0('0x7'));config['redis']=_[_0xd5d0('0x8')](config['redis'],{'host':_0xd5d0('0x9'),'port':0x18eb});var io=require(_0xd5d0('0xa'))(new Redis(config[_0xd5d0('0xb')]));var headers={'Content-Type':_0xd5d0('0xc'),'Accept':'application/json'};function emit(_0x5223e2,_0x23e1d8,_0x24dcf1){io['to'](_0x5223e2)[_0xd5d0('0xd')](_0x23e1d8,_0x24dcf1);}function getTicket(_0x29ebc4,_0x2295f3,_0x3fffe9,_0x2dcfad,_0x3e2cd6){logger[_0xd5d0('0xe')](_0xd5d0('0xf'));var _0x13e580=_[_0xd5d0('0x10')]({'responder_id':_0x2295f3['id'],'requester_id':_0x3fffe9['id'],'name':util[_0xd5d0('0x11')](_0xd5d0('0x12'),_0x3e2cd6[_0xd5d0('0x13')]),'phone':_0x3e2cd6['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xd5d0('0x14')](_0x2dcfad[_0xd5d0('0x15')],_0x3e2cd6,'\x20'),'description':intUtil[_0xd5d0('0x14')](_0x2dcfad['Descriptions'],_0x3e2cd6,_0xd5d0('0x16')),'tags':getTags(_0x2dcfad['Tags'],_0xd5d0('0x17'))},getCustomFields(_0x2dcfad[_0xd5d0('0x18')],_0x3e2cd6));_0x13e580[_0xd5d0('0x19')]=_[_0xd5d0('0x1a')](_[_0xd5d0('0x1b')](_0x13e580[_0xd5d0('0x19')],'id'),'value');return request({'uri':util[_0xd5d0('0x11')](_0xd5d0('0x1c'),_0x29ebc4[_0xd5d0('0x1d')]),'method':_0xd5d0('0x1e'),'body':_0x13e580})[_0xd5d0('0x1f')](function(_0x4d0cff){logger['info']('Ticket\x20created!');return _0x4d0cff;});}function getUser(_0x22e014,_0x329b39){if(intUtil['validateEmail'](_0x329b39)){return request({'uri':util[_0xd5d0('0x11')](_0xd5d0('0x20'),_0x22e014[_0xd5d0('0x1d')]),'qs':{'email':_0x329b39}})[_0xd5d0('0x1f')](function(_0x3b4e6e){if(_0x3b4e6e['length']){logger[_0xd5d0('0xe')]('Agent\x20found!');return _[_0xd5d0('0x21')](_0x3b4e6e,function(_0x5695d8){return _0x5695d8[_0xd5d0('0x22')][_0xd5d0('0x23')]===_0x329b39;});}else{logger[_0xd5d0('0xe')]('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0xd5d0('0x11')](_0xd5d0('0x24'),_0x22e014[_0xd5d0('0x1d')])})[_0xd5d0('0x1f')](function(_0x2e6003){logger[_0xd5d0('0xe')](_0xd5d0('0x25'));return _0x2e6003;});}});}else{logger[_0xd5d0('0xe')](_0xd5d0('0x26'));return request({'uri':util[_0xd5d0('0x11')](_0xd5d0('0x24'),_0x22e014[_0xd5d0('0x1d')])})[_0xd5d0('0x1f')](function(_0x10e716){logger[_0xd5d0('0xe')](_0xd5d0('0x25'));return _0x10e716;});}}function getEndUser(_0x372abe,_0x5b0c4e,_0x51b52a){logger[_0xd5d0('0xe')]('Searching\x20enduser\x20with\x20phone',_0x51b52a);return request({'uri':util['format'](_0xd5d0('0x27'),_0x372abe[_0xd5d0('0x1d')]),'qs':{'phone':_0x51b52a}})['then'](function(_0xfbf71c){if(_0xfbf71c[_0xd5d0('0x28')]){logger[_0xd5d0('0xe')](_0xd5d0('0x29'));return _[_0xd5d0('0x21')](_0xfbf71c,{'phone':_0x51b52a});}else{logger[_0xd5d0('0xe')](_0xd5d0('0x2a'));return request({'uri':util[_0xd5d0('0x11')](_0xd5d0('0x27'),_0x372abe[_0xd5d0('0x1d')]),'method':_0xd5d0('0x1e'),'body':{'name':_0x5b0c4e,'phone':_0x51b52a}})[_0xd5d0('0x1f')](function(_0x328b4e){logger[_0xd5d0('0xe')](_0xd5d0('0x2b'));return _0x328b4e;});}});}function getAuth(_0x461f0a){return util[_0xd5d0('0x11')](_0xd5d0('0x2c'),new Buffer(_0x461f0a[_0xd5d0('0x2d')]+':X')[_0xd5d0('0x2e')](_0xd5d0('0x2f')));}function request(_0x71dca7){logger[_0xd5d0('0x30')]('[HTTP]',JSON['stringify'](_0x71dca7));return rp(_[_0xd5d0('0x8')](_0x71dca7,{'method':_0xd5d0('0x31'),'headers':headers,'json':!![]}));}function getTags(_0x2b11de,_0x5cc533){var _0x1baa56=[];if(_0x2b11de&&_0x2b11de['length']>0x0){_0x1baa56=_[_0xd5d0('0x32')](_0x2b11de,_0x5cc533);}return _0x1baa56;}function getCustomFields(_0x268d91,_0xb2eefd){var _0x461e0a=[];var _0x131b7a={'custom_fields':[]};if(_0x268d91['length']>0x0){_['forEach'](_0x268d91,function(_0x178886){if(_['includes']([_0xd5d0('0x33'),'picklist'],_0x178886[_0xd5d0('0x34')])&&_0x178886[_0xd5d0('0x35')]&&!_0x178886[_0xd5d0('0x36')]){_0x131b7a[_0x178886[_0xd5d0('0x35')][_0xd5d0('0x37')]()]=_0x178886[_0xd5d0('0x38')][_0xd5d0('0x2e')]();}else if(_['includes']([_0xd5d0('0x33'),_0xd5d0('0x39')],_0x178886[_0xd5d0('0x34')])&&_0x178886[_0xd5d0('0x3a')]&&_0x178886[_0xd5d0('0x36')]){_0x131b7a['custom_fields']['push']({'id':_0x178886[_0xd5d0('0x3a')],'value':_0x178886[_0xd5d0('0x38')]['toString']()});}else if(_0x178886['type']==='variable'&&_0x178886[_0xd5d0('0x3b')]&&_0x178886[_0xd5d0('0x3a')]&&_0x178886[_0xd5d0('0x36')]){_0xb2eefd[_0x178886[_0xd5d0('0x3b')]]&&_0x131b7a[_0xd5d0('0x19')][_0xd5d0('0x3c')]({'id':_0x178886[_0xd5d0('0x3a')],'value':_0xb2eefd[_0x178886[_0xd5d0('0x3b')]]['toString']()});}else if(_0x178886[_0xd5d0('0x34')]==='customVariable'&&_0x178886[_0xd5d0('0x3d')]&&_0x178886[_0xd5d0('0x3d')][_0xd5d0('0x17')]&&_0x178886[_0xd5d0('0x3a')]&&_0x178886[_0xd5d0('0x36')]){_0xb2eefd[_0x178886[_0xd5d0('0x3d')][_0xd5d0('0x17')]['toLowerCase']()]&&_0x131b7a[_0xd5d0('0x19')][_0xd5d0('0x3c')]({'id':_0x178886['idField'],'value':_0xb2eefd[_0x178886[_0xd5d0('0x3d')]['name'][_0xd5d0('0x37')]()][_0xd5d0('0x2e')]()});}});}return _0x131b7a;}exports[_0xd5d0('0x3e')]=function(_0x111380,_0x23d78c,_0x2b2708,_0x4e795c,_0x5554f0,_0x3fc7d3){var _0x18c20e,_0x479e45;_0x3fc7d3['remoteUri']=intUtil[_0xd5d0('0x3f')](_0x3fc7d3['remoteUri']);_0x3fc7d3[_0xd5d0('0x40')]=intUtil[_0xd5d0('0x3f')](_0x3fc7d3['serverUrl']);if(_0x5554f0&&_0x5554f0[_0xd5d0('0x41')]){logger[_0xd5d0('0xe')](_0xd5d0('0x42'),'Recording\x20is\x20enabled!');_0x23d78c[_0xd5d0('0x43')]=util[_0xd5d0('0x11')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x3fc7d3['serverUrl'],_0x23d78c[_0xd5d0('0x44')],md5(_0x23d78c[_0xd5d0('0x44')]));}else{_0x23d78c[_0xd5d0('0x43')]='';}headers[_0xd5d0('0x45')]=getAuth(_0x3fc7d3);return getUser(_0x3fc7d3,_0x4e795c[_0xd5d0('0x23')])[_0xd5d0('0x1f')](function(_0x1682c4){_0x18c20e=_0x1682c4;logger[_0xd5d0('0xe')](_0xd5d0('0x46'),_0x18c20e['id']);return getEndUser(_0x3fc7d3,_0x23d78c[_0xd5d0('0x13')],_0x23d78c[_0xd5d0('0x47')]);})[_0xd5d0('0x1f')](function(_0x1eb7e9){_0x479e45=_0x1eb7e9;logger[_0xd5d0('0xe')](_0xd5d0('0x48'),_0x479e45['id']);return getTicket(_0x3fc7d3,_0x18c20e,_0x479e45,_0x2b2708,_0x23d78c);})['then'](function(_0x5d2166){if(_0x5d2166&&_0x5d2166['id']){logger[_0xd5d0('0xe')](_0xd5d0('0x49'));logger[_0xd5d0('0xe')](_0xd5d0('0x4a'),_0x5d2166['id']);logger['info'](_0xd5d0('0x42'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xd5d0('0x11')](_0xd5d0('0x4b'),_0x4e795c[_0xd5d0('0x17')]),_0xd5d0('0x4c'),{'uri':util[_0xd5d0('0x11')](_0xd5d0('0x4d'),_0x3fc7d3['remoteUri'],_0x5d2166['id'])});}})['catch'](function(_0x2fbf6f){logger[_0xd5d0('0x4e')]('[QUEUE]',JSON[_0xd5d0('0x4f')](_0x2fbf6f));});};exports[_0xd5d0('0x50')]=function(_0x3234a7,_0x2a6082,_0x123ffb,_0x182a64,_0xabcdc3,_0x1263be,_0x400080){var _0x5f3ec8,_0x3af14c;_0x1263be[_0xd5d0('0x1d')]=intUtil[_0xd5d0('0x3f')](_0x1263be[_0xd5d0('0x1d')]);_0x1263be['serverUrl']=intUtil[_0xd5d0('0x3f')](_0x1263be[_0xd5d0('0x40')]);if(_0x400080&&_0x400080[_0xd5d0('0x51')]&&_0x400080['recordingFormat']!==_0xd5d0('0x52')){logger[_0xd5d0('0xe')](_0xd5d0('0x53'),_0xd5d0('0x54'));_0x2a6082[_0xd5d0('0x43')]=util[_0xd5d0('0x11')](_0xd5d0('0x55'),_0x1263be[_0xd5d0('0x40')],_0x2a6082[_0xd5d0('0x44')],md5(_0x2a6082[_0xd5d0('0x44')]));}headers[_0xd5d0('0x45')]=getAuth(_0x1263be);return getUser(_0x1263be,_0x182a64[_0xd5d0('0x23')])['then'](function(_0x5d8926){_0x5f3ec8=_0x5d8926;logger[_0xd5d0('0xe')](_0xd5d0('0x46'),_0x5f3ec8['id']);return getEndUser(_0x1263be,_0x2a6082[_0xd5d0('0x56')],_0x2a6082[_0xd5d0('0x57')]);})[_0xd5d0('0x1f')](function(_0x50921e){_0x3af14c=_0x50921e;logger['info'](_0xd5d0('0x48'),_0x3af14c['id']);return getTicket(_0x1263be,_0x5f3ec8,_0x3af14c,_0x123ffb,_0x2a6082);})[_0xd5d0('0x1f')](function(_0x18b15d){if(_0x18b15d&&_0x18b15d['id']){logger[_0xd5d0('0xe')]('Ticket\x20created!');logger['info'](_0xd5d0('0x4a'),_0x18b15d['id']);logger[_0xd5d0('0xe')]('[OUTBOUND]',_0xd5d0('0x58'));emit(util[_0xd5d0('0x11')]('user:%s',_0x182a64['name']),_0xd5d0('0x4c'),{'uri':util[_0xd5d0('0x11')](_0xd5d0('0x4d'),_0x1263be[_0xd5d0('0x1d')],_0x18b15d['id'])});}})[_0xd5d0('0x59')](function(_0x3e4563){logger[_0xd5d0('0x4e')](_0xd5d0('0x53'),JSON[_0xd5d0('0x4f')](_0x3e4563));});};exports[_0xd5d0('0x5a')]=function(_0x34ae94,_0x26d644,_0xb3cb82,_0x59df7f,_0x1e91a6,_0x524e28){var _0x10e5b1,_0x162e75;_0x524e28['remoteUri']=intUtil[_0xd5d0('0x3f')](_0x524e28[_0xd5d0('0x1d')]);_0x524e28[_0xd5d0('0x40')]=intUtil[_0xd5d0('0x3f')](_0x524e28[_0xd5d0('0x40')]);if(_0x1e91a6&&_0x1e91a6[_0xd5d0('0x41')]){logger[_0xd5d0('0xe')]('['+_0x26d644[_0xd5d0('0x5b')][_0xd5d0('0x5c')]()+']',_0xd5d0('0x54'));_0x26d644['recordingURL']=util[_0xd5d0('0x11')](_0xd5d0('0x55'),_0x524e28[_0xd5d0('0x40')],_0x26d644[_0xd5d0('0x44')],md5(_0x26d644['uniqueid']));}else{_0x26d644[_0xd5d0('0x43')]='';}headers[_0xd5d0('0x45')]=getAuth(_0x524e28);return getUser(_0x524e28,'')[_0xd5d0('0x1f')](function(_0x2eec77){_0x10e5b1=_0x2eec77;logger[_0xd5d0('0xe')]('The\x20User\x20ID\x20is:',_0x10e5b1['id']);return getEndUser(_0x524e28,_0x26d644[_0xd5d0('0x13')],_0x26d644['calleridnum']);})['then'](function(_0x1481a1){_0x162e75=_0x1481a1;logger[_0xd5d0('0xe')](_0xd5d0('0x48'),_0x162e75['id']);return getTicket(_0x524e28,_0x10e5b1,_0x162e75,_0xb3cb82,_0x26d644);})[_0xd5d0('0x1f')](function(_0x239aca){if(_0x239aca){logger[_0xd5d0('0xe')](_0xd5d0('0x49'));logger['info'](_0xd5d0('0x4a'),_0x239aca['id']);}})[_0xd5d0('0x59')](function(_0x11654c){logger[_0xd5d0('0x4e')]('['+_0x26d644[_0xd5d0('0x5b')][_0xd5d0('0x5c')]()+']',JSON['stringify'](_0x11654c));});};
\ No newline at end of file