Built motion from commit fe909640.|2.6.8
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 1d7f000..457faff 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd48f=['find','contacts','format','contactNumber','mobile_number','endUserId','Contact\x20found\x20work_number:','Contact\x20created:','POST','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','Creating\x20new\x20task','/api/tasks','getString','Subjects','Descriptions','Contact','add','ticketId','task','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','serverUrl','stripTrailingSlash','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','queue','unmanaged','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','The\x20ticket\x20ID\x20is:\x20%s','name',']\x20Error\x20running\x20Freshsales\x20integration','lodash','request-promise','moment','bluebird','./util','../../../../config/environment','../../../../config/logger','freshsales','defaults','redis','localhost','socket.io-emitter','GET','/api/selector/owners','headers','info','Getting\x20admin\x20information','then','users','length','email','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','Getting\x20user\x20list','agentEmail','Getting\x20user\x20with\x20email','userId','User\x20found:','Admin\x20selected','userEmail','adminEmail','/api/lookup?q=','&entities=contact'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0xd48f,0x1cc));var _0xfd48=function(_0xef8146,_0x459c34){_0xef8146=_0xef8146-0x0;var _0x5a6cb0=_0xd48f[_0xef8146];return _0x5a6cb0;};'use strict';var _=require(_0xfd48('0x0'));var rp=require(_0xfd48('0x1'));var md5=require('md5');var util=require('util');var moment=require(_0xfd48('0x2'));var Promise=require(_0xfd48('0x3'));var Redis=require('ioredis');var intUtil=require(_0xfd48('0x4'));var config=require(_0xfd48('0x5'));var logger=require(_0xfd48('0x6'))(_0xfd48('0x7'));config['redis']=_[_0xfd48('0x8')](config[_0xfd48('0x9')],{'host':_0xfd48('0xa'),'port':0x18eb});var io=require(_0xfd48('0xb'))(new Redis(config[_0xfd48('0x9')]));function getAdminId(_0x47ce5a,_0x2988e6,_0x3670c9,_0x3bbd5a){return new Promise(function(_0x3f69cc,_0x48824f){var _0x59e4aa=![];var _0x4f2ff0={'method':_0xfd48('0xc'),'uri':_0x3bbd5a+_0xfd48('0xd'),'json':!![]};_0x4f2ff0[_0xfd48('0xe')]=_0x3670c9;logger[_0xfd48('0xf')](_0xfd48('0x10'));return rp(_0x4f2ff0)[_0xfd48('0x11')](function(_0x3c801a){if(_0x3c801a){var _0x41d1bc=_0x3c801a[_0xfd48('0x12')];var _0xc5999e=null;for(_0xc5999e=0x0;_0xc5999e<_0x41d1bc[_0xfd48('0x13')];_0xc5999e++){if(_0x41d1bc[_0xc5999e][_0xfd48('0x14')]===_0x47ce5a['adminEmail']){_0x47ce5a[_0xfd48('0x15')]=_0x41d1bc[_0xc5999e]['id'];_0x59e4aa=!![];}}if(_0x59e4aa){logger[_0xfd48('0xf')](_0xfd48('0x16'),_0x47ce5a['adminId']);_0x3f69cc(_0x47ce5a);}else{_0x48824f({'statusCode':0x194,'message':_0xfd48('0x17')});}}else{_0x48824f({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0xfd48('0x18')](function(_0x4a5105){logger[_0xfd48('0x19')]('['+[_0x2988e6[_0xfd48('0x1a')]()]+']',_0x4a5105[_0xfd48('0x1b')]);_0x48824f(_0x4a5105);});});}function getUser(_0x497cdc,_0x4c7ba1,_0x434063){return function(_0xbeb1a4){return new Promise(function(_0x1a6d91,_0x5d6ccf){var _0x384199={'method':_0xfd48('0xc'),'uri':_0x434063+'/api/selector/owners','json':!![]};_0x384199[_0xfd48('0xe')]=_0x4c7ba1;logger[_0xfd48('0xf')](_0xfd48('0x1c'));return rp(_0x384199)[_0xfd48('0x11')](function(_0x234eb4){if(_0x234eb4){var _0xa956ca=_0x234eb4[_0xfd48('0x12')];var _0xba8293=![];var _0x51bfdf=null;if(_0xbeb1a4[_0xfd48('0x1d')]!==null){logger[_0xfd48('0xf')](_0xfd48('0x1e'),_0xbeb1a4[_0xfd48('0x1d')]);_0xbeb1a4['userEmail']=_0xbeb1a4[_0xfd48('0x1d')];for(_0x51bfdf=0x0;_0x51bfdf<_0xa956ca[_0xfd48('0x13')];_0x51bfdf++){if(_0xa956ca[_0x51bfdf]['email']===_0xbeb1a4['agentEmail']){_0xba8293=!![];_0xbeb1a4[_0xfd48('0x1f')]=_0xa956ca[_0x51bfdf]['id'];logger[_0xfd48('0xf')](_0xfd48('0x20'),_0xbeb1a4[_0xfd48('0x1f')]);}}}if(!_0xba8293){logger[_0xfd48('0xf')](_0xfd48('0x21'));_0xbeb1a4[_0xfd48('0x22')]=_0xbeb1a4[_0xfd48('0x23')];_0xbeb1a4[_0xfd48('0x1f')]=_0xbeb1a4['adminId'];_0xba8293=!![];}if(_0xba8293){_0x1a6d91(_0xbeb1a4);}else{_0x5d6ccf({'statusCode':0x194,'message':_0xfd48('0x17')});}}else{_0x5d6ccf({'statusCode':0x194,'message':_0xfd48('0x17')});}})['catch'](function(_0x33bc7d){logger['error']('['+[_0x497cdc[_0xfd48('0x1a')]()]+']',_0x33bc7d[_0xfd48('0x1b')]);_0x5d6ccf(_0x33bc7d);});});};}function searchContact(_0x42344f,_0x1c3f0e,_0x956ea3,_0x16afc5){return new Promise(function(_0x814079,_0x123a47){var _0x180ae3={'method':_0xfd48('0xc'),'headers':_0x1c3f0e,'uri':_0x42344f+_0xfd48('0x24')+_0x16afc5+'&f='+_0x956ea3+_0xfd48('0x25'),'json':!![]};rp(_0x180ae3)[_0xfd48('0x11')](function(_0x5c0a6a){var _0x381ffc=_[_0xfd48('0x26')](_0x5c0a6a['contacts'][_0xfd48('0x27')],[_0x956ea3,_0x16afc5]);_0x814079(_0x381ffc);})[_0xfd48('0x18')](function(_0x2d613d){_0x123a47(_0x2d613d);});});}function getEndUser(_0xaf2c35,_0x4e92ad,_0x598b62){return function(_0x59d873){return new Promise(function(_0x265236,_0x3f34c2){logger[_0xfd48('0xf')](util[_0xfd48('0x28')]('Searching\x20contact\x20with\x20phone\x20%s',_0x59d873[_0xfd48('0x29')]));searchContact(_0x598b62,_0x4e92ad,_0xfd48('0x2a'),_0x59d873[_0xfd48('0x29')])['then'](function(_0x3eefa5){if(_0x3eefa5){_0x59d873[_0xfd48('0x2b')]=_0x3eefa5['id'];logger['info']('Contact\x20found\x20mobile_number:',_0x59d873[_0xfd48('0x2b')]);return _0x265236(_0x59d873);}searchContact(_0x598b62,_0x4e92ad,'work_number',_0x59d873[_0xfd48('0x29')])[_0xfd48('0x11')](function(_0x4764e6){if(_0x4764e6){_0x59d873['endUserId']=_0x4764e6['id'];logger['info'](_0xfd48('0x2c'),_0x59d873[_0xfd48('0x2b')]);return _0x265236(_0x59d873);}createEndUser(_0x59d873,_0xaf2c35,_0x4e92ad,_0x598b62)['then'](function(_0x205742){logger[_0xfd48('0xf')](_0xfd48('0x2d'),_0x205742[_0xfd48('0x2b')]);return _0x265236(_0x205742);});});})[_0xfd48('0x18')](function(_0x1dd678){_0x3f34c2(_0x1dd678);});});};}function createEndUser(_0x1c8d5c,_0x492e60,_0x20222b,_0x31eed8){return new Promise(function(_0x340366,_0x1fadfd){var _0x4c1e04=moment();var _0x15244b={'method':_0xfd48('0x2e'),'uri':_0x31eed8+'/api/contacts','body':{'contact':{'last_name':_0x1c8d5c['contactNumber'],'work_number':_0x1c8d5c[_0xfd48('0x29')],'mobile_number':_0x1c8d5c[_0xfd48('0x29')],'owner_id':_0x1c8d5c[_0xfd48('0x1f')],'created_at':_0x4c1e04[_0xfd48('0x28')](_0xfd48('0x2f'))}},'json':!![]};_0x15244b[_0xfd48('0xe')]=_0x20222b;logger[_0xfd48('0xf')](_0xfd48('0x30'));return rp(_0x15244b)['then'](function(_0x21ddb6){_0x1c8d5c[_0xfd48('0x2b')]=_0x21ddb6['contact']['id'];_0x340366(_0x1c8d5c);})[_0xfd48('0x18')](function(_0x5a1eea){logger['error']('['+[_0x492e60[_0xfd48('0x1a')]()]+']',_0x5a1eea['message']);_0x1fadfd(_0x5a1eea[_0xfd48('0x1b')]);});});}function getTicket(_0x55d3d3,_0xcb50db,_0x32d95d,_0x2d982e,_0x15ef52){return function(_0x1c2c91){logger[_0xfd48('0xf')](_0xfd48('0x31'));return new Promise(function(_0x1641c1,_0x22ce70){var _0x3665f6=moment();var _0x577f5={'method':_0xfd48('0x2e'),'uri':_0x32d95d+_0xfd48('0x32'),'body':{'title':intUtil[_0xfd48('0x33')](_0x2d982e[_0xfd48('0x34')],_0x15ef52,'\x20'),'description':intUtil['getString'](_0x2d982e[_0xfd48('0x35')],_0x15ef52,'\x0a'),'owner_id':_0x1c2c91['userId'],'creater_id':_0x1c2c91[_0xfd48('0x15')],'targetable_id':_0x1c2c91[_0xfd48('0x2b')],'targetable_type':_0xfd48('0x36'),'created_at':_0x3665f6[_0xfd48('0x28')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x3665f6[_0xfd48('0x37')](0x1e,'m')[_0xfd48('0x28')](_0xfd48('0x2f'))},'json':!![]};_0x577f5[_0xfd48('0xe')]=_0xcb50db;return rp(_0x577f5)['then'](function(_0x349a8d){_0x1c2c91[_0xfd48('0x38')]=_0x349a8d[_0xfd48('0x39')]['id'];logger[_0xfd48('0xf')]('Task\x20created:',_0x1c2c91[_0xfd48('0x38')]);_0x1641c1(_0x1c2c91);})['catch'](function(_0x767ae9){logger[_0xfd48('0x19')]('['+[_0x55d3d3['toUpperCase']()]+']',_0x767ae9[_0xfd48('0x1b')]);_0x22ce70(_0x767ae9[_0xfd48('0x1b')]);});});};}function emit(_0x4ffe51,_0x3a0733,_0x448811){var _0x43973f={'uri':_0x4ffe51+'/contacts/'+_0x448811};io['to'](util[_0xfd48('0x28')](_0xfd48('0x3a'),_0x3a0733))[_0xfd48('0x3b')](_0xfd48('0x3c'),_0x43973f);}exports['cs']=function(_0x3a286d,_0x4f2307,_0x1cdf15,_0x3dab5c,_0x22b5c8,_0x24b1c8,_0x1518aa,_0xa43d90){var _0x21f1a2={};var _0x4e0361={'Authorization':_0xfd48('0x3d')+_0x24b1c8[_0xfd48('0x3e')]};_0x24b1c8[_0xfd48('0x3f')]=intUtil['stripTrailingSlash'](_0x24b1c8[_0xfd48('0x3f')]);_0x24b1c8[_0xfd48('0x40')]=intUtil[_0xfd48('0x41')](_0x24b1c8[_0xfd48('0x40')]);var _0x294b4b=_0x24b1c8[_0xfd48('0x3f')];_0x21f1a2[_0xfd48('0x23')]=_0x24b1c8['username'];_0x21f1a2[_0xfd48('0x29')]=_0xa43d90[_0xfd48('0x42')]()===_0xfd48('0x43')?_0x4f2307[_0xfd48('0x44')]:_0x4f2307[_0xfd48('0x45')];_0x21f1a2[_0xfd48('0x46')]=_0xa43d90===_0xfd48('0x47')||_0xa43d90===_0xfd48('0x48')?_0xfd48('0x47'):_0xfd48('0x43');if(_0x3dab5c){_0x21f1a2[_0xfd48('0x1d')]=_0x3dab5c['email'];}var _0xbab56e=util[_0xfd48('0x28')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x24b1c8[_0xfd48('0x40')],_0x4f2307[_0xfd48('0x49')],md5(_0x4f2307[_0xfd48('0x49')]));if(_0x22b5c8&&_0x22b5c8[_0xfd48('0x4a')]){logger[_0xfd48('0xf')](_0xfd48('0x4b'),_0xfd48('0x4c'));_0x4f2307[_0xfd48('0x4d')]=_0xbab56e;}else if(_0x1518aa&&_0x1518aa[_0xfd48('0x4e')]&&_0x1518aa[_0xfd48('0x4e')]!==_0xfd48('0x4f')){logger[_0xfd48('0xf')]('[OUTBOUND]',_0xfd48('0x4c'));_0x4f2307['recordingURL']=_0xbab56e;}else{_0x4f2307['recordingURL']='';}return getAdminId(_0x21f1a2,_0xa43d90,_0x4e0361,_0x294b4b)[_0xfd48('0x11')](getUser(_0xa43d90,_0x4e0361,_0x294b4b))[_0xfd48('0x11')](getEndUser(_0xa43d90,_0x4e0361,_0x294b4b))[_0xfd48('0x11')](getTicket(_0xa43d90,_0x4e0361,_0x294b4b,_0x1cdf15,_0x4f2307))['then'](function(_0xad4141){logger[_0xfd48('0xf')](util[_0xfd48('0x28')](_0xfd48('0x50'),_0xad4141[_0xfd48('0x38')]));if(_0xa43d90!==_0xfd48('0x48')){logger[_0xfd48('0xf')]('['+[_0xa43d90[_0xfd48('0x1a')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x294b4b,_0x3dab5c[_0xfd48('0x51')],_0xad4141['endUserId']);}})[_0xfd48('0x18')](function(_0xcf394f){logger[_0xfd48('0x19')]('['+[_0xa43d90[_0xfd48('0x1a')]()]+_0xfd48('0x52'),util['inspect'](_0xcf394f,{'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