Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index cd48d05..ba6b0d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7bc2=['getString','Subjects','Contact','add','ticketId','task','Task\x20created:','/contacts/','user:%s','trigger:browser:url','Token\x20token=','apiKey','stripTrailingSlash','serverUrl','remoteUri','outbound','callDirection','queue','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','Recording\x20is\x20enabled!','recordingFormat','none','recordingURL','The\x20ticket\x20ID\x20is:\x20%s','name',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','request-promise','util','moment','bluebird','./util','../../../../config/environment','redis','defaults','localhost','socket.io-emitter','GET','/api/selector/owners','headers','info','Getting\x20admin\x20information','users','email','adminId','Requested\x20Resource\x20not\x20Found','catch','error','message','Getting\x20user\x20list','agentEmail','Getting\x20user\x20with\x20email','userEmail','length','userId','User\x20found:','Admin\x20selected','adminEmail','toUpperCase','/api/contacts/filters','then','filters','forEach','All\x20Contacts','Getting\x20contact\x20list','/api/contacts/view/','contactNumber','find','mobile_number','endUserId','Contact\x20found:','Contact\x20created:','POST','/api/contacts','format','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','/api/tasks'];(function(_0x1fb5a6,_0x2b1312){var _0x39d126=function(_0x5b7a7c){while(--_0x5b7a7c){_0x1fb5a6['push'](_0x1fb5a6['shift']());}};_0x39d126(++_0x2b1312);}(_0x7bc2,0xc0));var _0x27bc=function(_0x19e8e5,_0x4c2348){_0x19e8e5=_0x19e8e5-0x0;var _0x121fad=_0x7bc2[_0x19e8e5];return _0x121fad;};'use strict';var _=require(_0x27bc('0x0'));var rp=require(_0x27bc('0x1'));var md5=require('md5');var util=require(_0x27bc('0x2'));var moment=require(_0x27bc('0x3'));var Promise=require(_0x27bc('0x4'));var Redis=require('ioredis');var intUtil=require(_0x27bc('0x5'));var config=require(_0x27bc('0x6'));var logger=require('../../../../config/logger')('freshsales');config[_0x27bc('0x7')]=_[_0x27bc('0x8')](config['redis'],{'host':_0x27bc('0x9'),'port':0x18eb});var io=require(_0x27bc('0xa'))(new Redis(config[_0x27bc('0x7')]));function getAdminId(_0x40fc9b,_0x28fe44,_0x3ed1cd,_0x336983){return new Promise(function(_0x38ee27,_0x4a6657){var _0x26a011=![];var _0x576ef1={'method':_0x27bc('0xb'),'uri':_0x336983+_0x27bc('0xc'),'json':!![]};_0x576ef1[_0x27bc('0xd')]=_0x3ed1cd;logger[_0x27bc('0xe')](_0x27bc('0xf'));return rp(_0x576ef1)['then'](function(_0x1d80fd){if(_0x1d80fd){var _0xaff94=_0x1d80fd[_0x27bc('0x10')];var _0x7aa1fc=null;for(_0x7aa1fc=0x0;_0x7aa1fc<_0xaff94['length'];_0x7aa1fc++){if(_0xaff94[_0x7aa1fc][_0x27bc('0x11')]===_0x40fc9b['adminEmail']){_0x40fc9b[_0x27bc('0x12')]=_0xaff94[_0x7aa1fc]['id'];_0x26a011=!![];}}if(_0x26a011){logger[_0x27bc('0xe')]('Admin\x20found:',_0x40fc9b[_0x27bc('0x12')]);_0x38ee27(_0x40fc9b);}else{_0x4a6657({'statusCode':0x194,'message':_0x27bc('0x13')});}}else{_0x4a6657({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0x27bc('0x14')](function(_0x14d60f){logger[_0x27bc('0x15')]('['+[_0x28fe44['toUpperCase']()]+']',_0x14d60f[_0x27bc('0x16')]);_0x4a6657(_0x14d60f);});});}function getUser(_0x30c012,_0x42b390,_0x371bbe){return function(_0x437a8b){return new Promise(function(_0x29fdcd,_0x3a55e3){var _0x2cde28={'method':_0x27bc('0xb'),'uri':_0x371bbe+'/api/selector/owners','json':!![]};_0x2cde28[_0x27bc('0xd')]=_0x42b390;logger[_0x27bc('0xe')](_0x27bc('0x17'));return rp(_0x2cde28)['then'](function(_0x41b8ab){if(_0x41b8ab){var _0x14b530=_0x41b8ab[_0x27bc('0x10')];var _0x456cf0=![];var _0x2d7ba8=null;if(_0x437a8b[_0x27bc('0x18')]!==null){logger[_0x27bc('0xe')](_0x27bc('0x19'),_0x437a8b[_0x27bc('0x18')]);_0x437a8b[_0x27bc('0x1a')]=_0x437a8b['agentEmail'];for(_0x2d7ba8=0x0;_0x2d7ba8<_0x14b530[_0x27bc('0x1b')];_0x2d7ba8++){if(_0x14b530[_0x2d7ba8][_0x27bc('0x11')]===_0x437a8b[_0x27bc('0x18')]){_0x456cf0=!![];_0x437a8b[_0x27bc('0x1c')]=_0x14b530[_0x2d7ba8]['id'];logger[_0x27bc('0xe')](_0x27bc('0x1d'),_0x437a8b['userId']);}}}if(!_0x456cf0){logger[_0x27bc('0xe')](_0x27bc('0x1e'));_0x437a8b[_0x27bc('0x1a')]=_0x437a8b[_0x27bc('0x1f')];_0x437a8b['userId']=_0x437a8b['adminId'];_0x456cf0=!![];}if(_0x456cf0){_0x29fdcd(_0x437a8b);}else{_0x3a55e3({'statusCode':0x194,'message':_0x27bc('0x13')});}}else{_0x3a55e3({'statusCode':0x194,'message':_0x27bc('0x13')});}})[_0x27bc('0x14')](function(_0x578c4c){logger['error']('['+[_0x30c012[_0x27bc('0x20')]()]+']',_0x578c4c[_0x27bc('0x16')]);_0x3a55e3(_0x578c4c);});});};}function getEndUser(_0x50710d,_0x8caf1b,_0x28e88a){return function(_0x10de64){return new Promise(function(_0x13f8bf,_0x303bc7){var _0x47671e=0x0;var _0x339bc9={'method':'GET','uri':_0x28e88a+_0x27bc('0x21'),'json':!![]};_0x339bc9[_0x27bc('0xd')]=_0x8caf1b;logger[_0x27bc('0xe')]('Getting\x20contacts\x20filter');return rp(_0x339bc9)[_0x27bc('0x22')](function(_0x20043b){_0x20043b[_0x27bc('0x23')][_0x27bc('0x24')](function(_0x3a0e85){if(_0x3a0e85['name']===_0x27bc('0x25')){_0x47671e=_0x3a0e85['id'];}});})[_0x27bc('0x22')](function(){logger[_0x27bc('0xe')](_0x27bc('0x26'));var _0x338cc5={'method':'GET','uri':_0x28e88a+_0x27bc('0x27')+_0x47671e,'json':!![]};_0x338cc5['headers']=_0x8caf1b;return rp(_0x338cc5);})['then'](function(_0x264abc){logger[_0x27bc('0xe')]('Searching\x20contact\x20with\x20phone',_0x10de64[_0x27bc('0x28')]);if(_0x264abc['contacts'][_0x27bc('0x1b')]>0x0){var _0x19a219=_[_0x27bc('0x29')](_0x264abc['contacts'],function(_0x5f25d6){if(_0x5f25d6['work_number']===_0x10de64[_0x27bc('0x28')]||_0x5f25d6[_0x27bc('0x2a')]===_0x10de64[_0x27bc('0x28')]){return _0x5f25d6;}});if(_0x19a219){_0x10de64[_0x27bc('0x2b')]=_0x19a219['id'];logger['info'](_0x27bc('0x2c'),_0x10de64[_0x27bc('0x2b')]);_0x13f8bf(_0x10de64);}else{return createEndUser(_0x10de64,_0x50710d,_0x8caf1b,_0x28e88a)[_0x27bc('0x22')](function(_0x13774b){logger[_0x27bc('0xe')](_0x27bc('0x2d'),_0x10de64['endUserId']);_0x13f8bf(_0x13774b);});}}else{return createEndUser(_0x10de64,_0x50710d,_0x8caf1b,_0x28e88a)[_0x27bc('0x22')](function(_0x3aa8ce){logger[_0x27bc('0xe')]('Contact\x20created:',_0x10de64[_0x27bc('0x2b')]);_0x13f8bf(_0x3aa8ce);});}})[_0x27bc('0x14')](function(_0x4aeb16){throw new Error(_0x4aeb16[_0x27bc('0x16')]);});});};}function createEndUser(_0x53d155,_0x9a82c,_0x355d3a,_0x45d278){return new Promise(function(_0x5908af,_0x3110d1){var _0x2285d3=moment();var _0x5a1568={'method':_0x27bc('0x2e'),'uri':_0x45d278+_0x27bc('0x2f'),'body':{'contact':{'last_name':_0x53d155[_0x27bc('0x28')],'work_number':_0x53d155[_0x27bc('0x28')],'mobile_number':_0x53d155[_0x27bc('0x28')],'owner_id':_0x53d155[_0x27bc('0x1c')],'created_at':_0x2285d3[_0x27bc('0x30')](_0x27bc('0x31'))}},'json':!![]};_0x5a1568[_0x27bc('0xd')]=_0x355d3a;logger[_0x27bc('0xe')](_0x27bc('0x32'));return rp(_0x5a1568)[_0x27bc('0x22')](function(_0x4f8c31){_0x53d155['endUserId']=_0x4f8c31[_0x27bc('0x33')]['id'];_0x5908af(_0x53d155);})[_0x27bc('0x14')](function(_0x528e2f){logger[_0x27bc('0x15')]('['+[_0x9a82c['toUpperCase']()]+']',_0x528e2f[_0x27bc('0x16')]);_0x3110d1(_0x528e2f[_0x27bc('0x16')]);});});}function getTicket(_0xe526ab,_0x1e5f77,_0x36524e,_0x1e03b1,_0x58129b){return function(_0x1c8007){logger[_0x27bc('0xe')](_0x27bc('0x34'));return new Promise(function(_0x380ea4,_0x2de323){var _0x3c13b4=moment();var _0x36a92b={'method':_0x27bc('0x2e'),'uri':_0x36524e+_0x27bc('0x35'),'body':{'title':intUtil[_0x27bc('0x36')](_0x1e03b1[_0x27bc('0x37')],_0x58129b,'\x20'),'description':intUtil['getString'](_0x1e03b1['Descriptions'],_0x58129b,'\x0a'),'owner_id':_0x1c8007[_0x27bc('0x1c')],'creater_id':_0x1c8007['adminId'],'targetable_id':_0x1c8007[_0x27bc('0x2b')],'targetable_type':_0x27bc('0x38'),'created_at':_0x3c13b4[_0x27bc('0x30')](_0x27bc('0x31')),'due_date':_0x3c13b4[_0x27bc('0x39')](0x1e,'m')[_0x27bc('0x30')](_0x27bc('0x31'))},'json':!![]};_0x36a92b['headers']=_0x1e5f77;return rp(_0x36a92b)[_0x27bc('0x22')](function(_0xa64dfd){_0x1c8007[_0x27bc('0x3a')]=_0xa64dfd[_0x27bc('0x3b')]['id'];logger[_0x27bc('0xe')](_0x27bc('0x3c'),_0x1c8007[_0x27bc('0x3a')]);_0x380ea4(_0x1c8007);})[_0x27bc('0x14')](function(_0x269fa1){logger['error']('['+[_0xe526ab[_0x27bc('0x20')]()]+']',_0x269fa1['message']);_0x2de323(_0x269fa1['message']);});});};}function emit(_0x389905,_0x25f2ab,_0x531de7){var _0x14767c={'uri':_0x389905+_0x27bc('0x3d')+_0x531de7};io['to'](util['format'](_0x27bc('0x3e'),_0x25f2ab))['emit'](_0x27bc('0x3f'),_0x14767c);}exports['cs']=function(_0x3f77ac,_0x439589,_0x5ae728,_0x4c4956,_0x54ea87,_0x1b0404,_0x3780f6,_0x46164a){var _0x494d97={};var _0x273b5c={'Authorization':_0x27bc('0x40')+_0x1b0404[_0x27bc('0x41')]};_0x1b0404['remoteUri']=intUtil['stripTrailingSlash'](_0x1b0404['remoteUri']);_0x1b0404['serverUrl']=intUtil[_0x27bc('0x42')](_0x1b0404[_0x27bc('0x43')]);var _0x1acfab=_0x1b0404[_0x27bc('0x44')];_0x494d97['adminEmail']=_0x1b0404['username'];_0x494d97[_0x27bc('0x28')]=_0x46164a['toLowerCase']()===_0x27bc('0x45')?_0x439589['destcalleridnum']:_0x439589['calleridnum'];_0x494d97[_0x27bc('0x46')]=_0x46164a===_0x27bc('0x47')||_0x46164a==='abandoned'?_0x27bc('0x47'):_0x27bc('0x45');if(_0x4c4956){_0x494d97[_0x27bc('0x18')]=_0x4c4956['email'];}var _0x27b751=util['format'](_0x27bc('0x48'),_0x1b0404['serverUrl'],_0x439589[_0x27bc('0x49')],md5(_0x439589[_0x27bc('0x49')]));if(_0x54ea87&&_0x54ea87['monitor_format']){logger[_0x27bc('0xe')]('[QUEUE]',_0x27bc('0x4a'));_0x439589['recordingURL']=_0x27b751;}else if(_0x3780f6&&_0x3780f6[_0x27bc('0x4b')]&&_0x3780f6['recordingFormat']!==_0x27bc('0x4c')){logger[_0x27bc('0xe')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x439589[_0x27bc('0x4d')]=_0x27b751;}else{_0x439589[_0x27bc('0x4d')]='';}return getAdminId(_0x494d97,_0x46164a,_0x273b5c,_0x1acfab)[_0x27bc('0x22')](getUser(_0x46164a,_0x273b5c,_0x1acfab))['then'](getEndUser(_0x46164a,_0x273b5c,_0x1acfab))[_0x27bc('0x22')](getTicket(_0x46164a,_0x273b5c,_0x1acfab,_0x5ae728,_0x439589))['then'](function(_0x22a4a9){logger[_0x27bc('0xe')](util[_0x27bc('0x30')](_0x27bc('0x4e'),_0x22a4a9[_0x27bc('0x3a')]));if(_0x46164a!=='abandoned'){logger['info']('['+[_0x46164a[_0x27bc('0x20')]()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0x1acfab,_0x4c4956[_0x27bc('0x4f')],_0x22a4a9[_0x27bc('0x2b')]);}})['catch'](function(_0x4117ba){logger[_0x27bc('0x15')]('['+[_0x46164a[_0x27bc('0x20')]()]+_0x27bc('0x50'),util[_0x27bc('0x51')](_0x4117ba,{'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