Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index ce3298c..ba6b0d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x23f4=['Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','agentEmail','userEmail','length','userId','User\x20found:','Admin\x20selected','/api/lookup?q=','&entities=contact','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','mobile_number','endUserId','Contact\x20found\x20mobile_number:','work_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','Descriptions','add','ticketId','task','Task\x20created:','/contacts/','user:%s','emit','trigger:browser:url','Token\x20token=','apiKey','stripTrailingSlash','serverUrl','remoteUri','username','toLowerCase','destcalleridnum','calleridnum','callDirection','queue','unmanaged','outbound','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','[OUTBOUND]','Displaying\x20task\x20in\x20a\x20new\x20tab...',']\x20Error\x20running\x20Freshsales\x20integration','inspect','request-promise','moment','bluebird','ioredis','./util','../../../../config/environment','../../../../config/logger','freshsales','redis','defaults','localhost','socket.io-emitter','GET','/api/selector/owners','headers','info','then','users','email','adminEmail','adminId','Admin\x20found:'];(function(_0xf3c800,_0x152d3d){var _0x40eee9=function(_0x24b3a8){while(--_0x24b3a8){_0xf3c800['push'](_0xf3c800['shift']());}};_0x40eee9(++_0x152d3d);}(_0x23f4,0x1ee));var _0x423f=function(_0x19d6fe,_0x26ef55){_0x19d6fe=_0x19d6fe-0x0;var _0x467fa7=_0x23f4[_0x19d6fe];return _0x467fa7;};'use strict';var _=require('lodash');var rp=require(_0x423f('0x0'));var md5=require('md5');var util=require('util');var moment=require(_0x423f('0x1'));var Promise=require(_0x423f('0x2'));var Redis=require(_0x423f('0x3'));var intUtil=require(_0x423f('0x4'));var config=require(_0x423f('0x5'));var logger=require(_0x423f('0x6'))(_0x423f('0x7'));config[_0x423f('0x8')]=_[_0x423f('0x9')](config['redis'],{'host':_0x423f('0xa'),'port':0x18eb});var io=require(_0x423f('0xb'))(new Redis(config['redis']));function getAdminId(_0x727b4e,_0x416fb1,_0xe4b068,_0x50301a){return new Promise(function(_0x5b5ee6,_0x4b8a90){var _0x4143a0=![];var _0x481c41={'method':_0x423f('0xc'),'uri':_0x50301a+_0x423f('0xd'),'json':!![]};_0x481c41[_0x423f('0xe')]=_0xe4b068;logger[_0x423f('0xf')]('Getting\x20admin\x20information');return rp(_0x481c41)[_0x423f('0x10')](function(_0x125f2c){if(_0x125f2c){var _0x3b6a1c=_0x125f2c[_0x423f('0x11')];var _0x216360=null;for(_0x216360=0x0;_0x216360<_0x3b6a1c['length'];_0x216360++){if(_0x3b6a1c[_0x216360][_0x423f('0x12')]===_0x727b4e[_0x423f('0x13')]){_0x727b4e[_0x423f('0x14')]=_0x3b6a1c[_0x216360]['id'];_0x4143a0=!![];}}if(_0x4143a0){logger[_0x423f('0xf')](_0x423f('0x15'),_0x727b4e[_0x423f('0x14')]);_0x5b5ee6(_0x727b4e);}else{_0x4b8a90({'statusCode':0x194,'message':_0x423f('0x16')});}}else{_0x4b8a90({'statusCode':0x194,'message':_0x423f('0x16')});}})[_0x423f('0x17')](function(_0x235c86){logger[_0x423f('0x18')]('['+[_0x416fb1[_0x423f('0x19')]()]+']',_0x235c86[_0x423f('0x1a')]);_0x4b8a90(_0x235c86);});});}function getUser(_0x1fef4d,_0x9d1487,_0x3ed5ce){return function(_0x3fd56d){return new Promise(function(_0x34e968,_0x26b6d1){var _0x5424e6={'method':_0x423f('0xc'),'uri':_0x3ed5ce+'/api/selector/owners','json':!![]};_0x5424e6['headers']=_0x9d1487;logger[_0x423f('0xf')]('Getting\x20user\x20list');return rp(_0x5424e6)[_0x423f('0x10')](function(_0xd7b80e){if(_0xd7b80e){var _0x4f6960=_0xd7b80e[_0x423f('0x11')];var _0x1fc317=![];var _0x56c21e=null;if(_0x3fd56d[_0x423f('0x1b')]!==null){logger[_0x423f('0xf')]('Getting\x20user\x20with\x20email',_0x3fd56d[_0x423f('0x1b')]);_0x3fd56d[_0x423f('0x1c')]=_0x3fd56d['agentEmail'];for(_0x56c21e=0x0;_0x56c21e<_0x4f6960[_0x423f('0x1d')];_0x56c21e++){if(_0x4f6960[_0x56c21e]['email']===_0x3fd56d[_0x423f('0x1b')]){_0x1fc317=!![];_0x3fd56d[_0x423f('0x1e')]=_0x4f6960[_0x56c21e]['id'];logger[_0x423f('0xf')](_0x423f('0x1f'),_0x3fd56d[_0x423f('0x1e')]);}}}if(!_0x1fc317){logger[_0x423f('0xf')](_0x423f('0x20'));_0x3fd56d[_0x423f('0x1c')]=_0x3fd56d[_0x423f('0x13')];_0x3fd56d[_0x423f('0x1e')]=_0x3fd56d[_0x423f('0x14')];_0x1fc317=!![];}if(_0x1fc317){_0x34e968(_0x3fd56d);}else{_0x26b6d1({'statusCode':0x194,'message':_0x423f('0x16')});}}else{_0x26b6d1({'statusCode':0x194,'message':_0x423f('0x16')});}})[_0x423f('0x17')](function(_0x4a98f2){logger[_0x423f('0x18')]('['+[_0x1fef4d[_0x423f('0x19')]()]+']',_0x4a98f2[_0x423f('0x1a')]);_0x26b6d1(_0x4a98f2);});});};}function searchContact(_0x593f9d,_0x4fc44d,_0x30a9bc,_0x496c25){return new Promise(function(_0x323c61,_0x4c2f21){var _0x5882ed={'method':_0x423f('0xc'),'headers':_0x4fc44d,'uri':_0x593f9d+_0x423f('0x21')+_0x496c25+'&f='+_0x30a9bc+_0x423f('0x22'),'json':!![]};rp(_0x5882ed)[_0x423f('0x10')](function(_0x3022a5){var _0x1da775=_['find'](_0x3022a5[_0x423f('0x23')][_0x423f('0x23')],[_0x30a9bc,_0x496c25]);_0x323c61(_0x1da775);})[_0x423f('0x17')](function(_0x15c0e8){_0x4c2f21(_0x15c0e8);});});}function getEndUser(_0x5616ab,_0x6145ff,_0x150846){return function(_0x200cfa){return new Promise(function(_0x8e7bcb,_0x341728){logger[_0x423f('0xf')](util[_0x423f('0x24')](_0x423f('0x25'),_0x200cfa[_0x423f('0x26')]));searchContact(_0x150846,_0x6145ff,_0x423f('0x27'),_0x200cfa['contactNumber'])[_0x423f('0x10')](function(_0x20377b){if(_0x20377b){_0x200cfa[_0x423f('0x28')]=_0x20377b['id'];logger['info'](_0x423f('0x29'),_0x200cfa['endUserId']);return _0x8e7bcb(_0x200cfa);}searchContact(_0x150846,_0x6145ff,_0x423f('0x2a'),_0x200cfa[_0x423f('0x26')])[_0x423f('0x10')](function(_0x40ee34){if(_0x40ee34){_0x200cfa[_0x423f('0x28')]=_0x40ee34['id'];logger['info']('Contact\x20found\x20work_number:',_0x200cfa[_0x423f('0x28')]);return _0x8e7bcb(_0x200cfa);}createEndUser(_0x200cfa,_0x5616ab,_0x6145ff,_0x150846)[_0x423f('0x10')](function(_0x239a49){logger[_0x423f('0xf')](_0x423f('0x2b'),_0x239a49[_0x423f('0x28')]);return _0x8e7bcb(_0x239a49);});});})[_0x423f('0x17')](function(_0x183665){_0x341728(_0x183665);});});};}function createEndUser(_0xd99eb0,_0x2bc0b9,_0x3aeb17,_0x38086d){return new Promise(function(_0x8ffb84,_0x4f6fdf){var _0x5bd9b2=moment();var _0x382f91={'method':_0x423f('0x2c'),'uri':_0x38086d+_0x423f('0x2d'),'body':{'contact':{'last_name':_0xd99eb0[_0x423f('0x26')],'work_number':_0xd99eb0[_0x423f('0x26')],'mobile_number':_0xd99eb0['contactNumber'],'owner_id':_0xd99eb0[_0x423f('0x1e')],'created_at':_0x5bd9b2[_0x423f('0x24')](_0x423f('0x2e'))}},'json':!![]};_0x382f91[_0x423f('0xe')]=_0x3aeb17;logger[_0x423f('0xf')](_0x423f('0x2f'));return rp(_0x382f91)[_0x423f('0x10')](function(_0x1d280f){_0xd99eb0[_0x423f('0x28')]=_0x1d280f[_0x423f('0x30')]['id'];_0x8ffb84(_0xd99eb0);})['catch'](function(_0x55e279){logger[_0x423f('0x18')]('['+[_0x2bc0b9[_0x423f('0x19')]()]+']',_0x55e279[_0x423f('0x1a')]);_0x4f6fdf(_0x55e279[_0x423f('0x1a')]);});});}function getTicket(_0x2316e8,_0x20660e,_0x56b564,_0x36ad04,_0x2af0bf){return function(_0x44e3a7){logger[_0x423f('0xf')](_0x423f('0x31'));return new Promise(function(_0x69e312,_0x21b720){var _0x1919aa=moment();var _0x518443={'method':_0x423f('0x2c'),'uri':_0x56b564+_0x423f('0x32'),'body':{'title':intUtil[_0x423f('0x33')](_0x36ad04[_0x423f('0x34')],_0x2af0bf,'\x20'),'description':intUtil[_0x423f('0x33')](_0x36ad04[_0x423f('0x35')],_0x2af0bf,'\x0a'),'owner_id':_0x44e3a7[_0x423f('0x1e')],'creater_id':_0x44e3a7[_0x423f('0x14')],'targetable_id':_0x44e3a7[_0x423f('0x28')],'targetable_type':'Contact','created_at':_0x1919aa[_0x423f('0x24')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x1919aa[_0x423f('0x36')](0x1e,'m')[_0x423f('0x24')](_0x423f('0x2e'))},'json':!![]};_0x518443[_0x423f('0xe')]=_0x20660e;return rp(_0x518443)[_0x423f('0x10')](function(_0x3ad48c){_0x44e3a7[_0x423f('0x37')]=_0x3ad48c[_0x423f('0x38')]['id'];logger[_0x423f('0xf')](_0x423f('0x39'),_0x44e3a7[_0x423f('0x37')]);_0x69e312(_0x44e3a7);})[_0x423f('0x17')](function(_0x25612b){logger[_0x423f('0x18')]('['+[_0x2316e8[_0x423f('0x19')]()]+']',_0x25612b[_0x423f('0x1a')]);_0x21b720(_0x25612b[_0x423f('0x1a')]);});});};}function emit(_0x2715cf,_0x165a8a,_0x2145a5){var _0x580db1={'uri':_0x2715cf+_0x423f('0x3a')+_0x2145a5};io['to'](util['format'](_0x423f('0x3b'),_0x165a8a))[_0x423f('0x3c')](_0x423f('0x3d'),_0x580db1);}exports['cs']=function(_0x37035a,_0x57f5d6,_0x10bad3,_0x221b38,_0x265440,_0x20f72c,_0x471c95,_0x31b88e){var _0x2dcbec={};var _0x489894={'Authorization':_0x423f('0x3e')+_0x20f72c[_0x423f('0x3f')]};_0x20f72c['remoteUri']=intUtil[_0x423f('0x40')](_0x20f72c['remoteUri']);_0x20f72c[_0x423f('0x41')]=intUtil['stripTrailingSlash'](_0x20f72c['serverUrl']);var _0x286159=_0x20f72c[_0x423f('0x42')];_0x2dcbec[_0x423f('0x13')]=_0x20f72c[_0x423f('0x43')];_0x2dcbec['contactNumber']=_0x31b88e[_0x423f('0x44')]()==='outbound'?_0x57f5d6[_0x423f('0x45')]:_0x57f5d6[_0x423f('0x46')];_0x2dcbec[_0x423f('0x47')]=_0x31b88e===_0x423f('0x48')||_0x31b88e===_0x423f('0x49')?_0x423f('0x48'):_0x423f('0x4a');if(_0x221b38){_0x2dcbec[_0x423f('0x1b')]=_0x221b38[_0x423f('0x12')];}var _0x4e3003=util[_0x423f('0x24')](_0x423f('0x4b'),_0x20f72c['serverUrl'],_0x57f5d6[_0x423f('0x4c')],md5(_0x57f5d6['uniqueid']));if(_0x265440&&_0x265440[_0x423f('0x4d')]){logger[_0x423f('0xf')](_0x423f('0x4e'),_0x423f('0x4f'));_0x57f5d6[_0x423f('0x50')]=_0x4e3003;}else if(_0x471c95&&_0x471c95[_0x423f('0x51')]&&_0x471c95['recordingFormat']!=='none'){logger[_0x423f('0xf')](_0x423f('0x52'),_0x423f('0x4f'));_0x57f5d6[_0x423f('0x50')]=_0x4e3003;}else{_0x57f5d6[_0x423f('0x50')]='';}return getAdminId(_0x2dcbec,_0x31b88e,_0x489894,_0x286159)[_0x423f('0x10')](getUser(_0x31b88e,_0x489894,_0x286159))[_0x423f('0x10')](getEndUser(_0x31b88e,_0x489894,_0x286159))[_0x423f('0x10')](getTicket(_0x31b88e,_0x489894,_0x286159,_0x10bad3,_0x57f5d6))[_0x423f('0x10')](function(_0x5cec20){logger[_0x423f('0xf')](util[_0x423f('0x24')]('The\x20ticket\x20ID\x20is:\x20%s',_0x5cec20[_0x423f('0x37')]));if(_0x31b88e!=='unmanaged'){logger[_0x423f('0xf')]('['+[_0x31b88e[_0x423f('0x19')]()]+']',_0x423f('0x53'));emit(_0x286159,_0x221b38['name'],_0x5cec20['endUserId']);}})[_0x423f('0x17')](function(_0x31a86c){logger[_0x423f('0x18')]('['+[_0x31b88e['toUpperCase']()]+_0x423f('0x54'),util[_0x423f('0x55')](_0x31a86c,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file
+var _0xfc76=['ticketId','unmanaged','Displaying\x20task\x20in\x20a\x20new\x20tab...','name',']\x20Error\x20running\x20Freshsales\x20integration','request-promise','md5','util','moment','bluebird','./util','../../../../config/environment','freshsales','defaults','redis','localhost','GET','/api/selector/owners','headers','info','then','users','email','adminEmail','Admin\x20found:','adminId','catch','toUpperCase','message','Getting\x20user\x20list','agentEmail','length','userId','User\x20found:','Admin\x20selected','userEmail','Requested\x20Resource\x20not\x20Found','error','/api/lookup?q=','&f=','&entities=contact','contacts','format','contactNumber','endUserId','Contact\x20found\x20mobile_number:','work_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','Descriptions','Contact','add','task','/contacts/','user:%s','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','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','[OUTBOUND]','The\x20ticket\x20ID\x20is:\x20%s'];(function(_0x35f976,_0x4bd8f7){var _0x5b1ef3=function(_0x3cdca4){while(--_0x3cdca4){_0x35f976['push'](_0x35f976['shift']());}};_0x5b1ef3(++_0x4bd8f7);}(_0xfc76,0xb5));var _0x6fc7=function(_0xb3bcd6,_0xb1f7a6){_0xb3bcd6=_0xb3bcd6-0x0;var _0x10467c=_0xfc76[_0xb3bcd6];return _0x10467c;};'use strict';var _=require('lodash');var rp=require(_0x6fc7('0x0'));var md5=require(_0x6fc7('0x1'));var util=require(_0x6fc7('0x2'));var moment=require(_0x6fc7('0x3'));var Promise=require(_0x6fc7('0x4'));var Redis=require('ioredis');var intUtil=require(_0x6fc7('0x5'));var config=require(_0x6fc7('0x6'));var logger=require('../../../../config/logger')(_0x6fc7('0x7'));config['redis']=_[_0x6fc7('0x8')](config[_0x6fc7('0x9')],{'host':_0x6fc7('0xa'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6fc7('0x9')]));function getAdminId(_0x407b0a,_0x347c00,_0x1d4fee,_0x36cb16){return new Promise(function(_0x23d12f,_0x4de75e){var _0xdddc47=![];var _0x61730a={'method':_0x6fc7('0xb'),'uri':_0x36cb16+_0x6fc7('0xc'),'json':!![]};_0x61730a[_0x6fc7('0xd')]=_0x1d4fee;logger[_0x6fc7('0xe')]('Getting\x20admin\x20information');return rp(_0x61730a)[_0x6fc7('0xf')](function(_0x19cc08){if(_0x19cc08){var _0x5cd139=_0x19cc08[_0x6fc7('0x10')];var _0x2c32b8=null;for(_0x2c32b8=0x0;_0x2c32b8<_0x5cd139['length'];_0x2c32b8++){if(_0x5cd139[_0x2c32b8][_0x6fc7('0x11')]===_0x407b0a[_0x6fc7('0x12')]){_0x407b0a['adminId']=_0x5cd139[_0x2c32b8]['id'];_0xdddc47=!![];}}if(_0xdddc47){logger[_0x6fc7('0xe')](_0x6fc7('0x13'),_0x407b0a[_0x6fc7('0x14')]);_0x23d12f(_0x407b0a);}else{_0x4de75e({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}else{_0x4de75e({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0x6fc7('0x15')](function(_0x45d585){logger['error']('['+[_0x347c00[_0x6fc7('0x16')]()]+']',_0x45d585[_0x6fc7('0x17')]);_0x4de75e(_0x45d585);});});}function getUser(_0x124cd6,_0x41269a,_0x51a886){return function(_0x816704){return new Promise(function(_0x69ea70,_0x280c69){var _0x62ec76={'method':_0x6fc7('0xb'),'uri':_0x51a886+_0x6fc7('0xc'),'json':!![]};_0x62ec76['headers']=_0x41269a;logger[_0x6fc7('0xe')](_0x6fc7('0x18'));return rp(_0x62ec76)[_0x6fc7('0xf')](function(_0x3bd771){if(_0x3bd771){var _0x13f5f8=_0x3bd771['users'];var _0x277f9e=![];var _0x2427a=null;if(_0x816704['agentEmail']!==null){logger[_0x6fc7('0xe')]('Getting\x20user\x20with\x20email',_0x816704[_0x6fc7('0x19')]);_0x816704['userEmail']=_0x816704[_0x6fc7('0x19')];for(_0x2427a=0x0;_0x2427a<_0x13f5f8[_0x6fc7('0x1a')];_0x2427a++){if(_0x13f5f8[_0x2427a][_0x6fc7('0x11')]===_0x816704['agentEmail']){_0x277f9e=!![];_0x816704[_0x6fc7('0x1b')]=_0x13f5f8[_0x2427a]['id'];logger['info'](_0x6fc7('0x1c'),_0x816704[_0x6fc7('0x1b')]);}}}if(!_0x277f9e){logger[_0x6fc7('0xe')](_0x6fc7('0x1d'));_0x816704[_0x6fc7('0x1e')]=_0x816704[_0x6fc7('0x12')];_0x816704[_0x6fc7('0x1b')]=_0x816704[_0x6fc7('0x14')];_0x277f9e=!![];}if(_0x277f9e){_0x69ea70(_0x816704);}else{_0x280c69({'statusCode':0x194,'message':_0x6fc7('0x1f')});}}else{_0x280c69({'statusCode':0x194,'message':_0x6fc7('0x1f')});}})[_0x6fc7('0x15')](function(_0x426872){logger[_0x6fc7('0x20')]('['+[_0x124cd6[_0x6fc7('0x16')]()]+']',_0x426872[_0x6fc7('0x17')]);_0x280c69(_0x426872);});});};}function searchContact(_0x5880cc,_0x266af9,_0x3053b1,_0x168c87){return new Promise(function(_0x82c8cd,_0x5c1fd3){var _0xfff989={'method':_0x6fc7('0xb'),'headers':_0x266af9,'uri':_0x5880cc+_0x6fc7('0x21')+_0x168c87+_0x6fc7('0x22')+_0x3053b1+_0x6fc7('0x23'),'json':!![]};rp(_0xfff989)[_0x6fc7('0xf')](function(_0x367b37){var _0x2428c9=_['find'](_0x367b37['contacts'][_0x6fc7('0x24')],[_0x3053b1,_0x168c87]);_0x82c8cd(_0x2428c9);})[_0x6fc7('0x15')](function(_0x3e796a){_0x5c1fd3(_0x3e796a);});});}function getEndUser(_0x2ce491,_0x3f89f2,_0x3185ee){return function(_0x527f29){return new Promise(function(_0x278f8f,_0xbf7528){logger[_0x6fc7('0xe')](util[_0x6fc7('0x25')]('Searching\x20contact\x20with\x20phone\x20%s',_0x527f29['contactNumber']));searchContact(_0x3185ee,_0x3f89f2,'mobile_number',_0x527f29[_0x6fc7('0x26')])[_0x6fc7('0xf')](function(_0x2fd248){if(_0x2fd248){_0x527f29[_0x6fc7('0x27')]=_0x2fd248['id'];logger[_0x6fc7('0xe')](_0x6fc7('0x28'),_0x527f29[_0x6fc7('0x27')]);return _0x278f8f(_0x527f29);}searchContact(_0x3185ee,_0x3f89f2,_0x6fc7('0x29'),_0x527f29[_0x6fc7('0x26')])['then'](function(_0x13c800){if(_0x13c800){_0x527f29['endUserId']=_0x13c800['id'];logger[_0x6fc7('0xe')](_0x6fc7('0x2a'),_0x527f29[_0x6fc7('0x27')]);return _0x278f8f(_0x527f29);}createEndUser(_0x527f29,_0x2ce491,_0x3f89f2,_0x3185ee)[_0x6fc7('0xf')](function(_0x52aea5){logger[_0x6fc7('0xe')](_0x6fc7('0x2b'),_0x52aea5[_0x6fc7('0x27')]);return _0x278f8f(_0x52aea5);});});})[_0x6fc7('0x15')](function(_0x5717cd){_0xbf7528(_0x5717cd);});});};}function createEndUser(_0x11167e,_0x5f1c2e,_0xec700a,_0x59e181){return new Promise(function(_0x5c9e12,_0x5549aa){var _0x40f328=moment();var _0x516580={'method':_0x6fc7('0x2c'),'uri':_0x59e181+_0x6fc7('0x2d'),'body':{'contact':{'last_name':_0x11167e[_0x6fc7('0x26')],'work_number':_0x11167e[_0x6fc7('0x26')],'mobile_number':_0x11167e[_0x6fc7('0x26')],'owner_id':_0x11167e[_0x6fc7('0x1b')],'created_at':_0x40f328[_0x6fc7('0x25')](_0x6fc7('0x2e'))}},'json':!![]};_0x516580[_0x6fc7('0xd')]=_0xec700a;logger[_0x6fc7('0xe')](_0x6fc7('0x2f'));return rp(_0x516580)[_0x6fc7('0xf')](function(_0x3c652e){_0x11167e[_0x6fc7('0x27')]=_0x3c652e[_0x6fc7('0x30')]['id'];_0x5c9e12(_0x11167e);})[_0x6fc7('0x15')](function(_0x306d21){logger[_0x6fc7('0x20')]('['+[_0x5f1c2e['toUpperCase']()]+']',_0x306d21['message']);_0x5549aa(_0x306d21[_0x6fc7('0x17')]);});});}function getTicket(_0x120627,_0x26e733,_0x4336b1,_0x584fb6,_0x43aadf){return function(_0x377205){logger[_0x6fc7('0xe')](_0x6fc7('0x31'));return new Promise(function(_0x66856e,_0x4786ee){var _0x2056c0=moment();var _0x4754da={'method':_0x6fc7('0x2c'),'uri':_0x4336b1+_0x6fc7('0x32'),'body':{'title':intUtil[_0x6fc7('0x33')](_0x584fb6[_0x6fc7('0x34')],_0x43aadf,'\x20'),'description':intUtil['getString'](_0x584fb6[_0x6fc7('0x35')],_0x43aadf,'\x0a'),'owner_id':_0x377205[_0x6fc7('0x1b')],'creater_id':_0x377205['adminId'],'targetable_id':_0x377205[_0x6fc7('0x27')],'targetable_type':_0x6fc7('0x36'),'created_at':_0x2056c0[_0x6fc7('0x25')](_0x6fc7('0x2e')),'due_date':_0x2056c0[_0x6fc7('0x37')](0x1e,'m')[_0x6fc7('0x25')](_0x6fc7('0x2e'))},'json':!![]};_0x4754da[_0x6fc7('0xd')]=_0x26e733;return rp(_0x4754da)[_0x6fc7('0xf')](function(_0x1a727d){_0x377205['ticketId']=_0x1a727d[_0x6fc7('0x38')]['id'];logger[_0x6fc7('0xe')]('Task\x20created:',_0x377205['ticketId']);_0x66856e(_0x377205);})[_0x6fc7('0x15')](function(_0x38ba18){logger[_0x6fc7('0x20')]('['+[_0x120627['toUpperCase']()]+']',_0x38ba18[_0x6fc7('0x17')]);_0x4786ee(_0x38ba18[_0x6fc7('0x17')]);});});};}function emit(_0x53e631,_0x12d65f,_0x5c1e87){var _0x31374f={'uri':_0x53e631+_0x6fc7('0x39')+_0x5c1e87};io['to'](util[_0x6fc7('0x25')](_0x6fc7('0x3a'),_0x12d65f))[_0x6fc7('0x3b')](_0x6fc7('0x3c'),_0x31374f);}exports['cs']=function(_0x357d7a,_0x24df1f,_0x237c06,_0x5e08c0,_0x4a7ce1,_0x4f4266,_0x5734d8,_0x22a0c5){var _0x5d4d40={};var _0x3357f9={'Authorization':_0x6fc7('0x3d')+_0x4f4266[_0x6fc7('0x3e')]};_0x4f4266[_0x6fc7('0x3f')]=intUtil[_0x6fc7('0x40')](_0x4f4266[_0x6fc7('0x3f')]);_0x4f4266['serverUrl']=intUtil[_0x6fc7('0x40')](_0x4f4266[_0x6fc7('0x41')]);var _0x515b6e=_0x4f4266[_0x6fc7('0x3f')];_0x5d4d40[_0x6fc7('0x12')]=_0x4f4266[_0x6fc7('0x42')];_0x5d4d40[_0x6fc7('0x26')]=_0x22a0c5[_0x6fc7('0x43')]()===_0x6fc7('0x44')?_0x24df1f[_0x6fc7('0x45')]:_0x24df1f[_0x6fc7('0x46')];_0x5d4d40[_0x6fc7('0x47')]=_0x22a0c5===_0x6fc7('0x48')||_0x22a0c5==='unmanaged'?_0x6fc7('0x48'):_0x6fc7('0x44');if(_0x5e08c0){_0x5d4d40[_0x6fc7('0x19')]=_0x5e08c0['email'];}var _0x44105e=util['format'](_0x6fc7('0x49'),_0x4f4266['serverUrl'],_0x24df1f[_0x6fc7('0x4a')],md5(_0x24df1f[_0x6fc7('0x4a')]));if(_0x4a7ce1&&_0x4a7ce1[_0x6fc7('0x4b')]){logger[_0x6fc7('0xe')](_0x6fc7('0x4c'),_0x6fc7('0x4d'));_0x24df1f[_0x6fc7('0x4e')]=_0x44105e;}else if(_0x5734d8&&_0x5734d8[_0x6fc7('0x4f')]&&_0x5734d8['recordingFormat']!==_0x6fc7('0x50')){logger[_0x6fc7('0xe')](_0x6fc7('0x51'),_0x6fc7('0x4d'));_0x24df1f[_0x6fc7('0x4e')]=_0x44105e;}else{_0x24df1f['recordingURL']='';}return getAdminId(_0x5d4d40,_0x22a0c5,_0x3357f9,_0x515b6e)[_0x6fc7('0xf')](getUser(_0x22a0c5,_0x3357f9,_0x515b6e))[_0x6fc7('0xf')](getEndUser(_0x22a0c5,_0x3357f9,_0x515b6e))[_0x6fc7('0xf')](getTicket(_0x22a0c5,_0x3357f9,_0x515b6e,_0x237c06,_0x24df1f))[_0x6fc7('0xf')](function(_0x1927d6){logger[_0x6fc7('0xe')](util[_0x6fc7('0x25')](_0x6fc7('0x52'),_0x1927d6[_0x6fc7('0x53')]));if(_0x22a0c5!==_0x6fc7('0x54')){logger[_0x6fc7('0xe')]('['+[_0x22a0c5['toUpperCase']()]+']',_0x6fc7('0x55'));emit(_0x515b6e,_0x5e08c0[_0x6fc7('0x56')],_0x1927d6[_0x6fc7('0x27')]);}})[_0x6fc7('0x15')](function(_0x4006a3){logger[_0x6fc7('0x20')]('['+[_0x22a0c5[_0x6fc7('0x16')]()]+_0x6fc7('0x57'),util['inspect'](_0x4006a3,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file