Built motion from commit 936e8062.|2.5.33
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 8aa1ec3..d4fab1d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1c5a=['add','ticketId','task','Task\x20created:','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','stripTrailingSlash','serverUrl','username','toLowerCase','destcalleridnum','calleridnum','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','[QUEUE]','recordingURL','recordingFormat','none','Recording\x20is\x20enabled!','The\x20ticket\x20ID\x20is:\x20%s','unmanaged','Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','md5','util','moment','bluebird','ioredis','../../../../config/logger','freshsales','redis','defaults','localhost','socket.io-emitter','GET','headers','info','Getting\x20admin\x20information','users','length','email','adminEmail','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','Getting\x20user\x20list','agentEmail','userEmail','userId','User\x20found:','Admin\x20selected','message','/api/lookup?q=','&f=','&entities=contact','then','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','endUserId','Contact\x20found\x20mobile_number:','work_number','Contact\x20created:','POST','YYYY-MM-DDTHH:mm:ss','contact','/api/tasks','getString','Subjects','Contact'];(function(_0xe7ac42,_0x21eff5){var _0x53be1b=function(_0x489238){while(--_0x489238){_0xe7ac42['push'](_0xe7ac42['shift']());}};_0x53be1b(++_0x21eff5);}(_0x1c5a,0x173));var _0xa1c5=function(_0x21549c,_0x6d64d1){_0x21549c=_0x21549c-0x0;var _0x426cbd=_0x1c5a[_0x21549c];return _0x426cbd;};'use strict';var _=require(_0xa1c5('0x0'));var rp=require(_0xa1c5('0x1'));var md5=require(_0xa1c5('0x2'));var util=require(_0xa1c5('0x3'));var moment=require(_0xa1c5('0x4'));var Promise=require(_0xa1c5('0x5'));var Redis=require(_0xa1c5('0x6'));var intUtil=require('./util');var config=require('../../../../config/environment');var logger=require(_0xa1c5('0x7'))(_0xa1c5('0x8'));config[_0xa1c5('0x9')]=_[_0xa1c5('0xa')](config[_0xa1c5('0x9')],{'host':_0xa1c5('0xb'),'port':0x18eb});var io=require(_0xa1c5('0xc'))(new Redis(config[_0xa1c5('0x9')]));function getAdminId(_0x5807c4,_0x2ba8dc,_0x44c95b,_0x43ed65){return new Promise(function(_0x537eef,_0x13698b){var _0x10e7b5=![];var _0x141524={'method':_0xa1c5('0xd'),'uri':_0x43ed65+'/api/selector/owners','json':!![]};_0x141524[_0xa1c5('0xe')]=_0x44c95b;logger[_0xa1c5('0xf')](_0xa1c5('0x10'));return rp(_0x141524)['then'](function(_0x412c72){if(_0x412c72){var _0x252161=_0x412c72[_0xa1c5('0x11')];var _0x2bf045=null;for(_0x2bf045=0x0;_0x2bf045<_0x252161[_0xa1c5('0x12')];_0x2bf045++){if(_0x252161[_0x2bf045][_0xa1c5('0x13')]===_0x5807c4[_0xa1c5('0x14')]){_0x5807c4[_0xa1c5('0x15')]=_0x252161[_0x2bf045]['id'];_0x10e7b5=!![];}}if(_0x10e7b5){logger[_0xa1c5('0xf')](_0xa1c5('0x16'),_0x5807c4[_0xa1c5('0x15')]);_0x537eef(_0x5807c4);}else{_0x13698b({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x13698b({'statusCode':0x194,'message':_0xa1c5('0x17')});}})[_0xa1c5('0x18')](function(_0xc76405){logger[_0xa1c5('0x19')]('['+[_0x2ba8dc[_0xa1c5('0x1a')]()]+']',_0xc76405['message']);_0x13698b(_0xc76405);});});}function getUser(_0x1c3c9a,_0x4cbb0f,_0x25d6ab){return function(_0x3da84d){return new Promise(function(_0xe0806d,_0x98823c){var _0x52b8ba={'method':'GET','uri':_0x25d6ab+'/api/selector/owners','json':!![]};_0x52b8ba[_0xa1c5('0xe')]=_0x4cbb0f;logger['info'](_0xa1c5('0x1b'));return rp(_0x52b8ba)['then'](function(_0x3b24f7){if(_0x3b24f7){var _0x1ce398=_0x3b24f7[_0xa1c5('0x11')];var _0x2b7d9e=![];var _0x3b42b0=null;if(_0x3da84d[_0xa1c5('0x1c')]!==null){logger[_0xa1c5('0xf')]('Getting\x20user\x20with\x20email',_0x3da84d[_0xa1c5('0x1c')]);_0x3da84d[_0xa1c5('0x1d')]=_0x3da84d[_0xa1c5('0x1c')];for(_0x3b42b0=0x0;_0x3b42b0<_0x1ce398[_0xa1c5('0x12')];_0x3b42b0++){if(_0x1ce398[_0x3b42b0][_0xa1c5('0x13')]===_0x3da84d[_0xa1c5('0x1c')]){_0x2b7d9e=!![];_0x3da84d[_0xa1c5('0x1e')]=_0x1ce398[_0x3b42b0]['id'];logger[_0xa1c5('0xf')](_0xa1c5('0x1f'),_0x3da84d['userId']);}}}if(!_0x2b7d9e){logger[_0xa1c5('0xf')](_0xa1c5('0x20'));_0x3da84d['userEmail']=_0x3da84d[_0xa1c5('0x14')];_0x3da84d[_0xa1c5('0x1e')]=_0x3da84d['adminId'];_0x2b7d9e=!![];}if(_0x2b7d9e){_0xe0806d(_0x3da84d);}else{_0x98823c({'statusCode':0x194,'message':_0xa1c5('0x17')});}}else{_0x98823c({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})['catch'](function(_0xbf84b0){logger['error']('['+[_0x1c3c9a['toUpperCase']()]+']',_0xbf84b0[_0xa1c5('0x21')]);_0x98823c(_0xbf84b0);});});};}function searchContact(_0x34b968,_0x58f19d,_0x2c3054,_0x1cac5e){return new Promise(function(_0x42ffc4,_0x300158){var _0x57ff55={'method':_0xa1c5('0xd'),'headers':_0x58f19d,'uri':_0x34b968+_0xa1c5('0x22')+_0x1cac5e+_0xa1c5('0x23')+_0x2c3054+_0xa1c5('0x24'),'json':!![]};rp(_0x57ff55)[_0xa1c5('0x25')](function(_0x4a8e5d){var _0x2f2ef8=_[_0xa1c5('0x26')](_0x4a8e5d[_0xa1c5('0x27')]['contacts'],[_0x2c3054,_0x1cac5e]);_0x42ffc4(_0x2f2ef8);})[_0xa1c5('0x18')](function(_0x2e639a){_0x300158(_0x2e639a);});});}function getEndUser(_0x2d8a87,_0x206ce8,_0x2a668a){return function(_0xbf2cee){return new Promise(function(_0x3de0c8,_0x22a18){logger['info'](util[_0xa1c5('0x28')](_0xa1c5('0x29'),_0xbf2cee['contactNumber']));searchContact(_0x2a668a,_0x206ce8,'mobile_number',_0xbf2cee[_0xa1c5('0x2a')])[_0xa1c5('0x25')](function(_0x4b562a){if(_0x4b562a){_0xbf2cee[_0xa1c5('0x2b')]=_0x4b562a['id'];logger[_0xa1c5('0xf')](_0xa1c5('0x2c'),_0xbf2cee[_0xa1c5('0x2b')]);return _0x3de0c8(_0xbf2cee);}searchContact(_0x2a668a,_0x206ce8,_0xa1c5('0x2d'),_0xbf2cee[_0xa1c5('0x2a')])[_0xa1c5('0x25')](function(_0xfb0f70){if(_0xfb0f70){_0xbf2cee[_0xa1c5('0x2b')]=_0xfb0f70['id'];logger[_0xa1c5('0xf')]('Contact\x20found\x20work_number:',_0xbf2cee['endUserId']);return _0x3de0c8(_0xbf2cee);}createEndUser(_0xbf2cee,_0x2d8a87,_0x206ce8,_0x2a668a)[_0xa1c5('0x25')](function(_0x652c6b){logger[_0xa1c5('0xf')](_0xa1c5('0x2e'),_0x652c6b[_0xa1c5('0x2b')]);return _0x3de0c8(_0x652c6b);});});})['catch'](function(_0x5924b6){_0x22a18(_0x5924b6);});});};}function createEndUser(_0x283484,_0x199bc1,_0x3d4cdf,_0xef6db2){return new Promise(function(_0x6a0072,_0x4efe49){var _0x2501a0=moment();var _0x559ed={'method':_0xa1c5('0x2f'),'uri':_0xef6db2+'/api/contacts','body':{'contact':{'last_name':_0x283484[_0xa1c5('0x2a')],'work_number':_0x283484['contactNumber'],'mobile_number':_0x283484[_0xa1c5('0x2a')],'owner_id':_0x283484[_0xa1c5('0x1e')],'created_at':_0x2501a0[_0xa1c5('0x28')](_0xa1c5('0x30'))}},'json':!![]};_0x559ed[_0xa1c5('0xe')]=_0x3d4cdf;logger[_0xa1c5('0xf')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0x559ed)[_0xa1c5('0x25')](function(_0x61c560){_0x283484[_0xa1c5('0x2b')]=_0x61c560[_0xa1c5('0x31')]['id'];_0x6a0072(_0x283484);})[_0xa1c5('0x18')](function(_0x10ded5){logger[_0xa1c5('0x19')]('['+[_0x199bc1[_0xa1c5('0x1a')]()]+']',_0x10ded5[_0xa1c5('0x21')]);_0x4efe49(_0x10ded5[_0xa1c5('0x21')]);});});}function getTicket(_0x192741,_0x4c2b4e,_0x1a983d,_0x3dccb8,_0x39382d){return function(_0x8a75f9){logger[_0xa1c5('0xf')]('Creating\x20new\x20task');return new Promise(function(_0x19af9c,_0x191b5a){var _0x315727=moment();var _0x2760a1={'method':_0xa1c5('0x2f'),'uri':_0x1a983d+_0xa1c5('0x32'),'body':{'title':intUtil[_0xa1c5('0x33')](_0x3dccb8[_0xa1c5('0x34')],_0x39382d,'\x20'),'description':intUtil['getString'](_0x3dccb8['Descriptions'],_0x39382d,'\x0a'),'owner_id':_0x8a75f9[_0xa1c5('0x1e')],'creater_id':_0x8a75f9['adminId'],'targetable_id':_0x8a75f9[_0xa1c5('0x2b')],'targetable_type':_0xa1c5('0x35'),'created_at':_0x315727[_0xa1c5('0x28')](_0xa1c5('0x30')),'due_date':_0x315727[_0xa1c5('0x36')](0x1e,'m')[_0xa1c5('0x28')](_0xa1c5('0x30'))},'json':!![]};_0x2760a1['headers']=_0x4c2b4e;return rp(_0x2760a1)[_0xa1c5('0x25')](function(_0x142409){_0x8a75f9[_0xa1c5('0x37')]=_0x142409[_0xa1c5('0x38')]['id'];logger['info'](_0xa1c5('0x39'),_0x8a75f9['ticketId']);_0x19af9c(_0x8a75f9);})[_0xa1c5('0x18')](function(_0x4d6d6a){logger[_0xa1c5('0x19')]('['+[_0x192741[_0xa1c5('0x1a')]()]+']',_0x4d6d6a[_0xa1c5('0x21')]);_0x191b5a(_0x4d6d6a[_0xa1c5('0x21')]);});});};}function emit(_0x494394,_0x124670,_0x3496ff){var _0x42f0d7={'uri':_0x494394+'/contacts/'+_0x3496ff};io['to'](util[_0xa1c5('0x28')](_0xa1c5('0x3a'),_0x124670))[_0xa1c5('0x3b')](_0xa1c5('0x3c'),_0x42f0d7);}exports['cs']=function(_0x1cc815,_0x192a8e,_0x24f722,_0xf93363,_0x41271e,_0x1b9596,_0x333268,_0xbadb7e){var _0x140d13={};var _0x4bdff1={'Authorization':_0xa1c5('0x3d')+_0x1b9596[_0xa1c5('0x3e')]};_0x1b9596['remoteUri']=intUtil['stripTrailingSlash'](_0x1b9596[_0xa1c5('0x3f')]);_0x1b9596['serverUrl']=intUtil[_0xa1c5('0x40')](_0x1b9596[_0xa1c5('0x41')]);var _0x5df615=_0x1b9596[_0xa1c5('0x3f')];_0x140d13['adminEmail']=_0x1b9596[_0xa1c5('0x42')];_0x140d13[_0xa1c5('0x2a')]=_0xbadb7e[_0xa1c5('0x43')]()==='outbound'?_0x192a8e[_0xa1c5('0x44')]:_0x192a8e[_0xa1c5('0x45')];_0x140d13['callDirection']=_0xbadb7e===_0xa1c5('0x46')||_0xbadb7e==='unmanaged'?_0xa1c5('0x46'):'outbound';if(_0xf93363){_0x140d13[_0xa1c5('0x1c')]=_0xf93363[_0xa1c5('0x13')];}var _0x25433e=util['format'](_0xa1c5('0x47'),_0x1b9596[_0xa1c5('0x41')],_0x192a8e[_0xa1c5('0x48')],md5(_0x192a8e[_0xa1c5('0x48')]));if(_0x41271e&&_0x41271e[_0xa1c5('0x49')]){logger[_0xa1c5('0xf')](_0xa1c5('0x4a'),'Recording\x20is\x20enabled!');_0x192a8e[_0xa1c5('0x4b')]=_0x25433e;}else if(_0x333268&&_0x333268[_0xa1c5('0x4c')]&&_0x333268[_0xa1c5('0x4c')]!==_0xa1c5('0x4d')){logger[_0xa1c5('0xf')]('[OUTBOUND]',_0xa1c5('0x4e'));_0x192a8e[_0xa1c5('0x4b')]=_0x25433e;}else{_0x192a8e[_0xa1c5('0x4b')]='';}return getAdminId(_0x140d13,_0xbadb7e,_0x4bdff1,_0x5df615)[_0xa1c5('0x25')](getUser(_0xbadb7e,_0x4bdff1,_0x5df615))['then'](getEndUser(_0xbadb7e,_0x4bdff1,_0x5df615))[_0xa1c5('0x25')](getTicket(_0xbadb7e,_0x4bdff1,_0x5df615,_0x24f722,_0x192a8e))[_0xa1c5('0x25')](function(_0x303de1){logger['info'](util['format'](_0xa1c5('0x4f'),_0x303de1[_0xa1c5('0x37')]));if(_0xbadb7e!==_0xa1c5('0x50')){logger[_0xa1c5('0xf')]('['+[_0xbadb7e[_0xa1c5('0x1a')]()]+']',_0xa1c5('0x51'));emit(_0x5df615,_0xf93363[_0xa1c5('0x52')],_0x303de1[_0xa1c5('0x2b')]);}})[_0xa1c5('0x18')](function(_0xced2e2){logger[_0xa1c5('0x19')]('['+[_0xbadb7e['toUpperCase']()]+_0xa1c5('0x53'),util[_0xa1c5('0x54')](_0xced2e2,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0xf187=['adminId','info','Requested\x20Resource\x20not\x20Found','toUpperCase','GET','Getting\x20user\x20list','agentEmail','userEmail','length','userId','Admin\x20selected','catch','message','/api/lookup?q=','&f=','&entities=contact','find','contacts','format','contactNumber','mobile_number','endUserId','work_number','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','error','Creating\x20new\x20task','POST','/api/tasks','getString','Subjects','Descriptions','Contact','add','ticketId','Task\x20created:','/contacts/','emit','trigger:browser:url','apiKey','remoteUri','stripTrailingSlash','serverUrl','destcalleridnum','calleridnum','queue','unmanaged','outbound','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingURL','recordingFormat','[OUTBOUND]','Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','lodash','request-promise','util','bluebird','ioredis','../../../../config/environment','../../../../config/logger','freshsales','redis','localhost','socket.io-emitter','/api/selector/owners','headers','Getting\x20admin\x20information','then','users','email','adminEmail'];(function(_0x2e0a0b,_0x2efce7){var _0x5bc68b=function(_0x246bd4){while(--_0x246bd4){_0x2e0a0b['push'](_0x2e0a0b['shift']());}};_0x5bc68b(++_0x2efce7);}(_0xf187,0x1bc));var _0x7f18=function(_0x140a73,_0x107a17){_0x140a73=_0x140a73-0x0;var _0x5d1e61=_0xf187[_0x140a73];return _0x5d1e61;};'use strict';var _=require(_0x7f18('0x0'));var rp=require(_0x7f18('0x1'));var md5=require('md5');var util=require(_0x7f18('0x2'));var moment=require('moment');var Promise=require(_0x7f18('0x3'));var Redis=require(_0x7f18('0x4'));var intUtil=require('./util');var config=require(_0x7f18('0x5'));var logger=require(_0x7f18('0x6'))(_0x7f18('0x7'));config[_0x7f18('0x8')]=_['defaults'](config[_0x7f18('0x8')],{'host':_0x7f18('0x9'),'port':0x18eb});var io=require(_0x7f18('0xa'))(new Redis(config[_0x7f18('0x8')]));function getAdminId(_0x43c3e6,_0x182389,_0x9163d9,_0x5ba422){return new Promise(function(_0x50a2c3,_0x484b34){var _0x25e39d=![];var _0x31377c={'method':'GET','uri':_0x5ba422+_0x7f18('0xb'),'json':!![]};_0x31377c[_0x7f18('0xc')]=_0x9163d9;logger['info'](_0x7f18('0xd'));return rp(_0x31377c)[_0x7f18('0xe')](function(_0x5c1a12){if(_0x5c1a12){var _0x1093c9=_0x5c1a12[_0x7f18('0xf')];var _0x4b6912=null;for(_0x4b6912=0x0;_0x4b6912<_0x1093c9['length'];_0x4b6912++){if(_0x1093c9[_0x4b6912][_0x7f18('0x10')]===_0x43c3e6[_0x7f18('0x11')]){_0x43c3e6[_0x7f18('0x12')]=_0x1093c9[_0x4b6912]['id'];_0x25e39d=!![];}}if(_0x25e39d){logger[_0x7f18('0x13')]('Admin\x20found:',_0x43c3e6[_0x7f18('0x12')]);_0x50a2c3(_0x43c3e6);}else{_0x484b34({'statusCode':0x194,'message':_0x7f18('0x14')});}}else{_0x484b34({'statusCode':0x194,'message':_0x7f18('0x14')});}})['catch'](function(_0x26c5cf){logger['error']('['+[_0x182389[_0x7f18('0x15')]()]+']',_0x26c5cf['message']);_0x484b34(_0x26c5cf);});});}function getUser(_0x5639ad,_0x388199,_0x495f30){return function(_0x2a205c){return new Promise(function(_0x159bac,_0x5dbdfe){var _0x206554={'method':_0x7f18('0x16'),'uri':_0x495f30+'/api/selector/owners','json':!![]};_0x206554['headers']=_0x388199;logger[_0x7f18('0x13')](_0x7f18('0x17'));return rp(_0x206554)[_0x7f18('0xe')](function(_0x276e7){if(_0x276e7){var _0x5a5fc5=_0x276e7[_0x7f18('0xf')];var _0x28c439=![];var _0x19cca3=null;if(_0x2a205c[_0x7f18('0x18')]!==null){logger['info']('Getting\x20user\x20with\x20email',_0x2a205c[_0x7f18('0x18')]);_0x2a205c[_0x7f18('0x19')]=_0x2a205c[_0x7f18('0x18')];for(_0x19cca3=0x0;_0x19cca3<_0x5a5fc5[_0x7f18('0x1a')];_0x19cca3++){if(_0x5a5fc5[_0x19cca3][_0x7f18('0x10')]===_0x2a205c[_0x7f18('0x18')]){_0x28c439=!![];_0x2a205c['userId']=_0x5a5fc5[_0x19cca3]['id'];logger['info']('User\x20found:',_0x2a205c[_0x7f18('0x1b')]);}}}if(!_0x28c439){logger[_0x7f18('0x13')](_0x7f18('0x1c'));_0x2a205c[_0x7f18('0x19')]=_0x2a205c[_0x7f18('0x11')];_0x2a205c['userId']=_0x2a205c['adminId'];_0x28c439=!![];}if(_0x28c439){_0x159bac(_0x2a205c);}else{_0x5dbdfe({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x5dbdfe({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0x7f18('0x1d')](function(_0x5f16d6){logger['error']('['+[_0x5639ad[_0x7f18('0x15')]()]+']',_0x5f16d6[_0x7f18('0x1e')]);_0x5dbdfe(_0x5f16d6);});});};}function searchContact(_0x12406c,_0x595bd9,_0x345610,_0x28a36a){return new Promise(function(_0xad029d,_0x5b78fa){var _0x45b52b={'method':_0x7f18('0x16'),'headers':_0x595bd9,'uri':_0x12406c+_0x7f18('0x1f')+_0x28a36a+_0x7f18('0x20')+_0x345610+_0x7f18('0x21'),'json':!![]};rp(_0x45b52b)[_0x7f18('0xe')](function(_0x1b13fb){var _0x55e92c=_[_0x7f18('0x22')](_0x1b13fb['contacts'][_0x7f18('0x23')],[_0x345610,_0x28a36a]);_0xad029d(_0x55e92c);})['catch'](function(_0x4315a9){_0x5b78fa(_0x4315a9);});});}function getEndUser(_0x1091f2,_0x8b365c,_0x4a9b9f){return function(_0x172b26){return new Promise(function(_0x577558,_0x1b48a4){logger[_0x7f18('0x13')](util[_0x7f18('0x24')]('Searching\x20contact\x20with\x20phone\x20%s',_0x172b26[_0x7f18('0x25')]));searchContact(_0x4a9b9f,_0x8b365c,_0x7f18('0x26'),_0x172b26[_0x7f18('0x25')])[_0x7f18('0xe')](function(_0x10abb5){if(_0x10abb5){_0x172b26[_0x7f18('0x27')]=_0x10abb5['id'];logger[_0x7f18('0x13')]('Contact\x20found\x20mobile_number:',_0x172b26['endUserId']);return _0x577558(_0x172b26);}searchContact(_0x4a9b9f,_0x8b365c,_0x7f18('0x28'),_0x172b26[_0x7f18('0x25')])[_0x7f18('0xe')](function(_0x123072){if(_0x123072){_0x172b26[_0x7f18('0x27')]=_0x123072['id'];logger[_0x7f18('0x13')]('Contact\x20found\x20work_number:',_0x172b26[_0x7f18('0x27')]);return _0x577558(_0x172b26);}createEndUser(_0x172b26,_0x1091f2,_0x8b365c,_0x4a9b9f)[_0x7f18('0xe')](function(_0x430a40){logger[_0x7f18('0x13')]('Contact\x20created:',_0x430a40[_0x7f18('0x27')]);return _0x577558(_0x430a40);});});})['catch'](function(_0x4f0fcd){_0x1b48a4(_0x4f0fcd);});});};}function createEndUser(_0xf84747,_0x369e1f,_0x2fc7d6,_0x49b596){return new Promise(function(_0x115df7,_0x4cae96){var _0x30a16b=moment();var _0x2720b3={'method':'POST','uri':_0x49b596+'/api/contacts','body':{'contact':{'last_name':_0xf84747[_0x7f18('0x25')],'work_number':_0xf84747['contactNumber'],'mobile_number':_0xf84747['contactNumber'],'owner_id':_0xf84747[_0x7f18('0x1b')],'created_at':_0x30a16b[_0x7f18('0x24')](_0x7f18('0x29'))}},'json':!![]};_0x2720b3[_0x7f18('0xc')]=_0x2fc7d6;logger[_0x7f18('0x13')](_0x7f18('0x2a'));return rp(_0x2720b3)[_0x7f18('0xe')](function(_0x536809){_0xf84747[_0x7f18('0x27')]=_0x536809[_0x7f18('0x2b')]['id'];_0x115df7(_0xf84747);})['catch'](function(_0x29cd11){logger[_0x7f18('0x2c')]('['+[_0x369e1f['toUpperCase']()]+']',_0x29cd11[_0x7f18('0x1e')]);_0x4cae96(_0x29cd11['message']);});});}function getTicket(_0x40ac8d,_0x16ee86,_0x3d31a0,_0x2fbe40,_0x33c788){return function(_0x269b9a){logger[_0x7f18('0x13')](_0x7f18('0x2d'));return new Promise(function(_0x39c39e,_0x4c1769){var _0x1e894e=moment();var _0x5f1f4c={'method':_0x7f18('0x2e'),'uri':_0x3d31a0+_0x7f18('0x2f'),'body':{'title':intUtil[_0x7f18('0x30')](_0x2fbe40[_0x7f18('0x31')],_0x33c788,'\x20'),'description':intUtil['getString'](_0x2fbe40[_0x7f18('0x32')],_0x33c788,'\x0a'),'owner_id':_0x269b9a[_0x7f18('0x1b')],'creater_id':_0x269b9a[_0x7f18('0x12')],'targetable_id':_0x269b9a['endUserId'],'targetable_type':_0x7f18('0x33'),'created_at':_0x1e894e[_0x7f18('0x24')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x1e894e[_0x7f18('0x34')](0x1e,'m')['format']('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x5f1f4c[_0x7f18('0xc')]=_0x16ee86;return rp(_0x5f1f4c)['then'](function(_0x2ecf54){_0x269b9a[_0x7f18('0x35')]=_0x2ecf54['task']['id'];logger[_0x7f18('0x13')](_0x7f18('0x36'),_0x269b9a[_0x7f18('0x35')]);_0x39c39e(_0x269b9a);})[_0x7f18('0x1d')](function(_0x530e9e){logger[_0x7f18('0x2c')]('['+[_0x40ac8d[_0x7f18('0x15')]()]+']',_0x530e9e[_0x7f18('0x1e')]);_0x4c1769(_0x530e9e[_0x7f18('0x1e')]);});});};}function emit(_0x5e9c96,_0x5a5ab4,_0x4e0f10){var _0x53283a={'uri':_0x5e9c96+_0x7f18('0x37')+_0x4e0f10};io['to'](util[_0x7f18('0x24')]('user:%s',_0x5a5ab4))[_0x7f18('0x38')](_0x7f18('0x39'),_0x53283a);}exports['cs']=function(_0x305183,_0x24a3e5,_0x4b0a72,_0x587af1,_0x537ecf,_0x2c0f24,_0xd96c8c,_0x250e02){var _0x1c7cd0={};var _0x39e1c0={'Authorization':'Token\x20token='+_0x2c0f24[_0x7f18('0x3a')]};_0x2c0f24[_0x7f18('0x3b')]=intUtil[_0x7f18('0x3c')](_0x2c0f24[_0x7f18('0x3b')]);_0x2c0f24[_0x7f18('0x3d')]=intUtil['stripTrailingSlash'](_0x2c0f24[_0x7f18('0x3d')]);var _0x1b3180=_0x2c0f24[_0x7f18('0x3b')];_0x1c7cd0['adminEmail']=_0x2c0f24['username'];_0x1c7cd0['contactNumber']=_0x250e02['toLowerCase']()==='outbound'?_0x24a3e5[_0x7f18('0x3e')]:_0x24a3e5[_0x7f18('0x3f')];_0x1c7cd0['callDirection']=_0x250e02===_0x7f18('0x40')||_0x250e02===_0x7f18('0x41')?_0x7f18('0x40'):_0x7f18('0x42');if(_0x587af1){_0x1c7cd0['agentEmail']=_0x587af1[_0x7f18('0x10')];}var _0x531d76=util[_0x7f18('0x24')](_0x7f18('0x43'),_0x2c0f24['serverUrl'],_0x24a3e5[_0x7f18('0x44')],md5(_0x24a3e5[_0x7f18('0x44')]));if(_0x537ecf&&_0x537ecf[_0x7f18('0x45')]){logger[_0x7f18('0x13')]('[QUEUE]',_0x7f18('0x46'));_0x24a3e5[_0x7f18('0x47')]=_0x531d76;}else if(_0xd96c8c&&_0xd96c8c[_0x7f18('0x48')]&&_0xd96c8c[_0x7f18('0x48')]!=='none'){logger['info'](_0x7f18('0x49'),'Recording\x20is\x20enabled!');_0x24a3e5[_0x7f18('0x47')]=_0x531d76;}else{_0x24a3e5[_0x7f18('0x47')]='';}return getAdminId(_0x1c7cd0,_0x250e02,_0x39e1c0,_0x1b3180)[_0x7f18('0xe')](getUser(_0x250e02,_0x39e1c0,_0x1b3180))[_0x7f18('0xe')](getEndUser(_0x250e02,_0x39e1c0,_0x1b3180))[_0x7f18('0xe')](getTicket(_0x250e02,_0x39e1c0,_0x1b3180,_0x4b0a72,_0x24a3e5))['then'](function(_0x2c238b){logger['info'](util[_0x7f18('0x24')]('The\x20ticket\x20ID\x20is:\x20%s',_0x2c238b[_0x7f18('0x35')]));if(_0x250e02!=='unmanaged'){logger[_0x7f18('0x13')]('['+[_0x250e02[_0x7f18('0x15')]()]+']',_0x7f18('0x4a'));emit(_0x1b3180,_0x587af1[_0x7f18('0x4b')],_0x2c238b[_0x7f18('0x27')]);}})[_0x7f18('0x1d')](function(_0x48953e){logger['error']('['+[_0x250e02[_0x7f18('0x15')]()]+_0x7f18('0x4c'),util['inspect'](_0x48953e,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file