Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index 7e99328..eaf450a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x6675=['../../../../config/logger','freshdesk','defaults','redis','localhost','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','format','Caller\x20-\x20%s','calleridnum','Subjects','getString','Descriptions','<br>','name','custom_fields','mapValues','keyBy','value','%s/api/v2/tickets','remoteUri','POST','then','Ticket\x20created!','validateEmail','%s/api/v2/agents','length','contact','email','%s/api/v2/agents/me','Admin\x20account\x20selected.','Enduser\x20found!','find','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','%s/api/v2/contacts','Enduser\x20created.','base64','debug','[HTTP]','GET','map','forEach','includes','string','picklist','type','nameField','customField','toLowerCase','toString','idField','push','content','variable','variableName','customVariable','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:','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','stringify','outbound','recordingFormat','none','destcalleridname','destcalleridnum','[OUTBOUND]','unmanaged','lastevent','catch','toUpperCase','lodash','request-promise','ioredis','./util'];(function(_0x4ff09b,_0x53f67d){var _0x3f5c2e=function(_0x124592){while(--_0x124592){_0x4ff09b['push'](_0x4ff09b['shift']());}};_0x3f5c2e(++_0x53f67d);}(_0x6675,0x16c));var _0x5667=function(_0x28f2f8,_0x575e5c){_0x28f2f8=_0x28f2f8-0x0;var _0xb8d48=_0x6675[_0x28f2f8];return _0xb8d48;};'use strict';var _=require(_0x5667('0x0'));var rp=require(_0x5667('0x1'));var md5=require('md5');var util=require('util');var Redis=require(_0x5667('0x2'));var intUtil=require(_0x5667('0x3'));var config=require('../../../../config/environment');var logger=require(_0x5667('0x4'))(_0x5667('0x5'));config['redis']=_[_0x5667('0x6')](config[_0x5667('0x7')],{'host':_0x5667('0x8'),'port':0x18eb});var io=require(_0x5667('0x9'))(new Redis(config[_0x5667('0x7')]));var headers={'Content-Type':'application/json','Accept':_0x5667('0xa')};function emit(_0x4496b4,_0xd00a66,_0x597777){io['to'](_0x4496b4)[_0x5667('0xb')](_0xd00a66,_0x597777);}function getTicket(_0x4f73a6,_0x45a146,_0x24a913,_0x4286ed,_0x47c4b8){logger[_0x5667('0xc')](_0x5667('0xd'));var _0x5781af=_['merge']({'responder_id':_0x45a146['id'],'requester_id':_0x24a913['id'],'name':util[_0x5667('0xe')](_0x5667('0xf'),_0x47c4b8['calleridname']),'phone':_0x47c4b8[_0x5667('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil['getString'](_0x4286ed[_0x5667('0x11')],_0x47c4b8,'\x20'),'description':intUtil[_0x5667('0x12')](_0x4286ed[_0x5667('0x13')],_0x47c4b8,_0x5667('0x14')),'tags':getTags(_0x4286ed['Tags'],_0x5667('0x15'))},getCustomFields(_0x4286ed['Fields'],_0x47c4b8));_0x5781af[_0x5667('0x16')]=_[_0x5667('0x17')](_[_0x5667('0x18')](_0x5781af['custom_fields'],'id'),_0x5667('0x19'));return request({'uri':util[_0x5667('0xe')](_0x5667('0x1a'),_0x4f73a6[_0x5667('0x1b')]),'method':_0x5667('0x1c'),'body':_0x5781af})[_0x5667('0x1d')](function(_0xbf799){logger['info'](_0x5667('0x1e'));return _0xbf799;});}function getUser(_0x36b4f9,_0x151527){if(intUtil[_0x5667('0x1f')](_0x151527)){return request({'uri':util[_0x5667('0xe')](_0x5667('0x20'),_0x36b4f9[_0x5667('0x1b')]),'qs':{'email':_0x151527}})[_0x5667('0x1d')](function(_0x103edc){if(_0x103edc[_0x5667('0x21')]){logger['info']('Agent\x20found!');return _['find'](_0x103edc,function(_0x2af17b){return _0x2af17b[_0x5667('0x22')][_0x5667('0x23')]===_0x151527;});}else{logger['info']('Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x5667('0xe')](_0x5667('0x24'),_0x36b4f9[_0x5667('0x1b')])})[_0x5667('0x1d')](function(_0x35196b){logger[_0x5667('0xc')](_0x5667('0x25'));return _0x35196b;});}});}else{logger[_0x5667('0xc')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x5667('0xe')](_0x5667('0x24'),_0x36b4f9['remoteUri'])})['then'](function(_0x19cb96){logger[_0x5667('0xc')](_0x5667('0x25'));return _0x19cb96;});}}function getEndUser(_0x3b6de4,_0x426abb,_0x40440d){logger[_0x5667('0xc')]('Searching\x20enduser\x20with\x20phone',_0x40440d);return request({'uri':util[_0x5667('0xe')]('%s/api/v2/contacts',_0x3b6de4[_0x5667('0x1b')]),'qs':{'phone':_0x40440d}})['then'](function(_0x285003){if(_0x285003[_0x5667('0x21')]){logger[_0x5667('0xc')](_0x5667('0x26'));return _[_0x5667('0x27')](_0x285003,{'phone':_0x40440d});}else{logger['info'](_0x5667('0x28'));return request({'uri':util[_0x5667('0xe')](_0x5667('0x29'),_0x3b6de4[_0x5667('0x1b')]),'method':_0x5667('0x1c'),'body':{'name':_0x426abb,'phone':_0x40440d}})[_0x5667('0x1d')](function(_0x1ca85a){logger[_0x5667('0xc')](_0x5667('0x2a'));return _0x1ca85a;});}});}function getAuth(_0x329f79){return util[_0x5667('0xe')]('Basic\x20%s',new Buffer(_0x329f79['apiKey']+':X')['toString'](_0x5667('0x2b')));}function request(_0x1a1dda){logger[_0x5667('0x2c')](_0x5667('0x2d'),JSON['stringify'](_0x1a1dda));return rp(_[_0x5667('0x6')](_0x1a1dda,{'method':_0x5667('0x2e'),'headers':headers,'json':!![]}));}function getTags(_0x1293d8,_0x1fbfea){var _0x5f3f82=[];if(_0x1293d8&&_0x1293d8['length']>0x0){_0x5f3f82=_[_0x5667('0x2f')](_0x1293d8,_0x1fbfea);}return _0x5f3f82;}function getCustomFields(_0x557604,_0x3a2e3a){var _0x50b7eb=[];var _0x1e99dd={'custom_fields':[]};if(_0x557604['length']>0x0){_[_0x5667('0x30')](_0x557604,function(_0x29087d){if(_[_0x5667('0x31')]([_0x5667('0x32'),_0x5667('0x33')],_0x29087d[_0x5667('0x34')])&&_0x29087d[_0x5667('0x35')]&&!_0x29087d[_0x5667('0x36')]){_0x1e99dd[_0x29087d['nameField'][_0x5667('0x37')]()]=_0x29087d['content'][_0x5667('0x38')]();}else if(_[_0x5667('0x31')]([_0x5667('0x32'),'picklist'],_0x29087d['type'])&&_0x29087d[_0x5667('0x39')]&&_0x29087d[_0x5667('0x36')]){_0x1e99dd['custom_fields'][_0x5667('0x3a')]({'id':_0x29087d[_0x5667('0x39')],'value':_0x29087d[_0x5667('0x3b')][_0x5667('0x38')]()});}else if(_0x29087d[_0x5667('0x34')]===_0x5667('0x3c')&&_0x29087d[_0x5667('0x3d')]&&_0x29087d[_0x5667('0x39')]&&_0x29087d[_0x5667('0x36')]){_0x3a2e3a[_0x29087d[_0x5667('0x3d')]]&&_0x1e99dd[_0x5667('0x16')][_0x5667('0x3a')]({'id':_0x29087d[_0x5667('0x39')],'value':_0x3a2e3a[_0x29087d[_0x5667('0x3d')]][_0x5667('0x38')]()});}else if(_0x29087d['type']===_0x5667('0x3e')&&_0x29087d['Variable']&&_0x29087d[_0x5667('0x3f')]['name']&&_0x29087d[_0x5667('0x39')]&&_0x29087d[_0x5667('0x36')]){_0x3a2e3a[_0x29087d[_0x5667('0x3f')][_0x5667('0x15')][_0x5667('0x37')]()]&&_0x1e99dd[_0x5667('0x16')][_0x5667('0x3a')]({'id':_0x29087d[_0x5667('0x39')],'value':_0x3a2e3a[_0x29087d[_0x5667('0x3f')][_0x5667('0x15')][_0x5667('0x37')]()][_0x5667('0x38')]()});}});}return _0x1e99dd;}exports[_0x5667('0x40')]=function(_0x1ac7d6,_0x28d639,_0x3dcb87,_0x78e165,_0x588999,_0x5f59bd){var _0x5a4f90,_0x5d2e5d;_0x5f59bd['remoteUri']=intUtil[_0x5667('0x41')](_0x5f59bd[_0x5667('0x1b')]);_0x5f59bd[_0x5667('0x42')]=intUtil['stripTrailingSlash'](_0x5f59bd[_0x5667('0x42')]);if(_0x588999&&_0x588999[_0x5667('0x43')]){logger[_0x5667('0xc')](_0x5667('0x44'),_0x5667('0x45'));_0x28d639[_0x5667('0x46')]=util[_0x5667('0xe')](_0x5667('0x47'),_0x5f59bd[_0x5667('0x42')],_0x28d639[_0x5667('0x48')],md5(_0x28d639[_0x5667('0x48')]));}else{_0x28d639[_0x5667('0x46')]='';}headers[_0x5667('0x49')]=getAuth(_0x5f59bd);return getUser(_0x5f59bd,_0x78e165[_0x5667('0x23')])[_0x5667('0x1d')](function(_0x2eb064){_0x5a4f90=_0x2eb064;logger['info'](_0x5667('0x4a'),_0x5a4f90['id']);return getEndUser(_0x5f59bd,_0x28d639[_0x5667('0x4b')],_0x28d639[_0x5667('0x10')]);})[_0x5667('0x1d')](function(_0x51c597){_0x5d2e5d=_0x51c597;logger[_0x5667('0xc')](_0x5667('0x4c'),_0x5d2e5d['id']);return getTicket(_0x5f59bd,_0x5a4f90,_0x5d2e5d,_0x3dcb87,_0x28d639);})['then'](function(_0x5a791f){if(_0x5a791f&&_0x5a791f['id']){logger['info'](_0x5667('0x1e'));logger[_0x5667('0xc')]('The\x20Ticket\x20ID\x20is:',_0x5a791f['id']);logger[_0x5667('0xc')]('[QUEUE]',_0x5667('0x4d'));emit(util[_0x5667('0xe')](_0x5667('0x4e'),_0x78e165[_0x5667('0x15')]),_0x5667('0x4f'),{'uri':util['format'](_0x5667('0x50'),_0x5f59bd[_0x5667('0x1b')],_0x5a791f['id'])});}})['catch'](function(_0x595e7b){logger['error'](_0x5667('0x44'),JSON[_0x5667('0x51')](_0x595e7b));});};exports[_0x5667('0x52')]=function(_0x41f4e4,_0x355b26,_0x58c26f,_0x5eba65,_0xff0c14,_0x1a80ab,_0x1ab241){var _0x2998d2,_0x8676a2;_0x1a80ab['remoteUri']=intUtil[_0x5667('0x41')](_0x1a80ab[_0x5667('0x1b')]);_0x1a80ab[_0x5667('0x42')]=intUtil[_0x5667('0x41')](_0x1a80ab['serverUrl']);if(_0x1ab241&&_0x1ab241['recordingFormat']&&_0x1ab241[_0x5667('0x53')]!==_0x5667('0x54')){logger[_0x5667('0xc')]('[OUTBOUND]',_0x5667('0x45'));_0x355b26[_0x5667('0x46')]=util[_0x5667('0xe')](_0x5667('0x47'),_0x1a80ab['serverUrl'],_0x355b26[_0x5667('0x48')],md5(_0x355b26[_0x5667('0x48')]));}headers[_0x5667('0x49')]=getAuth(_0x1a80ab);return getUser(_0x1a80ab,_0x5eba65['email'])[_0x5667('0x1d')](function(_0x5935b){_0x2998d2=_0x5935b;logger['info'](_0x5667('0x4a'),_0x2998d2['id']);return getEndUser(_0x1a80ab,_0x355b26[_0x5667('0x55')],_0x355b26[_0x5667('0x56')]);})[_0x5667('0x1d')](function(_0x23428e){_0x8676a2=_0x23428e;logger[_0x5667('0xc')](_0x5667('0x4c'),_0x8676a2['id']);return getTicket(_0x1a80ab,_0x2998d2,_0x8676a2,_0x58c26f,_0x355b26);})['then'](function(_0x4b02b2){if(_0x4b02b2&&_0x4b02b2['id']){logger[_0x5667('0xc')](_0x5667('0x1e'));logger[_0x5667('0xc')]('The\x20Ticket\x20ID\x20is:',_0x4b02b2['id']);logger[_0x5667('0xc')](_0x5667('0x57'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x5667('0xe')](_0x5667('0x4e'),_0x5eba65[_0x5667('0x15')]),_0x5667('0x4f'),{'uri':util[_0x5667('0xe')](_0x5667('0x50'),_0x1a80ab[_0x5667('0x1b')],_0x4b02b2['id'])});}})['catch'](function(_0x520a51){logger['error'](_0x5667('0x57'),JSON[_0x5667('0x51')](_0x520a51));});};exports[_0x5667('0x58')]=function(_0x545edd,_0x120c4d,_0xe5c3a,_0x5a49ea,_0x3812c4,_0x2eb152){var _0x348bb6,_0x38e40c;_0x2eb152['remoteUri']=intUtil[_0x5667('0x41')](_0x2eb152[_0x5667('0x1b')]);_0x2eb152[_0x5667('0x42')]=intUtil[_0x5667('0x41')](_0x2eb152[_0x5667('0x42')]);if(_0x3812c4&&_0x3812c4[_0x5667('0x43')]){logger[_0x5667('0xc')]('['+_0x120c4d[_0x5667('0x59')]['toUpperCase']()+']',_0x5667('0x45'));_0x120c4d[_0x5667('0x46')]=util[_0x5667('0xe')](_0x5667('0x47'),_0x2eb152['serverUrl'],_0x120c4d['uniqueid'],md5(_0x120c4d[_0x5667('0x48')]));}else{_0x120c4d[_0x5667('0x46')]='';}headers[_0x5667('0x49')]=getAuth(_0x2eb152);return getUser(_0x2eb152,'')[_0x5667('0x1d')](function(_0x3de59c){_0x348bb6=_0x3de59c;logger['info'](_0x5667('0x4a'),_0x348bb6['id']);return getEndUser(_0x2eb152,_0x120c4d[_0x5667('0x4b')],_0x120c4d[_0x5667('0x10')]);})['then'](function(_0x5eccfa){_0x38e40c=_0x5eccfa;logger[_0x5667('0xc')](_0x5667('0x4c'),_0x38e40c['id']);return getTicket(_0x2eb152,_0x348bb6,_0x38e40c,_0xe5c3a,_0x120c4d);})[_0x5667('0x1d')](function(_0x5eaa8b){if(_0x5eaa8b){logger[_0x5667('0xc')](_0x5667('0x1e'));logger[_0x5667('0xc')]('The\x20Ticket\x20ID\x20is:',_0x5eaa8b['id']);}})[_0x5667('0x5a')](function(_0x1a9eba){logger['error']('['+_0x120c4d[_0x5667('0x59')][_0x5667('0x5b')]()+']',JSON[_0x5667('0x51')](_0x1a9eba));});};
\ No newline at end of file