Built motion from commit 9d1906d1.|2.5.40
[motion2.git] / server / services / ami / trigger / integration / freshsales.js
index cd48d05..eb98201 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 _0x78f7=['callDirection','queue','unmanaged','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','recordingFormat','none','The\x20ticket\x20ID\x20is:\x20%s',']\x20Error\x20running\x20Freshsales\x20integration','inspect','lodash','util','moment','../../../../config/environment','../../../../config/logger','freshsales','redis','defaults','localhost','socket.io-emitter','headers','Getting\x20admin\x20information','then','users','adminId','Admin\x20found:','Requested\x20Resource\x20not\x20Found','catch','toUpperCase','message','GET','/api/selector/owners','info','Getting\x20user\x20list','agentEmail','userEmail','length','email','userId','User\x20found:','Admin\x20selected','adminEmail','error','/api/lookup?q=','&f=','&entities=contact','find','contacts','format','Searching\x20contact\x20with\x20phone\x20%s','mobile_number','contactNumber','endUserId','Contact\x20found\x20mobile_number:','work_number','Contact\x20found\x20work_number:','Contact\x20created:','POST','/api/contacts','Creating\x20new\x20task','/api/tasks','getString','Subjects','YYYY-MM-DDTHH:mm:ss','ticketId','/contacts/','user:%s','emit','trigger:browser:url','apiKey','remoteUri','stripTrailingSlash','serverUrl','toLowerCase','outbound','calleridnum'];(function(_0x4d878a,_0x3135d3){var _0x2f6701=function(_0x337408){while(--_0x337408){_0x4d878a['push'](_0x4d878a['shift']());}};_0x2f6701(++_0x3135d3);}(_0x78f7,0x198));var _0x778f=function(_0x573ba4,_0x5c2465){_0x573ba4=_0x573ba4-0x0;var _0x511fd8=_0x78f7[_0x573ba4];return _0x511fd8;};'use strict';var _=require(_0x778f('0x0'));var rp=require('request-promise');var md5=require('md5');var util=require(_0x778f('0x1'));var moment=require(_0x778f('0x2'));var Promise=require('bluebird');var Redis=require('ioredis');var intUtil=require('./util');var config=require(_0x778f('0x3'));var logger=require(_0x778f('0x4'))(_0x778f('0x5'));config[_0x778f('0x6')]=_[_0x778f('0x7')](config[_0x778f('0x6')],{'host':_0x778f('0x8'),'port':0x18eb});var io=require(_0x778f('0x9'))(new Redis(config[_0x778f('0x6')]));function getAdminId(_0x59b6d9,_0x48c3d3,_0x1b6f71,_0x1c1f68){return new Promise(function(_0x52bfc6,_0x165794){var _0x24f9d9=![];var _0x597274={'method':'GET','uri':_0x1c1f68+'/api/selector/owners','json':!![]};_0x597274[_0x778f('0xa')]=_0x1b6f71;logger['info'](_0x778f('0xb'));return rp(_0x597274)[_0x778f('0xc')](function(_0x1e2112){if(_0x1e2112){var _0x591e34=_0x1e2112[_0x778f('0xd')];var _0x22c577=null;for(_0x22c577=0x0;_0x22c577<_0x591e34['length'];_0x22c577++){if(_0x591e34[_0x22c577]['email']===_0x59b6d9['adminEmail']){_0x59b6d9[_0x778f('0xe')]=_0x591e34[_0x22c577]['id'];_0x24f9d9=!![];}}if(_0x24f9d9){logger['info'](_0x778f('0xf'),_0x59b6d9['adminId']);_0x52bfc6(_0x59b6d9);}else{_0x165794({'statusCode':0x194,'message':_0x778f('0x10')});}}else{_0x165794({'statusCode':0x194,'message':_0x778f('0x10')});}})[_0x778f('0x11')](function(_0x184fd9){logger['error']('['+[_0x48c3d3[_0x778f('0x12')]()]+']',_0x184fd9[_0x778f('0x13')]);_0x165794(_0x184fd9);});});}function getUser(_0x393a13,_0x1b9d38,_0x5af3f8){return function(_0x71c301){return new Promise(function(_0x2d702d,_0x88c57){var _0x2a5234={'method':_0x778f('0x14'),'uri':_0x5af3f8+_0x778f('0x15'),'json':!![]};_0x2a5234[_0x778f('0xa')]=_0x1b9d38;logger[_0x778f('0x16')](_0x778f('0x17'));return rp(_0x2a5234)[_0x778f('0xc')](function(_0x32158d){if(_0x32158d){var _0x4eeba3=_0x32158d['users'];var _0x40df29=![];var _0x4d91f9=null;if(_0x71c301[_0x778f('0x18')]!==null){logger[_0x778f('0x16')]('Getting\x20user\x20with\x20email',_0x71c301[_0x778f('0x18')]);_0x71c301[_0x778f('0x19')]=_0x71c301[_0x778f('0x18')];for(_0x4d91f9=0x0;_0x4d91f9<_0x4eeba3[_0x778f('0x1a')];_0x4d91f9++){if(_0x4eeba3[_0x4d91f9][_0x778f('0x1b')]===_0x71c301[_0x778f('0x18')]){_0x40df29=!![];_0x71c301[_0x778f('0x1c')]=_0x4eeba3[_0x4d91f9]['id'];logger[_0x778f('0x16')](_0x778f('0x1d'),_0x71c301[_0x778f('0x1c')]);}}}if(!_0x40df29){logger[_0x778f('0x16')](_0x778f('0x1e'));_0x71c301[_0x778f('0x19')]=_0x71c301[_0x778f('0x1f')];_0x71c301['userId']=_0x71c301[_0x778f('0xe')];_0x40df29=!![];}if(_0x40df29){_0x2d702d(_0x71c301);}else{_0x88c57({'statusCode':0x194,'message':_0x778f('0x10')});}}else{_0x88c57({'statusCode':0x194,'message':_0x778f('0x10')});}})[_0x778f('0x11')](function(_0x3cbf3b){logger[_0x778f('0x20')]('['+[_0x393a13['toUpperCase']()]+']',_0x3cbf3b[_0x778f('0x13')]);_0x88c57(_0x3cbf3b);});});};}function searchContact(_0x175c53,_0x1aa591,_0x56b1c7,_0x1ac5a9){return new Promise(function(_0x5874c0,_0xcda205){var _0x4d7215={'method':'GET','headers':_0x1aa591,'uri':_0x175c53+_0x778f('0x21')+_0x1ac5a9+_0x778f('0x22')+_0x56b1c7+_0x778f('0x23'),'json':!![]};rp(_0x4d7215)['then'](function(_0x359963){var _0x45c029=_[_0x778f('0x24')](_0x359963[_0x778f('0x25')][_0x778f('0x25')],[_0x56b1c7,_0x1ac5a9]);_0x5874c0(_0x45c029);})[_0x778f('0x11')](function(_0xea9e15){_0xcda205(_0xea9e15);});});}function getEndUser(_0x4f4bfe,_0x373d78,_0x5889ef){return function(_0x2a743e){return new Promise(function(_0x521d50,_0x148843){logger[_0x778f('0x16')](util[_0x778f('0x26')](_0x778f('0x27'),_0x2a743e['contactNumber']));searchContact(_0x5889ef,_0x373d78,_0x778f('0x28'),_0x2a743e[_0x778f('0x29')])[_0x778f('0xc')](function(_0x5b9b8b){if(_0x5b9b8b){_0x2a743e[_0x778f('0x2a')]=_0x5b9b8b['id'];logger[_0x778f('0x16')](_0x778f('0x2b'),_0x2a743e['endUserId']);return _0x521d50(_0x2a743e);}searchContact(_0x5889ef,_0x373d78,_0x778f('0x2c'),_0x2a743e[_0x778f('0x29')])['then'](function(_0x4b5fc3){if(_0x4b5fc3){_0x2a743e[_0x778f('0x2a')]=_0x4b5fc3['id'];logger[_0x778f('0x16')](_0x778f('0x2d'),_0x2a743e['endUserId']);return _0x521d50(_0x2a743e);}createEndUser(_0x2a743e,_0x4f4bfe,_0x373d78,_0x5889ef)[_0x778f('0xc')](function(_0x213c0a){logger[_0x778f('0x16')](_0x778f('0x2e'),_0x213c0a[_0x778f('0x2a')]);return _0x521d50(_0x213c0a);});});})[_0x778f('0x11')](function(_0x3f5bf4){_0x148843(_0x3f5bf4);});});};}function createEndUser(_0x1cb85f,_0x513ef5,_0x2aed4c,_0x29ca99){return new Promise(function(_0x130ce0,_0x5cd1b9){var _0x39e34a=moment();var _0x1126b5={'method':_0x778f('0x2f'),'uri':_0x29ca99+_0x778f('0x30'),'body':{'contact':{'last_name':_0x1cb85f['contactNumber'],'work_number':_0x1cb85f[_0x778f('0x29')],'mobile_number':_0x1cb85f[_0x778f('0x29')],'owner_id':_0x1cb85f[_0x778f('0x1c')],'created_at':_0x39e34a['format']('YYYY-MM-DDTHH:mm:ss')}},'json':!![]};_0x1126b5[_0x778f('0xa')]=_0x2aed4c;logger[_0x778f('0x16')]('Contact\x20not\x20found,\x20creating\x20a\x20new\x20contact');return rp(_0x1126b5)[_0x778f('0xc')](function(_0x129ff0){_0x1cb85f[_0x778f('0x2a')]=_0x129ff0['contact']['id'];_0x130ce0(_0x1cb85f);})[_0x778f('0x11')](function(_0x398c97){logger[_0x778f('0x20')]('['+[_0x513ef5['toUpperCase']()]+']',_0x398c97[_0x778f('0x13')]);_0x5cd1b9(_0x398c97[_0x778f('0x13')]);});});}function getTicket(_0x48540e,_0x4a285a,_0x4e1a3e,_0x538b60,_0x3ae661){return function(_0x214a7a){logger[_0x778f('0x16')](_0x778f('0x31'));return new Promise(function(_0x507943,_0x1234dd){var _0x404fd9=moment();var _0x17b622={'method':'POST','uri':_0x4e1a3e+_0x778f('0x32'),'body':{'title':intUtil[_0x778f('0x33')](_0x538b60[_0x778f('0x34')],_0x3ae661,'\x20'),'description':intUtil[_0x778f('0x33')](_0x538b60['Descriptions'],_0x3ae661,'\x0a'),'owner_id':_0x214a7a[_0x778f('0x1c')],'creater_id':_0x214a7a[_0x778f('0xe')],'targetable_id':_0x214a7a[_0x778f('0x2a')],'targetable_type':'Contact','created_at':_0x404fd9[_0x778f('0x26')]('YYYY-MM-DDTHH:mm:ss'),'due_date':_0x404fd9['add'](0x1e,'m')[_0x778f('0x26')](_0x778f('0x35'))},'json':!![]};_0x17b622['headers']=_0x4a285a;return rp(_0x17b622)[_0x778f('0xc')](function(_0x91446a){_0x214a7a[_0x778f('0x36')]=_0x91446a['task']['id'];logger[_0x778f('0x16')]('Task\x20created:',_0x214a7a['ticketId']);_0x507943(_0x214a7a);})[_0x778f('0x11')](function(_0x3d83e6){logger[_0x778f('0x20')]('['+[_0x48540e['toUpperCase']()]+']',_0x3d83e6[_0x778f('0x13')]);_0x1234dd(_0x3d83e6[_0x778f('0x13')]);});});};}function emit(_0x2ae1a8,_0x81fac6,_0x335a87){var _0xa31dcb={'uri':_0x2ae1a8+_0x778f('0x37')+_0x335a87};io['to'](util[_0x778f('0x26')](_0x778f('0x38'),_0x81fac6))[_0x778f('0x39')](_0x778f('0x3a'),_0xa31dcb);}exports['cs']=function(_0x3d4a19,_0x5d628c,_0x1b443a,_0x5deff2,_0x7cfe5d,_0x43a32d,_0x5aa773,_0x3c155e){var _0x4217a8={};var _0xe796bb={'Authorization':'Token\x20token='+_0x43a32d[_0x778f('0x3b')]};_0x43a32d[_0x778f('0x3c')]=intUtil[_0x778f('0x3d')](_0x43a32d[_0x778f('0x3c')]);_0x43a32d[_0x778f('0x3e')]=intUtil[_0x778f('0x3d')](_0x43a32d[_0x778f('0x3e')]);var _0xb99d06=_0x43a32d[_0x778f('0x3c')];_0x4217a8['adminEmail']=_0x43a32d['username'];_0x4217a8[_0x778f('0x29')]=_0x3c155e[_0x778f('0x3f')]()===_0x778f('0x40')?_0x5d628c['destcalleridnum']:_0x5d628c[_0x778f('0x41')];_0x4217a8[_0x778f('0x42')]=_0x3c155e===_0x778f('0x43')||_0x3c155e===_0x778f('0x44')?'queue':_0x778f('0x40');if(_0x5deff2){_0x4217a8[_0x778f('0x18')]=_0x5deff2[_0x778f('0x1b')];}var _0x54fab7=util[_0x778f('0x26')](_0x778f('0x45'),_0x43a32d['serverUrl'],_0x5d628c['uniqueid'],md5(_0x5d628c[_0x778f('0x46')]));if(_0x7cfe5d&&_0x7cfe5d['monitor_format']){logger[_0x778f('0x16')](_0x778f('0x47'),_0x778f('0x48'));_0x5d628c[_0x778f('0x49')]=_0x54fab7;}else if(_0x5aa773&&_0x5aa773[_0x778f('0x4a')]&&_0x5aa773[_0x778f('0x4a')]!==_0x778f('0x4b')){logger[_0x778f('0x16')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x5d628c[_0x778f('0x49')]=_0x54fab7;}else{_0x5d628c[_0x778f('0x49')]='';}return getAdminId(_0x4217a8,_0x3c155e,_0xe796bb,_0xb99d06)[_0x778f('0xc')](getUser(_0x3c155e,_0xe796bb,_0xb99d06))['then'](getEndUser(_0x3c155e,_0xe796bb,_0xb99d06))[_0x778f('0xc')](getTicket(_0x3c155e,_0xe796bb,_0xb99d06,_0x1b443a,_0x5d628c))[_0x778f('0xc')](function(_0x56defc){logger['info'](util[_0x778f('0x26')](_0x778f('0x4c'),_0x56defc[_0x778f('0x36')]));if(_0x3c155e!==_0x778f('0x44')){logger[_0x778f('0x16')]('['+[_0x3c155e['toUpperCase']()]+']','Displaying\x20task\x20in\x20a\x20new\x20tab...');emit(_0xb99d06,_0x5deff2['name'],_0x56defc[_0x778f('0x2a')]);}})[_0x778f('0x11')](function(_0x1bf233){logger[_0x778f('0x20')]('['+[_0x3c155e['toUpperCase']()]+_0x778f('0x4d'),util[_0x778f('0x4e')](_0x1bf233,{'showHidden':!![],'depth':null}));});};
\ No newline at end of file