Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index f8e409c..839b097 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1ccc=['toLowerCase','outbound','destcalleridnum','callDirection','queue','unmanaged','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','[QUEUE]','Recording\x20is\x20enabled!','recordingFormat','none','[OUTBOUND]','recordingURL','The\x20ticket\x20ID\x20is:\x20%s',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','md5','util','moment','bluebird','ioredis','./util','../../../../config/logger','freshsales','redis','localhost','GET','/api/selector/owners','headers','Getting\x20admin\x20information','users','length','email','adminEmail','adminId','info','Requested\x20Resource\x20not\x20Found','error','toUpperCase','message','Getting\x20user\x20list','agentEmail','userId','User\x20found:','Admin\x20selected','catch','/api/lookup?q=','&f=','then','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','endUserId','Contact\x20found\x20mobile_number:','work_number','Contact\x20found\x20work_number:','Contact\x20created:','POST','/api/contacts','YYYY-MM-DDTHH:mm:ss','/api/tasks','getString','Subjects','Descriptions','Contact','task','Task\x20created:','ticketId','user:%s','emit','trigger:browser:url','Token\x20token=','serverUrl','stripTrailingSlash','remoteUri','username'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x1ccc,0x104));var _0xc1cc=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0x1ccc[_0x57b54c];return _0x59cc19;};'use strict';var _=require(_0xc1cc('0x0'));var rp=require(_0xc1cc('0x1'));var md5=require(_0xc1cc('0x2'));var util=require(_0xc1cc('0x3'));var moment=require(_0xc1cc('0x4'));var Promise=require(_0xc1cc('0x5'));var Redis=require(_0xc1cc('0x6'));var intUtil=require(_0xc1cc('0x7'));var config=require('../../../../config/environment');var logger=require(_0xc1cc('0x8'))(_0xc1cc('0x9'));config[_0xc1cc('0xa')]=_['defaults'](config[_0xc1cc('0xa')],{'host':_0xc1cc('0xb'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function getAdminId(_0x4d98db,_0x27b41a,_0x3cb170,_0xf4879d){return new Promise(function(_0x115e44,_0x34300d){var _0x3b39dd=![];var _0x50fc23={'method':_0xc1cc('0xc'),'uri':_0xf4879d+_0xc1cc('0xd'),'json':!![]};_0x50fc23[_0xc1cc('0xe')]=_0x3cb170;logger['info'](_0xc1cc('0xf'));return rp(_0x50fc23)['then'](function(_0x568ca3){if(_0x568ca3){var _0x579da3=_0x568ca3[_0xc1cc('0x10')];var _0x203ee6=null;for(_0x203ee6=0x0;_0x203ee6<_0x579da3[_0xc1cc('0x11')];_0x203ee6++){if(_0x579da3[_0x203ee6][_0xc1cc('0x12')]===_0x4d98db[_0xc1cc('0x13')]){_0x4d98db[_0xc1cc('0x14')]=_0x579da3[_0x203ee6]['id'];_0x3b39dd=!![];}}if(_0x3b39dd){logger[_0xc1cc('0x15')]('Admin\x20found:',_0x4d98db[_0xc1cc('0x14')]);_0x115e44(_0x4d98db);}else{_0x34300d({'statusCode':0x194,'message':_0xc1cc('0x16')});}}else{_0x34300d({'statusCode':0x194,'message':_0xc1cc('0x16')});}})['catch'](function(_0x1e39aa){logger[_0xc1cc('0x17')]('['+[_0x27b41a[_0xc1cc('0x18')]()]+']',_0x1e39aa[_0xc1cc('0x19')]);_0x34300d(_0x1e39aa);});});}function getUser(_0x310afe,_0x577a15,_0xd444bc){return function(_0x149921){return new Promise(function(_0x263858,_0x5cf57e){var _0x50ae61={'method':_0xc1cc('0xc'),'uri':_0xd444bc+'/api/selector/owners','json':!![]};_0x50ae61[_0xc1cc('0xe')]=_0x577a15;logger['info'](_0xc1cc('0x1a'));return rp(_0x50ae61)['then'](function(_0x333ba7){if(_0x333ba7){var _0x23a613=_0x333ba7[_0xc1cc('0x10')];var _0x2d70fd=![];var _0x4c1480=null;if(_0x149921[_0xc1cc('0x1b')]!==null){logger[_0xc1cc('0x15')]('Getting\x20user\x20with\x20email',_0x149921['agentEmail']);_0x149921['userEmail']=_0x149921[_0xc1cc('0x1b')];for(_0x4c1480=0x0;_0x4c1480<_0x23a613[_0xc1cc('0x11')];_0x4c1480++){if(_0x23a613[_0x4c1480][_0xc1cc('0x12')]===_0x149921[_0xc1cc('0x1b')]){_0x2d70fd=!![];_0x149921[_0xc1cc('0x1c')]=_0x23a613[_0x4c1480]['id'];logger[_0xc1cc('0x15')](_0xc1cc('0x1d'),_0x149921[_0xc1cc('0x1c')]);}}}if(!_0x2d70fd){logger[_0xc1cc('0x15')](_0xc1cc('0x1e'));_0x149921['userEmail']=_0x149921['adminEmail'];_0x149921[_0xc1cc('0x1c')]=_0x149921[_0xc1cc('0x14')];_0x2d70fd=!![];}if(_0x2d70fd){_0x263858(_0x149921);}else{_0x5cf57e({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x5cf57e({'statusCode':0x194,'message':_0xc1cc('0x16')});}})[_0xc1cc('0x1f')](function(_0x6a12e0){logger[_0xc1cc('0x17')]('['+[_0x310afe[_0xc1cc('0x18')]()]+']',_0x6a12e0[_0xc1cc('0x19')]);_0x5cf57e(_0x6a12e0);});});};}function searchContact(_0x5d2cfc,_0xa08495,_0x44ba4a,_0x11021a){return new Promise(function(_0x9cc478,_0x22445b){var _0x32df5b={'method':_0xc1cc('0xc'),'headers':_0xa08495,'uri':_0x5d2cfc+_0xc1cc('0x20')+_0x11021a+_0xc1cc('0x21')+_0x44ba4a+'&entities=contact','json':!![]};rp(_0x32df5b)[_0xc1cc('0x22')](function(_0x54cb4b){var _0xc9428d=_[_0xc1cc('0x23')](_0x54cb4b[_0xc1cc('0x24')][_0xc1cc('0x24')],[_0x44ba4a,_0x11021a]);_0x9cc478(_0xc9428d);})[_0xc1cc('0x1f')](function(_0x1220db){_0x22445b(_0x1220db);});});}function getEndUser(_0x390e50,_0x8da23a,_0x1a389c){return function(_0xb28544){return new Promise(function(_0x4af552,_0x3378a7){logger[_0xc1cc('0x15')](util[_0xc1cc('0x25')](_0xc1cc('0x26'),_0xb28544[_0xc1cc('0x27')]));searchContact(_0x1a389c,_0x8da23a,'mobile_number',_0xb28544[_0xc1cc('0x27')])['then'](function(_0x4262db){if(_0x4262db){_0xb28544[_0xc1cc('0x28')]=_0x4262db['id'];logger[_0xc1cc('0x15')](_0xc1cc('0x29'),_0xb28544[_0xc1cc('0x28')]);return _0x4af552(_0xb28544);}searchContact(_0x1a389c,_0x8da23a,_0xc1cc('0x2a'),_0xb28544['contactNumber'])[_0xc1cc('0x22')](function(_0x564482){if(_0x564482){_0xb28544[_0xc1cc('0x28')]=_0x564482['id'];logger['info'](_0xc1cc('0x2b'),_0xb28544[_0xc1cc('0x28')]);return _0x4af552(_0xb28544);}createEndUser(_0xb28544,_0x390e50,_0x8da23a,_0x1a389c)['then'](function(_0x4464b7){logger[_0xc1cc('0x15')](_0xc1cc('0x2c'),_0x4464b7[_0xc1cc('0x28')]);return _0x4af552(_0x4464b7);});});})['catch'](function(_0x18b752){_0x3378a7(_0x18b752);});});};}function createEndUser(_0x2d54cb,_0x1849ef,_0x28a87a,_0x370caa){return new Promise(function(_0x5f587a,_0x5de39e){var _0x148878=moment();var _0x59f188={'method':_0xc1cc('0x2d'),'uri':_0x370caa+_0xc1cc('0x2e'),'body':{'contact':{'last_name':_0x2d54cb[_0xc1cc('0x27')],'work_number':_0x2d54cb['contactNumber'],'mobile_number':_0x2d54cb[_0xc1cc('0x27')],'owner_id':_0x2d54cb['userId'],'created_at':_0x148878[_0xc1cc('0x25')](_0xc1cc('0x2f'))}},'json':!![]};_0x59f188[_0xc1cc('0xe')]=_0x28a87a;logger[_0xc1cc('0x15')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0x59f188)[_0xc1cc('0x22')](function(_0x584099){_0x2d54cb[_0xc1cc('0x28')]=_0x584099['contact']['id'];_0x5f587a(_0x2d54cb);})[_0xc1cc('0x1f')](function(_0x27fd3b){logger[_0xc1cc('0x17')]('['+[_0x1849ef[_0xc1cc('0x18')]()]+']',_0x27fd3b[_0xc1cc('0x19')]);_0x5de39e(_0x27fd3b[_0xc1cc('0x19')]);});});}function getTicket(_0x573387,_0x114b4b,_0x3cd4c5,_0x2728e6,_0x3f692a){return function(_0x3d0a09){logger['info']('Creating\x20new\x20task');return new Promise(function(_0x55298b,_0x2f9152){var _0x550061=moment();var _0xca2c9d={'method':_0xc1cc('0x2d'),'uri':_0x3cd4c5+_0xc1cc('0x30'),'body':{'title':intUtil[_0xc1cc('0x31')](_0x2728e6[_0xc1cc('0x32')],_0x3f692a,'\x20'),'description':intUtil['getString'](_0x2728e6[_0xc1cc('0x33')],_0x3f692a,'\x0a'),'owner_id':_0x3d0a09[_0xc1cc('0x1c')],'creater_id':_0x3d0a09['adminId'],'targetable_id':_0x3d0a09[_0xc1cc('0x28')],'targetable_type':_0xc1cc('0x34'),'created_at':_0x550061[_0xc1cc('0x25')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x550061['add'](0x1e,'m')[_0xc1cc('0x25')](_0xc1cc('0x2f'))},'json':!![]};_0xca2c9d[_0xc1cc('0xe')]=_0x114b4b;return rp(_0xca2c9d)[_0xc1cc('0x22')](function(_0x4bf093){_0x3d0a09['ticketId']=_0x4bf093[_0xc1cc('0x35')]['id'];logger[_0xc1cc('0x15')](_0xc1cc('0x36'),_0x3d0a09[_0xc1cc('0x37')]);_0x55298b(_0x3d0a09);})['catch'](function(_0x2937ea){logger[_0xc1cc('0x17')]('['+[_0x573387[_0xc1cc('0x18')]()]+']',_0x2937ea['message']);_0x2f9152(_0x2937ea[_0xc1cc('0x19')]);});});};}function emit(_0xcbed4,_0x41637e,_0x317d88){var _0x573777={'uri':_0xcbed4+'/contacts/'+_0x317d88};io['to'](util['format'](_0xc1cc('0x38'),_0x41637e))[_0xc1cc('0x39')](_0xc1cc('0x3a'),_0x573777);}exports['cs']=function(_0x49da7e,_0x55bf3c,_0x8846b6,_0x392761,_0x5c9a59,_0xbec50b,_0x1779fd,_0x355ec6){var _0x1becef={};var _0x10e99a={'Authorization':_0xc1cc('0x3b')+_0xbec50b['apiKey']};_0xbec50b['remoteUri']=intUtil['stripTrailingSlash'](_0xbec50b['remoteUri']);_0xbec50b[_0xc1cc('0x3c')]=intUtil[_0xc1cc('0x3d')](_0xbec50b['serverUrl']);var _0x45f9c2=_0xbec50b[_0xc1cc('0x3e')];_0x1becef[_0xc1cc('0x13')]=_0xbec50b[_0xc1cc('0x3f')];_0x1becef[_0xc1cc('0x27')]=_0x355ec6[_0xc1cc('0x40')]()===_0xc1cc('0x41')?_0x55bf3c[_0xc1cc('0x42')]:_0x55bf3c['calleridnum'];_0x1becef[_0xc1cc('0x43')]=_0x355ec6===_0xc1cc('0x44')||_0x355ec6===_0xc1cc('0x45')?'queue':_0xc1cc('0x41');if(_0x392761){_0x1becef[_0xc1cc('0x1b')]=_0x392761[_0xc1cc('0x12')];}var _0x1645f3=util[_0xc1cc('0x25')](_0xc1cc('0x46'),_0xbec50b['serverUrl'],_0x55bf3c[_0xc1cc('0x47')],md5(_0x55bf3c[_0xc1cc('0x47')]));if(_0x5c9a59&&_0x5c9a59['monitor_format']){logger['info'](_0xc1cc('0x48'),_0xc1cc('0x49'));_0x55bf3c['recordingURL']=_0x1645f3;}else if(_0x1779fd&&_0x1779fd[_0xc1cc('0x4a')]&&_0x1779fd[_0xc1cc('0x4a')]!==_0xc1cc('0x4b')){logger['info'](_0xc1cc('0x4c'),_0xc1cc('0x49'));_0x55bf3c[_0xc1cc('0x4d')]=_0x1645f3;}else{_0x55bf3c[_0xc1cc('0x4d')]='';}return getAdminId(_0x1becef,_0x355ec6,_0x10e99a,_0x45f9c2)[_0xc1cc('0x22')](getUser(_0x355ec6,_0x10e99a,_0x45f9c2))['then'](getEndUser(_0x355ec6,_0x10e99a,_0x45f9c2))[_0xc1cc('0x22')](getTicket(_0x355ec6,_0x10e99a,_0x45f9c2,_0x8846b6,_0x55bf3c))['then'](function(_0x3461bd){logger[_0xc1cc('0x15')](util[_0xc1cc('0x25')](_0xc1cc('0x4e'),_0x3461bd['ticketId']));if(_0x355ec6!==_0xc1cc('0x45')){logger[_0xc1cc('0x15')]('['+[_0x355ec6[_0xc1cc('0x18')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x45f9c2,_0x392761['name'],_0x3461bd['endUserId']);}})[_0xc1cc('0x1f')](function(_0x5a4019){logger['error']('['+[_0x355ec6[_0xc1cc('0x18')]()]+_0xc1cc('0x4f'),util[_0xc1cc('0x50')](_0x5a4019,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0xfc8b=['user:%s','emit','trigger:browser:url','Token\x20token=','remoteUri','stripTrailingSlash','serverUrl','toLowerCase','destcalleridnum','calleridnum','callDirection','unmanaged','queue','outbound','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingURL','The\x20ticket\x20ID\x20is:\x20%s','name','lodash','request-promise','util','moment','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','redis','defaults','localhost','socket.io-emitter','/api/selector/owners','headers','info','Getting\x20admin\x20information','then','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','GET','Getting\x20user\x20list','users','agentEmail','Getting\x20user\x20with\x20email','userEmail','length','email','User\x20found:','userId','adminEmail','/api/lookup?q=','&f=','&entities=contact','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','endUserId','Contact\x20found\x20mobile_number:','Contact\x20found\x20work_number:','Contact\x20created:','POST','/api/contacts','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','message','Creating\x20new\x20task','/api/tasks','Subjects','getString','Descriptions','Contact','add','ticketId','task','Task\x20created:'];(function(_0x124d74,_0x18eda2){var _0x46418e=function(_0x75f580){while(--_0x75f580){_0x124d74['push'](_0x124d74['shift']());}};_0x46418e(++_0x18eda2);}(_0xfc8b,0xbb));var _0xbfc8=function(_0x8e98e6,_0x55b4bd){_0x8e98e6=_0x8e98e6-0x0;var _0x1d4063=_0xfc8b[_0x8e98e6];return _0x1d4063;};'use strict';var _=require(_0xbfc8('0x0'));var rp=require(_0xbfc8('0x1'));var md5=require('md5');var util=require(_0xbfc8('0x2'));var moment=require(_0xbfc8('0x3'));var Promise=require('bluebird');var Redis=require(_0xbfc8('0x4'));var intUtil=require(_0xbfc8('0x5'));var config=require(_0xbfc8('0x6'));var logger=require(_0xbfc8('0x7'))(_0xbfc8('0x8'));config[_0xbfc8('0x9')]=_[_0xbfc8('0xa')](config[_0xbfc8('0x9')],{'host':_0xbfc8('0xb'),'port':0x18eb});var io=require(_0xbfc8('0xc'))(new Redis(config[_0xbfc8('0x9')]));function getAdminId(_0x21c417,_0x311487,_0x5a4783,_0x4916d9){return new Promise(function(_0x5a044a,_0x2af829){var _0xdd4afc=![];var _0x15825c={'method':'GET','uri':_0x4916d9+_0xbfc8('0xd'),'json':!![]};_0x15825c[_0xbfc8('0xe')]=_0x5a4783;logger[_0xbfc8('0xf')](_0xbfc8('0x10'));return rp(_0x15825c)[_0xbfc8('0x11')](function(_0x2bdf9d){if(_0x2bdf9d){var _0x109e07=_0x2bdf9d['users'];var _0x28d3db=null;for(_0x28d3db=0x0;_0x28d3db<_0x109e07['length'];_0x28d3db++){if(_0x109e07[_0x28d3db]['email']===_0x21c417['adminEmail']){_0x21c417[_0xbfc8('0x12')]=_0x109e07[_0x28d3db]['id'];_0xdd4afc=!![];}}if(_0xdd4afc){logger[_0xbfc8('0xf')](_0xbfc8('0x13'),_0x21c417['adminId']);_0x5a044a(_0x21c417);}else{_0x2af829({'statusCode':0x194,'message':_0xbfc8('0x14')});}}else{_0x2af829({'statusCode':0x194,'message':_0xbfc8('0x14')});}})[_0xbfc8('0x15')](function(_0x62437e){logger[_0xbfc8('0x16')]('['+[_0x311487[_0xbfc8('0x17')]()]+']',_0x62437e['message']);_0x2af829(_0x62437e);});});}function getUser(_0x30d0d6,_0x19a0fa,_0x530122){return function(_0x5b6279){return new Promise(function(_0x39ea0d,_0x5eee63){var _0x183084={'method':_0xbfc8('0x18'),'uri':_0x530122+_0xbfc8('0xd'),'json':!![]};_0x183084[_0xbfc8('0xe')]=_0x19a0fa;logger['info'](_0xbfc8('0x19'));return rp(_0x183084)[_0xbfc8('0x11')](function(_0xa46d8){if(_0xa46d8){var _0x4e1914=_0xa46d8[_0xbfc8('0x1a')];var _0x44e4f8=![];var _0x6fa5df=null;if(_0x5b6279[_0xbfc8('0x1b')]!==null){logger[_0xbfc8('0xf')](_0xbfc8('0x1c'),_0x5b6279['agentEmail']);_0x5b6279[_0xbfc8('0x1d')]=_0x5b6279[_0xbfc8('0x1b')];for(_0x6fa5df=0x0;_0x6fa5df<_0x4e1914[_0xbfc8('0x1e')];_0x6fa5df++){if(_0x4e1914[_0x6fa5df][_0xbfc8('0x1f')]===_0x5b6279['agentEmail']){_0x44e4f8=!![];_0x5b6279['userId']=_0x4e1914[_0x6fa5df]['id'];logger[_0xbfc8('0xf')](_0xbfc8('0x20'),_0x5b6279[_0xbfc8('0x21')]);}}}if(!_0x44e4f8){logger[_0xbfc8('0xf')]('Admin\x20selected');_0x5b6279['userEmail']=_0x5b6279[_0xbfc8('0x22')];_0x5b6279[_0xbfc8('0x21')]=_0x5b6279[_0xbfc8('0x12')];_0x44e4f8=!![];}if(_0x44e4f8){_0x39ea0d(_0x5b6279);}else{_0x5eee63({'statusCode':0x194,'message':_0xbfc8('0x14')});}}else{_0x5eee63({'statusCode':0x194,'message':_0xbfc8('0x14')});}})[_0xbfc8('0x15')](function(_0x29fca9){logger[_0xbfc8('0x16')]('['+[_0x30d0d6['toUpperCase']()]+']',_0x29fca9['message']);_0x5eee63(_0x29fca9);});});};}function searchContact(_0x583d54,_0x2d3884,_0x4f02a0,_0x5df1ae){return new Promise(function(_0x413c45,_0x423953){var _0x3cce10={'method':'GET','headers':_0x2d3884,'uri':_0x583d54+_0xbfc8('0x23')+_0x5df1ae+_0xbfc8('0x24')+_0x4f02a0+_0xbfc8('0x25'),'json':!![]};rp(_0x3cce10)[_0xbfc8('0x11')](function(_0x361f12){var _0x3503e3=_['find'](_0x361f12[_0xbfc8('0x26')][_0xbfc8('0x26')],[_0x4f02a0,_0x5df1ae]);_0x413c45(_0x3503e3);})[_0xbfc8('0x15')](function(_0xa26e55){_0x423953(_0xa26e55);});});}function getEndUser(_0x2094ee,_0x15a97c,_0x3977af){return function(_0x1e3dcc){return new Promise(function(_0x17cfca,_0x40bd80){logger[_0xbfc8('0xf')](util[_0xbfc8('0x27')](_0xbfc8('0x28'),_0x1e3dcc[_0xbfc8('0x29')]));searchContact(_0x3977af,_0x15a97c,'mobile_number',_0x1e3dcc['contactNumber'])[_0xbfc8('0x11')](function(_0x54d854){if(_0x54d854){_0x1e3dcc[_0xbfc8('0x2a')]=_0x54d854['id'];logger[_0xbfc8('0xf')](_0xbfc8('0x2b'),_0x1e3dcc['endUserId']);return _0x17cfca(_0x1e3dcc);}searchContact(_0x3977af,_0x15a97c,'work_number',_0x1e3dcc['contactNumber'])[_0xbfc8('0x11')](function(_0x23304a){if(_0x23304a){_0x1e3dcc[_0xbfc8('0x2a')]=_0x23304a['id'];logger['info'](_0xbfc8('0x2c'),_0x1e3dcc[_0xbfc8('0x2a')]);return _0x17cfca(_0x1e3dcc);}createEndUser(_0x1e3dcc,_0x2094ee,_0x15a97c,_0x3977af)[_0xbfc8('0x11')](function(_0x1dab13){logger[_0xbfc8('0xf')](_0xbfc8('0x2d'),_0x1dab13[_0xbfc8('0x2a')]);return _0x17cfca(_0x1dab13);});});})[_0xbfc8('0x15')](function(_0x2dbe92){_0x40bd80(_0x2dbe92);});});};}function createEndUser(_0x2ebff2,_0x46dcbf,_0x318801,_0x306ebf){return new Promise(function(_0xb7cd38,_0x390610){var _0x24dbf2=moment();var _0x1c6e05={'method':_0xbfc8('0x2e'),'uri':_0x306ebf+_0xbfc8('0x2f'),'body':{'contact':{'last_name':_0x2ebff2[_0xbfc8('0x29')],'work_number':_0x2ebff2[_0xbfc8('0x29')],'mobile_number':_0x2ebff2['contactNumber'],'owner_id':_0x2ebff2[_0xbfc8('0x21')],'created_at':_0x24dbf2[_0xbfc8('0x27')](_0xbfc8('0x30'))}},'json':!![]};_0x1c6e05[_0xbfc8('0xe')]=_0x318801;logger[_0xbfc8('0xf')](_0xbfc8('0x31'));return rp(_0x1c6e05)[_0xbfc8('0x11')](function(_0x5d506a){_0x2ebff2[_0xbfc8('0x2a')]=_0x5d506a[_0xbfc8('0x32')]['id'];_0xb7cd38(_0x2ebff2);})[_0xbfc8('0x15')](function(_0x3ab6ea){logger[_0xbfc8('0x16')]('['+[_0x46dcbf[_0xbfc8('0x17')]()]+']',_0x3ab6ea['message']);_0x390610(_0x3ab6ea[_0xbfc8('0x33')]);});});}function getTicket(_0x385c69,_0x2afbac,_0x5c1449,_0x569943,_0x32ef79){return function(_0x54916c){logger[_0xbfc8('0xf')](_0xbfc8('0x34'));return new Promise(function(_0x3f461d,_0x46e908){var _0x1966f8=moment();var _0x5080ac={'method':_0xbfc8('0x2e'),'uri':_0x5c1449+_0xbfc8('0x35'),'body':{'title':intUtil['getString'](_0x569943[_0xbfc8('0x36')],_0x32ef79,'\x20'),'description':intUtil[_0xbfc8('0x37')](_0x569943[_0xbfc8('0x38')],_0x32ef79,'\x0a'),'owner_id':_0x54916c['userId'],'creater_id':_0x54916c[_0xbfc8('0x12')],'targetable_id':_0x54916c[_0xbfc8('0x2a')],'targetable_type':_0xbfc8('0x39'),'created_at':_0x1966f8[_0xbfc8('0x27')](_0xbfc8('0x30')),'due_date':_0x1966f8[_0xbfc8('0x3a')](0x1e,'m')['format'](_0xbfc8('0x30'))},'json':!![]};_0x5080ac['headers']=_0x2afbac;return rp(_0x5080ac)[_0xbfc8('0x11')](function(_0x58321b){_0x54916c[_0xbfc8('0x3b')]=_0x58321b[_0xbfc8('0x3c')]['id'];logger[_0xbfc8('0xf')](_0xbfc8('0x3d'),_0x54916c[_0xbfc8('0x3b')]);_0x3f461d(_0x54916c);})[_0xbfc8('0x15')](function(_0x3248dc){logger['error']('['+[_0x385c69[_0xbfc8('0x17')]()]+']',_0x3248dc[_0xbfc8('0x33')]);_0x46e908(_0x3248dc[_0xbfc8('0x33')]);});});};}function emit(_0x512001,_0x3d6fc2,_0x30042e){var _0x10d298={'uri':_0x512001+'/contacts/'+_0x30042e};io['to'](util[_0xbfc8('0x27')](_0xbfc8('0x3e'),_0x3d6fc2))[_0xbfc8('0x3f')](_0xbfc8('0x40'),_0x10d298);}exports['cs']=function(_0x42213e,_0x3fe18a,_0x3ad7d7,_0x32536f,_0x2800cb,_0x3509b2,_0x1a612c,_0x56b983){var _0x444756={};var _0x535e06={'Authorization':_0xbfc8('0x41')+_0x3509b2['apiKey']};_0x3509b2[_0xbfc8('0x42')]=intUtil[_0xbfc8('0x43')](_0x3509b2[_0xbfc8('0x42')]);_0x3509b2[_0xbfc8('0x44')]=intUtil[_0xbfc8('0x43')](_0x3509b2['serverUrl']);var _0x324e7e=_0x3509b2[_0xbfc8('0x42')];_0x444756[_0xbfc8('0x22')]=_0x3509b2['username'];_0x444756[_0xbfc8('0x29')]=_0x56b983[_0xbfc8('0x45')]()==='outbound'?_0x3fe18a[_0xbfc8('0x46')]:_0x3fe18a[_0xbfc8('0x47')];_0x444756[_0xbfc8('0x48')]=_0x56b983==='queue'||_0x56b983===_0xbfc8('0x49')?_0xbfc8('0x4a'):_0xbfc8('0x4b');if(_0x32536f){_0x444756['agentEmail']=_0x32536f['email'];}var _0x44fd1e=util[_0xbfc8('0x27')](_0xbfc8('0x4c'),_0x3509b2[_0xbfc8('0x44')],_0x3fe18a[_0xbfc8('0x4d')],md5(_0x3fe18a[_0xbfc8('0x4d')]));if(_0x2800cb&&_0x2800cb[_0xbfc8('0x4e')]){logger[_0xbfc8('0xf')]('[QUEUE]',_0xbfc8('0x4f'));_0x3fe18a[_0xbfc8('0x50')]=_0x44fd1e;}else if(_0x1a612c&&_0x1a612c['recordingFormat']&&_0x1a612c['recordingFormat']!=='none'){logger[_0xbfc8('0xf')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x3fe18a['recordingURL']=_0x44fd1e;}else{_0x3fe18a[_0xbfc8('0x50')]='';}return getAdminId(_0x444756,_0x56b983,_0x535e06,_0x324e7e)[_0xbfc8('0x11')](getUser(_0x56b983,_0x535e06,_0x324e7e))[_0xbfc8('0x11')](getEndUser(_0x56b983,_0x535e06,_0x324e7e))['then'](getTicket(_0x56b983,_0x535e06,_0x324e7e,_0x3ad7d7,_0x3fe18a))[_0xbfc8('0x11')](function(_0x58689a){logger[_0xbfc8('0xf')](util['format'](_0xbfc8('0x51'),_0x58689a[_0xbfc8('0x3b')]));if(_0x56b983!==_0xbfc8('0x49')){logger['info']('['+[_0x56b983['toUpperCase']()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x324e7e,_0x32536f[_0xbfc8('0x52')],_0x58689a[_0xbfc8('0x2a')]);}})[_0xbfc8('0x15')](function(_0x3c9261){logger[_0xbfc8('0x16')]('['+[_0x56b983['toUpperCase']()]+']\x20Error\x20running\x20Freshsales\x20integration',util['inspect'](_0x3c9261,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file