Built motion from commit fe909640.|2.6.8
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index cae4135..457faff 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xff70=['request-promise','md5','moment','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','socket.io-emitter','redis','GET','/api/selector/owners','info','Getting\x20admin\x20information','users','length','email','adminId','Requested\x20Resource\x20not\x20Found','catch','message','headers','Getting\x20user\x20list','then','agentEmail','Getting\x20user\x20with\x20email','userEmail','userId','User\x20found:','Admin\x20selected','adminEmail','toUpperCase','/api/lookup?q=','find','contacts','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','endUserId','Contact\x20found\x20mobile_number:','Contact\x20found\x20work_number:','Contact\x20created:','/api/contacts','format','contact','POST','getString','Descriptions','YYYY-MM-DDTHH:mm:ss','add','ticketId','task','Task\x20created:','error','/contacts/','user:%s','emit','Token\x20token=','apiKey','remoteUri','stripTrailingSlash','serverUrl','username','outbound','destcalleridnum','calleridnum','callDirection','queue','unmanaged','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','The\x20ticket\x20ID\x20is:\x20%s','name',']\x20Error\x20running\x20Freshsales\x20integration','lodash'];(function(_0x38b6f0,_0x26fee4){var _0x19d435=function(_0x9d20b2){while(--_0x9d20b2){_0x38b6f0['push'](_0x38b6f0['shift']());}};_0x19d435(++_0x26fee4);}(_0xff70,0x1df));var _0x0ff7=function(_0x4cdcdc,_0x34eac7){_0x4cdcdc=_0x4cdcdc-0x0;var _0x4704ce=_0xff70[_0x4cdcdc];return _0x4704ce;};'use strict';var _=require(_0x0ff7('0x0'));var rp=require(_0x0ff7('0x1'));var md5=require(_0x0ff7('0x2'));var util=require('util');var moment=require(_0x0ff7('0x3'));var Promise=require('bluebird');var Redis=require(_0x0ff7('0x4'));var intUtil=require(_0x0ff7('0x5'));var config=require(_0x0ff7('0x6'));var logger=require(_0x0ff7('0x7'))(_0x0ff7('0x8'));config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x0ff7('0x9'))(new Redis(config[_0x0ff7('0xa')]));function getAdminId(_0x5a4f9f,_0x24d7bf,_0x1d20e0,_0x3f4a03){return new Promise(function(_0x21fc14,_0x9ad26e){var _0x5cd236=![];var _0x57ec42={'method':_0x0ff7('0xb'),'uri':_0x3f4a03+_0x0ff7('0xc'),'json':!![]};_0x57ec42['headers']=_0x1d20e0;logger[_0x0ff7('0xd')](_0x0ff7('0xe'));return rp(_0x57ec42)['then'](function(_0x40709e){if(_0x40709e){var _0x295260=_0x40709e[_0x0ff7('0xf')];var _0x23889b=null;for(_0x23889b=0x0;_0x23889b<_0x295260[_0x0ff7('0x10')];_0x23889b++){if(_0x295260[_0x23889b][_0x0ff7('0x11')]===_0x5a4f9f['adminEmail']){_0x5a4f9f[_0x0ff7('0x12')]=_0x295260[_0x23889b]['id'];_0x5cd236=!![];}}if(_0x5cd236){logger[_0x0ff7('0xd')]('Admin\x20found:',_0x5a4f9f[_0x0ff7('0x12')]);_0x21fc14(_0x5a4f9f);}else{_0x9ad26e({'statusCode':0x194,'message':_0x0ff7('0x13')});}}else{_0x9ad26e({'statusCode':0x194,'message':_0x0ff7('0x13')});}})[_0x0ff7('0x14')](function(_0x6444a0){logger['error']('['+[_0x24d7bf['toUpperCase']()]+']',_0x6444a0[_0x0ff7('0x15')]);_0x9ad26e(_0x6444a0);});});}function getUser(_0x7ed2a1,_0x24463f,_0x335a4d){return function(_0xc5f79a){return new Promise(function(_0x26b463,_0xecb9e4){var _0x556f2d={'method':_0x0ff7('0xb'),'uri':_0x335a4d+'/api/selector/owners','json':!![]};_0x556f2d[_0x0ff7('0x16')]=_0x24463f;logger['info'](_0x0ff7('0x17'));return rp(_0x556f2d)[_0x0ff7('0x18')](function(_0x157116){if(_0x157116){var _0x5a1b4c=_0x157116[_0x0ff7('0xf')];var _0x3fdde4=![];var _0x559c3d=null;if(_0xc5f79a[_0x0ff7('0x19')]!==null){logger['info'](_0x0ff7('0x1a'),_0xc5f79a[_0x0ff7('0x19')]);_0xc5f79a[_0x0ff7('0x1b')]=_0xc5f79a['agentEmail'];for(_0x559c3d=0x0;_0x559c3d<_0x5a1b4c[_0x0ff7('0x10')];_0x559c3d++){if(_0x5a1b4c[_0x559c3d][_0x0ff7('0x11')]===_0xc5f79a[_0x0ff7('0x19')]){_0x3fdde4=!![];_0xc5f79a[_0x0ff7('0x1c')]=_0x5a1b4c[_0x559c3d]['id'];logger['info'](_0x0ff7('0x1d'),_0xc5f79a[_0x0ff7('0x1c')]);}}}if(!_0x3fdde4){logger[_0x0ff7('0xd')](_0x0ff7('0x1e'));_0xc5f79a[_0x0ff7('0x1b')]=_0xc5f79a[_0x0ff7('0x1f')];_0xc5f79a[_0x0ff7('0x1c')]=_0xc5f79a[_0x0ff7('0x12')];_0x3fdde4=!![];}if(_0x3fdde4){_0x26b463(_0xc5f79a);}else{_0xecb9e4({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0xecb9e4({'statusCode':0x194,'message':_0x0ff7('0x13')});}})[_0x0ff7('0x14')](function(_0x2ea043){logger['error']('['+[_0x7ed2a1[_0x0ff7('0x20')]()]+']',_0x2ea043[_0x0ff7('0x15')]);_0xecb9e4(_0x2ea043);});});};}function searchContact(_0x1619f0,_0x5d25be,_0xb6f483,_0xe71e11){return new Promise(function(_0x5f319c,_0x54af7e){var _0x46329a={'method':'GET','headers':_0x5d25be,'uri':_0x1619f0+_0x0ff7('0x21')+_0xe71e11+'&f='+_0xb6f483+'&entities=contact','json':!![]};rp(_0x46329a)[_0x0ff7('0x18')](function(_0x435b24){var _0x51e9d6=_[_0x0ff7('0x22')](_0x435b24[_0x0ff7('0x23')][_0x0ff7('0x23')],[_0xb6f483,_0xe71e11]);_0x5f319c(_0x51e9d6);})[_0x0ff7('0x14')](function(_0x651bd6){_0x54af7e(_0x651bd6);});});}function getEndUser(_0x128fb9,_0x2c064b,_0x1477cc){return function(_0x56aa20){return new Promise(function(_0x4fb843,_0x54f4ac){logger[_0x0ff7('0xd')](util['format'](_0x0ff7('0x24'),_0x56aa20[_0x0ff7('0x25')]));searchContact(_0x1477cc,_0x2c064b,'mobile_number',_0x56aa20['contactNumber'])['then'](function(_0x5d199d){if(_0x5d199d){_0x56aa20[_0x0ff7('0x26')]=_0x5d199d['id'];logger[_0x0ff7('0xd')](_0x0ff7('0x27'),_0x56aa20[_0x0ff7('0x26')]);return _0x4fb843(_0x56aa20);}searchContact(_0x1477cc,_0x2c064b,'work_number',_0x56aa20[_0x0ff7('0x25')])[_0x0ff7('0x18')](function(_0x200034){if(_0x200034){_0x56aa20[_0x0ff7('0x26')]=_0x200034['id'];logger[_0x0ff7('0xd')](_0x0ff7('0x28'),_0x56aa20['endUserId']);return _0x4fb843(_0x56aa20);}createEndUser(_0x56aa20,_0x128fb9,_0x2c064b,_0x1477cc)[_0x0ff7('0x18')](function(_0x34b722){logger[_0x0ff7('0xd')](_0x0ff7('0x29'),_0x34b722['endUserId']);return _0x4fb843(_0x34b722);});});})['catch'](function(_0x3d4e79){_0x54f4ac(_0x3d4e79);});});};}function createEndUser(_0xadfce1,_0x413608,_0x5e5d38,_0x3b61cb){return new Promise(function(_0x5d2eec,_0x1ce838){var _0x10380b=moment();var _0x583a77={'method':'POST','uri':_0x3b61cb+_0x0ff7('0x2a'),'body':{'contact':{'last_name':_0xadfce1[_0x0ff7('0x25')],'work_number':_0xadfce1[_0x0ff7('0x25')],'mobile_number':_0xadfce1['contactNumber'],'owner_id':_0xadfce1['userId'],'created_at':_0x10380b[_0x0ff7('0x2b')]('YYYY-MM-DDTHH:mm:ss')}},'json':!![]};_0x583a77[_0x0ff7('0x16')]=_0x5e5d38;logger[_0x0ff7('0xd')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0x583a77)[_0x0ff7('0x18')](function(_0x561d5f){_0xadfce1['endUserId']=_0x561d5f[_0x0ff7('0x2c')]['id'];_0x5d2eec(_0xadfce1);})[_0x0ff7('0x14')](function(_0x39ab43){logger['error']('['+[_0x413608[_0x0ff7('0x20')]()]+']',_0x39ab43[_0x0ff7('0x15')]);_0x1ce838(_0x39ab43[_0x0ff7('0x15')]);});});}function getTicket(_0x524460,_0x2a8bac,_0x4d742f,_0x58e054,_0x3a00cf){return function(_0xd8781e){logger[_0x0ff7('0xd')]('Creating\x20new\x20task');return new Promise(function(_0xcdab1a,_0x321086){var _0x11c871=moment();var _0x1fab6e={'method':_0x0ff7('0x2d'),'uri':_0x4d742f+'/api/tasks','body':{'title':intUtil[_0x0ff7('0x2e')](_0x58e054['Subjects'],_0x3a00cf,'\x20'),'description':intUtil[_0x0ff7('0x2e')](_0x58e054[_0x0ff7('0x2f')],_0x3a00cf,'\x0a'),'owner_id':_0xd8781e[_0x0ff7('0x1c')],'creater_id':_0xd8781e['adminId'],'targetable_id':_0xd8781e[_0x0ff7('0x26')],'targetable_type':'Contact','created_at':_0x11c871[_0x0ff7('0x2b')](_0x0ff7('0x30')),'due_date':_0x11c871[_0x0ff7('0x31')](0x1e,'m')[_0x0ff7('0x2b')](_0x0ff7('0x30'))},'json':!![]};_0x1fab6e[_0x0ff7('0x16')]=_0x2a8bac;return rp(_0x1fab6e)['then'](function(_0x27702c){_0xd8781e[_0x0ff7('0x32')]=_0x27702c[_0x0ff7('0x33')]['id'];logger['info'](_0x0ff7('0x34'),_0xd8781e[_0x0ff7('0x32')]);_0xcdab1a(_0xd8781e);})[_0x0ff7('0x14')](function(_0x4ef258){logger[_0x0ff7('0x35')]('['+[_0x524460[_0x0ff7('0x20')]()]+']',_0x4ef258[_0x0ff7('0x15')]);_0x321086(_0x4ef258[_0x0ff7('0x15')]);});});};}function emit(_0x235b40,_0x3e7478,_0x4e63ac){var _0x3737b7={'uri':_0x235b40+_0x0ff7('0x36')+_0x4e63ac};io['to'](util[_0x0ff7('0x2b')](_0x0ff7('0x37'),_0x3e7478))[_0x0ff7('0x38')]('trigger:browser:url',_0x3737b7);}exports['cs']=function(_0x3b28dc,_0x5a047d,_0x319646,_0x421c29,_0x7f12ce,_0x159f30,_0xc5f46f,_0x23c09e){var _0x354c11={};var _0x52e993={'Authorization':_0x0ff7('0x39')+_0x159f30[_0x0ff7('0x3a')]};_0x159f30[_0x0ff7('0x3b')]=intUtil[_0x0ff7('0x3c')](_0x159f30[_0x0ff7('0x3b')]);_0x159f30['serverUrl']=intUtil[_0x0ff7('0x3c')](_0x159f30[_0x0ff7('0x3d')]);var _0x182a91=_0x159f30['remoteUri'];_0x354c11[_0x0ff7('0x1f')]=_0x159f30[_0x0ff7('0x3e')];_0x354c11[_0x0ff7('0x25')]=_0x23c09e['toLowerCase']()===_0x0ff7('0x3f')?_0x5a047d[_0x0ff7('0x40')]:_0x5a047d[_0x0ff7('0x41')];_0x354c11[_0x0ff7('0x42')]=_0x23c09e===_0x0ff7('0x43')||_0x23c09e===_0x0ff7('0x44')?_0x0ff7('0x43'):'outbound';if(_0x421c29){_0x354c11[_0x0ff7('0x19')]=_0x421c29[_0x0ff7('0x11')];}var _0x215bb1=util[_0x0ff7('0x2b')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x159f30[_0x0ff7('0x3d')],_0x5a047d[_0x0ff7('0x45')],md5(_0x5a047d[_0x0ff7('0x45')]));if(_0x7f12ce&&_0x7f12ce[_0x0ff7('0x46')]){logger['info'](_0x0ff7('0x47'),_0x0ff7('0x48'));_0x5a047d[_0x0ff7('0x49')]=_0x215bb1;}else if(_0xc5f46f&&_0xc5f46f[_0x0ff7('0x4a')]&&_0xc5f46f[_0x0ff7('0x4a')]!==_0x0ff7('0x4b')){logger[_0x0ff7('0xd')](_0x0ff7('0x4c'),_0x0ff7('0x48'));_0x5a047d['recordingURL']=_0x215bb1;}else{_0x5a047d[_0x0ff7('0x49')]='';}return getAdminId(_0x354c11,_0x23c09e,_0x52e993,_0x182a91)['then'](getUser(_0x23c09e,_0x52e993,_0x182a91))[_0x0ff7('0x18')](getEndUser(_0x23c09e,_0x52e993,_0x182a91))[_0x0ff7('0x18')](getTicket(_0x23c09e,_0x52e993,_0x182a91,_0x319646,_0x5a047d))['then'](function(_0x809d69){logger[_0x0ff7('0xd')](util[_0x0ff7('0x2b')](_0x0ff7('0x4d'),_0x809d69[_0x0ff7('0x32')]));if(_0x23c09e!==_0x0ff7('0x44')){logger['info']('['+[_0x23c09e[_0x0ff7('0x20')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x182a91,_0x421c29[_0x0ff7('0x4e')],_0x809d69[_0x0ff7('0x26')]);}})[_0x0ff7('0x14')](function(_0x19685a){logger[_0x0ff7('0x35')]('['+[_0x23c09e[_0x0ff7('0x20')]()]+_0x0ff7('0x4f'),util['inspect'](_0x19685a,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0x76f9=['contactNumber','mobile_number','then','Contact\x20found\x20mobile_number:','endUserId','Contact\x20found\x20work_number:','Contact\x20created:','POST','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','/api/tasks','getString','Subjects','Contact','task','Task\x20created:','ticketId','/contacts/','user:%s','emit','trigger:browser:url','apiKey','remoteUri','stripTrailingSlash','serverUrl','toLowerCase','outbound','destcalleridnum','callDirection','queue','unmanaged','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','The\x20ticket\x20ID\x20is:\x20%s','Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','request-promise','md5','moment','bluebird','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','defaults','socket.io-emitter','redis','GET','/api/selector/owners','headers','info','Getting\x20admin\x20information','length','email','adminEmail','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','error','toUpperCase','message','Getting\x20user\x20list','users','agentEmail','userEmail','userId','User\x20found:','Admin\x20selected','catch','/api/lookup?q=','&f=','&entities=contact','contacts','format','Searching\x20contact\x20with\x20phone\x20%s'];(function(_0x113f06,_0xdd48ea){var _0x58ff7b=function(_0x1b0eb2){while(--_0x1b0eb2){_0x113f06['push'](_0x113f06['shift']());}};_0x58ff7b(++_0xdd48ea);}(_0x76f9,0xd7));var _0x976f=function(_0x40ebef,_0x4c544d){_0x40ebef=_0x40ebef-0x0;var _0x3fdef5=_0x76f9[_0x40ebef];return _0x3fdef5;};'use strict';var _=require('lodash');var rp=require(_0x976f('0x0'));var md5=require(_0x976f('0x1'));var util=require('util');var moment=require(_0x976f('0x2'));var Promise=require(_0x976f('0x3'));var Redis=require(_0x976f('0x4'));var intUtil=require(_0x976f('0x5'));var config=require(_0x976f('0x6'));var logger=require(_0x976f('0x7'))(_0x976f('0x8'));config['redis']=_[_0x976f('0x9')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x976f('0xa'))(new Redis(config[_0x976f('0xb')]));function getAdminId(_0x64c5e6,_0x32e681,_0x461c5c,_0x7115cc){return new Promise(function(_0x4cf89d,_0x211830){var _0x5da156=![];var _0x5e662f={'method':_0x976f('0xc'),'uri':_0x7115cc+_0x976f('0xd'),'json':!![]};_0x5e662f[_0x976f('0xe')]=_0x461c5c;logger[_0x976f('0xf')](_0x976f('0x10'));return rp(_0x5e662f)['then'](function(_0x875ae1){if(_0x875ae1){var _0x4b0707=_0x875ae1['users'];var _0x182f94=null;for(_0x182f94=0x0;_0x182f94<_0x4b0707[_0x976f('0x11')];_0x182f94++){if(_0x4b0707[_0x182f94][_0x976f('0x12')]===_0x64c5e6[_0x976f('0x13')]){_0x64c5e6[_0x976f('0x14')]=_0x4b0707[_0x182f94]['id'];_0x5da156=!![];}}if(_0x5da156){logger[_0x976f('0xf')](_0x976f('0x15'),_0x64c5e6[_0x976f('0x14')]);_0x4cf89d(_0x64c5e6);}else{_0x211830({'statusCode':0x194,'message':_0x976f('0x16')});}}else{_0x211830({'statusCode':0x194,'message':_0x976f('0x16')});}})['catch'](function(_0x4716b6){logger[_0x976f('0x17')]('['+[_0x32e681[_0x976f('0x18')]()]+']',_0x4716b6[_0x976f('0x19')]);_0x211830(_0x4716b6);});});}function getUser(_0x1e741d,_0x3ac4dc,_0x2a1a7e){return function(_0x40ab03){return new Promise(function(_0x79c800,_0x51dfbb){var _0x580652={'method':_0x976f('0xc'),'uri':_0x2a1a7e+_0x976f('0xd'),'json':!![]};_0x580652['headers']=_0x3ac4dc;logger['info'](_0x976f('0x1a'));return rp(_0x580652)['then'](function(_0x23ca91){if(_0x23ca91){var _0x22787f=_0x23ca91[_0x976f('0x1b')];var _0x301ce4=![];var _0xda891f=null;if(_0x40ab03[_0x976f('0x1c')]!==null){logger[_0x976f('0xf')]('Getting\x20user\x20with\x20email',_0x40ab03[_0x976f('0x1c')]);_0x40ab03[_0x976f('0x1d')]=_0x40ab03[_0x976f('0x1c')];for(_0xda891f=0x0;_0xda891f<_0x22787f[_0x976f('0x11')];_0xda891f++){if(_0x22787f[_0xda891f]['email']===_0x40ab03[_0x976f('0x1c')]){_0x301ce4=!![];_0x40ab03[_0x976f('0x1e')]=_0x22787f[_0xda891f]['id'];logger['info'](_0x976f('0x1f'),_0x40ab03[_0x976f('0x1e')]);}}}if(!_0x301ce4){logger[_0x976f('0xf')](_0x976f('0x20'));_0x40ab03[_0x976f('0x1d')]=_0x40ab03['adminEmail'];_0x40ab03[_0x976f('0x1e')]=_0x40ab03[_0x976f('0x14')];_0x301ce4=!![];}if(_0x301ce4){_0x79c800(_0x40ab03);}else{_0x51dfbb({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x51dfbb({'statusCode':0x194,'message':_0x976f('0x16')});}})[_0x976f('0x21')](function(_0x367fb0){logger[_0x976f('0x17')]('['+[_0x1e741d[_0x976f('0x18')]()]+']',_0x367fb0[_0x976f('0x19')]);_0x51dfbb(_0x367fb0);});});};}function searchContact(_0x39ced6,_0xc320e0,_0x4a564c,_0x5b9991){return new Promise(function(_0x419ab8,_0x5dbf39){var _0x5795f4={'method':_0x976f('0xc'),'headers':_0xc320e0,'uri':_0x39ced6+_0x976f('0x22')+_0x5b9991+_0x976f('0x23')+_0x4a564c+_0x976f('0x24'),'json':!![]};rp(_0x5795f4)['then'](function(_0x23825f){var _0x122000=_['find'](_0x23825f[_0x976f('0x25')][_0x976f('0x25')],[_0x4a564c,_0x5b9991]);_0x419ab8(_0x122000);})['catch'](function(_0x1fa372){_0x5dbf39(_0x1fa372);});});}function getEndUser(_0x5e4ff6,_0x36aaef,_0x304cbb){return function(_0x599e60){return new Promise(function(_0x498425,_0x15459e){logger[_0x976f('0xf')](util[_0x976f('0x26')](_0x976f('0x27'),_0x599e60[_0x976f('0x28')]));searchContact(_0x304cbb,_0x36aaef,_0x976f('0x29'),_0x599e60[_0x976f('0x28')])[_0x976f('0x2a')](function(_0x3eda0d){if(_0x3eda0d){_0x599e60['endUserId']=_0x3eda0d['id'];logger[_0x976f('0xf')](_0x976f('0x2b'),_0x599e60[_0x976f('0x2c')]);return _0x498425(_0x599e60);}searchContact(_0x304cbb,_0x36aaef,'work_number',_0x599e60['contactNumber'])[_0x976f('0x2a')](function(_0x210975){if(_0x210975){_0x599e60['endUserId']=_0x210975['id'];logger[_0x976f('0xf')](_0x976f('0x2d'),_0x599e60['endUserId']);return _0x498425(_0x599e60);}createEndUser(_0x599e60,_0x5e4ff6,_0x36aaef,_0x304cbb)[_0x976f('0x2a')](function(_0x40024f){logger[_0x976f('0xf')](_0x976f('0x2e'),_0x40024f[_0x976f('0x2c')]);return _0x498425(_0x40024f);});});})[_0x976f('0x21')](function(_0x11cc1f){_0x15459e(_0x11cc1f);});});};}function createEndUser(_0x4e7d64,_0x43f8b9,_0x1161ee,_0x39e1d1){return new Promise(function(_0x3828c1,_0x2e7a78){var _0x955df6=moment();var _0x56fdfa={'method':_0x976f('0x2f'),'uri':_0x39e1d1+'/api/contacts','body':{'contact':{'last_name':_0x4e7d64['contactNumber'],'work_number':_0x4e7d64['contactNumber'],'mobile_number':_0x4e7d64[_0x976f('0x28')],'owner_id':_0x4e7d64[_0x976f('0x1e')],'created_at':_0x955df6['format'](_0x976f('0x30'))}},'json':!![]};_0x56fdfa[_0x976f('0xe')]=_0x1161ee;logger[_0x976f('0xf')](_0x976f('0x31'));return rp(_0x56fdfa)[_0x976f('0x2a')](function(_0x5f483b){_0x4e7d64[_0x976f('0x2c')]=_0x5f483b[_0x976f('0x32')]['id'];_0x3828c1(_0x4e7d64);})['catch'](function(_0x5f259a){logger[_0x976f('0x17')]('['+[_0x43f8b9['toUpperCase']()]+']',_0x5f259a[_0x976f('0x19')]);_0x2e7a78(_0x5f259a[_0x976f('0x19')]);});});}function getTicket(_0x55c413,_0x3b8bc2,_0x2ee2f6,_0x38714a,_0x4c4839){return function(_0x3b8e21){logger[_0x976f('0xf')](_0x976f('0x33'));return new Promise(function(_0x5ca1bc,_0x423eca){var _0x8779f6=moment();var _0x5c111a={'method':_0x976f('0x2f'),'uri':_0x2ee2f6+_0x976f('0x34'),'body':{'title':intUtil[_0x976f('0x35')](_0x38714a[_0x976f('0x36')],_0x4c4839,'\x20'),'description':intUtil[_0x976f('0x35')](_0x38714a['Descriptions'],_0x4c4839,'\x0a'),'owner_id':_0x3b8e21[_0x976f('0x1e')],'creater_id':_0x3b8e21[_0x976f('0x14')],'targetable_id':_0x3b8e21['endUserId'],'targetable_type':_0x976f('0x37'),'created_at':_0x8779f6[_0x976f('0x26')](_0x976f('0x30')),'due_date':_0x8779f6['add'](0x1e,'m')[_0x976f('0x26')](_0x976f('0x30'))},'json':!![]};_0x5c111a[_0x976f('0xe')]=_0x3b8bc2;return rp(_0x5c111a)['then'](function(_0x56bdcf){_0x3b8e21['ticketId']=_0x56bdcf[_0x976f('0x38')]['id'];logger['info'](_0x976f('0x39'),_0x3b8e21[_0x976f('0x3a')]);_0x5ca1bc(_0x3b8e21);})[_0x976f('0x21')](function(_0x4000e5){logger[_0x976f('0x17')]('['+[_0x55c413[_0x976f('0x18')]()]+']',_0x4000e5[_0x976f('0x19')]);_0x423eca(_0x4000e5[_0x976f('0x19')]);});});};}function emit(_0x259434,_0x2005bf,_0x238f02){var _0x470a78={'uri':_0x259434+_0x976f('0x3b')+_0x238f02};io['to'](util[_0x976f('0x26')](_0x976f('0x3c'),_0x2005bf))[_0x976f('0x3d')](_0x976f('0x3e'),_0x470a78);}exports['cs']=function(_0x8a2ed1,_0x187160,_0x58aac8,_0x512599,_0x31bd0a,_0x107061,_0x3077bc,_0x1fe160){var _0x279153={};var _0x434092={'Authorization':'Token\x20token='+_0x107061[_0x976f('0x3f')]};_0x107061[_0x976f('0x40')]=intUtil[_0x976f('0x41')](_0x107061['remoteUri']);_0x107061[_0x976f('0x42')]=intUtil[_0x976f('0x41')](_0x107061[_0x976f('0x42')]);var _0x90e3c5=_0x107061[_0x976f('0x40')];_0x279153['adminEmail']=_0x107061['username'];_0x279153[_0x976f('0x28')]=_0x1fe160[_0x976f('0x43')]()===_0x976f('0x44')?_0x187160[_0x976f('0x45')]:_0x187160['calleridnum'];_0x279153[_0x976f('0x46')]=_0x1fe160===_0x976f('0x47')||_0x1fe160===_0x976f('0x48')?'queue':_0x976f('0x44');if(_0x512599){_0x279153[_0x976f('0x1c')]=_0x512599[_0x976f('0x12')];}var _0x2d39ec=util[_0x976f('0x26')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x107061[_0x976f('0x42')],_0x187160[_0x976f('0x49')],md5(_0x187160[_0x976f('0x49')]));if(_0x31bd0a&&_0x31bd0a[_0x976f('0x4a')]){logger[_0x976f('0xf')](_0x976f('0x4b'),_0x976f('0x4c'));_0x187160[_0x976f('0x4d')]=_0x2d39ec;}else if(_0x3077bc&&_0x3077bc[_0x976f('0x4e')]&&_0x3077bc[_0x976f('0x4e')]!==_0x976f('0x4f')){logger['info']('[OUTBOUND]','Recording\x20is\x20enabled!');_0x187160[_0x976f('0x4d')]=_0x2d39ec;}else{_0x187160[_0x976f('0x4d')]='';}return getAdminId(_0x279153,_0x1fe160,_0x434092,_0x90e3c5)[_0x976f('0x2a')](getUser(_0x1fe160,_0x434092,_0x90e3c5))[_0x976f('0x2a')](getEndUser(_0x1fe160,_0x434092,_0x90e3c5))[_0x976f('0x2a')](getTicket(_0x1fe160,_0x434092,_0x90e3c5,_0x58aac8,_0x187160))[_0x976f('0x2a')](function(_0x395a08){logger[_0x976f('0xf')](util[_0x976f('0x26')](_0x976f('0x50'),_0x395a08[_0x976f('0x3a')]));if(_0x1fe160!==_0x976f('0x48')){logger['info']('['+[_0x1fe160[_0x976f('0x18')]()]+']',_0x976f('0x51'));emit(_0x90e3c5,_0x512599[_0x976f('0x52')],_0x395a08['endUserId']);}})[_0x976f('0x21')](function(_0x583083){logger[_0x976f('0x17')]('['+[_0x1fe160[_0x976f('0x18')]()]+_0x976f('0x53'),util[_0x976f('0x54')](_0x583083,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file