Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / ami / trigger / integration / freshdesk.js
index c63c8ec..5add06c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3912=['Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','Admin\x20account\x20selected.','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Basic\x20%s','apiKey','base64','debug','[HTTP]','stringify','defaults','GET','forEach','includes','string','picklist','nameField','toLowerCase','toString','type','customField','push','content','variable','variableName','idField','customVariable','Variable','queue','serverUrl','stripTrailingSlash','monitor_format','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:','[QUEUE]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','outbound','recordingFormat','none','[OUTBOUND]','email','destcalleridname','destcalleridnum','The\x20Ticket\x20ID\x20is:','toUpperCase','lastevent','request-promise','md5','util','ioredis','./util','../../../../config/logger','freshdesk','redis','socket.io-emitter','application/json','emit','info','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridnum','getString','Subjects','Tags','name','custom_fields','mapValues','%s/api/v2/tickets','remoteUri','POST','then','Ticket\x20created!','validateEmail','length','Agent\x20found!','find','contact'];(function(_0x413feb,_0x10477f){var _0x40ee88=function(_0x32a3f6){while(--_0x32a3f6){_0x413feb['push'](_0x413feb['shift']());}};_0x40ee88(++_0x10477f);}(_0x3912,0x95));var _0x2391=function(_0x335d86,_0x1782a2){_0x335d86=_0x335d86-0x0;var _0x36dfa1=_0x3912[_0x335d86];return _0x36dfa1;};'use strict';var _=require('lodash');var rp=require(_0x2391('0x0'));var md5=require(_0x2391('0x1'));var util=require(_0x2391('0x2'));var Redis=require(_0x2391('0x3'));var intUtil=require(_0x2391('0x4'));var config=require('../../../../config/environment');var logger=require(_0x2391('0x5'))(_0x2391('0x6'));config[_0x2391('0x7')]=_['defaults'](config[_0x2391('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x2391('0x8'))(new Redis(config[_0x2391('0x7')]));var headers={'Content-Type':_0x2391('0x9'),'Accept':_0x2391('0x9')};function emit(_0x12dd6f,_0x36f01a,_0x13a9d2){io['to'](_0x12dd6f)[_0x2391('0xa')](_0x36f01a,_0x13a9d2);}function getTicket(_0x9884c2,_0x48ddeb,_0x10f8fd,_0x44f89f,_0x458a26){logger[_0x2391('0xb')](_0x2391('0xc'));var _0x3d1045=_[_0x2391('0xd')]({'responder_id':_0x48ddeb['id'],'requester_id':_0x10f8fd['id'],'name':util[_0x2391('0xe')](_0x2391('0xf'),_0x458a26['calleridname']),'phone':_0x458a26[_0x2391('0x10')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0x2391('0x11')](_0x44f89f[_0x2391('0x12')],_0x458a26,'\x20'),'description':intUtil[_0x2391('0x11')](_0x44f89f['Descriptions'],_0x458a26,'<br>'),'tags':getTags(_0x44f89f[_0x2391('0x13')],_0x2391('0x14'))},getCustomFields(_0x44f89f['Fields'],_0x458a26));_0x3d1045[_0x2391('0x15')]=_[_0x2391('0x16')](_['keyBy'](_0x3d1045['custom_fields'],'id'),'value');return request({'uri':util['format'](_0x2391('0x17'),_0x9884c2[_0x2391('0x18')]),'method':_0x2391('0x19'),'body':_0x3d1045})[_0x2391('0x1a')](function(_0x50b470){logger[_0x2391('0xb')](_0x2391('0x1b'));return _0x50b470;});}function getUser(_0x39f20e,_0x5d1de7){if(intUtil[_0x2391('0x1c')](_0x5d1de7)){return request({'uri':util[_0x2391('0xe')]('%s/api/v2/agents',_0x39f20e[_0x2391('0x18')]),'qs':{'email':_0x5d1de7}})['then'](function(_0x3932b7){if(_0x3932b7[_0x2391('0x1d')]){logger[_0x2391('0xb')](_0x2391('0x1e'));return _[_0x2391('0x1f')](_0x3932b7,function(_0x25a33e){return _0x25a33e[_0x2391('0x20')]['email']===_0x5d1de7;});}else{logger[_0x2391('0xb')](_0x2391('0x21'));return request({'uri':util['format']('%s/api/v2/agents/me',_0x39f20e[_0x2391('0x18')])})['then'](function(_0x4f8345){logger['info'](_0x2391('0x22'));return _0x4f8345;});}});}else{logger[_0x2391('0xb')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util[_0x2391('0xe')]('%s/api/v2/agents/me',_0x39f20e[_0x2391('0x18')])})[_0x2391('0x1a')](function(_0x4468a3){logger['info']('Admin\x20account\x20selected.');return _0x4468a3;});}}function getEndUser(_0x4520d5,_0x21c422,_0x4c57ef){logger[_0x2391('0xb')](_0x2391('0x23'),_0x4c57ef);return request({'uri':util['format'](_0x2391('0x24'),_0x4520d5['remoteUri']),'qs':{'phone':_0x4c57ef}})[_0x2391('0x1a')](function(_0x21947c){if(_0x21947c[_0x2391('0x1d')]){logger[_0x2391('0xb')]('Enduser\x20found!');return _[_0x2391('0x1f')](_0x21947c,{'phone':_0x4c57ef});}else{logger['info'](_0x2391('0x25'));return request({'uri':util[_0x2391('0xe')](_0x2391('0x24'),_0x4520d5['remoteUri']),'method':_0x2391('0x19'),'body':{'name':_0x21c422,'phone':_0x4c57ef}})[_0x2391('0x1a')](function(_0x51cc47){logger[_0x2391('0xb')]('Enduser\x20created.');return _0x51cc47;});}});}function getAuth(_0x102438){return util[_0x2391('0xe')](_0x2391('0x26'),new Buffer(_0x102438[_0x2391('0x27')]+':X')['toString'](_0x2391('0x28')));}function request(_0x2e9b84){logger[_0x2391('0x29')](_0x2391('0x2a'),JSON[_0x2391('0x2b')](_0x2e9b84));return rp(_[_0x2391('0x2c')](_0x2e9b84,{'method':_0x2391('0x2d'),'headers':headers,'json':!![]}));}function getTags(_0x5ef921,_0x48c2cf){var _0x13fbe9=[];if(_0x5ef921&&_0x5ef921['length']>0x0){_0x13fbe9=_['map'](_0x5ef921,_0x48c2cf);}return _0x13fbe9;}function getCustomFields(_0x181a02,_0x1e9f25){var _0x37b27a=[];var _0x5ed6e3={'custom_fields':[]};if(_0x181a02[_0x2391('0x1d')]>0x0){_[_0x2391('0x2e')](_0x181a02,function(_0x517ac5){if(_[_0x2391('0x2f')]([_0x2391('0x30'),_0x2391('0x31')],_0x517ac5['type'])&&_0x517ac5[_0x2391('0x32')]&&!_0x517ac5['customField']){_0x5ed6e3[_0x517ac5['nameField'][_0x2391('0x33')]()]=_0x517ac5['content'][_0x2391('0x34')]();}else if(_[_0x2391('0x2f')]([_0x2391('0x30'),'picklist'],_0x517ac5[_0x2391('0x35')])&&_0x517ac5['idField']&&_0x517ac5[_0x2391('0x36')]){_0x5ed6e3[_0x2391('0x15')][_0x2391('0x37')]({'id':_0x517ac5['idField'],'value':_0x517ac5[_0x2391('0x38')][_0x2391('0x34')]()});}else if(_0x517ac5[_0x2391('0x35')]===_0x2391('0x39')&&_0x517ac5[_0x2391('0x3a')]&&_0x517ac5[_0x2391('0x3b')]&&_0x517ac5['customField']){_0x1e9f25[_0x517ac5[_0x2391('0x3a')]]&&_0x5ed6e3[_0x2391('0x15')][_0x2391('0x37')]({'id':_0x517ac5['idField'],'value':_0x1e9f25[_0x517ac5[_0x2391('0x3a')]][_0x2391('0x34')]()});}else if(_0x517ac5['type']===_0x2391('0x3c')&&_0x517ac5[_0x2391('0x3d')]&&_0x517ac5[_0x2391('0x3d')][_0x2391('0x14')]&&_0x517ac5[_0x2391('0x3b')]&&_0x517ac5[_0x2391('0x36')]){_0x1e9f25[_0x517ac5[_0x2391('0x3d')][_0x2391('0x14')]['toLowerCase']()]&&_0x5ed6e3[_0x2391('0x15')][_0x2391('0x37')]({'id':_0x517ac5[_0x2391('0x3b')],'value':_0x1e9f25[_0x517ac5[_0x2391('0x3d')][_0x2391('0x14')][_0x2391('0x33')]()]['toString']()});}});}return _0x5ed6e3;}exports[_0x2391('0x3e')]=function(_0x7a11ee,_0x6e6fde,_0x1dac11,_0xa9c837,_0x2ad330,_0xfb58ff){var _0x2dcf65,_0x1c8bbf;_0xfb58ff[_0x2391('0x18')]=intUtil['stripTrailingSlash'](_0xfb58ff[_0x2391('0x18')]);_0xfb58ff[_0x2391('0x3f')]=intUtil[_0x2391('0x40')](_0xfb58ff['serverUrl']);if(_0x2ad330&&_0x2ad330[_0x2391('0x41')]){logger['info']('[QUEUE]',_0x2391('0x42'));_0x6e6fde[_0x2391('0x43')]=util[_0x2391('0xe')](_0x2391('0x44'),_0xfb58ff['serverUrl'],_0x6e6fde[_0x2391('0x45')],md5(_0x6e6fde[_0x2391('0x45')]));}else{_0x6e6fde['recordingURL']='';}headers[_0x2391('0x46')]=getAuth(_0xfb58ff);return getUser(_0xfb58ff,_0xa9c837['email'])[_0x2391('0x1a')](function(_0x37aaa2){_0x2dcf65=_0x37aaa2;logger[_0x2391('0xb')](_0x2391('0x47'),_0x2dcf65['id']);return getEndUser(_0xfb58ff,_0x6e6fde[_0x2391('0x48')],_0x6e6fde[_0x2391('0x10')]);})[_0x2391('0x1a')](function(_0x5c7a01){_0x1c8bbf=_0x5c7a01;logger['info'](_0x2391('0x49'),_0x1c8bbf['id']);return getTicket(_0xfb58ff,_0x2dcf65,_0x1c8bbf,_0x1dac11,_0x6e6fde);})[_0x2391('0x1a')](function(_0x30c376){if(_0x30c376&&_0x30c376['id']){logger[_0x2391('0xb')]('Ticket\x20created!');logger['info']('The\x20Ticket\x20ID\x20is:',_0x30c376['id']);logger[_0x2391('0xb')](_0x2391('0x4a'),_0x2391('0x4b'));emit(util[_0x2391('0xe')](_0x2391('0x4c'),_0xa9c837[_0x2391('0x14')]),_0x2391('0x4d'),{'uri':util[_0x2391('0xe')](_0x2391('0x4e'),_0xfb58ff['remoteUri'],_0x30c376['id'])});}})[_0x2391('0x4f')](function(_0xeeb96b){logger[_0x2391('0x50')](_0x2391('0x4a'),JSON['stringify'](_0xeeb96b));});};exports[_0x2391('0x51')]=function(_0x594ed6,_0x1c8132,_0x431990,_0x145023,_0x83f839,_0x4725e9,_0x483b6f){var _0x438d63,_0x5a8761;_0x4725e9[_0x2391('0x18')]=intUtil[_0x2391('0x40')](_0x4725e9[_0x2391('0x18')]);_0x4725e9[_0x2391('0x3f')]=intUtil[_0x2391('0x40')](_0x4725e9[_0x2391('0x3f')]);if(_0x483b6f&&_0x483b6f['recordingFormat']&&_0x483b6f[_0x2391('0x52')]!==_0x2391('0x53')){logger[_0x2391('0xb')](_0x2391('0x54'),_0x2391('0x42'));_0x1c8132['recordingURL']=util[_0x2391('0xe')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x4725e9['serverUrl'],_0x1c8132[_0x2391('0x45')],md5(_0x1c8132['uniqueid']));}headers[_0x2391('0x46')]=getAuth(_0x4725e9);return getUser(_0x4725e9,_0x145023[_0x2391('0x55')])['then'](function(_0x54223d){_0x438d63=_0x54223d;logger[_0x2391('0xb')]('The\x20User\x20ID\x20is:',_0x438d63['id']);return getEndUser(_0x4725e9,_0x1c8132[_0x2391('0x56')],_0x1c8132[_0x2391('0x57')]);})[_0x2391('0x1a')](function(_0x323912){_0x5a8761=_0x323912;logger['info'](_0x2391('0x49'),_0x5a8761['id']);return getTicket(_0x4725e9,_0x438d63,_0x5a8761,_0x431990,_0x1c8132);})[_0x2391('0x1a')](function(_0x3adcc5){if(_0x3adcc5&&_0x3adcc5['id']){logger[_0x2391('0xb')](_0x2391('0x1b'));logger['info'](_0x2391('0x58'),_0x3adcc5['id']);logger[_0x2391('0xb')]('[OUTBOUND]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x2391('0xe')]('user:%s',_0x145023[_0x2391('0x14')]),_0x2391('0x4d'),{'uri':util[_0x2391('0xe')]('%s/helpdesk/tickets/%d',_0x4725e9[_0x2391('0x18')],_0x3adcc5['id'])});}})[_0x2391('0x4f')](function(_0x30bdc6){logger[_0x2391('0x50')](_0x2391('0x54'),JSON[_0x2391('0x2b')](_0x30bdc6));});};exports['unmanaged']=function(_0x399c3c,_0x376053,_0x40d7f3,_0x1674f3,_0x647cce,_0x698d48){var _0x1d70df,_0x3e6316;_0x698d48[_0x2391('0x18')]=intUtil[_0x2391('0x40')](_0x698d48[_0x2391('0x18')]);_0x698d48[_0x2391('0x3f')]=intUtil[_0x2391('0x40')](_0x698d48[_0x2391('0x3f')]);if(_0x647cce&&_0x647cce[_0x2391('0x41')]){logger['info']('['+_0x376053['lastevent'][_0x2391('0x59')]()+']',_0x2391('0x42'));_0x376053[_0x2391('0x43')]=util[_0x2391('0xe')](_0x2391('0x44'),_0x698d48['serverUrl'],_0x376053[_0x2391('0x45')],md5(_0x376053[_0x2391('0x45')]));}else{_0x376053['recordingURL']='';}headers[_0x2391('0x46')]=getAuth(_0x698d48);return getUser(_0x698d48,'')[_0x2391('0x1a')](function(_0x239370){_0x1d70df=_0x239370;logger['info'](_0x2391('0x47'),_0x1d70df['id']);return getEndUser(_0x698d48,_0x376053[_0x2391('0x48')],_0x376053[_0x2391('0x10')]);})[_0x2391('0x1a')](function(_0x3abded){_0x3e6316=_0x3abded;logger[_0x2391('0xb')]('The\x20Enduser\x20ID\x20is:',_0x3e6316['id']);return getTicket(_0x698d48,_0x1d70df,_0x3e6316,_0x40d7f3,_0x376053);})[_0x2391('0x1a')](function(_0x4be44e){if(_0x4be44e){logger[_0x2391('0xb')](_0x2391('0x1b'));logger[_0x2391('0xb')](_0x2391('0x58'),_0x4be44e['id']);}})[_0x2391('0x4f')](function(_0x12ab0c){logger[_0x2391('0x50')]('['+_0x376053[_0x2391('0x5a')]['toUpperCase']()+']',JSON[_0x2391('0x2b')](_0x12ab0c));});};
\ No newline at end of file
+var _0xcbee=['picklist','customField','nameField','toLowerCase','content','type','idField','variable','push','variableName','customVariable','Variable','queue','stripTrailingSlash','serverUrl','monitor_format','Recording\x20is\x20enabled!','recordingURL','%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]','Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','%s/helpdesk/tickets/%d','catch','error','outbound','recordingFormat','none','[OUTBOUND]','destcalleridname','destcalleridnum','stringify','toUpperCase','lastevent','lodash','request-promise','util','ioredis','./util','../../../../config/environment','redis','localhost','application/json','emit','Creating\x20new\x20ticket...','merge','format','Caller\x20-\x20%s','calleridname','calleridnum','getString','Descriptions','<br>','Tags','name','Fields','mapValues','keyBy','custom_fields','value','%s/api/v2/tickets','remoteUri','POST','info','Ticket\x20created!','validateEmail','%s/api/v2/agents','length','Agent\x20found!','find','email','Agent\x20not\x20found,\x20using\x20the\x20admin\x20account!','%s/api/v2/agents/me','Admin\x20account\x20selected.','then','Searching\x20enduser\x20with\x20phone','%s/api/v2/contacts','Enduser\x20found!','Enduser\x20not\x20found,\x20creating\x20a\x20new\x20enduser!','Enduser\x20created.','Basic\x20%s','toString','debug','[HTTP]','defaults','GET','map','forEach','includes','string'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xcbee,0x1a8));var _0xecbe=function(_0x39af5a,_0x5c5bf0){_0x39af5a=_0x39af5a-0x0;var _0xea428e=_0xcbee[_0x39af5a];return _0xea428e;};'use strict';var _=require(_0xecbe('0x0'));var rp=require(_0xecbe('0x1'));var md5=require('md5');var util=require(_0xecbe('0x2'));var Redis=require(_0xecbe('0x3'));var intUtil=require(_0xecbe('0x4'));var config=require(_0xecbe('0x5'));var logger=require('../../../../config/logger')('freshdesk');config[_0xecbe('0x6')]=_['defaults'](config['redis'],{'host':_0xecbe('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var headers={'Content-Type':_0xecbe('0x8'),'Accept':_0xecbe('0x8')};function emit(_0x177705,_0x53600d,_0x1fc455){io['to'](_0x177705)[_0xecbe('0x9')](_0x53600d,_0x1fc455);}function getTicket(_0x50471f,_0x365173,_0x1437ff,_0x549422,_0x1a1166){logger['info'](_0xecbe('0xa'));var _0xe7ad5f=_[_0xecbe('0xb')]({'responder_id':_0x365173['id'],'requester_id':_0x1437ff['id'],'name':util[_0xecbe('0xc')](_0xecbe('0xd'),_0x1a1166[_0xecbe('0xe')]),'phone':_0x1a1166[_0xecbe('0xf')],'source':0x3,'priority':0x1,'status':0x2,'subject':intUtil[_0xecbe('0x10')](_0x549422['Subjects'],_0x1a1166,'\x20'),'description':intUtil[_0xecbe('0x10')](_0x549422[_0xecbe('0x11')],_0x1a1166,_0xecbe('0x12')),'tags':getTags(_0x549422[_0xecbe('0x13')],_0xecbe('0x14'))},getCustomFields(_0x549422[_0xecbe('0x15')],_0x1a1166));_0xe7ad5f['custom_fields']=_[_0xecbe('0x16')](_[_0xecbe('0x17')](_0xe7ad5f[_0xecbe('0x18')],'id'),_0xecbe('0x19'));return request({'uri':util[_0xecbe('0xc')](_0xecbe('0x1a'),_0x50471f[_0xecbe('0x1b')]),'method':_0xecbe('0x1c'),'body':_0xe7ad5f})['then'](function(_0x405ab2){logger[_0xecbe('0x1d')](_0xecbe('0x1e'));return _0x405ab2;});}function getUser(_0x5cc878,_0x2cdcf9){if(intUtil[_0xecbe('0x1f')](_0x2cdcf9)){return request({'uri':util[_0xecbe('0xc')](_0xecbe('0x20'),_0x5cc878[_0xecbe('0x1b')]),'qs':{'email':_0x2cdcf9}})['then'](function(_0x1695e5){if(_0x1695e5[_0xecbe('0x21')]){logger['info'](_0xecbe('0x22'));return _[_0xecbe('0x23')](_0x1695e5,function(_0x595f9b){return _0x595f9b['contact'][_0xecbe('0x24')]===_0x2cdcf9;});}else{logger[_0xecbe('0x1d')](_0xecbe('0x25'));return request({'uri':util['format'](_0xecbe('0x26'),_0x5cc878['remoteUri'])})['then'](function(_0x9d6345){logger[_0xecbe('0x1d')](_0xecbe('0x27'));return _0x9d6345;});}});}else{logger[_0xecbe('0x1d')]('Invalid\x20email\x20format,\x20using\x20the\x20admin\x20account!');return request({'uri':util['format']('%s/api/v2/agents/me',_0x5cc878[_0xecbe('0x1b')])})[_0xecbe('0x28')](function(_0x54bebf){logger[_0xecbe('0x1d')](_0xecbe('0x27'));return _0x54bebf;});}}function getEndUser(_0x71d4c2,_0x48d289,_0x81f839){logger[_0xecbe('0x1d')](_0xecbe('0x29'),_0x81f839);return request({'uri':util[_0xecbe('0xc')](_0xecbe('0x2a'),_0x71d4c2['remoteUri']),'qs':{'phone':_0x81f839}})[_0xecbe('0x28')](function(_0x1bd0c6){if(_0x1bd0c6['length']){logger[_0xecbe('0x1d')](_0xecbe('0x2b'));return _[_0xecbe('0x23')](_0x1bd0c6,{'phone':_0x81f839});}else{logger[_0xecbe('0x1d')](_0xecbe('0x2c'));return request({'uri':util[_0xecbe('0xc')](_0xecbe('0x2a'),_0x71d4c2['remoteUri']),'method':'POST','body':{'name':_0x48d289,'phone':_0x81f839}})[_0xecbe('0x28')](function(_0x3b4704){logger[_0xecbe('0x1d')](_0xecbe('0x2d'));return _0x3b4704;});}});}function getAuth(_0x3f850c){return util[_0xecbe('0xc')](_0xecbe('0x2e'),new Buffer(_0x3f850c['apiKey']+':X')[_0xecbe('0x2f')]('base64'));}function request(_0x40ff36){logger[_0xecbe('0x30')](_0xecbe('0x31'),JSON['stringify'](_0x40ff36));return rp(_[_0xecbe('0x32')](_0x40ff36,{'method':_0xecbe('0x33'),'headers':headers,'json':!![]}));}function getTags(_0x173630,_0x1063a4){var _0x5b4bec=[];if(_0x173630&&_0x173630['length']>0x0){_0x5b4bec=_[_0xecbe('0x34')](_0x173630,_0x1063a4);}return _0x5b4bec;}function getCustomFields(_0x3b3e68,_0x1b1631){var _0x212db1=[];var _0x2cfc09={'custom_fields':[]};if(_0x3b3e68['length']>0x0){_[_0xecbe('0x35')](_0x3b3e68,function(_0x3db034){if(_[_0xecbe('0x36')]([_0xecbe('0x37'),_0xecbe('0x38')],_0x3db034['type'])&&_0x3db034['nameField']&&!_0x3db034[_0xecbe('0x39')]){_0x2cfc09[_0x3db034[_0xecbe('0x3a')][_0xecbe('0x3b')]()]=_0x3db034[_0xecbe('0x3c')]['toString']();}else if(_[_0xecbe('0x36')](['string','picklist'],_0x3db034[_0xecbe('0x3d')])&&_0x3db034[_0xecbe('0x3e')]&&_0x3db034[_0xecbe('0x39')]){_0x2cfc09[_0xecbe('0x18')]['push']({'id':_0x3db034[_0xecbe('0x3e')],'value':_0x3db034['content'][_0xecbe('0x2f')]()});}else if(_0x3db034[_0xecbe('0x3d')]===_0xecbe('0x3f')&&_0x3db034['variableName']&&_0x3db034[_0xecbe('0x3e')]&&_0x3db034[_0xecbe('0x39')]){_0x1b1631[_0x3db034['variableName']]&&_0x2cfc09[_0xecbe('0x18')][_0xecbe('0x40')]({'id':_0x3db034[_0xecbe('0x3e')],'value':_0x1b1631[_0x3db034[_0xecbe('0x41')]][_0xecbe('0x2f')]()});}else if(_0x3db034[_0xecbe('0x3d')]===_0xecbe('0x42')&&_0x3db034[_0xecbe('0x43')]&&_0x3db034['Variable'][_0xecbe('0x14')]&&_0x3db034['idField']&&_0x3db034[_0xecbe('0x39')]){_0x1b1631[_0x3db034[_0xecbe('0x43')][_0xecbe('0x14')][_0xecbe('0x3b')]()]&&_0x2cfc09[_0xecbe('0x18')][_0xecbe('0x40')]({'id':_0x3db034['idField'],'value':_0x1b1631[_0x3db034['Variable'][_0xecbe('0x14')][_0xecbe('0x3b')]()][_0xecbe('0x2f')]()});}});}return _0x2cfc09;}exports[_0xecbe('0x44')]=function(_0x353502,_0x373074,_0x20110b,_0x7b545,_0x34832a,_0x393291){var _0x4abd16,_0x452345;_0x393291[_0xecbe('0x1b')]=intUtil[_0xecbe('0x45')](_0x393291[_0xecbe('0x1b')]);_0x393291[_0xecbe('0x46')]=intUtil[_0xecbe('0x45')](_0x393291[_0xecbe('0x46')]);if(_0x34832a&&_0x34832a[_0xecbe('0x47')]){logger[_0xecbe('0x1d')]('[QUEUE]',_0xecbe('0x48'));_0x373074[_0xecbe('0x49')]=util[_0xecbe('0xc')](_0xecbe('0x4a'),_0x393291['serverUrl'],_0x373074[_0xecbe('0x4b')],md5(_0x373074['uniqueid']));}else{_0x373074[_0xecbe('0x49')]='';}headers[_0xecbe('0x4c')]=getAuth(_0x393291);return getUser(_0x393291,_0x7b545['email'])[_0xecbe('0x28')](function(_0x16ea4b){_0x4abd16=_0x16ea4b;logger[_0xecbe('0x1d')](_0xecbe('0x4d'),_0x4abd16['id']);return getEndUser(_0x393291,_0x373074[_0xecbe('0xe')],_0x373074[_0xecbe('0xf')]);})[_0xecbe('0x28')](function(_0x28768a){_0x452345=_0x28768a;logger[_0xecbe('0x1d')](_0xecbe('0x4e'),_0x452345['id']);return getTicket(_0x393291,_0x4abd16,_0x452345,_0x20110b,_0x373074);})[_0xecbe('0x28')](function(_0x16bb9c){if(_0x16bb9c&&_0x16bb9c['id']){logger[_0xecbe('0x1d')]('Ticket\x20created!');logger[_0xecbe('0x1d')](_0xecbe('0x4f'),_0x16bb9c['id']);logger[_0xecbe('0x1d')](_0xecbe('0x50'),_0xecbe('0x51'));emit(util[_0xecbe('0xc')](_0xecbe('0x52'),_0x7b545[_0xecbe('0x14')]),_0xecbe('0x53'),{'uri':util[_0xecbe('0xc')](_0xecbe('0x54'),_0x393291[_0xecbe('0x1b')],_0x16bb9c['id'])});}})[_0xecbe('0x55')](function(_0x669621){logger[_0xecbe('0x56')](_0xecbe('0x50'),JSON['stringify'](_0x669621));});};exports[_0xecbe('0x57')]=function(_0x229d8f,_0x404fe5,_0x46cc01,_0x1a1358,_0x2f9e29,_0x206068,_0x515378){var _0x46a4f2,_0x394dcf;_0x206068[_0xecbe('0x1b')]=intUtil[_0xecbe('0x45')](_0x206068['remoteUri']);_0x206068['serverUrl']=intUtil['stripTrailingSlash'](_0x206068[_0xecbe('0x46')]);if(_0x515378&&_0x515378['recordingFormat']&&_0x515378[_0xecbe('0x58')]!==_0xecbe('0x59')){logger[_0xecbe('0x1d')](_0xecbe('0x5a'),_0xecbe('0x48'));_0x404fe5['recordingURL']=util[_0xecbe('0xc')](_0xecbe('0x4a'),_0x206068[_0xecbe('0x46')],_0x404fe5[_0xecbe('0x4b')],md5(_0x404fe5[_0xecbe('0x4b')]));}headers['Authorization']=getAuth(_0x206068);return getUser(_0x206068,_0x1a1358[_0xecbe('0x24')])[_0xecbe('0x28')](function(_0x5a51be){_0x46a4f2=_0x5a51be;logger[_0xecbe('0x1d')]('The\x20User\x20ID\x20is:',_0x46a4f2['id']);return getEndUser(_0x206068,_0x404fe5[_0xecbe('0x5b')],_0x404fe5[_0xecbe('0x5c')]);})[_0xecbe('0x28')](function(_0x1ea72f){_0x394dcf=_0x1ea72f;logger[_0xecbe('0x1d')]('The\x20Enduser\x20ID\x20is:',_0x394dcf['id']);return getTicket(_0x206068,_0x46a4f2,_0x394dcf,_0x46cc01,_0x404fe5);})[_0xecbe('0x28')](function(_0x2e9f09){if(_0x2e9f09&&_0x2e9f09['id']){logger[_0xecbe('0x1d')]('Ticket\x20created!');logger[_0xecbe('0x1d')](_0xecbe('0x4f'),_0x2e9f09['id']);logger['info'](_0xecbe('0x5a'),'Displaying\x20ticket\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0xecbe('0xc')]('user:%s',_0x1a1358[_0xecbe('0x14')]),_0xecbe('0x53'),{'uri':util[_0xecbe('0xc')](_0xecbe('0x54'),_0x206068[_0xecbe('0x1b')],_0x2e9f09['id'])});}})[_0xecbe('0x55')](function(_0x3802ce){logger[_0xecbe('0x56')](_0xecbe('0x5a'),JSON[_0xecbe('0x5d')](_0x3802ce));});};exports['unmanaged']=function(_0x60bd24,_0x48614f,_0x5b92de,_0x1501d1,_0xd5d51d,_0x3c46a6){var _0x3ed28f,_0x33afe2;_0x3c46a6[_0xecbe('0x1b')]=intUtil[_0xecbe('0x45')](_0x3c46a6[_0xecbe('0x1b')]);_0x3c46a6[_0xecbe('0x46')]=intUtil[_0xecbe('0x45')](_0x3c46a6[_0xecbe('0x46')]);if(_0xd5d51d&&_0xd5d51d['monitor_format']){logger[_0xecbe('0x1d')]('['+_0x48614f['lastevent'][_0xecbe('0x5e')]()+']',_0xecbe('0x48'));_0x48614f[_0xecbe('0x49')]=util[_0xecbe('0xc')](_0xecbe('0x4a'),_0x3c46a6['serverUrl'],_0x48614f[_0xecbe('0x4b')],md5(_0x48614f[_0xecbe('0x4b')]));}else{_0x48614f[_0xecbe('0x49')]='';}headers[_0xecbe('0x4c')]=getAuth(_0x3c46a6);return getUser(_0x3c46a6,'')[_0xecbe('0x28')](function(_0x2ccdd3){_0x3ed28f=_0x2ccdd3;logger[_0xecbe('0x1d')]('The\x20User\x20ID\x20is:',_0x3ed28f['id']);return getEndUser(_0x3c46a6,_0x48614f[_0xecbe('0xe')],_0x48614f['calleridnum']);})[_0xecbe('0x28')](function(_0x7cdacc){_0x33afe2=_0x7cdacc;logger[_0xecbe('0x1d')](_0xecbe('0x4e'),_0x33afe2['id']);return getTicket(_0x3c46a6,_0x3ed28f,_0x33afe2,_0x5b92de,_0x48614f);})[_0xecbe('0x28')](function(_0x28a3ce){if(_0x28a3ce){logger['info'](_0xecbe('0x1e'));logger[_0xecbe('0x1d')]('The\x20Ticket\x20ID\x20is:',_0x28a3ce['id']);}})[_0xecbe('0x55')](function(_0x44e619){logger[_0xecbe('0x56')]('['+_0x48614f[_0xecbe('0x5f')]['toUpperCase']()+']',JSON[_0xecbe('0x5d')](_0x44e619));});};
\ No newline at end of file