Built motion from commit da617fac.|2.6.6
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index f8e409c..b0d040c 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 _0x0cd2=['adminEmail','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','toUpperCase','message','Getting\x20user\x20list','agentEmail','userEmail','userId','Admin\x20selected','/api/lookup?q=','&f=','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','mobile_number','endUserId','work_number','Contact\x20found\x20work_number:','POST','/api/contacts','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','error','Creating\x20new\x20task','/api/tasks','getString','Subjects','Contact','add','ticketId','Task\x20created:','/contacts/','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','serverUrl','username','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','unmanaged','queue','email','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','[QUEUE]','recordingFormat','none','Recording\x20is\x20enabled!','recordingURL','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','md5','moment','bluebird','./util','../../../../config/environment','freshsales','redis','localhost','socket.io-emitter','GET','/api/selector/owners','headers','info','then','users','length'];(function(_0x15c8e0,_0x332c04){var _0xcf223b=function(_0x1dbadb){while(--_0x1dbadb){_0x15c8e0['push'](_0x15c8e0['shift']());}};_0xcf223b(++_0x332c04);}(_0x0cd2,0x18d));var _0x20cd=function(_0x242fd5,_0xfdc4e){_0x242fd5=_0x242fd5-0x0;var _0x440d39=_0x0cd2[_0x242fd5];return _0x440d39;};'use strict';var _=require(_0x20cd('0x0'));var rp=require(_0x20cd('0x1'));var md5=require(_0x20cd('0x2'));var util=require('util');var moment=require(_0x20cd('0x3'));var Promise=require(_0x20cd('0x4'));var Redis=require('ioredis');var intUtil=require(_0x20cd('0x5'));var config=require(_0x20cd('0x6'));var logger=require('../../../../config/logger')(_0x20cd('0x7'));config['redis']=_['defaults'](config[_0x20cd('0x8')],{'host':_0x20cd('0x9'),'port':0x18eb});var io=require(_0x20cd('0xa'))(new Redis(config['redis']));function getAdminId(_0x400b4d,_0x50be65,_0x243a5d,_0x126b11){return new Promise(function(_0x40f8f3,_0x5d1de0){var _0xdc748f=![];var _0x1373e7={'method':_0x20cd('0xb'),'uri':_0x126b11+_0x20cd('0xc'),'json':!![]};_0x1373e7[_0x20cd('0xd')]=_0x243a5d;logger[_0x20cd('0xe')]('Getting\x20admin\x20information');return rp(_0x1373e7)[_0x20cd('0xf')](function(_0x4f1edf){if(_0x4f1edf){var _0x4cab8e=_0x4f1edf[_0x20cd('0x10')];var _0x4f9e3e=null;for(_0x4f9e3e=0x0;_0x4f9e3e<_0x4cab8e[_0x20cd('0x11')];_0x4f9e3e++){if(_0x4cab8e[_0x4f9e3e]['email']===_0x400b4d[_0x20cd('0x12')]){_0x400b4d[_0x20cd('0x13')]=_0x4cab8e[_0x4f9e3e]['id'];_0xdc748f=!![];}}if(_0xdc748f){logger[_0x20cd('0xe')](_0x20cd('0x14'),_0x400b4d[_0x20cd('0x13')]);_0x40f8f3(_0x400b4d);}else{_0x5d1de0({'statusCode':0x194,'message':_0x20cd('0x15')});}}else{_0x5d1de0({'statusCode':0x194,'message':_0x20cd('0x15')});}})[_0x20cd('0x16')](function(_0x5c5cbe){logger['error']('['+[_0x50be65[_0x20cd('0x17')]()]+']',_0x5c5cbe[_0x20cd('0x18')]);_0x5d1de0(_0x5c5cbe);});});}function getUser(_0x327137,_0x24a90f,_0x436f2d){return function(_0x2c496f){return new Promise(function(_0x23473e,_0x3cb1f4){var _0x3bb244={'method':'GET','uri':_0x436f2d+_0x20cd('0xc'),'json':!![]};_0x3bb244[_0x20cd('0xd')]=_0x24a90f;logger[_0x20cd('0xe')](_0x20cd('0x19'));return rp(_0x3bb244)[_0x20cd('0xf')](function(_0x31c695){if(_0x31c695){var _0x384740=_0x31c695[_0x20cd('0x10')];var _0x49b527=![];var _0x3cb4d4=null;if(_0x2c496f[_0x20cd('0x1a')]!==null){logger[_0x20cd('0xe')]('Getting\x20user\x20with\x20email',_0x2c496f['agentEmail']);_0x2c496f[_0x20cd('0x1b')]=_0x2c496f[_0x20cd('0x1a')];for(_0x3cb4d4=0x0;_0x3cb4d4<_0x384740[_0x20cd('0x11')];_0x3cb4d4++){if(_0x384740[_0x3cb4d4]['email']===_0x2c496f[_0x20cd('0x1a')]){_0x49b527=!![];_0x2c496f[_0x20cd('0x1c')]=_0x384740[_0x3cb4d4]['id'];logger['info']('User\x20found:',_0x2c496f[_0x20cd('0x1c')]);}}}if(!_0x49b527){logger['info'](_0x20cd('0x1d'));_0x2c496f[_0x20cd('0x1b')]=_0x2c496f[_0x20cd('0x12')];_0x2c496f['userId']=_0x2c496f[_0x20cd('0x13')];_0x49b527=!![];}if(_0x49b527){_0x23473e(_0x2c496f);}else{_0x3cb1f4({'statusCode':0x194,'message':_0x20cd('0x15')});}}else{_0x3cb1f4({'statusCode':0x194,'message':_0x20cd('0x15')});}})[_0x20cd('0x16')](function(_0x4c7fb8){logger['error']('['+[_0x327137['toUpperCase']()]+']',_0x4c7fb8[_0x20cd('0x18')]);_0x3cb1f4(_0x4c7fb8);});});};}function searchContact(_0x443a3c,_0x43e753,_0x52aa34,_0x2e36b2){return new Promise(function(_0x4833ad,_0x56b534){var _0x2dc571={'method':_0x20cd('0xb'),'headers':_0x43e753,'uri':_0x443a3c+_0x20cd('0x1e')+_0x2e36b2+_0x20cd('0x1f')+_0x52aa34+'&entities=contact','json':!![]};rp(_0x2dc571)[_0x20cd('0xf')](function(_0xa22254){var _0x10b98=_[_0x20cd('0x20')](_0xa22254['contacts'][_0x20cd('0x21')],[_0x52aa34,_0x2e36b2]);_0x4833ad(_0x10b98);})[_0x20cd('0x16')](function(_0x5e0af4){_0x56b534(_0x5e0af4);});});}function getEndUser(_0x41ed97,_0x69194,_0x1512b8){return function(_0x598b53){return new Promise(function(_0x2d5ac3,_0x69b789){logger[_0x20cd('0xe')](util[_0x20cd('0x22')](_0x20cd('0x23'),_0x598b53[_0x20cd('0x24')]));searchContact(_0x1512b8,_0x69194,_0x20cd('0x25'),_0x598b53[_0x20cd('0x24')])[_0x20cd('0xf')](function(_0x1cbd87){if(_0x1cbd87){_0x598b53[_0x20cd('0x26')]=_0x1cbd87['id'];logger[_0x20cd('0xe')]('Contact\x20found\x20mobile_number:',_0x598b53[_0x20cd('0x26')]);return _0x2d5ac3(_0x598b53);}searchContact(_0x1512b8,_0x69194,_0x20cd('0x27'),_0x598b53[_0x20cd('0x24')])['then'](function(_0x4aadaa){if(_0x4aadaa){_0x598b53[_0x20cd('0x26')]=_0x4aadaa['id'];logger[_0x20cd('0xe')](_0x20cd('0x28'),_0x598b53[_0x20cd('0x26')]);return _0x2d5ac3(_0x598b53);}createEndUser(_0x598b53,_0x41ed97,_0x69194,_0x1512b8)[_0x20cd('0xf')](function(_0x4caa29){logger['info']('Contact\x20created:',_0x4caa29[_0x20cd('0x26')]);return _0x2d5ac3(_0x4caa29);});});})[_0x20cd('0x16')](function(_0x392455){_0x69b789(_0x392455);});});};}function createEndUser(_0x665016,_0x1639b0,_0x421e11,_0x4bbdcf){return new Promise(function(_0x4428b4,_0x49cf3a){var _0x57a76=moment();var _0x95ccc8={'method':_0x20cd('0x29'),'uri':_0x4bbdcf+_0x20cd('0x2a'),'body':{'contact':{'last_name':_0x665016['contactNumber'],'work_number':_0x665016[_0x20cd('0x24')],'mobile_number':_0x665016[_0x20cd('0x24')],'owner_id':_0x665016['userId'],'created_at':_0x57a76[_0x20cd('0x22')](_0x20cd('0x2b'))}},'json':!![]};_0x95ccc8['headers']=_0x421e11;logger[_0x20cd('0xe')](_0x20cd('0x2c'));return rp(_0x95ccc8)[_0x20cd('0xf')](function(_0x4efd65){_0x665016[_0x20cd('0x26')]=_0x4efd65[_0x20cd('0x2d')]['id'];_0x4428b4(_0x665016);})[_0x20cd('0x16')](function(_0x496995){logger[_0x20cd('0x2e')]('['+[_0x1639b0[_0x20cd('0x17')]()]+']',_0x496995[_0x20cd('0x18')]);_0x49cf3a(_0x496995[_0x20cd('0x18')]);});});}function getTicket(_0xd92697,_0x2a620d,_0x50b60b,_0xf37fd,_0x2bca9a){return function(_0x444ed9){logger[_0x20cd('0xe')](_0x20cd('0x2f'));return new Promise(function(_0x57a43e,_0x27a107){var _0x184856=moment();var _0x38d0ff={'method':_0x20cd('0x29'),'uri':_0x50b60b+_0x20cd('0x30'),'body':{'title':intUtil[_0x20cd('0x31')](_0xf37fd[_0x20cd('0x32')],_0x2bca9a,'\x20'),'description':intUtil[_0x20cd('0x31')](_0xf37fd['Descriptions'],_0x2bca9a,'\x0a'),'owner_id':_0x444ed9[_0x20cd('0x1c')],'creater_id':_0x444ed9[_0x20cd('0x13')],'targetable_id':_0x444ed9[_0x20cd('0x26')],'targetable_type':_0x20cd('0x33'),'created_at':_0x184856['format'](_0x20cd('0x2b')),'due_date':_0x184856[_0x20cd('0x34')](0x1e,'m')[_0x20cd('0x22')](_0x20cd('0x2b'))},'json':!![]};_0x38d0ff[_0x20cd('0xd')]=_0x2a620d;return rp(_0x38d0ff)[_0x20cd('0xf')](function(_0x2076d3){_0x444ed9[_0x20cd('0x35')]=_0x2076d3['task']['id'];logger[_0x20cd('0xe')](_0x20cd('0x36'),_0x444ed9[_0x20cd('0x35')]);_0x57a43e(_0x444ed9);})['catch'](function(_0x20c6a5){logger[_0x20cd('0x2e')]('['+[_0xd92697[_0x20cd('0x17')]()]+']',_0x20c6a5[_0x20cd('0x18')]);_0x27a107(_0x20c6a5[_0x20cd('0x18')]);});});};}function emit(_0x19d206,_0x3e1602,_0x200471){var _0x4fe847={'uri':_0x19d206+_0x20cd('0x37')+_0x200471};io['to'](util[_0x20cd('0x22')](_0x20cd('0x38'),_0x3e1602))[_0x20cd('0x39')](_0x20cd('0x3a'),_0x4fe847);}exports['cs']=function(_0x54ff57,_0x273165,_0x97996e,_0x26ef8c,_0x5a33d4,_0x5ae417,_0x579700,_0x55d615){var _0x16d9ba={};var _0x21f137={'Authorization':_0x20cd('0x3b')+_0x5ae417[_0x20cd('0x3c')]};_0x5ae417[_0x20cd('0x3d')]=intUtil['stripTrailingSlash'](_0x5ae417[_0x20cd('0x3d')]);_0x5ae417[_0x20cd('0x3e')]=intUtil['stripTrailingSlash'](_0x5ae417[_0x20cd('0x3e')]);var _0x131cc9=_0x5ae417[_0x20cd('0x3d')];_0x16d9ba[_0x20cd('0x12')]=_0x5ae417[_0x20cd('0x3f')];_0x16d9ba[_0x20cd('0x24')]=_0x55d615[_0x20cd('0x40')]()===_0x20cd('0x41')?_0x273165[_0x20cd('0x42')]:_0x273165[_0x20cd('0x43')];_0x16d9ba[_0x20cd('0x44')]=_0x55d615==='queue'||_0x55d615===_0x20cd('0x45')?_0x20cd('0x46'):'outbound';if(_0x26ef8c){_0x16d9ba[_0x20cd('0x1a')]=_0x26ef8c[_0x20cd('0x47')];}var _0x3a19ed=util[_0x20cd('0x22')](_0x20cd('0x48'),_0x5ae417[_0x20cd('0x3e')],_0x273165[_0x20cd('0x49')],md5(_0x273165['uniqueid']));if(_0x5a33d4&&_0x5a33d4[_0x20cd('0x4a')]){logger[_0x20cd('0xe')](_0x20cd('0x4b'),'Recording\x20is\x20enabled!');_0x273165['recordingURL']=_0x3a19ed;}else if(_0x579700&&_0x579700['recordingFormat']&&_0x579700[_0x20cd('0x4c')]!==_0x20cd('0x4d')){logger[_0x20cd('0xe')]('[OUTBOUND]',_0x20cd('0x4e'));_0x273165[_0x20cd('0x4f')]=_0x3a19ed;}else{_0x273165[_0x20cd('0x4f')]='';}return getAdminId(_0x16d9ba,_0x55d615,_0x21f137,_0x131cc9)[_0x20cd('0xf')](getUser(_0x55d615,_0x21f137,_0x131cc9))[_0x20cd('0xf')](getEndUser(_0x55d615,_0x21f137,_0x131cc9))[_0x20cd('0xf')](getTicket(_0x55d615,_0x21f137,_0x131cc9,_0x97996e,_0x273165))['then'](function(_0x19fba3){logger[_0x20cd('0xe')](util[_0x20cd('0x22')]('The\x20ticket\x20ID\x20is:\x20%s',_0x19fba3[_0x20cd('0x35')]));if(_0x55d615!==_0x20cd('0x45')){logger['info']('['+[_0x55d615[_0x20cd('0x17')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x131cc9,_0x26ef8c[_0x20cd('0x50')],_0x19fba3[_0x20cd('0x26')]);}})['catch'](function(_0x2e3297){logger['error']('['+[_0x55d615[_0x20cd('0x17')]()]+_0x20cd('0x51'),util[_0x20cd('0x52')](_0x2e3297,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file