Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index ad4aa49..7e99328 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x34ff=['push','toString','variable','variableName','customVariable','Variable','queue','stripTrailingSlash','serverUrl','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','The\x20User\x20ID\x20is:','calleridnum','The\x20Enduser\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','outbound','recordingFormat','none','[OUTBOUND]','Authorization','destcalleridname','The\x20Ticket\x20ID\x20is:','unmanaged','monitor_format','lastevent','error','toUpperCase','lodash','request-promise','util','./util','freshdesk','defaults','redis','localhost','application/json','emit','info','Creating\x20new\x20ticket...','format','Caller\x20-\x20%s','calleridname','getString','Descriptions','<br>','Tags','name','Fields','custom_fields','keyBy','value','%s/api/v2/tickets','remoteUri','then','Ticket\x20created!','%s/api/v2/agents','length','Agent\x20found!','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','POST','Basic\x20%s','apiKey','debug','stringify','GET','forEach','string','picklist','nameField','customField','toLowerCase','content','includes','type','idField'];(function(_0x1ad30b,_0x34fcee){var _0x54e155=function(_0x5b3074){while(--_0x5b3074){_0x1ad30b['push'](_0x1ad30b['shift']());}};_0x54e155(++_0x34fcee);}(_0x34ff,0x1e9));var _0xf34f=function(_0x2daa75,_0x13b3ca){_0x2daa75=_0x2daa75-0x0;var _0x18fad1=_0x34ff[_0x2daa75];return _0x18fad1;};'use strict';var _=require(_0xf34f('0x0'));var rp=require(_0xf34f('0x1'));var md5=require('md5');var util=require(_0xf34f('0x2'));var Redis=require('ioredis');var intUtil=require(_0xf34f('0x3'));var config=require('../../../../config/environment');var logger=require('../../../../config/logger')(_0xf34f('0x4'));config['redis']=_[_0xf34f('0x5')](config[_0xf34f('0x6')],{'host':_0xf34f('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var headers={'Content-Type':_0xf34f('0x8'),'Accept':_0xf34f('0x8')};function emit(_0xcc40a4,_0x4daefe,_0x366972){io['to'](_0xcc40a4)[_0xf34f('0x9')](_0x4daefe,_0x366972);}function getTicket(_0x17c0fc,_0x2dc0c4,_0x1f5c46,_0x1f7004,_0x34d390){logger[_0xf34f('0xa')](_0xf34f('0xb'));var _0x3b02fa=_['merge']({'responder_id':_0x2dc0c4['id'],'requester_id':_0x1f5c46['id'],'name':util[_0xf34f('0xc')](_0xf34f('0xd'),_0x34d390[_0xf34f('0xe')]),'phone':_0x34d390['calleridnum'],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xf34f('0xf')](_0x1f7004['Subjects'],_0x34d390,'\x20'),'description':intUtil[_0xf34f('0xf')](_0x1f7004[_0xf34f('0x10')],_0x34d390,_0xf34f('0x11')),'tags':getTags(_0x1f7004[_0xf34f('0x12')],_0xf34f('0x13'))},getCustomFields(_0x1f7004[_0xf34f('0x14')],_0x34d390));_0x3b02fa[_0xf34f('0x15')]=_['mapValues'](_[_0xf34f('0x16')](_0x3b02fa[_0xf34f('0x15')],'id'),_0xf34f('0x17'));return request({'uri':util['format'](_0xf34f('0x18'),_0x17c0fc[_0xf34f('0x19')]),'method':'POST','body':_0x3b02fa})[_0xf34f('0x1a')](function(_0x5502d1){logger[_0xf34f('0xa')](_0xf34f('0x1b'));return _0x5502d1;});}function getUser(_0x35ad7e,_0x5d90bc){if(intUtil['validateEmail'](_0x5d90bc)){return request({'uri':util['format'](_0xf34f('0x1c'),_0x35ad7e[_0xf34f('0x19')]),'qs':{'email':_0x5d90bc}})[_0xf34f('0x1a')](function(_0x17e1f6){if(_0x17e1f6[_0xf34f('0x1d')]){logger[_0xf34f('0xa')](_0xf34f('0x1e'));return _[_0xf34f('0x1f')](_0x17e1f6,function(_0x251353){return _0x251353[_0xf34f('0x20')][_0xf34f('0x21')]===_0x5d90bc;});}else{logger[_0xf34f('0xa')](_0xf34f('0x22'));return request({'uri':util['format']('%s/api/v2/agents/me',_0x35ad7e[_0xf34f('0x19')])})[_0xf34f('0x1a')](function(_0x2f1d8a){logger[_0xf34f('0xa')](_0xf34f('0x23'));return _0x2f1d8a;});}});}else{logger[_0xf34f('0xa')](_0xf34f('0x24'));return request({'uri':util[_0xf34f('0xc')](_0xf34f('0x25'),_0x35ad7e[_0xf34f('0x19')])})['then'](function(_0x160a87){logger[_0xf34f('0xa')](_0xf34f('0x23'));return _0x160a87;});}}function getEndUser(_0x17e744,_0x2bf8d7,_0x265247){logger[_0xf34f('0xa')](_0xf34f('0x26'),_0x265247);return request({'uri':util[_0xf34f('0xc')](_0xf34f('0x27'),_0x17e744['remoteUri']),'qs':{'phone':_0x265247}})['then'](function(_0x576de3){if(_0x576de3[_0xf34f('0x1d')]){logger['info']('Enduser\x20found!');return _['find'](_0x576de3,{'phone':_0x265247});}else{logger['info'](_0xf34f('0x28'));return request({'uri':util[_0xf34f('0xc')](_0xf34f('0x27'),_0x17e744[_0xf34f('0x19')]),'method':_0xf34f('0x29'),'body':{'name':_0x2bf8d7,'phone':_0x265247}})[_0xf34f('0x1a')](function(_0x3faea7){logger[_0xf34f('0xa')]('Enduser\x20created.');return _0x3faea7;});}});}function getAuth(_0x1ce547){return util[_0xf34f('0xc')](_0xf34f('0x2a'),new Buffer(_0x1ce547[_0xf34f('0x2b')]+':X')['toString']('base64'));}function request(_0x457426){logger[_0xf34f('0x2c')]('[HTTP]',JSON[_0xf34f('0x2d')](_0x457426));return rp(_[_0xf34f('0x5')](_0x457426,{'method':_0xf34f('0x2e'),'headers':headers,'json':!![]}));}function getTags(_0xec8cb8,_0x909cbe){var _0xd4df92=[];if(_0xec8cb8&&_0xec8cb8[_0xf34f('0x1d')]>0x0){_0xd4df92=_['map'](_0xec8cb8,_0x909cbe);}return _0xd4df92;}function getCustomFields(_0x536ab9,_0x4d3fbd){var _0x47c4f4=[];var _0x32047d={'custom_fields':[]};if(_0x536ab9['length']>0x0){_[_0xf34f('0x2f')](_0x536ab9,function(_0x1dc475){if(_['includes']([_0xf34f('0x30'),_0xf34f('0x31')],_0x1dc475['type'])&&_0x1dc475[_0xf34f('0x32')]&&!_0x1dc475[_0xf34f('0x33')]){_0x32047d[_0x1dc475[_0xf34f('0x32')][_0xf34f('0x34')]()]=_0x1dc475[_0xf34f('0x35')]['toString']();}else if(_[_0xf34f('0x36')]([_0xf34f('0x30'),_0xf34f('0x31')],_0x1dc475[_0xf34f('0x37')])&&_0x1dc475[_0xf34f('0x38')]&&_0x1dc475[_0xf34f('0x33')]){_0x32047d['custom_fields'][_0xf34f('0x39')]({'id':_0x1dc475[_0xf34f('0x38')],'value':_0x1dc475[_0xf34f('0x35')][_0xf34f('0x3a')]()});}else if(_0x1dc475[_0xf34f('0x37')]===_0xf34f('0x3b')&&_0x1dc475[_0xf34f('0x3c')]&&_0x1dc475['idField']&&_0x1dc475[_0xf34f('0x33')]){_0x4d3fbd[_0x1dc475[_0xf34f('0x3c')]]&&_0x32047d['custom_fields']['push']({'id':_0x1dc475[_0xf34f('0x38')],'value':_0x4d3fbd[_0x1dc475[_0xf34f('0x3c')]][_0xf34f('0x3a')]()});}else if(_0x1dc475[_0xf34f('0x37')]===_0xf34f('0x3d')&&_0x1dc475[_0xf34f('0x3e')]&&_0x1dc475['Variable'][_0xf34f('0x13')]&&_0x1dc475[_0xf34f('0x38')]&&_0x1dc475['customField']){_0x4d3fbd[_0x1dc475[_0xf34f('0x3e')][_0xf34f('0x13')]['toLowerCase']()]&&_0x32047d[_0xf34f('0x15')][_0xf34f('0x39')]({'id':_0x1dc475[_0xf34f('0x38')],'value':_0x4d3fbd[_0x1dc475[_0xf34f('0x3e')][_0xf34f('0x13')]['toLowerCase']()][_0xf34f('0x3a')]()});}});}return _0x32047d;}exports[_0xf34f('0x3f')]=function(_0x2091f9,_0x3b7683,_0x40d0f1,_0x2bca06,_0x45d0d1,_0x3e179c){var _0x1503d3,_0x508a71;_0x3e179c[_0xf34f('0x19')]=intUtil[_0xf34f('0x40')](_0x3e179c[_0xf34f('0x19')]);_0x3e179c[_0xf34f('0x41')]=intUtil[_0xf34f('0x40')](_0x3e179c['serverUrl']);if(_0x45d0d1&&_0x45d0d1['monitor_format']){logger[_0xf34f('0xa')](_0xf34f('0x42'),_0xf34f('0x43'));_0x3b7683[_0xf34f('0x44')]=util[_0xf34f('0xc')](_0xf34f('0x45'),_0x3e179c[_0xf34f('0x41')],_0x3b7683[_0xf34f('0x46')],md5(_0x3b7683[_0xf34f('0x46')]));}else{_0x3b7683[_0xf34f('0x44')]='';}headers['Authorization']=getAuth(_0x3e179c);return getUser(_0x3e179c,_0x2bca06[_0xf34f('0x21')])[_0xf34f('0x1a')](function(_0x14ba12){_0x1503d3=_0x14ba12;logger[_0xf34f('0xa')](_0xf34f('0x47'),_0x1503d3['id']);return getEndUser(_0x3e179c,_0x3b7683['calleridname'],_0x3b7683[_0xf34f('0x48')]);})[_0xf34f('0x1a')](function(_0x11b2d3){_0x508a71=_0x11b2d3;logger[_0xf34f('0xa')](_0xf34f('0x49'),_0x508a71['id']);return getTicket(_0x3e179c,_0x1503d3,_0x508a71,_0x40d0f1,_0x3b7683);})[_0xf34f('0x1a')](function(_0x18a21d){if(_0x18a21d&&_0x18a21d['id']){logger[_0xf34f('0xa')](_0xf34f('0x1b'));logger[_0xf34f('0xa')]('The\x20Ticket\x20ID\x20is:',_0x18a21d['id']);logger[_0xf34f('0xa')](_0xf34f('0x42'),_0xf34f('0x4a'));emit(util[_0xf34f('0xc')](_0xf34f('0x4b'),_0x2bca06[_0xf34f('0x13')]),_0xf34f('0x4c'),{'uri':util[_0xf34f('0xc')](_0xf34f('0x4d'),_0x3e179c[_0xf34f('0x19')],_0x18a21d['id'])});}})[_0xf34f('0x4e')](function(_0x8f43a6){logger['error'](_0xf34f('0x42'),JSON[_0xf34f('0x2d')](_0x8f43a6));});};exports[_0xf34f('0x4f')]=function(_0x437162,_0x206e9e,_0x3ed716,_0x4d22c3,_0x54744c,_0x5e81f0,_0x80efbd){var _0x4538b0,_0x3072a6;_0x5e81f0[_0xf34f('0x19')]=intUtil[_0xf34f('0x40')](_0x5e81f0[_0xf34f('0x19')]);_0x5e81f0['serverUrl']=intUtil[_0xf34f('0x40')](_0x5e81f0[_0xf34f('0x41')]);if(_0x80efbd&&_0x80efbd[_0xf34f('0x50')]&&_0x80efbd['recordingFormat']!==_0xf34f('0x51')){logger['info'](_0xf34f('0x52'),_0xf34f('0x43'));_0x206e9e[_0xf34f('0x44')]=util[_0xf34f('0xc')](_0xf34f('0x45'),_0x5e81f0[_0xf34f('0x41')],_0x206e9e[_0xf34f('0x46')],md5(_0x206e9e[_0xf34f('0x46')]));}headers[_0xf34f('0x53')]=getAuth(_0x5e81f0);return getUser(_0x5e81f0,_0x4d22c3[_0xf34f('0x21')])[_0xf34f('0x1a')](function(_0x4eebf3){_0x4538b0=_0x4eebf3;logger[_0xf34f('0xa')](_0xf34f('0x47'),_0x4538b0['id']);return getEndUser(_0x5e81f0,_0x206e9e[_0xf34f('0x54')],_0x206e9e['destcalleridnum']);})[_0xf34f('0x1a')](function(_0x55c5fd){_0x3072a6=_0x55c5fd;logger[_0xf34f('0xa')](_0xf34f('0x49'),_0x3072a6['id']);return getTicket(_0x5e81f0,_0x4538b0,_0x3072a6,_0x3ed716,_0x206e9e);})[_0xf34f('0x1a')](function(_0x3871db){if(_0x3871db&&_0x3871db['id']){logger[_0xf34f('0xa')](_0xf34f('0x1b'));logger[_0xf34f('0xa')](_0xf34f('0x55'),_0x3871db['id']);logger[_0xf34f('0xa')]('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xf34f('0xc')](_0xf34f('0x4b'),_0x4d22c3['name']),'trigger:browser:url',{'uri':util[_0xf34f('0xc')](_0xf34f('0x4d'),_0x5e81f0[_0xf34f('0x19')],_0x3871db['id'])});}})['catch'](function(_0x1762f1){logger['error'](_0xf34f('0x52'),JSON[_0xf34f('0x2d')](_0x1762f1));});};exports[_0xf34f('0x56')]=function(_0x150e11,_0x2781b9,_0x35381e,_0x3a6872,_0x4aebbd,_0xea6de){var _0x49478f,_0x2cb124;_0xea6de['remoteUri']=intUtil['stripTrailingSlash'](_0xea6de[_0xf34f('0x19')]);_0xea6de[_0xf34f('0x41')]=intUtil[_0xf34f('0x40')](_0xea6de[_0xf34f('0x41')]);if(_0x4aebbd&&_0x4aebbd[_0xf34f('0x57')]){logger[_0xf34f('0xa')]('['+_0x2781b9[_0xf34f('0x58')]['toUpperCase']()+']','Recording\x20is\x20enabled!');_0x2781b9[_0xf34f('0x44')]=util[_0xf34f('0xc')](_0xf34f('0x45'),_0xea6de[_0xf34f('0x41')],_0x2781b9[_0xf34f('0x46')],md5(_0x2781b9['uniqueid']));}else{_0x2781b9[_0xf34f('0x44')]='';}headers[_0xf34f('0x53')]=getAuth(_0xea6de);return getUser(_0xea6de,'')['then'](function(_0xbd6f1c){_0x49478f=_0xbd6f1c;logger[_0xf34f('0xa')](_0xf34f('0x47'),_0x49478f['id']);return getEndUser(_0xea6de,_0x2781b9[_0xf34f('0xe')],_0x2781b9['calleridnum']);})[_0xf34f('0x1a')](function(_0x487ad0){_0x2cb124=_0x487ad0;logger[_0xf34f('0xa')](_0xf34f('0x49'),_0x2cb124['id']);return getTicket(_0xea6de,_0x49478f,_0x2cb124,_0x35381e,_0x2781b9);})[_0xf34f('0x1a')](function(_0x166bb4){if(_0x166bb4){logger[_0xf34f('0xa')](_0xf34f('0x1b'));logger[_0xf34f('0xa')](_0xf34f('0x55'),_0x166bb4['id']);}})[_0xf34f('0x4e')](function(_0xcfd711){logger[_0xf34f('0x59')]('['+_0x2781b9[_0xf34f('0x58')][_0xf34f('0x5a')]()+']',JSON['stringify'](_0xcfd711));});};
\ No newline at end of file
+var _0xf527=['custom_fields','mapValues','keyBy','%s/api/v2/tickets','remoteUri','Ticket\x20created!','validateEmail','%s/api/v2/agents','then','length','Agent\x20found!','find','contact','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!','Searching\x20enduser\x20with\x20phone','Enduser\x20found!','%s/api/v2/contacts','Enduser\x20created.','Basic\x20%s','toString','base64','[HTTP]','stringify','includes','string','picklist','type','nameField','toLowerCase','content','idField','customField','variable','variableName','push','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Authorization','The\x20User\x20ID\x20is:','calleridname','The\x20Enduser\x20ID\x20is:','The\x20Ticket\x20ID\x20is:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','outbound','recordingFormat','none','[OUTBOUND]','destcalleridname','user:%s','toUpperCase','lastevent','lodash','md5','ioredis','./util','../../../../config/logger','freshdesk','redis','defaults','localhost','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','format','Caller\x20-\x20%s','calleridnum','getString','Subjects','<br>','Tags','name','Fields'];(function(_0x3c6ae2,_0x5c52d8){var _0x4edda=function(_0x5593eb){while(--_0x5593eb){_0x3c6ae2['push'](_0x3c6ae2['shift']());}};_0x4edda(++_0x5c52d8);}(_0xf527,0x9b));var _0x7f52=function(_0x52e9e3,_0xe465a7){_0x52e9e3=_0x52e9e3-0x0;var _0x960a8d=_0xf527[_0x52e9e3];return _0x960a8d;};'use strict';var _=require(_0x7f52('0x0'));var rp=require('request-promise');var md5=require(_0x7f52('0x1'));var util=require('util');var Redis=require(_0x7f52('0x2'));var intUtil=require(_0x7f52('0x3'));var config=require('../../../../config/environment');var logger=require(_0x7f52('0x4'))(_0x7f52('0x5'));config[_0x7f52('0x6')]=_[_0x7f52('0x7')](config['redis'],{'host':_0x7f52('0x8'),'port':0x18eb});var io=require(_0x7f52('0x9'))(new Redis(config[_0x7f52('0x6')]));var headers={'Content-Type':_0x7f52('0xa'),'Accept':_0x7f52('0xa')};function emit(_0x1f62c3,_0x37b3eb,_0x36b72f){io['to'](_0x1f62c3)[_0x7f52('0xb')](_0x37b3eb,_0x36b72f);}function getTicket(_0x1f203f,_0x4a3a46,_0x374172,_0x320783,_0x7d2896){logger[_0x7f52('0xc')](_0x7f52('0xd'));var _0x264bd2=_['merge']({'responder_id':_0x4a3a46['id'],'requester_id':_0x374172['id'],'name':util[_0x7f52('0xe')](_0x7f52('0xf'),_0x7d2896['calleridname']),'phone':_0x7d2896[_0x7f52('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x7f52('0x11')](_0x320783[_0x7f52('0x12')],_0x7d2896,'\x20'),'description':intUtil[_0x7f52('0x11')](_0x320783['Descriptions'],_0x7d2896,_0x7f52('0x13')),'tags':getTags(_0x320783[_0x7f52('0x14')],_0x7f52('0x15'))},getCustomFields(_0x320783[_0x7f52('0x16')],_0x7d2896));_0x264bd2[_0x7f52('0x17')]=_[_0x7f52('0x18')](_[_0x7f52('0x19')](_0x264bd2['custom_fields'],'id'),'value');return request({'uri':util[_0x7f52('0xe')](_0x7f52('0x1a'),_0x1f203f[_0x7f52('0x1b')]),'method':'POST','body':_0x264bd2})['then'](function(_0x480a20){logger[_0x7f52('0xc')](_0x7f52('0x1c'));return _0x480a20;});}function getUser(_0x3349f1,_0x550b72){if(intUtil[_0x7f52('0x1d')](_0x550b72)){return request({'uri':util[_0x7f52('0xe')](_0x7f52('0x1e'),_0x3349f1[_0x7f52('0x1b')]),'qs':{'email':_0x550b72}})[_0x7f52('0x1f')](function(_0x3f5521){if(_0x3f5521[_0x7f52('0x20')]){logger[_0x7f52('0xc')](_0x7f52('0x21'));return _[_0x7f52('0x22')](_0x3f5521,function(_0x2d248a){return _0x2d248a[_0x7f52('0x23')][_0x7f52('0x24')]===_0x550b72;});}else{logger['info'](_0x7f52('0x25'));return request({'uri':util[_0x7f52('0xe')]('%s/api/v2/agents/me',_0x3349f1[_0x7f52('0x1b')])})[_0x7f52('0x1f')](function(_0x3950d8){logger['info'](_0x7f52('0x26'));return _0x3950d8;});}});}else{logger[_0x7f52('0xc')](_0x7f52('0x27'));return request({'uri':util[_0x7f52('0xe')]('%s/api/v2/agents/me',_0x3349f1[_0x7f52('0x1b')])})[_0x7f52('0x1f')](function(_0x2892b3){logger[_0x7f52('0xc')](_0x7f52('0x26'));return _0x2892b3;});}}function getEndUser(_0x2c2dbd,_0x474f1a,_0x340952){logger[_0x7f52('0xc')](_0x7f52('0x28'),_0x340952);return request({'uri':util[_0x7f52('0xe')]('%s/api/v2/contacts',_0x2c2dbd[_0x7f52('0x1b')]),'qs':{'phone':_0x340952}})[_0x7f52('0x1f')](function(_0x26553a){if(_0x26553a[_0x7f52('0x20')]){logger[_0x7f52('0xc')](_0x7f52('0x29'));return _[_0x7f52('0x22')](_0x26553a,{'phone':_0x340952});}else{logger[_0x7f52('0xc')]('Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!');return request({'uri':util[_0x7f52('0xe')](_0x7f52('0x2a'),_0x2c2dbd['remoteUri']),'method':'POST','body':{'name':_0x474f1a,'phone':_0x340952}})[_0x7f52('0x1f')](function(_0x8bce5d){logger['info'](_0x7f52('0x2b'));return _0x8bce5d;});}});}function getAuth(_0x5c6f74){return util[_0x7f52('0xe')](_0x7f52('0x2c'),new Buffer(_0x5c6f74['apiKey']+':X')[_0x7f52('0x2d')](_0x7f52('0x2e')));}function request(_0x42bb6c){logger['debug'](_0x7f52('0x2f'),JSON[_0x7f52('0x30')](_0x42bb6c));return rp(_[_0x7f52('0x7')](_0x42bb6c,{'method':'GET','headers':headers,'json':!![]}));}function getTags(_0x1a403a,_0x490d8a){var _0x92ba53=[];if(_0x1a403a&&_0x1a403a[_0x7f52('0x20')]>0x0){_0x92ba53=_['map'](_0x1a403a,_0x490d8a);}return _0x92ba53;}function getCustomFields(_0x6d883f,_0x43ff5a){var _0x3da9fa=[];var _0x2196e6={'custom_fields':[]};if(_0x6d883f[_0x7f52('0x20')]>0x0){_['forEach'](_0x6d883f,function(_0x36fb29){if(_[_0x7f52('0x31')]([_0x7f52('0x32'),_0x7f52('0x33')],_0x36fb29[_0x7f52('0x34')])&&_0x36fb29[_0x7f52('0x35')]&&!_0x36fb29['customField']){_0x2196e6[_0x36fb29[_0x7f52('0x35')][_0x7f52('0x36')]()]=_0x36fb29[_0x7f52('0x37')][_0x7f52('0x2d')]();}else if(_[_0x7f52('0x31')]([_0x7f52('0x32'),'picklist'],_0x36fb29[_0x7f52('0x34')])&&_0x36fb29[_0x7f52('0x38')]&&_0x36fb29[_0x7f52('0x39')]){_0x2196e6[_0x7f52('0x17')]['push']({'id':_0x36fb29['idField'],'value':_0x36fb29[_0x7f52('0x37')]['toString']()});}else if(_0x36fb29[_0x7f52('0x34')]===_0x7f52('0x3a')&&_0x36fb29[_0x7f52('0x3b')]&&_0x36fb29[_0x7f52('0x38')]&&_0x36fb29['customField']){_0x43ff5a[_0x36fb29['variableName']]&&_0x2196e6[_0x7f52('0x17')][_0x7f52('0x3c')]({'id':_0x36fb29['idField'],'value':_0x43ff5a[_0x36fb29['variableName']][_0x7f52('0x2d')]()});}else if(_0x36fb29[_0x7f52('0x34')]==='customVariable'&&_0x36fb29[_0x7f52('0x3d')]&&_0x36fb29[_0x7f52('0x3d')][_0x7f52('0x15')]&&_0x36fb29[_0x7f52('0x38')]&&_0x36fb29[_0x7f52('0x39')]){_0x43ff5a[_0x36fb29[_0x7f52('0x3d')][_0x7f52('0x15')][_0x7f52('0x36')]()]&&_0x2196e6[_0x7f52('0x17')][_0x7f52('0x3c')]({'id':_0x36fb29['idField'],'value':_0x43ff5a[_0x36fb29[_0x7f52('0x3d')][_0x7f52('0x15')]['toLowerCase']()]['toString']()});}});}return _0x2196e6;}exports[_0x7f52('0x3e')]=function(_0x25bc69,_0x343325,_0x4f8541,_0x348610,_0x5eb762,_0x1b59d0){var _0x579a7c,_0x550788;_0x1b59d0[_0x7f52('0x1b')]=intUtil[_0x7f52('0x3f')](_0x1b59d0[_0x7f52('0x1b')]);_0x1b59d0[_0x7f52('0x40')]=intUtil[_0x7f52('0x3f')](_0x1b59d0[_0x7f52('0x40')]);if(_0x5eb762&&_0x5eb762[_0x7f52('0x41')]){logger[_0x7f52('0xc')](_0x7f52('0x42'),_0x7f52('0x43'));_0x343325[_0x7f52('0x44')]=util[_0x7f52('0xe')](_0x7f52('0x45'),_0x1b59d0['serverUrl'],_0x343325[_0x7f52('0x46')],md5(_0x343325[_0x7f52('0x46')]));}else{_0x343325['recordingURL']='';}headers[_0x7f52('0x47')]=getAuth(_0x1b59d0);return getUser(_0x1b59d0,_0x348610[_0x7f52('0x24')])[_0x7f52('0x1f')](function(_0x53af0a){_0x579a7c=_0x53af0a;logger[_0x7f52('0xc')](_0x7f52('0x48'),_0x579a7c['id']);return getEndUser(_0x1b59d0,_0x343325[_0x7f52('0x49')],_0x343325[_0x7f52('0x10')]);})[_0x7f52('0x1f')](function(_0xa1b9bd){_0x550788=_0xa1b9bd;logger['info'](_0x7f52('0x4a'),_0x550788['id']);return getTicket(_0x1b59d0,_0x579a7c,_0x550788,_0x4f8541,_0x343325);})['then'](function(_0x5afaad){if(_0x5afaad&&_0x5afaad['id']){logger[_0x7f52('0xc')](_0x7f52('0x1c'));logger[_0x7f52('0xc')](_0x7f52('0x4b'),_0x5afaad['id']);logger[_0x7f52('0xc')](_0x7f52('0x42'),_0x7f52('0x4c'));emit(util[_0x7f52('0xe')]('user:%s',_0x348610['name']),_0x7f52('0x4d'),{'uri':util[_0x7f52('0xe')](_0x7f52('0x4e'),_0x1b59d0['remoteUri'],_0x5afaad['id'])});}})[_0x7f52('0x4f')](function(_0x5ee835){logger[_0x7f52('0x50')](_0x7f52('0x42'),JSON[_0x7f52('0x30')](_0x5ee835));});};exports[_0x7f52('0x51')]=function(_0x95ad76,_0x39dc76,_0x1eb784,_0x5068dc,_0x11bdd2,_0x3c6593,_0x25105d){var _0x4b6d04,_0x19c741;_0x3c6593[_0x7f52('0x1b')]=intUtil['stripTrailingSlash'](_0x3c6593[_0x7f52('0x1b')]);_0x3c6593[_0x7f52('0x40')]=intUtil[_0x7f52('0x3f')](_0x3c6593['serverUrl']);if(_0x25105d&&_0x25105d['recordingFormat']&&_0x25105d[_0x7f52('0x52')]!==_0x7f52('0x53')){logger[_0x7f52('0xc')](_0x7f52('0x54'),'Recording\x20is\x20enabled!');_0x39dc76[_0x7f52('0x44')]=util[_0x7f52('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x3c6593[_0x7f52('0x40')],_0x39dc76['uniqueid'],md5(_0x39dc76['uniqueid']));}headers[_0x7f52('0x47')]=getAuth(_0x3c6593);return getUser(_0x3c6593,_0x5068dc[_0x7f52('0x24')])['then'](function(_0x582f99){_0x4b6d04=_0x582f99;logger[_0x7f52('0xc')](_0x7f52('0x48'),_0x4b6d04['id']);return getEndUser(_0x3c6593,_0x39dc76[_0x7f52('0x55')],_0x39dc76['destcalleridnum']);})[_0x7f52('0x1f')](function(_0x2f13ef){_0x19c741=_0x2f13ef;logger[_0x7f52('0xc')](_0x7f52('0x4a'),_0x19c741['id']);return getTicket(_0x3c6593,_0x4b6d04,_0x19c741,_0x1eb784,_0x39dc76);})['then'](function(_0x2a0014){if(_0x2a0014&&_0x2a0014['id']){logger['info'](_0x7f52('0x1c'));logger['info'](_0x7f52('0x4b'),_0x2a0014['id']);logger['info']('[OUTBOUND]',_0x7f52('0x4c'));emit(util[_0x7f52('0xe')](_0x7f52('0x56'),_0x5068dc[_0x7f52('0x15')]),_0x7f52('0x4d'),{'uri':util[_0x7f52('0xe')](_0x7f52('0x4e'),_0x3c6593[_0x7f52('0x1b')],_0x2a0014['id'])});}})[_0x7f52('0x4f')](function(_0x44562f){logger[_0x7f52('0x50')](_0x7f52('0x54'),JSON[_0x7f52('0x30')](_0x44562f));});};exports['unmanaged']=function(_0x5f17c2,_0x39e9e7,_0x22f274,_0x5664ed,_0xeaf317,_0x246419){var _0xac860c,_0x27ba26;_0x246419[_0x7f52('0x1b')]=intUtil[_0x7f52('0x3f')](_0x246419[_0x7f52('0x1b')]);_0x246419[_0x7f52('0x40')]=intUtil['stripTrailingSlash'](_0x246419[_0x7f52('0x40')]);if(_0xeaf317&&_0xeaf317[_0x7f52('0x41')]){logger['info']('['+_0x39e9e7['lastevent'][_0x7f52('0x57')]()+']',_0x7f52('0x43'));_0x39e9e7['recordingURL']=util['format'](_0x7f52('0x45'),_0x246419['serverUrl'],_0x39e9e7['uniqueid'],md5(_0x39e9e7['uniqueid']));}else{_0x39e9e7[_0x7f52('0x44')]='';}headers[_0x7f52('0x47')]=getAuth(_0x246419);return getUser(_0x246419,'')['then'](function(_0x3226df){_0xac860c=_0x3226df;logger[_0x7f52('0xc')](_0x7f52('0x48'),_0xac860c['id']);return getEndUser(_0x246419,_0x39e9e7['calleridname'],_0x39e9e7[_0x7f52('0x10')]);})[_0x7f52('0x1f')](function(_0x511e90){_0x27ba26=_0x511e90;logger[_0x7f52('0xc')](_0x7f52('0x4a'),_0x27ba26['id']);return getTicket(_0x246419,_0xac860c,_0x27ba26,_0x22f274,_0x39e9e7);})[_0x7f52('0x1f')](function(_0x1415cc){if(_0x1415cc){logger[_0x7f52('0xc')]('Ticket\x20created!');logger[_0x7f52('0xc')]('The\x20Ticket\x20ID\x20is:',_0x1415cc['id']);}})[_0x7f52('0x4f')](function(_0x116fb9){logger[_0x7f52('0x50')]('['+_0x39e9e7[_0x7f52('0x58')][_0x7f52('0x57')]()+']',JSON[_0x7f52('0x30')](_0x116fb9));});};
\ No newline at end of file