Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 328a204..c76f98b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x49e5=['ticketId','task','Task\x20created:','/contacts/','emit','trigger:browser:url','Token\x20token=','apiKey','stripTrailingSlash','serverUrl','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','queue','unmanaged','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingURL','recordingFormat','The\x20ticket\x20ID\x20is:\x20%s','Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','md5','util','moment','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','defaults','socket.io-emitter','redis','GET','/api/selector/owners','info','then','length','email','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','headers','Getting\x20user\x20list','users','agentEmail','Getting\x20user\x20with\x20email','User\x20found:','Admin\x20selected','userEmail','adminEmail','userId','/api/lookup?q=','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','mobile_number','endUserId','work_number','contactNumber','Contact\x20found\x20work_number:','Contact\x20created:','POST','/api/contacts','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','getString','Subjects','Descriptions','add'];(function(_0x250b35,_0x1fe099){var _0x242ee8=function(_0x130517){while(--_0x130517){_0x250b35['push'](_0x250b35['shift']());}};_0x242ee8(++_0x1fe099);}(_0x49e5,0x71));var _0x549e=function(_0x6a21f4,_0x220ad8){_0x6a21f4=_0x6a21f4-0x0;var _0x4c15ac=_0x49e5[_0x6a21f4];return _0x4c15ac;};'use strict';var _=require(_0x549e('0x0'));var rp=require(_0x549e('0x1'));var md5=require(_0x549e('0x2'));var util=require(_0x549e('0x3'));var moment=require(_0x549e('0x4'));var Promise=require('bluebird');var Redis=require(_0x549e('0x5'));var intUtil=require(_0x549e('0x6'));var config=require(_0x549e('0x7'));var logger=require(_0x549e('0x8'))(_0x549e('0x9'));config['redis']=_[_0x549e('0xa')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x549e('0xb'))(new Redis(config[_0x549e('0xc')]));function getAdminId(_0x158392,_0x5e3c38,_0x555864,_0x49ba7a){return new Promise(function(_0x230ae5,_0x28a6a2){var _0x254556=![];var _0x468c6c={'method':_0x549e('0xd'),'uri':_0x49ba7a+_0x549e('0xe'),'json':!![]};_0x468c6c['headers']=_0x555864;logger[_0x549e('0xf')]('Getting\x20admin\x20information');return rp(_0x468c6c)[_0x549e('0x10')](function(_0x3740a2){if(_0x3740a2){var _0x3b9c34=_0x3740a2['users'];var _0x3168da=null;for(_0x3168da=0x0;_0x3168da<_0x3b9c34[_0x549e('0x11')];_0x3168da++){if(_0x3b9c34[_0x3168da][_0x549e('0x12')]===_0x158392['adminEmail']){_0x158392[_0x549e('0x13')]=_0x3b9c34[_0x3168da]['id'];_0x254556=!![];}}if(_0x254556){logger[_0x549e('0xf')](_0x549e('0x14'),_0x158392[_0x549e('0x13')]);_0x230ae5(_0x158392);}else{_0x28a6a2({'statusCode':0x194,'message':_0x549e('0x15')});}}else{_0x28a6a2({'statusCode':0x194,'message':_0x549e('0x15')});}})[_0x549e('0x16')](function(_0x39d022){logger[_0x549e('0x17')]('['+[_0x5e3c38[_0x549e('0x18')]()]+']',_0x39d022[_0x549e('0x19')]);_0x28a6a2(_0x39d022);});});}function getUser(_0x207fe0,_0x402c51,_0x1c5877){return function(_0x347f67){return new Promise(function(_0x48c662,_0x294cb3){var _0x233a69={'method':'GET','uri':_0x1c5877+_0x549e('0xe'),'json':!![]};_0x233a69[_0x549e('0x1a')]=_0x402c51;logger[_0x549e('0xf')](_0x549e('0x1b'));return rp(_0x233a69)[_0x549e('0x10')](function(_0x10cdbe){if(_0x10cdbe){var _0x311de3=_0x10cdbe[_0x549e('0x1c')];var _0x16e9d1=![];var _0x244ac7=null;if(_0x347f67[_0x549e('0x1d')]!==null){logger[_0x549e('0xf')](_0x549e('0x1e'),_0x347f67['agentEmail']);_0x347f67['userEmail']=_0x347f67['agentEmail'];for(_0x244ac7=0x0;_0x244ac7<_0x311de3[_0x549e('0x11')];_0x244ac7++){if(_0x311de3[_0x244ac7][_0x549e('0x12')]===_0x347f67[_0x549e('0x1d')]){_0x16e9d1=!![];_0x347f67['userId']=_0x311de3[_0x244ac7]['id'];logger['info'](_0x549e('0x1f'),_0x347f67['userId']);}}}if(!_0x16e9d1){logger[_0x549e('0xf')](_0x549e('0x20'));_0x347f67[_0x549e('0x21')]=_0x347f67[_0x549e('0x22')];_0x347f67[_0x549e('0x23')]=_0x347f67['adminId'];_0x16e9d1=!![];}if(_0x16e9d1){_0x48c662(_0x347f67);}else{_0x294cb3({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x294cb3({'statusCode':0x194,'message':_0x549e('0x15')});}})[_0x549e('0x16')](function(_0x39f2b4){logger[_0x549e('0x17')]('['+[_0x207fe0['toUpperCase']()]+']',_0x39f2b4['message']);_0x294cb3(_0x39f2b4);});});};}function searchContact(_0x45587f,_0x337123,_0x21ae07,_0x29a0f0){return new Promise(function(_0x2c2064,_0x49c9d2){var _0x15cc9f={'method':_0x549e('0xd'),'headers':_0x337123,'uri':_0x45587f+_0x549e('0x24')+_0x29a0f0+'&f='+_0x21ae07+'&entities=contact','json':!![]};rp(_0x15cc9f)[_0x549e('0x10')](function(_0x1921e3){var _0x187f22=_[_0x549e('0x25')](_0x1921e3[_0x549e('0x26')][_0x549e('0x26')],[_0x21ae07,_0x29a0f0]);_0x2c2064(_0x187f22);})[_0x549e('0x16')](function(_0x2d1d41){_0x49c9d2(_0x2d1d41);});});}function getEndUser(_0x45e4c2,_0xbd6151,_0x5208eb){return function(_0xbcb5e1){return new Promise(function(_0x3492d5,_0x18f077){logger[_0x549e('0xf')](util[_0x549e('0x27')](_0x549e('0x28'),_0xbcb5e1['contactNumber']));searchContact(_0x5208eb,_0xbd6151,_0x549e('0x29'),_0xbcb5e1['contactNumber'])['then'](function(_0x2dc7b4){if(_0x2dc7b4){_0xbcb5e1[_0x549e('0x2a')]=_0x2dc7b4['id'];logger[_0x549e('0xf')]('Contact\x20found\x20mobile_number:',_0xbcb5e1[_0x549e('0x2a')]);return _0x3492d5(_0xbcb5e1);}searchContact(_0x5208eb,_0xbd6151,_0x549e('0x2b'),_0xbcb5e1[_0x549e('0x2c')])[_0x549e('0x10')](function(_0x1007a1){if(_0x1007a1){_0xbcb5e1['endUserId']=_0x1007a1['id'];logger[_0x549e('0xf')](_0x549e('0x2d'),_0xbcb5e1[_0x549e('0x2a')]);return _0x3492d5(_0xbcb5e1);}createEndUser(_0xbcb5e1,_0x45e4c2,_0xbd6151,_0x5208eb)[_0x549e('0x10')](function(_0x5a49af){logger[_0x549e('0xf')](_0x549e('0x2e'),_0x5a49af['endUserId']);return _0x3492d5(_0x5a49af);});});})[_0x549e('0x16')](function(_0x31b7e5){_0x18f077(_0x31b7e5);});});};}function createEndUser(_0x2e0a0b,_0x314a79,_0x20cc3d,_0x43da3f){return new Promise(function(_0x1568fd,_0x1da7d3){var _0x4a5653=moment();var _0x3aa382={'method':_0x549e('0x2f'),'uri':_0x43da3f+_0x549e('0x30'),'body':{'contact':{'last_name':_0x2e0a0b['contactNumber'],'work_number':_0x2e0a0b[_0x549e('0x2c')],'mobile_number':_0x2e0a0b[_0x549e('0x2c')],'owner_id':_0x2e0a0b[_0x549e('0x23')],'created_at':_0x4a5653['format'](_0x549e('0x31'))}},'json':!![]};_0x3aa382['headers']=_0x20cc3d;logger[_0x549e('0xf')](_0x549e('0x32'));return rp(_0x3aa382)[_0x549e('0x10')](function(_0x3bc599){_0x2e0a0b[_0x549e('0x2a')]=_0x3bc599[_0x549e('0x33')]['id'];_0x1568fd(_0x2e0a0b);})['catch'](function(_0x3996a4){logger[_0x549e('0x17')]('['+[_0x314a79['toUpperCase']()]+']',_0x3996a4[_0x549e('0x19')]);_0x1da7d3(_0x3996a4['message']);});});}function getTicket(_0x137cc1,_0x5ac7a0,_0x3301f8,_0x5209b3,_0x5e0f94){return function(_0x5864da){logger[_0x549e('0xf')](_0x549e('0x34'));return new Promise(function(_0x5033b8,_0x13fe0e){var _0x3b4ab4=moment();var _0x189b88={'method':'POST','uri':_0x3301f8+'/api/tasks','body':{'title':intUtil[_0x549e('0x35')](_0x5209b3[_0x549e('0x36')],_0x5e0f94,'\x20'),'description':intUtil[_0x549e('0x35')](_0x5209b3[_0x549e('0x37')],_0x5e0f94,'\x0a'),'owner_id':_0x5864da[_0x549e('0x23')],'creater_id':_0x5864da['adminId'],'targetable_id':_0x5864da[_0x549e('0x2a')],'targetable_type':'Contact','created_at':_0x3b4ab4[_0x549e('0x27')](_0x549e('0x31')),'due_date':_0x3b4ab4[_0x549e('0x38')](0x1e,'m')[_0x549e('0x27')]('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x189b88[_0x549e('0x1a')]=_0x5ac7a0;return rp(_0x189b88)['then'](function(_0xe4c65f){_0x5864da[_0x549e('0x39')]=_0xe4c65f[_0x549e('0x3a')]['id'];logger[_0x549e('0xf')](_0x549e('0x3b'),_0x5864da[_0x549e('0x39')]);_0x5033b8(_0x5864da);})[_0x549e('0x16')](function(_0x43fa0d){logger['error']('['+[_0x137cc1[_0x549e('0x18')]()]+']',_0x43fa0d[_0x549e('0x19')]);_0x13fe0e(_0x43fa0d[_0x549e('0x19')]);});});};}function emit(_0x15c410,_0x219d3c,_0x330dc0){var _0x1c8d47={'uri':_0x15c410+_0x549e('0x3c')+_0x330dc0};io['to'](util[_0x549e('0x27')]('user:%s',_0x219d3c))[_0x549e('0x3d')](_0x549e('0x3e'),_0x1c8d47);}exports['cs']=function(_0x348390,_0xc32cd5,_0x4f2b84,_0x30b6a1,_0x575b20,_0x5e4335,_0x1cbd9,_0x1aaa5d){var _0x376a4f={};var _0x5a539b={'Authorization':_0x549e('0x3f')+_0x5e4335[_0x549e('0x40')]};_0x5e4335['remoteUri']=intUtil[_0x549e('0x41')](_0x5e4335['remoteUri']);_0x5e4335[_0x549e('0x42')]=intUtil[_0x549e('0x41')](_0x5e4335['serverUrl']);var _0xc57850=_0x5e4335['remoteUri'];_0x376a4f['adminEmail']=_0x5e4335['username'];_0x376a4f[_0x549e('0x2c')]=_0x1aaa5d[_0x549e('0x43')]()===_0x549e('0x44')?_0xc32cd5[_0x549e('0x45')]:_0xc32cd5[_0x549e('0x46')];_0x376a4f[_0x549e('0x47')]=_0x1aaa5d===_0x549e('0x48')||_0x1aaa5d===_0x549e('0x49')?_0x549e('0x48'):_0x549e('0x44');if(_0x30b6a1){_0x376a4f[_0x549e('0x1d')]=_0x30b6a1[_0x549e('0x12')];}var _0x56bcff=util[_0x549e('0x27')](_0x549e('0x4a'),_0x5e4335[_0x549e('0x42')],_0xc32cd5[_0x549e('0x4b')],md5(_0xc32cd5['uniqueid']));if(_0x575b20&&_0x575b20[_0x549e('0x4c')]){logger['info']('[QUEUE]',_0x549e('0x4d'));_0xc32cd5[_0x549e('0x4e')]=_0x56bcff;}else if(_0x1cbd9&&_0x1cbd9[_0x549e('0x4f')]&&_0x1cbd9[_0x549e('0x4f')]!=='none'){logger[_0x549e('0xf')]('[OUTBOUND]',_0x549e('0x4d'));_0xc32cd5[_0x549e('0x4e')]=_0x56bcff;}else{_0xc32cd5[_0x549e('0x4e')]='';}return getAdminId(_0x376a4f,_0x1aaa5d,_0x5a539b,_0xc57850)[_0x549e('0x10')](getUser(_0x1aaa5d,_0x5a539b,_0xc57850))[_0x549e('0x10')](getEndUser(_0x1aaa5d,_0x5a539b,_0xc57850))[_0x549e('0x10')](getTicket(_0x1aaa5d,_0x5a539b,_0xc57850,_0x4f2b84,_0xc32cd5))[_0x549e('0x10')](function(_0x1f147e){logger[_0x549e('0xf')](util['format'](_0x549e('0x50'),_0x1f147e[_0x549e('0x39')]));if(_0x1aaa5d!==_0x549e('0x49')){logger[_0x549e('0xf')]('['+[_0x1aaa5d[_0x549e('0x18')]()]+']',_0x549e('0x51'));emit(_0xc57850,_0x30b6a1[_0x549e('0x52')],_0x1f147e[_0x549e('0x2a')]);}})[_0x549e('0x16')](function(_0x48b02a){logger[_0x549e('0x17')]('['+[_0x1aaa5d[_0x549e('0x18')]()]+_0x549e('0x53'),util[_0x549e('0x54')](_0x48b02a,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0x8cc5=['Token\x20token=','apiKey','remoteUri','stripTrailingSlash','username','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','serverUrl','uniqueid','recordingURL','recordingFormat','none','Recording\x20is\x20enabled!','unmanaged',']\x20Error\x20running\x20Freshsales\x20integration','inspect','request-promise','md5','moment','bluebird','ioredis','./util','../../../../config/environment','freshsales','defaults','localhost','redis','GET','/api/selector/owners','headers','info','Getting\x20admin\x20information','then','email','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','Getting\x20user\x20list','users','agentEmail','Getting\x20user\x20with\x20email','userEmail','length','User\x20found:','userId','Admin\x20selected','adminEmail','/api/lookup?q=','&f=','&entities=contact','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','mobile_number','endUserId','Contact\x20found\x20mobile_number:','Contact\x20found\x20work_number:','Contact\x20created:','/api/contacts','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','POST','/api/tasks','Subjects','Descriptions','YYYY-MM-DDTHH:mm:ss','ticketId','task','/contacts/','user:%s','emit','trigger:browser:url'];(function(_0xa39b2b,_0x8c128c){var _0x54d7f3=function(_0x139c09){while(--_0x139c09){_0xa39b2b['push'](_0xa39b2b['shift']());}};_0x54d7f3(++_0x8c128c);}(_0x8cc5,0x69));var _0x58cc=function(_0x22ed9d,_0x42fc51){_0x22ed9d=_0x22ed9d-0x0;var _0x4f1d8a=_0x8cc5[_0x22ed9d];return _0x4f1d8a;};'use strict';var _=require('lodash');var rp=require(_0x58cc('0x0'));var md5=require(_0x58cc('0x1'));var util=require('util');var moment=require(_0x58cc('0x2'));var Promise=require(_0x58cc('0x3'));var Redis=require(_0x58cc('0x4'));var intUtil=require(_0x58cc('0x5'));var config=require(_0x58cc('0x6'));var logger=require('../../../../config/logger')(_0x58cc('0x7'));config['redis']=_[_0x58cc('0x8')](config['redis'],{'host':_0x58cc('0x9'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x58cc('0xa')]));function getAdminId(_0x39cb1d,_0x2bccc5,_0x10233f,_0x36dafc){return new Promise(function(_0x32b9f7,_0x33fefa){var _0x3e9487=![];var _0x570c2b={'method':_0x58cc('0xb'),'uri':_0x36dafc+_0x58cc('0xc'),'json':!![]};_0x570c2b[_0x58cc('0xd')]=_0x10233f;logger[_0x58cc('0xe')](_0x58cc('0xf'));return rp(_0x570c2b)[_0x58cc('0x10')](function(_0x3257ee){if(_0x3257ee){var _0x4675c4=_0x3257ee['users'];var _0x3835e4=null;for(_0x3835e4=0x0;_0x3835e4<_0x4675c4['length'];_0x3835e4++){if(_0x4675c4[_0x3835e4][_0x58cc('0x11')]===_0x39cb1d['adminEmail']){_0x39cb1d[_0x58cc('0x12')]=_0x4675c4[_0x3835e4]['id'];_0x3e9487=!![];}}if(_0x3e9487){logger[_0x58cc('0xe')](_0x58cc('0x13'),_0x39cb1d[_0x58cc('0x12')]);_0x32b9f7(_0x39cb1d);}else{_0x33fefa({'statusCode':0x194,'message':_0x58cc('0x14')});}}else{_0x33fefa({'statusCode':0x194,'message':_0x58cc('0x14')});}})[_0x58cc('0x15')](function(_0x6a91c5){logger[_0x58cc('0x16')]('['+[_0x2bccc5[_0x58cc('0x17')]()]+']',_0x6a91c5[_0x58cc('0x18')]);_0x33fefa(_0x6a91c5);});});}function getUser(_0x41cf2a,_0x2fb3ed,_0x1d6553){return function(_0x1c0b38){return new Promise(function(_0x42bf6a,_0x281f1b){var _0x2ea696={'method':_0x58cc('0xb'),'uri':_0x1d6553+_0x58cc('0xc'),'json':!![]};_0x2ea696[_0x58cc('0xd')]=_0x2fb3ed;logger[_0x58cc('0xe')](_0x58cc('0x19'));return rp(_0x2ea696)['then'](function(_0x3337dc){if(_0x3337dc){var _0x5ae4b2=_0x3337dc[_0x58cc('0x1a')];var _0x213b82=![];var _0x3e5424=null;if(_0x1c0b38[_0x58cc('0x1b')]!==null){logger[_0x58cc('0xe')](_0x58cc('0x1c'),_0x1c0b38[_0x58cc('0x1b')]);_0x1c0b38[_0x58cc('0x1d')]=_0x1c0b38[_0x58cc('0x1b')];for(_0x3e5424=0x0;_0x3e5424<_0x5ae4b2[_0x58cc('0x1e')];_0x3e5424++){if(_0x5ae4b2[_0x3e5424]['email']===_0x1c0b38[_0x58cc('0x1b')]){_0x213b82=!![];_0x1c0b38['userId']=_0x5ae4b2[_0x3e5424]['id'];logger['info'](_0x58cc('0x1f'),_0x1c0b38[_0x58cc('0x20')]);}}}if(!_0x213b82){logger[_0x58cc('0xe')](_0x58cc('0x21'));_0x1c0b38['userEmail']=_0x1c0b38[_0x58cc('0x22')];_0x1c0b38[_0x58cc('0x20')]=_0x1c0b38[_0x58cc('0x12')];_0x213b82=!![];}if(_0x213b82){_0x42bf6a(_0x1c0b38);}else{_0x281f1b({'statusCode':0x194,'message':_0x58cc('0x14')});}}else{_0x281f1b({'statusCode':0x194,'message':_0x58cc('0x14')});}})[_0x58cc('0x15')](function(_0x4c43a4){logger[_0x58cc('0x16')]('['+[_0x41cf2a[_0x58cc('0x17')]()]+']',_0x4c43a4['message']);_0x281f1b(_0x4c43a4);});});};}function searchContact(_0x1727c6,_0x4a09ee,_0x5b1e19,_0x15c395){return new Promise(function(_0x4b78af,_0x2b110b){var _0x330f6e={'method':_0x58cc('0xb'),'headers':_0x4a09ee,'uri':_0x1727c6+_0x58cc('0x23')+_0x15c395+_0x58cc('0x24')+_0x5b1e19+_0x58cc('0x25'),'json':!![]};rp(_0x330f6e)['then'](function(_0x39627f){var _0x948a2b=_[_0x58cc('0x26')](_0x39627f[_0x58cc('0x27')][_0x58cc('0x27')],[_0x5b1e19,_0x15c395]);_0x4b78af(_0x948a2b);})[_0x58cc('0x15')](function(_0x4cf1c9){_0x2b110b(_0x4cf1c9);});});}function getEndUser(_0x5016d0,_0x4fb230,_0x502955){return function(_0x3e9219){return new Promise(function(_0x5b6e49,_0x2e825e){logger[_0x58cc('0xe')](util[_0x58cc('0x28')](_0x58cc('0x29'),_0x3e9219[_0x58cc('0x2a')]));searchContact(_0x502955,_0x4fb230,_0x58cc('0x2b'),_0x3e9219[_0x58cc('0x2a')])[_0x58cc('0x10')](function(_0x32598b){if(_0x32598b){_0x3e9219[_0x58cc('0x2c')]=_0x32598b['id'];logger[_0x58cc('0xe')](_0x58cc('0x2d'),_0x3e9219['endUserId']);return _0x5b6e49(_0x3e9219);}searchContact(_0x502955,_0x4fb230,'work_number',_0x3e9219[_0x58cc('0x2a')])[_0x58cc('0x10')](function(_0x253a0a){if(_0x253a0a){_0x3e9219[_0x58cc('0x2c')]=_0x253a0a['id'];logger['info'](_0x58cc('0x2e'),_0x3e9219[_0x58cc('0x2c')]);return _0x5b6e49(_0x3e9219);}createEndUser(_0x3e9219,_0x5016d0,_0x4fb230,_0x502955)[_0x58cc('0x10')](function(_0x5d6840){logger[_0x58cc('0xe')](_0x58cc('0x2f'),_0x5d6840[_0x58cc('0x2c')]);return _0x5b6e49(_0x5d6840);});});})['catch'](function(_0xf7b24){_0x2e825e(_0xf7b24);});});};}function createEndUser(_0x1e3d8c,_0x12f515,_0x195145,_0x25b2db){return new Promise(function(_0x392b71,_0x57f4c9){var _0x1116d7=moment();var _0x2ef774={'method':'POST','uri':_0x25b2db+_0x58cc('0x30'),'body':{'contact':{'last_name':_0x1e3d8c['contactNumber'],'work_number':_0x1e3d8c[_0x58cc('0x2a')],'mobile_number':_0x1e3d8c['contactNumber'],'owner_id':_0x1e3d8c['userId'],'created_at':_0x1116d7[_0x58cc('0x28')]('YYYY-MM-DDTHH:mm:ss')}},'json':!![]};_0x2ef774[_0x58cc('0xd')]=_0x195145;logger[_0x58cc('0xe')](_0x58cc('0x31'));return rp(_0x2ef774)[_0x58cc('0x10')](function(_0x157f5a){_0x1e3d8c['endUserId']=_0x157f5a[_0x58cc('0x32')]['id'];_0x392b71(_0x1e3d8c);})[_0x58cc('0x15')](function(_0x3a6964){logger[_0x58cc('0x16')]('['+[_0x12f515[_0x58cc('0x17')]()]+']',_0x3a6964[_0x58cc('0x18')]);_0x57f4c9(_0x3a6964[_0x58cc('0x18')]);});});}function getTicket(_0x1ecb96,_0xf0f154,_0x53ae8d,_0xe019b6,_0x5d3d08){return function(_0x211505){logger[_0x58cc('0xe')](_0x58cc('0x33'));return new Promise(function(_0x50ed72,_0x9b8671){var _0x4a9967=moment();var _0x58cbf5={'method':_0x58cc('0x34'),'uri':_0x53ae8d+_0x58cc('0x35'),'body':{'title':intUtil['getString'](_0xe019b6[_0x58cc('0x36')],_0x5d3d08,'\x20'),'description':intUtil['getString'](_0xe019b6[_0x58cc('0x37')],_0x5d3d08,'\x0a'),'owner_id':_0x211505[_0x58cc('0x20')],'creater_id':_0x211505[_0x58cc('0x12')],'targetable_id':_0x211505[_0x58cc('0x2c')],'targetable_type':'Contact','created_at':_0x4a9967[_0x58cc('0x28')](_0x58cc('0x38')),'due_date':_0x4a9967['add'](0x1e,'m')['format']('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x58cbf5[_0x58cc('0xd')]=_0xf0f154;return rp(_0x58cbf5)[_0x58cc('0x10')](function(_0x47b721){_0x211505[_0x58cc('0x39')]=_0x47b721[_0x58cc('0x3a')]['id'];logger[_0x58cc('0xe')]('Task\x20created:',_0x211505['ticketId']);_0x50ed72(_0x211505);})[_0x58cc('0x15')](function(_0x5717d5){logger['error']('['+[_0x1ecb96['toUpperCase']()]+']',_0x5717d5[_0x58cc('0x18')]);_0x9b8671(_0x5717d5['message']);});});};}function emit(_0x57a976,_0x23027d,_0xd315d6){var _0x18714c={'uri':_0x57a976+_0x58cc('0x3b')+_0xd315d6};io['to'](util['format'](_0x58cc('0x3c'),_0x23027d))[_0x58cc('0x3d')](_0x58cc('0x3e'),_0x18714c);}exports['cs']=function(_0x1fef96,_0x52441e,_0x313bec,_0x5dbb66,_0xe7cc76,_0x5e34a0,_0x12af32,_0x373cb3){var _0x2f39b8={};var _0x50337e={'Authorization':_0x58cc('0x3f')+_0x5e34a0[_0x58cc('0x40')]};_0x5e34a0[_0x58cc('0x41')]=intUtil[_0x58cc('0x42')](_0x5e34a0[_0x58cc('0x41')]);_0x5e34a0['serverUrl']=intUtil[_0x58cc('0x42')](_0x5e34a0['serverUrl']);var _0x317376=_0x5e34a0[_0x58cc('0x41')];_0x2f39b8[_0x58cc('0x22')]=_0x5e34a0[_0x58cc('0x43')];_0x2f39b8[_0x58cc('0x2a')]=_0x373cb3[_0x58cc('0x44')]()===_0x58cc('0x45')?_0x52441e[_0x58cc('0x46')]:_0x52441e[_0x58cc('0x47')];_0x2f39b8[_0x58cc('0x48')]=_0x373cb3===_0x58cc('0x49')||_0x373cb3==='unmanaged'?_0x58cc('0x49'):'outbound';if(_0x5dbb66){_0x2f39b8[_0x58cc('0x1b')]=_0x5dbb66[_0x58cc('0x11')];}var _0x2778c3=util['format'](_0x58cc('0x4a'),_0x5e34a0[_0x58cc('0x4b')],_0x52441e[_0x58cc('0x4c')],md5(_0x52441e[_0x58cc('0x4c')]));if(_0xe7cc76&&_0xe7cc76['monitor_format']){logger['info']('[QUEUE]','Recording\x20is\x20enabled!');_0x52441e[_0x58cc('0x4d')]=_0x2778c3;}else if(_0x12af32&&_0x12af32['recordingFormat']&&_0x12af32[_0x58cc('0x4e')]!==_0x58cc('0x4f')){logger[_0x58cc('0xe')]('[OUTBOUND]',_0x58cc('0x50'));_0x52441e[_0x58cc('0x4d')]=_0x2778c3;}else{_0x52441e[_0x58cc('0x4d')]='';}return getAdminId(_0x2f39b8,_0x373cb3,_0x50337e,_0x317376)[_0x58cc('0x10')](getUser(_0x373cb3,_0x50337e,_0x317376))[_0x58cc('0x10')](getEndUser(_0x373cb3,_0x50337e,_0x317376))[_0x58cc('0x10')](getTicket(_0x373cb3,_0x50337e,_0x317376,_0x313bec,_0x52441e))['then'](function(_0x99938d){logger[_0x58cc('0xe')](util[_0x58cc('0x28')]('The\x20ticket\x20ID\x20is:\x20%s',_0x99938d[_0x58cc('0x39')]));if(_0x373cb3!==_0x58cc('0x51')){logger[_0x58cc('0xe')]('['+[_0x373cb3[_0x58cc('0x17')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x317376,_0x5dbb66['name'],_0x99938d['endUserId']);}})[_0x58cc('0x15')](function(_0x408207){logger['error']('['+[_0x373cb3[_0x58cc('0x17')]()]+_0x58cc('0x52'),util[_0x58cc('0x53')](_0x408207,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file