Built motion from commit 980b26c3.|2.6.29
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index a034dd1..4daf529 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x24f0=['remoteUri','serverUrl','username','toLowerCase','outbound','destcalleridnum','calleridnum','callDirection','queue','unmanaged','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','The\x20ticket\x20ID\x20is:\x20%s','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','request-promise','moment','bluebird','ioredis','./util','../../../../config/environment','../../../../config/logger','redis','defaults','socket.io-emitter','/api/selector/owners','headers','info','Getting\x20admin\x20information','then','users','length','email','adminEmail','adminId','Requested\x20Resource\x20not\x20Found','catch','toUpperCase','message','Getting\x20user\x20list','agentEmail','Getting\x20user\x20with\x20email','userId','User\x20found:','Admin\x20selected','userEmail','error','GET','/api/lookup?q=','&f=','&entities=contact','find','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','Creating\x20new\x20task','/api/tasks','getString','Subjects','task','Task\x20created:','ticketId','/contacts/','user:%s','emit','trigger:browser:url','apiKey'];(function(_0x3030a9,_0x3e7be2){var _0x5e6b29=function(_0x4be727){while(--_0x4be727){_0x3030a9['push'](_0x3030a9['shift']());}};_0x5e6b29(++_0x3e7be2);}(_0x24f0,0x1ba));var _0x024f=function(_0x31e8f0,_0x688ba3){_0x31e8f0=_0x31e8f0-0x0;var _0x22b720=_0x24f0[_0x31e8f0];return _0x22b720;};'use strict';var _=require('lodash');var rp=require(_0x024f('0x0'));var md5=require('md5');var util=require('util');var moment=require(_0x024f('0x1'));var Promise=require(_0x024f('0x2'));var Redis=require(_0x024f('0x3'));var intUtil=require(_0x024f('0x4'));var config=require(_0x024f('0x5'));var logger=require(_0x024f('0x6'))('freshsales');config[_0x024f('0x7')]=_[_0x024f('0x8')](config[_0x024f('0x7')],{'host':'localhost','port':0x18eb});var io=require(_0x024f('0x9'))(new Redis(config[_0x024f('0x7')]));function getAdminId(_0x2eb71f,_0x3f9cf6,_0x213041,_0x1719d3){return new Promise(function(_0x4bf194,_0x294949){var _0x52e2a2=![];var _0x4efcb3={'method':'GET','uri':_0x1719d3+_0x024f('0xa'),'json':!![]};_0x4efcb3[_0x024f('0xb')]=_0x213041;logger[_0x024f('0xc')](_0x024f('0xd'));return rp(_0x4efcb3)[_0x024f('0xe')](function(_0x18cd7e){if(_0x18cd7e){var _0x26acfe=_0x18cd7e[_0x024f('0xf')];var _0x424e1d=null;for(_0x424e1d=0x0;_0x424e1d<_0x26acfe[_0x024f('0x10')];_0x424e1d++){if(_0x26acfe[_0x424e1d][_0x024f('0x11')]===_0x2eb71f[_0x024f('0x12')]){_0x2eb71f[_0x024f('0x13')]=_0x26acfe[_0x424e1d]['id'];_0x52e2a2=!![];}}if(_0x52e2a2){logger[_0x024f('0xc')]('Admin\x20found:',_0x2eb71f[_0x024f('0x13')]);_0x4bf194(_0x2eb71f);}else{_0x294949({'statusCode':0x194,'message':_0x024f('0x14')});}}else{_0x294949({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0x024f('0x15')](function(_0x14af0f){logger['error']('['+[_0x3f9cf6[_0x024f('0x16')]()]+']',_0x14af0f[_0x024f('0x17')]);_0x294949(_0x14af0f);});});}function getUser(_0x5a614a,_0x23559b,_0x4fbc05){return function(_0x360f51){return new Promise(function(_0x304baf,_0x2b83a0){var _0x241b17={'method':'GET','uri':_0x4fbc05+'/api/selector/owners','json':!![]};_0x241b17[_0x024f('0xb')]=_0x23559b;logger[_0x024f('0xc')](_0x024f('0x18'));return rp(_0x241b17)[_0x024f('0xe')](function(_0x240fb3){if(_0x240fb3){var _0x2b8962=_0x240fb3[_0x024f('0xf')];var _0x3acf9a=![];var _0x2f89ac=null;if(_0x360f51[_0x024f('0x19')]!==null){logger[_0x024f('0xc')](_0x024f('0x1a'),_0x360f51[_0x024f('0x19')]);_0x360f51['userEmail']=_0x360f51[_0x024f('0x19')];for(_0x2f89ac=0x0;_0x2f89ac<_0x2b8962[_0x024f('0x10')];_0x2f89ac++){if(_0x2b8962[_0x2f89ac][_0x024f('0x11')]===_0x360f51['agentEmail']){_0x3acf9a=!![];_0x360f51[_0x024f('0x1b')]=_0x2b8962[_0x2f89ac]['id'];logger[_0x024f('0xc')](_0x024f('0x1c'),_0x360f51[_0x024f('0x1b')]);}}}if(!_0x3acf9a){logger[_0x024f('0xc')](_0x024f('0x1d'));_0x360f51[_0x024f('0x1e')]=_0x360f51[_0x024f('0x12')];_0x360f51[_0x024f('0x1b')]=_0x360f51['adminId'];_0x3acf9a=!![];}if(_0x3acf9a){_0x304baf(_0x360f51);}else{_0x2b83a0({'statusCode':0x194,'message':_0x024f('0x14')});}}else{_0x2b83a0({'statusCode':0x194,'message':_0x024f('0x14')});}})[_0x024f('0x15')](function(_0x22430c){logger[_0x024f('0x1f')]('['+[_0x5a614a[_0x024f('0x16')]()]+']',_0x22430c[_0x024f('0x17')]);_0x2b83a0(_0x22430c);});});};}function searchContact(_0x12a761,_0x2ee3b3,_0x1c90e0,_0x58edab){return new Promise(function(_0x4b4415,_0x49d726){var _0x14eba0={'method':_0x024f('0x20'),'headers':_0x2ee3b3,'uri':_0x12a761+_0x024f('0x21')+_0x58edab+_0x024f('0x22')+_0x1c90e0+_0x024f('0x23'),'json':!![]};rp(_0x14eba0)[_0x024f('0xe')](function(_0x3ae7bf){var _0x2230cf=_[_0x024f('0x24')](_0x3ae7bf[_0x024f('0x25')][_0x024f('0x25')],[_0x1c90e0,_0x58edab]);_0x4b4415(_0x2230cf);})['catch'](function(_0x338cb6){_0x49d726(_0x338cb6);});});}function getEndUser(_0x493018,_0xf0bbef,_0x32b158){return function(_0x526048){return new Promise(function(_0x5cff0b,_0x4db515){logger['info'](util[_0x024f('0x26')](_0x024f('0x27'),_0x526048[_0x024f('0x28')]));searchContact(_0x32b158,_0xf0bbef,'mobile_number',_0x526048[_0x024f('0x28')])[_0x024f('0xe')](function(_0x1d6ff7){if(_0x1d6ff7){_0x526048[_0x024f('0x29')]=_0x1d6ff7['id'];logger['info'](_0x024f('0x2a'),_0x526048['endUserId']);return _0x5cff0b(_0x526048);}searchContact(_0x32b158,_0xf0bbef,'work_number',_0x526048[_0x024f('0x28')])[_0x024f('0xe')](function(_0x47a03b){if(_0x47a03b){_0x526048['endUserId']=_0x47a03b['id'];logger[_0x024f('0xc')](_0x024f('0x2b'),_0x526048[_0x024f('0x29')]);return _0x5cff0b(_0x526048);}createEndUser(_0x526048,_0x493018,_0xf0bbef,_0x32b158)[_0x024f('0xe')](function(_0x3461eb){logger[_0x024f('0xc')](_0x024f('0x2c'),_0x3461eb[_0x024f('0x29')]);return _0x5cff0b(_0x3461eb);});});})[_0x024f('0x15')](function(_0x25e8da){_0x4db515(_0x25e8da);});});};}function createEndUser(_0x1db12c,_0x1ef329,_0x2c3224,_0xc341ab){return new Promise(function(_0x1ad4af,_0x89a33d){var _0x3be5b3=moment();var _0x5dd811={'method':_0x024f('0x2d'),'uri':_0xc341ab+_0x024f('0x2e'),'body':{'contact':{'last_name':_0x1db12c[_0x024f('0x28')],'work_number':_0x1db12c['contactNumber'],'mobile_number':_0x1db12c[_0x024f('0x28')],'owner_id':_0x1db12c[_0x024f('0x1b')],'created_at':_0x3be5b3[_0x024f('0x26')](_0x024f('0x2f'))}},'json':!![]};_0x5dd811['headers']=_0x2c3224;logger[_0x024f('0xc')](_0x024f('0x30'));return rp(_0x5dd811)[_0x024f('0xe')](function(_0x352f18){_0x1db12c['endUserId']=_0x352f18[_0x024f('0x31')]['id'];_0x1ad4af(_0x1db12c);})[_0x024f('0x15')](function(_0x19ce93){logger[_0x024f('0x1f')]('['+[_0x1ef329[_0x024f('0x16')]()]+']',_0x19ce93[_0x024f('0x17')]);_0x89a33d(_0x19ce93[_0x024f('0x17')]);});});}function getTicket(_0x16b30f,_0x5c599d,_0x2e30fe,_0x31cbc0,_0x698f1d){return function(_0x4523d3){logger['info'](_0x024f('0x32'));return new Promise(function(_0x36897e,_0x592df2){var _0x479141=moment();var _0x216f63={'method':_0x024f('0x2d'),'uri':_0x2e30fe+_0x024f('0x33'),'body':{'title':intUtil[_0x024f('0x34')](_0x31cbc0[_0x024f('0x35')],_0x698f1d,'\x20'),'description':intUtil[_0x024f('0x34')](_0x31cbc0['Descriptions'],_0x698f1d,'\x0a'),'owner_id':_0x4523d3['userId'],'creater_id':_0x4523d3['adminId'],'targetable_id':_0x4523d3[_0x024f('0x29')],'targetable_type':'Contact','created_at':_0x479141[_0x024f('0x26')](_0x024f('0x2f')),'due_date':_0x479141['add'](0x1e,'m')[_0x024f('0x26')]('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x216f63[_0x024f('0xb')]=_0x5c599d;return rp(_0x216f63)['then'](function(_0x2d79fb){_0x4523d3['ticketId']=_0x2d79fb[_0x024f('0x36')]['id'];logger[_0x024f('0xc')](_0x024f('0x37'),_0x4523d3[_0x024f('0x38')]);_0x36897e(_0x4523d3);})['catch'](function(_0x512ed3){logger[_0x024f('0x1f')]('['+[_0x16b30f[_0x024f('0x16')]()]+']',_0x512ed3[_0x024f('0x17')]);_0x592df2(_0x512ed3[_0x024f('0x17')]);});});};}function emit(_0xb97741,_0x523411,_0x4018f7){var _0x48cc97={'uri':_0xb97741+_0x024f('0x39')+_0x4018f7};io['to'](util[_0x024f('0x26')](_0x024f('0x3a'),_0x523411))[_0x024f('0x3b')](_0x024f('0x3c'),_0x48cc97);}exports['cs']=function(_0x2e99a8,_0x35f1af,_0x33e3f3,_0x476f93,_0x4203a6,_0x3a3fcb,_0x37a92f,_0x163547){var _0x3a13a7={};var _0x2aa6ac={'Authorization':'Token\x20token='+_0x3a3fcb[_0x024f('0x3d')]};_0x3a3fcb[_0x024f('0x3e')]=intUtil['stripTrailingSlash'](_0x3a3fcb['remoteUri']);_0x3a3fcb[_0x024f('0x3f')]=intUtil['stripTrailingSlash'](_0x3a3fcb['serverUrl']);var _0x1c1ce0=_0x3a3fcb[_0x024f('0x3e')];_0x3a13a7['adminEmail']=_0x3a3fcb[_0x024f('0x40')];_0x3a13a7[_0x024f('0x28')]=_0x163547[_0x024f('0x41')]()===_0x024f('0x42')?_0x35f1af[_0x024f('0x43')]:_0x35f1af[_0x024f('0x44')];_0x3a13a7[_0x024f('0x45')]=_0x163547===_0x024f('0x46')||_0x163547===_0x024f('0x47')?_0x024f('0x46'):_0x024f('0x42');if(_0x476f93){_0x3a13a7[_0x024f('0x19')]=_0x476f93[_0x024f('0x11')];}var _0x542a1c=util[_0x024f('0x26')](_0x024f('0x48'),_0x3a3fcb[_0x024f('0x3f')],_0x35f1af[_0x024f('0x49')],md5(_0x35f1af[_0x024f('0x49')]));if(_0x4203a6&&_0x4203a6[_0x024f('0x4a')]){logger[_0x024f('0xc')]('[QUEUE]',_0x024f('0x4b'));_0x35f1af[_0x024f('0x4c')]=_0x542a1c;}else if(_0x37a92f&&_0x37a92f[_0x024f('0x4d')]&&_0x37a92f[_0x024f('0x4d')]!==_0x024f('0x4e')){logger[_0x024f('0xc')](_0x024f('0x4f'),'Recording\x20is\x20enabled!');_0x35f1af[_0x024f('0x4c')]=_0x542a1c;}else{_0x35f1af[_0x024f('0x4c')]='';}return getAdminId(_0x3a13a7,_0x163547,_0x2aa6ac,_0x1c1ce0)[_0x024f('0xe')](getUser(_0x163547,_0x2aa6ac,_0x1c1ce0))[_0x024f('0xe')](getEndUser(_0x163547,_0x2aa6ac,_0x1c1ce0))[_0x024f('0xe')](getTicket(_0x163547,_0x2aa6ac,_0x1c1ce0,_0x33e3f3,_0x35f1af))[_0x024f('0xe')](function(_0x41868f){logger['info'](util['format'](_0x024f('0x50'),_0x41868f[_0x024f('0x38')]));if(_0x163547!==_0x024f('0x47')){logger[_0x024f('0xc')]('['+[_0x163547[_0x024f('0x16')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x1c1ce0,_0x476f93[_0x024f('0x51')],_0x41868f['endUserId']);}})[_0x024f('0x15')](function(_0x4de212){logger[_0x024f('0x1f')]('['+[_0x163547[_0x024f('0x16')]()]+_0x024f('0x52'),util[_0x024f('0x53')](_0x4de212,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0x25c5=['serverUrl','username','outbound','destcalleridnum','callDirection','queue','unmanaged','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','Recording\x20is\x20enabled!','recordingFormat','none','[OUTBOUND]','recordingURL','Displaying\x20task\x20in\x20a\x20new\x20tab...',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','util','moment','bluebird','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','redis','defaults','localhost','socket.io-emitter','GET','/api/selector/owners','headers','Getting\x20admin\x20information','length','adminId','info','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','Getting\x20user\x20list','then','users','agentEmail','Getting\x20user\x20with\x20email','userEmail','email','userId','User\x20found:','Admin\x20selected','adminEmail','/api/lookup?q=','&f=','&entities=contact','find','contacts','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','mobile_number','endUserId','Contact\x20found\x20mobile_number:','work_number','Contact\x20found\x20work_number:','POST','/api/contacts','format','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','getString','Subjects','Descriptions','Contact','add','task','ticketId','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','remoteUri','stripTrailingSlash'];(function(_0x5ec1ab,_0x30e0d4){var _0x59fb33=function(_0x5294c9){while(--_0x5294c9){_0x5ec1ab['push'](_0x5ec1ab['shift']());}};_0x59fb33(++_0x30e0d4);}(_0x25c5,0xc2));var _0x525c=function(_0x467488,_0x38c7ae){_0x467488=_0x467488-0x0;var _0x56107f=_0x25c5[_0x467488];return _0x56107f;};'use strict';var _=require(_0x525c('0x0'));var rp=require('request-promise');var md5=require('md5');var util=require(_0x525c('0x1'));var moment=require(_0x525c('0x2'));var Promise=require(_0x525c('0x3'));var Redis=require(_0x525c('0x4'));var intUtil=require(_0x525c('0x5'));var config=require(_0x525c('0x6'));var logger=require(_0x525c('0x7'))(_0x525c('0x8'));config[_0x525c('0x9')]=_[_0x525c('0xa')](config[_0x525c('0x9')],{'host':_0x525c('0xb'),'port':0x18eb});var io=require(_0x525c('0xc'))(new Redis(config[_0x525c('0x9')]));function getAdminId(_0x32d331,_0xaa4dce,_0x19b7f8,_0x172bd8){return new Promise(function(_0x5e9e15,_0x437071){var _0x22f804=![];var _0x5c34ce={'method':_0x525c('0xd'),'uri':_0x172bd8+_0x525c('0xe'),'json':!![]};_0x5c34ce[_0x525c('0xf')]=_0x19b7f8;logger['info'](_0x525c('0x10'));return rp(_0x5c34ce)['then'](function(_0x363468){if(_0x363468){var _0x40387f=_0x363468['users'];var _0x479754=null;for(_0x479754=0x0;_0x479754<_0x40387f[_0x525c('0x11')];_0x479754++){if(_0x40387f[_0x479754]['email']===_0x32d331['adminEmail']){_0x32d331[_0x525c('0x12')]=_0x40387f[_0x479754]['id'];_0x22f804=!![];}}if(_0x22f804){logger[_0x525c('0x13')](_0x525c('0x14'),_0x32d331['adminId']);_0x5e9e15(_0x32d331);}else{_0x437071({'statusCode':0x194,'message':_0x525c('0x15')});}}else{_0x437071({'statusCode':0x194,'message':_0x525c('0x15')});}})[_0x525c('0x16')](function(_0x1b2146){logger[_0x525c('0x17')]('['+[_0xaa4dce[_0x525c('0x18')]()]+']',_0x1b2146[_0x525c('0x19')]);_0x437071(_0x1b2146);});});}function getUser(_0x3a9f0c,_0x12e08b,_0x40c7e3){return function(_0x41de18){return new Promise(function(_0x7505c2,_0x19c45f){var _0x5d95bd={'method':'GET','uri':_0x40c7e3+'/api/selector/owners','json':!![]};_0x5d95bd['headers']=_0x12e08b;logger[_0x525c('0x13')](_0x525c('0x1a'));return rp(_0x5d95bd)[_0x525c('0x1b')](function(_0x42a3db){if(_0x42a3db){var _0x24a279=_0x42a3db[_0x525c('0x1c')];var _0x9e5c6f=![];var _0x2ddf02=null;if(_0x41de18[_0x525c('0x1d')]!==null){logger[_0x525c('0x13')](_0x525c('0x1e'),_0x41de18[_0x525c('0x1d')]);_0x41de18[_0x525c('0x1f')]=_0x41de18[_0x525c('0x1d')];for(_0x2ddf02=0x0;_0x2ddf02<_0x24a279[_0x525c('0x11')];_0x2ddf02++){if(_0x24a279[_0x2ddf02][_0x525c('0x20')]===_0x41de18[_0x525c('0x1d')]){_0x9e5c6f=!![];_0x41de18[_0x525c('0x21')]=_0x24a279[_0x2ddf02]['id'];logger[_0x525c('0x13')](_0x525c('0x22'),_0x41de18['userId']);}}}if(!_0x9e5c6f){logger['info'](_0x525c('0x23'));_0x41de18[_0x525c('0x1f')]=_0x41de18[_0x525c('0x24')];_0x41de18[_0x525c('0x21')]=_0x41de18['adminId'];_0x9e5c6f=!![];}if(_0x9e5c6f){_0x7505c2(_0x41de18);}else{_0x19c45f({'statusCode':0x194,'message':_0x525c('0x15')});}}else{_0x19c45f({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0x525c('0x16')](function(_0x52f5c1){logger[_0x525c('0x17')]('['+[_0x3a9f0c[_0x525c('0x18')]()]+']',_0x52f5c1['message']);_0x19c45f(_0x52f5c1);});});};}function searchContact(_0x222dc3,_0x2a3bb0,_0x517489,_0x3004f6){return new Promise(function(_0x1421a3,_0x38dad5){var _0x30db30={'method':_0x525c('0xd'),'headers':_0x2a3bb0,'uri':_0x222dc3+_0x525c('0x25')+_0x3004f6+_0x525c('0x26')+_0x517489+_0x525c('0x27'),'json':!![]};rp(_0x30db30)['then'](function(_0x220225){var _0x2488db=_[_0x525c('0x28')](_0x220225[_0x525c('0x29')][_0x525c('0x29')],[_0x517489,_0x3004f6]);_0x1421a3(_0x2488db);})['catch'](function(_0x3a5026){_0x38dad5(_0x3a5026);});});}function getEndUser(_0x56ab37,_0x408cc5,_0x46b7b3){return function(_0x13db53){return new Promise(function(_0x18449b,_0x49037f){logger[_0x525c('0x13')](util['format'](_0x525c('0x2a'),_0x13db53[_0x525c('0x2b')]));searchContact(_0x46b7b3,_0x408cc5,_0x525c('0x2c'),_0x13db53[_0x525c('0x2b')])['then'](function(_0x2d6223){if(_0x2d6223){_0x13db53[_0x525c('0x2d')]=_0x2d6223['id'];logger[_0x525c('0x13')](_0x525c('0x2e'),_0x13db53[_0x525c('0x2d')]);return _0x18449b(_0x13db53);}searchContact(_0x46b7b3,_0x408cc5,_0x525c('0x2f'),_0x13db53[_0x525c('0x2b')])[_0x525c('0x1b')](function(_0x50fb1d){if(_0x50fb1d){_0x13db53[_0x525c('0x2d')]=_0x50fb1d['id'];logger['info'](_0x525c('0x30'),_0x13db53[_0x525c('0x2d')]);return _0x18449b(_0x13db53);}createEndUser(_0x13db53,_0x56ab37,_0x408cc5,_0x46b7b3)[_0x525c('0x1b')](function(_0x197350){logger[_0x525c('0x13')]('Contact\x20created:',_0x197350['endUserId']);return _0x18449b(_0x197350);});});})[_0x525c('0x16')](function(_0x3e8375){_0x49037f(_0x3e8375);});});};}function createEndUser(_0x3baa42,_0x5c1dd5,_0x48d4ff,_0x432bf3){return new Promise(function(_0x3ae88f,_0x52f025){var _0x17f9f5=moment();var _0x305ac4={'method':_0x525c('0x31'),'uri':_0x432bf3+_0x525c('0x32'),'body':{'contact':{'last_name':_0x3baa42[_0x525c('0x2b')],'work_number':_0x3baa42[_0x525c('0x2b')],'mobile_number':_0x3baa42[_0x525c('0x2b')],'owner_id':_0x3baa42[_0x525c('0x21')],'created_at':_0x17f9f5[_0x525c('0x33')](_0x525c('0x34'))}},'json':!![]};_0x305ac4[_0x525c('0xf')]=_0x48d4ff;logger['info'](_0x525c('0x35'));return rp(_0x305ac4)['then'](function(_0x5675a5){_0x3baa42[_0x525c('0x2d')]=_0x5675a5[_0x525c('0x36')]['id'];_0x3ae88f(_0x3baa42);})['catch'](function(_0x47116d){logger[_0x525c('0x17')]('['+[_0x5c1dd5['toUpperCase']()]+']',_0x47116d[_0x525c('0x19')]);_0x52f025(_0x47116d[_0x525c('0x19')]);});});}function getTicket(_0x168d63,_0x38f44b,_0x41a2a6,_0x50c7d1,_0x5a5ef1){return function(_0x27c1bf){logger[_0x525c('0x13')](_0x525c('0x37'));return new Promise(function(_0x3568c8,_0xccb6fd){var _0x323662=moment();var _0x1c1f6a={'method':_0x525c('0x31'),'uri':_0x41a2a6+'/api/tasks','body':{'title':intUtil[_0x525c('0x38')](_0x50c7d1[_0x525c('0x39')],_0x5a5ef1,'\x20'),'description':intUtil[_0x525c('0x38')](_0x50c7d1[_0x525c('0x3a')],_0x5a5ef1,'\x0a'),'owner_id':_0x27c1bf[_0x525c('0x21')],'creater_id':_0x27c1bf[_0x525c('0x12')],'targetable_id':_0x27c1bf[_0x525c('0x2d')],'targetable_type':_0x525c('0x3b'),'created_at':_0x323662[_0x525c('0x33')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x323662[_0x525c('0x3c')](0x1e,'m')[_0x525c('0x33')]('YYYY-MM-DDTHH:mm:ss')},'json':!![]};_0x1c1f6a['headers']=_0x38f44b;return rp(_0x1c1f6a)['then'](function(_0x53f5eb){_0x27c1bf['ticketId']=_0x53f5eb[_0x525c('0x3d')]['id'];logger[_0x525c('0x13')]('Task\x20created:',_0x27c1bf[_0x525c('0x3e')]);_0x3568c8(_0x27c1bf);})[_0x525c('0x16')](function(_0x279df7){logger[_0x525c('0x17')]('['+[_0x168d63[_0x525c('0x18')]()]+']',_0x279df7['message']);_0xccb6fd(_0x279df7[_0x525c('0x19')]);});});};}function emit(_0x3dc30d,_0x502e9e,_0x51512b){var _0x54e426={'uri':_0x3dc30d+'/contacts/'+_0x51512b};io['to'](util[_0x525c('0x33')](_0x525c('0x3f'),_0x502e9e))[_0x525c('0x40')](_0x525c('0x41'),_0x54e426);}exports['cs']=function(_0x45c8dc,_0x285da5,_0x2bc576,_0xb0ef8f,_0x4f6852,_0x2c1d98,_0x2f0a81,_0x929c6c){var _0x15a8b4={};var _0x13ee49={'Authorization':_0x525c('0x42')+_0x2c1d98[_0x525c('0x43')]};_0x2c1d98[_0x525c('0x44')]=intUtil[_0x525c('0x45')](_0x2c1d98[_0x525c('0x44')]);_0x2c1d98[_0x525c('0x46')]=intUtil[_0x525c('0x45')](_0x2c1d98[_0x525c('0x46')]);var _0x326b35=_0x2c1d98[_0x525c('0x44')];_0x15a8b4[_0x525c('0x24')]=_0x2c1d98[_0x525c('0x47')];_0x15a8b4[_0x525c('0x2b')]=_0x929c6c['toLowerCase']()===_0x525c('0x48')?_0x285da5[_0x525c('0x49')]:_0x285da5['calleridnum'];_0x15a8b4[_0x525c('0x4a')]=_0x929c6c===_0x525c('0x4b')||_0x929c6c===_0x525c('0x4c')?_0x525c('0x4b'):_0x525c('0x48');if(_0xb0ef8f){_0x15a8b4['agentEmail']=_0xb0ef8f[_0x525c('0x20')];}var _0x3ee6b7=util[_0x525c('0x33')](_0x525c('0x4d'),_0x2c1d98[_0x525c('0x46')],_0x285da5[_0x525c('0x4e')],md5(_0x285da5[_0x525c('0x4e')]));if(_0x4f6852&&_0x4f6852[_0x525c('0x4f')]){logger[_0x525c('0x13')]('[QUEUE]',_0x525c('0x50'));_0x285da5['recordingURL']=_0x3ee6b7;}else if(_0x2f0a81&&_0x2f0a81[_0x525c('0x51')]&&_0x2f0a81[_0x525c('0x51')]!==_0x525c('0x52')){logger[_0x525c('0x13')](_0x525c('0x53'),_0x525c('0x50'));_0x285da5[_0x525c('0x54')]=_0x3ee6b7;}else{_0x285da5[_0x525c('0x54')]='';}return getAdminId(_0x15a8b4,_0x929c6c,_0x13ee49,_0x326b35)[_0x525c('0x1b')](getUser(_0x929c6c,_0x13ee49,_0x326b35))['then'](getEndUser(_0x929c6c,_0x13ee49,_0x326b35))[_0x525c('0x1b')](getTicket(_0x929c6c,_0x13ee49,_0x326b35,_0x2bc576,_0x285da5))[_0x525c('0x1b')](function(_0x1d8009){logger[_0x525c('0x13')](util[_0x525c('0x33')]('The\x20ticket\x20ID\x20is:\x20%s',_0x1d8009[_0x525c('0x3e')]));if(_0x929c6c!=='unmanaged'){logger[_0x525c('0x13')]('['+[_0x929c6c[_0x525c('0x18')]()]+']',_0x525c('0x55'));emit(_0x326b35,_0xb0ef8f['name'],_0x1d8009[_0x525c('0x2d')]);}})[_0x525c('0x16')](function(_0x5a95e2){logger[_0x525c('0x17')]('['+[_0x929c6c['toUpperCase']()]+_0x525c('0x56'),util[_0x525c('0x57')](_0x5a95e2,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file