-
-
Save tzamora/635d49554d3a7563c2656ab6908e9088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getRacebookToken(options) { | |
return new Promise(async (resolve, reject) => { | |
try { | |
console.log('🐎 getRacebookToken'); | |
const currentBrand = process.env.INSTANCE_BRAND | |
const { externalEndpoints } = constantsSource.INSTANCE_BRANDS[currentBrand]; | |
const url = externalEndpoints.racebookToken; | |
console.log('racebook url', url); | |
console.log('🐎 externalEndpoints', externalEndpoints); | |
let workstationId = '190.113.96.130'; | |
if (process.env.NODE_ENV !== 'dev') { | |
workstationId = ipManager.address(); | |
console.warn('@@workstation ip', workstationId); | |
} | |
const is9backup = currentBrand === constantsSource.INSTANCE_BRANDS.hs9backup.label; | |
if(is9backup) { | |
workstationId = '192.168.104.71'; | |
} | |
let websiteId = '8015'; | |
switch (currentBrand) { | |
case 'heritage': websiteId = '8015'; | |
break; | |
case 'bet105': websiteId = '8040'; | |
break; | |
case 'betregal': websiteId = '8050'; | |
break; | |
case 'hs9backup': websiteId = '1581'; | |
break; | |
} | |
const args = { | |
sourceId: 'HeritageLogin', | |
sourcePassword: 'H3r1t4g3', | |
playerId: options.input.customerId, | |
password: options.input.password, | |
userId: 'INETUSR', | |
workstationId: workstationId, | |
// workstationId: workstationId, | |
applicationId: 'RIWA', | |
logonSource: 1,// 1 or 2 (It depends on the source device 1 means desktop and 2 means mobile) | |
websiteId: websiteId, | |
partnerId: '', | |
thridPartyToken: '', | |
} | |
console.log('🐎 arges', args); | |
soap.createClient(url, function (error, client) { | |
client.PlayerLogin(args, function (error, result) { | |
if (error) { | |
console.log('racebook error', error); | |
reject(error); | |
} else { | |
console.log('🐎 result', result); | |
if (result.PlayerLoginResult.Token) { | |
resolve({ token: result.PlayerLoginResult.Token }); | |
} else { | |
reject({ error: result.PlayerLoginResult.LocalizedMessage }); | |
} | |
} | |
}); | |
}); | |
} catch (err) { | |
console.log('racebook error catch', error); | |
reject(err); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment