Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 1939e1e..1d7f000 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xeb02=['[QUEUE]','recordingURL','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','The\x20ticket\x20ID\x20is:\x20%s','unmanaged','Displaying\x20task\x20in\x20a\x20new\x20tab...','name','request-promise','md5','util','moment','bluebird','../../../../config/environment','../../../../config/logger','freshsales','redis','defaults','socket.io-emitter','GET','headers','info','Getting\x20admin\x20information','then','users','length','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','error','toUpperCase','message','/api/selector/owners','Getting\x20user\x20with\x20email','agentEmail','userEmail','email','userId','User\x20found:','catch','/api/lookup?q=','&f=','&entities=contact','find','contacts','format','mobile_number','endUserId','Contact\x20found\x20mobile_number:','Contact\x20found\x20work_number:','Contact\x20created:','POST','contactNumber','YYYY-MM-DDTHH:mm:ss','contact','Creating\x20new\x20task','/api/tasks','getString','Descriptions','Contact','ticketId','task','Task\x20created:','/contacts/','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','stripTrailingSlash','serverUrl','username','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format'];(function(_0x39ebc3,_0xb760b9){var _0x1726cf=function(_0x2a1e3f){while(--_0x2a1e3f){_0x39ebc3['push'](_0x39ebc3['shift']());}};_0x1726cf(++_0xb760b9);}(_0xeb02,0x1a9));var _0x2eb0=function(_0x739e47,_0x311adb){_0x739e47=_0x739e47-0x0;var _0x4274a6=_0xeb02[_0x739e47];return _0x4274a6;};'use strict';var _=require('lodash');var rp=require(_0x2eb0('0x0'));var md5=require(_0x2eb0('0x1'));var util=require(_0x2eb0('0x2'));var moment=require(_0x2eb0('0x3'));var Promise=require(_0x2eb0('0x4'));var Redis=require('ioredis');var intUtil=require('./util');var config=require(_0x2eb0('0x5'));var logger=require(_0x2eb0('0x6'))(_0x2eb0('0x7'));config[_0x2eb0('0x8')]=_[_0x2eb0('0x9')](config[_0x2eb0('0x8')],{'host':'localhost','port':0x18eb});var io=require(_0x2eb0('0xa'))(new Redis(config[_0x2eb0('0x8')]));function getAdminId(_0x4e136d,_0x2d5125,_0x22f088,_0x2e5a1c){return new Promise(function(_0x28e484,_0x58fb19){var _0x3e0226=![];var _0x5a60af={'method':_0x2eb0('0xb'),'uri':_0x2e5a1c+'/api/selector/owners','json':!![]};_0x5a60af[_0x2eb0('0xc')]=_0x22f088;logger[_0x2eb0('0xd')](_0x2eb0('0xe'));return rp(_0x5a60af)[_0x2eb0('0xf')](function(_0x300114){if(_0x300114){var _0x364932=_0x300114[_0x2eb0('0x10')];var _0x5302fb=null;for(_0x5302fb=0x0;_0x5302fb<_0x364932[_0x2eb0('0x11')];_0x5302fb++){if(_0x364932[_0x5302fb]['email']===_0x4e136d['adminEmail']){_0x4e136d[_0x2eb0('0x12')]=_0x364932[_0x5302fb]['id'];_0x3e0226=!![];}}if(_0x3e0226){logger[_0x2eb0('0xd')](_0x2eb0('0x13'),_0x4e136d[_0x2eb0('0x12')]);_0x28e484(_0x4e136d);}else{_0x58fb19({'statusCode':0x194,'message':_0x2eb0('0x14')});}}else{_0x58fb19({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})['catch'](function(_0x4133ee){logger[_0x2eb0('0x15')]('['+[_0x2d5125[_0x2eb0('0x16')]()]+']',_0x4133ee[_0x2eb0('0x17')]);_0x58fb19(_0x4133ee);});});}function getUser(_0x1a33e6,_0x243f6e,_0x4196e3){return function(_0x433cf0){return new Promise(function(_0x2bd9a0,_0x97214b){var _0x2aad35={'method':_0x2eb0('0xb'),'uri':_0x4196e3+_0x2eb0('0x18'),'json':!![]};_0x2aad35[_0x2eb0('0xc')]=_0x243f6e;logger['info']('Getting\x20user\x20list');return rp(_0x2aad35)[_0x2eb0('0xf')](function(_0x4322bc){if(_0x4322bc){var _0x1b3964=_0x4322bc['users'];var _0x3b406d=![];var _0x38d7d3=null;if(_0x433cf0['agentEmail']!==null){logger['info'](_0x2eb0('0x19'),_0x433cf0[_0x2eb0('0x1a')]);_0x433cf0[_0x2eb0('0x1b')]=_0x433cf0['agentEmail'];for(_0x38d7d3=0x0;_0x38d7d3<_0x1b3964[_0x2eb0('0x11')];_0x38d7d3++){if(_0x1b3964[_0x38d7d3][_0x2eb0('0x1c')]===_0x433cf0[_0x2eb0('0x1a')]){_0x3b406d=!![];_0x433cf0[_0x2eb0('0x1d')]=_0x1b3964[_0x38d7d3]['id'];logger['info'](_0x2eb0('0x1e'),_0x433cf0[_0x2eb0('0x1d')]);}}}if(!_0x3b406d){logger[_0x2eb0('0xd')]('Admin\x20selected');_0x433cf0['userEmail']=_0x433cf0['adminEmail'];_0x433cf0['userId']=_0x433cf0[_0x2eb0('0x12')];_0x3b406d=!![];}if(_0x3b406d){_0x2bd9a0(_0x433cf0);}else{_0x97214b({'statusCode':0x194,'message':_0x2eb0('0x14')});}}else{_0x97214b({'statusCode':0x194,'message':_0x2eb0('0x14')});}})[_0x2eb0('0x1f')](function(_0x4e786f){logger[_0x2eb0('0x15')]('['+[_0x1a33e6[_0x2eb0('0x16')]()]+']',_0x4e786f['message']);_0x97214b(_0x4e786f);});});};}function searchContact(_0x1047ac,_0x12a773,_0x4b361b,_0x3eb99f){return new Promise(function(_0x3b9dd5,_0x301762){var _0x369a8d={'method':_0x2eb0('0xb'),'headers':_0x12a773,'uri':_0x1047ac+_0x2eb0('0x20')+_0x3eb99f+_0x2eb0('0x21')+_0x4b361b+_0x2eb0('0x22'),'json':!![]};rp(_0x369a8d)['then'](function(_0x52a74c){var _0x2a4590=_[_0x2eb0('0x23')](_0x52a74c[_0x2eb0('0x24')]['contacts'],[_0x4b361b,_0x3eb99f]);_0x3b9dd5(_0x2a4590);})['catch'](function(_0x28bf20){_0x301762(_0x28bf20);});});}function getEndUser(_0x29fa81,_0x505f9c,_0x5537ab){return function(_0x389a40){return new Promise(function(_0xa6af9d,_0x19e3cd){logger[_0x2eb0('0xd')](util[_0x2eb0('0x25')]('Searching\x20contact\x20with\x20phone\x20%s',_0x389a40['contactNumber']));searchContact(_0x5537ab,_0x505f9c,_0x2eb0('0x26'),_0x389a40['contactNumber'])[_0x2eb0('0xf')](function(_0x366e5b){if(_0x366e5b){_0x389a40[_0x2eb0('0x27')]=_0x366e5b['id'];logger[_0x2eb0('0xd')](_0x2eb0('0x28'),_0x389a40[_0x2eb0('0x27')]);return _0xa6af9d(_0x389a40);}searchContact(_0x5537ab,_0x505f9c,'work_number',_0x389a40['contactNumber'])[_0x2eb0('0xf')](function(_0x5e914b){if(_0x5e914b){_0x389a40['endUserId']=_0x5e914b['id'];logger[_0x2eb0('0xd')](_0x2eb0('0x29'),_0x389a40[_0x2eb0('0x27')]);return _0xa6af9d(_0x389a40);}createEndUser(_0x389a40,_0x29fa81,_0x505f9c,_0x5537ab)['then'](function(_0x29834b){logger[_0x2eb0('0xd')](_0x2eb0('0x2a'),_0x29834b['endUserId']);return _0xa6af9d(_0x29834b);});});})[_0x2eb0('0x1f')](function(_0xd7a3fd){_0x19e3cd(_0xd7a3fd);});});};}function createEndUser(_0x2f7710,_0x4aafd1,_0x1e2842,_0x49aea3){return new Promise(function(_0x4879f5,_0x4644d7){var _0x55949d=moment();var _0xcab4af={'method':_0x2eb0('0x2b'),'uri':_0x49aea3+'/api/contacts','body':{'contact':{'last_name':_0x2f7710['contactNumber'],'work_number':_0x2f7710[_0x2eb0('0x2c')],'mobile_number':_0x2f7710['contactNumber'],'owner_id':_0x2f7710[_0x2eb0('0x1d')],'created_at':_0x55949d[_0x2eb0('0x25')](_0x2eb0('0x2d'))}},'json':!![]};_0xcab4af['headers']=_0x1e2842;logger[_0x2eb0('0xd')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0xcab4af)[_0x2eb0('0xf')](function(_0x41125a){_0x2f7710[_0x2eb0('0x27')]=_0x41125a[_0x2eb0('0x2e')]['id'];_0x4879f5(_0x2f7710);})[_0x2eb0('0x1f')](function(_0x2c1468){logger[_0x2eb0('0x15')]('['+[_0x4aafd1[_0x2eb0('0x16')]()]+']',_0x2c1468[_0x2eb0('0x17')]);_0x4644d7(_0x2c1468['message']);});});}function getTicket(_0x4096a3,_0x312567,_0x3d4a8c,_0x37c171,_0x20db99){return function(_0x4e25da){logger[_0x2eb0('0xd')](_0x2eb0('0x2f'));return new Promise(function(_0x406071,_0x5455c6){var _0x455613=moment();var _0x5b10bc={'method':_0x2eb0('0x2b'),'uri':_0x3d4a8c+_0x2eb0('0x30'),'body':{'title':intUtil['getString'](_0x37c171['Subjects'],_0x20db99,'\x20'),'description':intUtil[_0x2eb0('0x31')](_0x37c171[_0x2eb0('0x32')],_0x20db99,'\x0a'),'owner_id':_0x4e25da[_0x2eb0('0x1d')],'creater_id':_0x4e25da['adminId'],'targetable_id':_0x4e25da['endUserId'],'targetable_type':_0x2eb0('0x33'),'created_at':_0x455613[_0x2eb0('0x25')](_0x2eb0('0x2d')),'due_date':_0x455613['add'](0x1e,'m')[_0x2eb0('0x25')](_0x2eb0('0x2d'))},'json':!![]};_0x5b10bc[_0x2eb0('0xc')]=_0x312567;return rp(_0x5b10bc)['then'](function(_0x2f0471){_0x4e25da[_0x2eb0('0x34')]=_0x2f0471[_0x2eb0('0x35')]['id'];logger[_0x2eb0('0xd')](_0x2eb0('0x36'),_0x4e25da[_0x2eb0('0x34')]);_0x406071(_0x4e25da);})[_0x2eb0('0x1f')](function(_0x2729ea){logger['error']('['+[_0x4096a3[_0x2eb0('0x16')]()]+']',_0x2729ea[_0x2eb0('0x17')]);_0x5455c6(_0x2729ea[_0x2eb0('0x17')]);});});};}function emit(_0x53ab3f,_0x38b639,_0x51a517){var _0x51a4f2={'uri':_0x53ab3f+_0x2eb0('0x37')+_0x51a517};io['to'](util[_0x2eb0('0x25')]('user:%s',_0x38b639))[_0x2eb0('0x38')](_0x2eb0('0x39'),_0x51a4f2);}exports['cs']=function(_0x2e38a1,_0x775d7e,_0x28a35c,_0x3f212e,_0x2097d1,_0x257412,_0x3cba16,_0x4232f1){var _0xdb1b10={};var _0x42e0ac={'Authorization':_0x2eb0('0x3a')+_0x257412[_0x2eb0('0x3b')]};_0x257412[_0x2eb0('0x3c')]=intUtil[_0x2eb0('0x3d')](_0x257412['remoteUri']);_0x257412[_0x2eb0('0x3e')]=intUtil['stripTrailingSlash'](_0x257412[_0x2eb0('0x3e')]);var _0x525a42=_0x257412['remoteUri'];_0xdb1b10['adminEmail']=_0x257412[_0x2eb0('0x3f')];_0xdb1b10[_0x2eb0('0x2c')]=_0x4232f1[_0x2eb0('0x40')]()===_0x2eb0('0x41')?_0x775d7e[_0x2eb0('0x42')]:_0x775d7e[_0x2eb0('0x43')];_0xdb1b10[_0x2eb0('0x44')]=_0x4232f1===_0x2eb0('0x45')||_0x4232f1==='unmanaged'?_0x2eb0('0x45'):'outbound';if(_0x3f212e){_0xdb1b10[_0x2eb0('0x1a')]=_0x3f212e[_0x2eb0('0x1c')];}var _0x1c8a33=util['format'](_0x2eb0('0x46'),_0x257412[_0x2eb0('0x3e')],_0x775d7e[_0x2eb0('0x47')],md5(_0x775d7e[_0x2eb0('0x47')]));if(_0x2097d1&&_0x2097d1[_0x2eb0('0x48')]){logger[_0x2eb0('0xd')](_0x2eb0('0x49'),'Recording\x20is\x20enabled!');_0x775d7e[_0x2eb0('0x4a')]=_0x1c8a33;}else if(_0x3cba16&&_0x3cba16[_0x2eb0('0x4b')]&&_0x3cba16[_0x2eb0('0x4b')]!==_0x2eb0('0x4c')){logger['info'](_0x2eb0('0x4d'),_0x2eb0('0x4e'));_0x775d7e['recordingURL']=_0x1c8a33;}else{_0x775d7e[_0x2eb0('0x4a')]='';}return getAdminId(_0xdb1b10,_0x4232f1,_0x42e0ac,_0x525a42)[_0x2eb0('0xf')](getUser(_0x4232f1,_0x42e0ac,_0x525a42))[_0x2eb0('0xf')](getEndUser(_0x4232f1,_0x42e0ac,_0x525a42))[_0x2eb0('0xf')](getTicket(_0x4232f1,_0x42e0ac,_0x525a42,_0x28a35c,_0x775d7e))['then'](function(_0x46d442){logger[_0x2eb0('0xd')](util['format'](_0x2eb0('0x4f'),_0x46d442[_0x2eb0('0x34')]));if(_0x4232f1!==_0x2eb0('0x50')){logger['info']('['+[_0x4232f1['toUpperCase']()]+']',_0x2eb0('0x51'));emit(_0x525a42,_0x3f212e[_0x2eb0('0x52')],_0x46d442[_0x2eb0('0x27')]);}})[_0x2eb0('0x1f')](function(_0xcbb7a3){logger[_0x2eb0('0x15')]('['+[_0x4232f1[_0x2eb0('0x16')]()]+']\x20Error\x20running\x20Freshsales\x20integration',util['inspect'](_0xcbb7a3,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+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