Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 457faff..585bdac 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0xca5f=['&entities=contact','find','format','Searching\x20contact\x20with\x20phone\x20%s','mobile_number','endUserId','Contact\x20found\x20mobile_number:','work_number','contactNumber','Contact\x20created:','POST','/api/contacts','YYYY-MM-DDTHH:mm:ss','contact','message','getString','Subjects','Descriptions','Contact','add','ticketId','task','/contacts/','user:%s','trigger:browser:url','apiKey','stripTrailingSlash','remoteUri','serverUrl','toLowerCase','destcalleridnum','callDirection','queue','unmanaged','outbound','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingFormat','none','[OUTBOUND]','recordingURL','The\x20ticket\x20ID\x20is:\x20%s','name','request-promise','md5','util','moment','bluebird','ioredis','./util','../../../../config/environment','defaults','redis','localhost','socket.io-emitter','GET','/api/selector/owners','headers','then','users','length','email','adminEmail','info','Admin\x20found:','Requested\x20Resource\x20not\x20Found','error','toUpperCase','Getting\x20user\x20list','agentEmail','userEmail','userId','Admin\x20selected','adminId','catch','/api/lookup?q=','&f='];(function(_0x19d0ed,_0xc6ad42){var _0x4c7fcf=function(_0x270fe2){while(--_0x270fe2){_0x19d0ed['push'](_0x19d0ed['shift']());}};_0x4c7fcf(++_0xc6ad42);}(_0xca5f,0xc8));var _0xfca5=function(_0x4ee96a,_0x186362){_0x4ee96a=_0x4ee96a-0x0;var _0x18acb1=_0xca5f[_0x4ee96a];return _0x18acb1;};'use strict';var _=require('lodash');var rp=require(_0xfca5('0x0'));var md5=require(_0xfca5('0x1'));var util=require(_0xfca5('0x2'));var moment=require(_0xfca5('0x3'));var Promise=require(_0xfca5('0x4'));var Redis=require(_0xfca5('0x5'));var intUtil=require(_0xfca5('0x6'));var config=require(_0xfca5('0x7'));var logger=require('../../../../config/logger')('freshsales');config['redis']=_[_0xfca5('0x8')](config[_0xfca5('0x9')],{'host':_0xfca5('0xa'),'port':0x18eb});var io=require(_0xfca5('0xb'))(new Redis(config[_0xfca5('0x9')]));function getAdminId(_0x38da3f,_0xfeaa77,_0x4a2be0,_0x21409a){return new Promise(function(_0x1b399d,_0x23039a){var _0x35a2ab=![];var _0x71f012={'method':_0xfca5('0xc'),'uri':_0x21409a+_0xfca5('0xd'),'json':!![]};_0x71f012[_0xfca5('0xe')]=_0x4a2be0;logger['info']('Getting\x20admin\x20information');return rp(_0x71f012)[_0xfca5('0xf')](function(_0x4477cc){if(_0x4477cc){var _0x5ab7c8=_0x4477cc[_0xfca5('0x10')];var _0x414f6d=null;for(_0x414f6d=0x0;_0x414f6d<_0x5ab7c8[_0xfca5('0x11')];_0x414f6d++){if(_0x5ab7c8[_0x414f6d][_0xfca5('0x12')]===_0x38da3f[_0xfca5('0x13')]){_0x38da3f['adminId']=_0x5ab7c8[_0x414f6d]['id'];_0x35a2ab=!![];}}if(_0x35a2ab){logger[_0xfca5('0x14')](_0xfca5('0x15'),_0x38da3f['adminId']);_0x1b399d(_0x38da3f);}else{_0x23039a({'statusCode':0x194,'message':_0xfca5('0x16')});}}else{_0x23039a({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})['catch'](function(_0x2723aa){logger[_0xfca5('0x17')]('['+[_0xfeaa77[_0xfca5('0x18')]()]+']',_0x2723aa['message']);_0x23039a(_0x2723aa);});});}function getUser(_0x1084b4,_0x24ab70,_0x5d660d){return function(_0x9842db){return new Promise(function(_0x70bcd5,_0x44e25a){var _0xcdddb7={'method':_0xfca5('0xc'),'uri':_0x5d660d+_0xfca5('0xd'),'json':!![]};_0xcdddb7[_0xfca5('0xe')]=_0x24ab70;logger[_0xfca5('0x14')](_0xfca5('0x19'));return rp(_0xcdddb7)[_0xfca5('0xf')](function(_0x2eaf28){if(_0x2eaf28){var _0x1cfba0=_0x2eaf28[_0xfca5('0x10')];var _0x538cc8=![];var _0x51dc40=null;if(_0x9842db['agentEmail']!==null){logger['info']('Getting\x20user\x20with\x20email',_0x9842db[_0xfca5('0x1a')]);_0x9842db[_0xfca5('0x1b')]=_0x9842db['agentEmail'];for(_0x51dc40=0x0;_0x51dc40<_0x1cfba0[_0xfca5('0x11')];_0x51dc40++){if(_0x1cfba0[_0x51dc40]['email']===_0x9842db['agentEmail']){_0x538cc8=!![];_0x9842db[_0xfca5('0x1c')]=_0x1cfba0[_0x51dc40]['id'];logger[_0xfca5('0x14')]('User\x20found:',_0x9842db[_0xfca5('0x1c')]);}}}if(!_0x538cc8){logger[_0xfca5('0x14')](_0xfca5('0x1d'));_0x9842db[_0xfca5('0x1b')]=_0x9842db[_0xfca5('0x13')];_0x9842db[_0xfca5('0x1c')]=_0x9842db[_0xfca5('0x1e')];_0x538cc8=!![];}if(_0x538cc8){_0x70bcd5(_0x9842db);}else{_0x44e25a({'statusCode':0x194,'message':_0xfca5('0x16')});}}else{_0x44e25a({'statusCode':0x194,'message':_0xfca5('0x16')});}})[_0xfca5('0x1f')](function(_0x52e3ff){logger[_0xfca5('0x17')]('['+[_0x1084b4[_0xfca5('0x18')]()]+']',_0x52e3ff['message']);_0x44e25a(_0x52e3ff);});});};}function searchContact(_0x9bd379,_0x3f7253,_0x341365,_0xf27b1b){return new Promise(function(_0x1927c0,_0x1ca1e1){var _0x3a9654={'method':_0xfca5('0xc'),'headers':_0x3f7253,'uri':_0x9bd379+_0xfca5('0x20')+_0xf27b1b+_0xfca5('0x21')+_0x341365+_0xfca5('0x22'),'json':!![]};rp(_0x3a9654)[_0xfca5('0xf')](function(_0x5e9bb8){var _0x571709=_[_0xfca5('0x23')](_0x5e9bb8['contacts']['contacts'],[_0x341365,_0xf27b1b]);_0x1927c0(_0x571709);})['catch'](function(_0x30526a){_0x1ca1e1(_0x30526a);});});}function getEndUser(_0x39af0b,_0x54e99d,_0x53d483){return function(_0x537af3){return new Promise(function(_0x2e3dff,_0x1bd18d){logger[_0xfca5('0x14')](util[_0xfca5('0x24')](_0xfca5('0x25'),_0x537af3['contactNumber']));searchContact(_0x53d483,_0x54e99d,_0xfca5('0x26'),_0x537af3['contactNumber'])[_0xfca5('0xf')](function(_0x37988e){if(_0x37988e){_0x537af3[_0xfca5('0x27')]=_0x37988e['id'];logger[_0xfca5('0x14')](_0xfca5('0x28'),_0x537af3[_0xfca5('0x27')]);return _0x2e3dff(_0x537af3);}searchContact(_0x53d483,_0x54e99d,_0xfca5('0x29'),_0x537af3[_0xfca5('0x2a')])['then'](function(_0x51350a){if(_0x51350a){_0x537af3[_0xfca5('0x27')]=_0x51350a['id'];logger[_0xfca5('0x14')]('Contact\x20found\x20work_number:',_0x537af3[_0xfca5('0x27')]);return _0x2e3dff(_0x537af3);}createEndUser(_0x537af3,_0x39af0b,_0x54e99d,_0x53d483)[_0xfca5('0xf')](function(_0x29ac30){logger[_0xfca5('0x14')](_0xfca5('0x2b'),_0x29ac30[_0xfca5('0x27')]);return _0x2e3dff(_0x29ac30);});});})['catch'](function(_0x12c958){_0x1bd18d(_0x12c958);});});};}function createEndUser(_0x1a0a96,_0x17e4c3,_0x306469,_0x26d5ad){return new Promise(function(_0x2ec8ef,_0x4d0a60){var _0x44539a=moment();var _0x5e602f={'method':_0xfca5('0x2c'),'uri':_0x26d5ad+_0xfca5('0x2d'),'body':{'contact':{'last_name':_0x1a0a96[_0xfca5('0x2a')],'work_number':_0x1a0a96[_0xfca5('0x2a')],'mobile_number':_0x1a0a96['contactNumber'],'owner_id':_0x1a0a96[_0xfca5('0x1c')],'created_at':_0x44539a['format'](_0xfca5('0x2e'))}},'json':!![]};_0x5e602f['headers']=_0x306469;logger[_0xfca5('0x14')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0x5e602f)['then'](function(_0x5cf3fe){_0x1a0a96[_0xfca5('0x27')]=_0x5cf3fe[_0xfca5('0x2f')]['id'];_0x2ec8ef(_0x1a0a96);})[_0xfca5('0x1f')](function(_0x5b1de9){logger[_0xfca5('0x17')]('['+[_0x17e4c3[_0xfca5('0x18')]()]+']',_0x5b1de9[_0xfca5('0x30')]);_0x4d0a60(_0x5b1de9[_0xfca5('0x30')]);});});}function getTicket(_0x20db15,_0x279471,_0x94fe7f,_0x2677db,_0x331b91){return function(_0x1f39a3){logger['info']('Creating\x20new\x20task');return new Promise(function(_0x54fd6f,_0xfbdedc){var _0x10e5bc=moment();var _0x4abe74={'method':_0xfca5('0x2c'),'uri':_0x94fe7f+'/api/tasks','body':{'title':intUtil[_0xfca5('0x31')](_0x2677db[_0xfca5('0x32')],_0x331b91,'\x20'),'description':intUtil['getString'](_0x2677db[_0xfca5('0x33')],_0x331b91,'\x0a'),'owner_id':_0x1f39a3[_0xfca5('0x1c')],'creater_id':_0x1f39a3[_0xfca5('0x1e')],'targetable_id':_0x1f39a3[_0xfca5('0x27')],'targetable_type':_0xfca5('0x34'),'created_at':_0x10e5bc[_0xfca5('0x24')](_0xfca5('0x2e')),'due_date':_0x10e5bc[_0xfca5('0x35')](0x1e,'m')[_0xfca5('0x24')](_0xfca5('0x2e'))},'json':!![]};_0x4abe74['headers']=_0x279471;return rp(_0x4abe74)[_0xfca5('0xf')](function(_0x40d5b2){_0x1f39a3[_0xfca5('0x36')]=_0x40d5b2[_0xfca5('0x37')]['id'];logger[_0xfca5('0x14')]('Task\x20created:',_0x1f39a3['ticketId']);_0x54fd6f(_0x1f39a3);})[_0xfca5('0x1f')](function(_0x3496cc){logger['error']('['+[_0x20db15[_0xfca5('0x18')]()]+']',_0x3496cc[_0xfca5('0x30')]);_0xfbdedc(_0x3496cc[_0xfca5('0x30')]);});});};}function emit(_0x29cae9,_0x30206f,_0x2279a8){var _0x28181f={'uri':_0x29cae9+_0xfca5('0x38')+_0x2279a8};io['to'](util['format'](_0xfca5('0x39'),_0x30206f))['emit'](_0xfca5('0x3a'),_0x28181f);}exports['cs']=function(_0x2bfb9d,_0x510c46,_0x2e6877,_0x25f863,_0x24fbe1,_0x6c58d0,_0x3124b8,_0x1e3b92){var _0x11ff9c={};var _0x65fde3={'Authorization':'Token\x20token='+_0x6c58d0[_0xfca5('0x3b')]};_0x6c58d0['remoteUri']=intUtil[_0xfca5('0x3c')](_0x6c58d0[_0xfca5('0x3d')]);_0x6c58d0[_0xfca5('0x3e')]=intUtil[_0xfca5('0x3c')](_0x6c58d0[_0xfca5('0x3e')]);var _0x2814ec=_0x6c58d0[_0xfca5('0x3d')];_0x11ff9c['adminEmail']=_0x6c58d0['username'];_0x11ff9c['contactNumber']=_0x1e3b92[_0xfca5('0x3f')]()==='outbound'?_0x510c46[_0xfca5('0x40')]:_0x510c46['calleridnum'];_0x11ff9c[_0xfca5('0x41')]=_0x1e3b92===_0xfca5('0x42')||_0x1e3b92===_0xfca5('0x43')?_0xfca5('0x42'):_0xfca5('0x44');if(_0x25f863){_0x11ff9c[_0xfca5('0x1a')]=_0x25f863[_0xfca5('0x12')];}var _0x41fb2d=util[_0xfca5('0x24')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x6c58d0[_0xfca5('0x3e')],_0x510c46[_0xfca5('0x45')],md5(_0x510c46[_0xfca5('0x45')]));if(_0x24fbe1&&_0x24fbe1[_0xfca5('0x46')]){logger[_0xfca5('0x14')]('[QUEUE]',_0xfca5('0x47'));_0x510c46['recordingURL']=_0x41fb2d;}else if(_0x3124b8&&_0x3124b8['recordingFormat']&&_0x3124b8[_0xfca5('0x48')]!==_0xfca5('0x49')){logger[_0xfca5('0x14')](_0xfca5('0x4a'),'Recording\x20is\x20enabled!');_0x510c46[_0xfca5('0x4b')]=_0x41fb2d;}else{_0x510c46[_0xfca5('0x4b')]='';}return getAdminId(_0x11ff9c,_0x1e3b92,_0x65fde3,_0x2814ec)[_0xfca5('0xf')](getUser(_0x1e3b92,_0x65fde3,_0x2814ec))['then'](getEndUser(_0x1e3b92,_0x65fde3,_0x2814ec))[_0xfca5('0xf')](getTicket(_0x1e3b92,_0x65fde3,_0x2814ec,_0x2e6877,_0x510c46))['then'](function(_0x5f59a6){logger['info'](util['format'](_0xfca5('0x4c'),_0x5f59a6[_0xfca5('0x36')]));if(_0x1e3b92!==_0xfca5('0x43')){logger[_0xfca5('0x14')]('['+[_0x1e3b92['toUpperCase']()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x2814ec,_0x25f863[_0xfca5('0x4d')],_0x5f59a6[_0xfca5('0x27')]);}})[_0xfca5('0x1f')](function(_0x1eb631){logger['error']('['+[_0x1e3b92[_0xfca5('0x18')]()]+']\x20Error\x20running\x20Freshsales\x20integration',util['inspect'](_0x1eb631,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file