Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index 1ec943f..ba6b0d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x975f=['Getting\x20user\x20with\x20email','userEmail','userId','User\x20found:','/api/lookup?q=','&f=','&entities=contact','then','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','contactNumber','mobile_number','Contact\x20found\x20mobile_number:','endUserId','Contact\x20found\x20work_number:','YYYY-MM-DDTHH:mm:ss','Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact','contact','Creating\x20new\x20task','POST','/api/tasks','getString','Subjects','Descriptions','add','ticketId','task','Task\x20created:','/contacts/','user:%s','emit','apiKey','remoteUri','stripTrailingSlash','serverUrl','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!','recordingFormat','none','[OUTBOUND]','recordingURL','The\x20ticket\x20ID\x20is:\x20%s','Displaying\x20task\x20in\x20a\x20new\x20tab...','name','lodash','md5','util','moment','bluebird','ioredis','./util','../../../../config/logger','freshsales','defaults','redis','localhost','socket.io-emitter','/api/selector/owners','headers','info','length','email','adminEmail','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','error','toUpperCase','message','GET','Getting\x20user\x20list','agentEmail'];(function(_0x4de586,_0x183427){var _0x46baf5=function(_0x1157f0){while(--_0x1157f0){_0x4de586['push'](_0x4de586['shift']());}};_0x46baf5(++_0x183427);}(_0x975f,0x191));var _0xf975=function(_0x1f1a97,_0xadfc15){_0x1f1a97=_0x1f1a97-0x0;var _0x29fc6a=_0x975f[_0x1f1a97];return _0x29fc6a;};'use strict';var _=require(_0xf975('0x0'));var rp=require('request-promise');var md5=require(_0xf975('0x1'));var util=require(_0xf975('0x2'));var moment=require(_0xf975('0x3'));var Promise=require(_0xf975('0x4'));var Redis=require(_0xf975('0x5'));var intUtil=require(_0xf975('0x6'));var config=require('../../../../config/environment');var logger=require(_0xf975('0x7'))(_0xf975('0x8'));config['redis']=_[_0xf975('0x9')](config[_0xf975('0xa')],{'host':_0xf975('0xb'),'port':0x18eb});var io=require(_0xf975('0xc'))(new Redis(config[_0xf975('0xa')]));function getAdminId(_0x197cad,_0x5d5860,_0x19fea0,_0x515abd){return new Promise(function(_0x137d54,_0x4b1029){var _0x32e936=![];var _0x30e02d={'method':'GET','uri':_0x515abd+_0xf975('0xd'),'json':!![]};_0x30e02d[_0xf975('0xe')]=_0x19fea0;logger[_0xf975('0xf')]('Getting\x20admin\x20information');return rp(_0x30e02d)['then'](function(_0x1c93d0){if(_0x1c93d0){var _0x1659ef=_0x1c93d0['users'];var _0x48177f=null;for(_0x48177f=0x0;_0x48177f<_0x1659ef[_0xf975('0x10')];_0x48177f++){if(_0x1659ef[_0x48177f][_0xf975('0x11')]===_0x197cad[_0xf975('0x12')]){_0x197cad[_0xf975('0x13')]=_0x1659ef[_0x48177f]['id'];_0x32e936=!![];}}if(_0x32e936){logger[_0xf975('0xf')](_0xf975('0x14'),_0x197cad[_0xf975('0x13')]);_0x137d54(_0x197cad);}else{_0x4b1029({'statusCode':0x194,'message':_0xf975('0x15')});}}else{_0x4b1029({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}})[_0xf975('0x16')](function(_0x2e54c5){logger[_0xf975('0x17')]('['+[_0x5d5860[_0xf975('0x18')]()]+']',_0x2e54c5[_0xf975('0x19')]);_0x4b1029(_0x2e54c5);});});}function getUser(_0x2ac0bd,_0x3e3f9e,_0x1513a8){return function(_0x298207){return new Promise(function(_0x3475bc,_0x3ef820){var _0xf52469={'method':_0xf975('0x1a'),'uri':_0x1513a8+'/api/selector/owners','json':!![]};_0xf52469[_0xf975('0xe')]=_0x3e3f9e;logger[_0xf975('0xf')](_0xf975('0x1b'));return rp(_0xf52469)['then'](function(_0xa4ae6f){if(_0xa4ae6f){var _0x5447a3=_0xa4ae6f['users'];var _0x242742=![];var _0x39a0fc=null;if(_0x298207[_0xf975('0x1c')]!==null){logger[_0xf975('0xf')](_0xf975('0x1d'),_0x298207[_0xf975('0x1c')]);_0x298207[_0xf975('0x1e')]=_0x298207[_0xf975('0x1c')];for(_0x39a0fc=0x0;_0x39a0fc<_0x5447a3[_0xf975('0x10')];_0x39a0fc++){if(_0x5447a3[_0x39a0fc][_0xf975('0x11')]===_0x298207[_0xf975('0x1c')]){_0x242742=!![];_0x298207[_0xf975('0x1f')]=_0x5447a3[_0x39a0fc]['id'];logger[_0xf975('0xf')](_0xf975('0x20'),_0x298207[_0xf975('0x1f')]);}}}if(!_0x242742){logger[_0xf975('0xf')]('Admin\x20selected');_0x298207[_0xf975('0x1e')]=_0x298207[_0xf975('0x12')];_0x298207[_0xf975('0x1f')]=_0x298207[_0xf975('0x13')];_0x242742=!![];}if(_0x242742){_0x3475bc(_0x298207);}else{_0x3ef820({'statusCode':0x194,'message':_0xf975('0x15')});}}else{_0x3ef820({'statusCode':0x194,'message':_0xf975('0x15')});}})[_0xf975('0x16')](function(_0x13bb6d){logger[_0xf975('0x17')]('['+[_0x2ac0bd[_0xf975('0x18')]()]+']',_0x13bb6d['message']);_0x3ef820(_0x13bb6d);});});};}function searchContact(_0x566f58,_0x565e35,_0x365032,_0x433f4a){return new Promise(function(_0x33d2e2,_0x3ddd47){var _0x5e5e1={'method':_0xf975('0x1a'),'headers':_0x565e35,'uri':_0x566f58+_0xf975('0x21')+_0x433f4a+_0xf975('0x22')+_0x365032+_0xf975('0x23'),'json':!![]};rp(_0x5e5e1)[_0xf975('0x24')](function(_0x3e2867){var _0x2a970b=_[_0xf975('0x25')](_0x3e2867[_0xf975('0x26')][_0xf975('0x26')],[_0x365032,_0x433f4a]);_0x33d2e2(_0x2a970b);})[_0xf975('0x16')](function(_0x36f990){_0x3ddd47(_0x36f990);});});}function getEndUser(_0x8606eb,_0x16fae2,_0x2bfe6e){return function(_0x5a2a8e){return new Promise(function(_0x3fb64b,_0x57731d){logger[_0xf975('0xf')](util[_0xf975('0x27')](_0xf975('0x28'),_0x5a2a8e[_0xf975('0x29')]));searchContact(_0x2bfe6e,_0x16fae2,_0xf975('0x2a'),_0x5a2a8e['contactNumber'])[_0xf975('0x24')](function(_0x3a7299){if(_0x3a7299){_0x5a2a8e['endUserId']=_0x3a7299['id'];logger[_0xf975('0xf')](_0xf975('0x2b'),_0x5a2a8e[_0xf975('0x2c')]);return _0x3fb64b(_0x5a2a8e);}searchContact(_0x2bfe6e,_0x16fae2,'work_number',_0x5a2a8e['contactNumber'])['then'](function(_0x5d7a91){if(_0x5d7a91){_0x5a2a8e[_0xf975('0x2c')]=_0x5d7a91['id'];logger[_0xf975('0xf')](_0xf975('0x2d'),_0x5a2a8e[_0xf975('0x2c')]);return _0x3fb64b(_0x5a2a8e);}createEndUser(_0x5a2a8e,_0x8606eb,_0x16fae2,_0x2bfe6e)[_0xf975('0x24')](function(_0xb823c6){logger[_0xf975('0xf')]('Contact\x20created:',_0xb823c6['endUserId']);return _0x3fb64b(_0xb823c6);});});})[_0xf975('0x16')](function(_0x2a3a93){_0x57731d(_0x2a3a93);});});};}function createEndUser(_0x184f79,_0x1ccc1b,_0x5bb149,_0x32b9f2){return new Promise(function(_0x4c8d85,_0x43ff37){var _0x58237b=moment();var _0x5ca61a={'method':'POST','uri':_0x32b9f2+'/api/contacts','body':{'contact':{'last_name':_0x184f79[_0xf975('0x29')],'work_number':_0x184f79['contactNumber'],'mobile_number':_0x184f79[_0xf975('0x29')],'owner_id':_0x184f79[_0xf975('0x1f')],'created_at':_0x58237b[_0xf975('0x27')](_0xf975('0x2e'))}},'json':!![]};_0x5ca61a['headers']=_0x5bb149;logger[_0xf975('0xf')](_0xf975('0x2f'));return rp(_0x5ca61a)[_0xf975('0x24')](function(_0x1dcc43){_0x184f79[_0xf975('0x2c')]=_0x1dcc43[_0xf975('0x30')]['id'];_0x4c8d85(_0x184f79);})[_0xf975('0x16')](function(_0x23d9f9){logger[_0xf975('0x17')]('['+[_0x1ccc1b[_0xf975('0x18')]()]+']',_0x23d9f9[_0xf975('0x19')]);_0x43ff37(_0x23d9f9[_0xf975('0x19')]);});});}function getTicket(_0x55624d,_0x5532f6,_0x5cb2c8,_0x1f12ff,_0x2aa749){return function(_0x4e4e51){logger['info'](_0xf975('0x31'));return new Promise(function(_0x7c3d7c,_0x4751ae){var _0x3c9d83=moment();var _0x21dd59={'method':_0xf975('0x32'),'uri':_0x5cb2c8+_0xf975('0x33'),'body':{'title':intUtil[_0xf975('0x34')](_0x1f12ff[_0xf975('0x35')],_0x2aa749,'\x20'),'description':intUtil[_0xf975('0x34')](_0x1f12ff[_0xf975('0x36')],_0x2aa749,'\x0a'),'owner_id':_0x4e4e51[_0xf975('0x1f')],'creater_id':_0x4e4e51[_0xf975('0x13')],'targetable_id':_0x4e4e51[_0xf975('0x2c')],'targetable_type':'Contact','created_at':_0x3c9d83[_0xf975('0x27')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x3c9d83[_0xf975('0x37')](0x1e,'m')['format'](_0xf975('0x2e'))},'json':!![]};_0x21dd59[_0xf975('0xe')]=_0x5532f6;return rp(_0x21dd59)[_0xf975('0x24')](function(_0x4e1547){_0x4e4e51[_0xf975('0x38')]=_0x4e1547[_0xf975('0x39')]['id'];logger[_0xf975('0xf')](_0xf975('0x3a'),_0x4e4e51['ticketId']);_0x7c3d7c(_0x4e4e51);})['catch'](function(_0x5df84f){logger[_0xf975('0x17')]('['+[_0x55624d[_0xf975('0x18')]()]+']',_0x5df84f[_0xf975('0x19')]);_0x4751ae(_0x5df84f['message']);});});};}function emit(_0x5821c0,_0x4f3404,_0x56fae2){var _0x14573d={'uri':_0x5821c0+_0xf975('0x3b')+_0x56fae2};io['to'](util[_0xf975('0x27')](_0xf975('0x3c'),_0x4f3404))[_0xf975('0x3d')]('trigger:browser:url',_0x14573d);}exports['cs']=function(_0x4b5ccf,_0x5a3312,_0x4281b8,_0x13c9cf,_0x293171,_0x1d2e7a,_0x27d38e,_0x44bacf){var _0x45d337={};var _0x56665f={'Authorization':'Token\x20token='+_0x1d2e7a[_0xf975('0x3e')]};_0x1d2e7a[_0xf975('0x3f')]=intUtil['stripTrailingSlash'](_0x1d2e7a[_0xf975('0x3f')]);_0x1d2e7a['serverUrl']=intUtil[_0xf975('0x40')](_0x1d2e7a[_0xf975('0x41')]);var _0xafaa67=_0x1d2e7a[_0xf975('0x3f')];_0x45d337[_0xf975('0x12')]=_0x1d2e7a[_0xf975('0x42')];_0x45d337['contactNumber']=_0x44bacf[_0xf975('0x43')]()==='outbound'?_0x5a3312[_0xf975('0x44')]:_0x5a3312[_0xf975('0x45')];_0x45d337[_0xf975('0x46')]=_0x44bacf===_0xf975('0x47')||_0x44bacf===_0xf975('0x48')?_0xf975('0x47'):_0xf975('0x49');if(_0x13c9cf){_0x45d337['agentEmail']=_0x13c9cf['email'];}var _0x8fcf79=util[_0xf975('0x27')](_0xf975('0x4a'),_0x1d2e7a['serverUrl'],_0x5a3312[_0xf975('0x4b')],md5(_0x5a3312[_0xf975('0x4b')]));if(_0x293171&&_0x293171[_0xf975('0x4c')]){logger[_0xf975('0xf')](_0xf975('0x4d'),_0xf975('0x4e'));_0x5a3312['recordingURL']=_0x8fcf79;}else if(_0x27d38e&&_0x27d38e[_0xf975('0x4f')]&&_0x27d38e['recordingFormat']!==_0xf975('0x50')){logger['info'](_0xf975('0x51'),_0xf975('0x4e'));_0x5a3312[_0xf975('0x52')]=_0x8fcf79;}else{_0x5a3312[_0xf975('0x52')]='';}return getAdminId(_0x45d337,_0x44bacf,_0x56665f,_0xafaa67)[_0xf975('0x24')](getUser(_0x44bacf,_0x56665f,_0xafaa67))[_0xf975('0x24')](getEndUser(_0x44bacf,_0x56665f,_0xafaa67))[_0xf975('0x24')](getTicket(_0x44bacf,_0x56665f,_0xafaa67,_0x4281b8,_0x5a3312))[_0xf975('0x24')](function(_0xfaca88){logger[_0xf975('0xf')](util[_0xf975('0x27')](_0xf975('0x53'),_0xfaca88['ticketId']));if(_0x44bacf!==_0xf975('0x48')){logger[_0xf975('0xf')]('['+[_0x44bacf['toUpperCase']()]+']',_0xf975('0x54'));emit(_0xafaa67,_0x13c9cf[_0xf975('0x55')],_0xfaca88[_0xf975('0x2c')]);}})[_0xf975('0x16')](function(_0x34cb50){logger[_0xf975('0x17')]('['+[_0x44bacf[_0xf975('0x18')]()]+']\x20Error\x20running\x20Freshsales\x20integration',util['inspect'](_0x34cb50,{'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