Example
Proxy Integration Example - for dataProviderConfig example check Widgets.CustomBet.UOFProxy.UOFDataProviderConfig
<script>
(function (a, b, c, d, e, f, g, h, i) {
a[e] || (i = a[e] = function () {
(a[e].q = a[e].q || []).push(arguments)
}, i.l = 1 * new Date, i.o = f,
g = b.createElement(c), h = b.getElementsByTagName(c)[0], g.async = 1, g.src = d, g
.setAttribute("n", e), h.parentNode.insertBefore(g, h)
)
})(window, document, "script",
"https://master-cb.review.widgets.bets-stg.euc1.srcloud.io/betradarsolid/widgetloader", "SIR", {
language: "en",
oddsType: "eu" // eu, uk, us is accepted
});
SIR("addWidget", ".sr-widget", "customBet", {
matchId: 32015685,
dataProvider: 'uofProxy',
// for dataProviderConfig props check type definitions
dataProviderConfig: {
getFixture,
getMarkets,
calculate,
getAvailableMarkets,
getProfile,
addToBetSlip
}
});
</script>
<div id="sr-widget"></div>
Type Definitions
# UOFDataProviderCallback(error, data)
Parameters
Name | Type | Description |
---|---|---|
error |
CBError Widgets.CustomBet.CustomBet.CBError | string | undefined | Error object or UOF forwarded xml as string. |
data |
string | Forwarded UOF xml data as string. |
# UOFDataProviderConfig
Collection of functions used for commination between widget and client code. Examples can be found in corresponding type definitions.
Properties:
Name | Type | Description |
---|---|---|
getFixture |
getFixture Widgets.CustomBet.UOFProxy.getFixture | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Static%20sport%20event%20information/fixturesForEvent. |
getMarkets |
getMarkets Widgets.CustomBet.UOFProxy.getMarkets | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets. |
calculate |
calculate Widgets.CustomBet.UOFProxy.calculate | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/calculateProbability. |
getAvailableMarkets |
getAvailableMarkets Widgets.CustomBet.UOFProxy.getAvailableMarkets | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/availableSelections. |
getProfile |
getProfile Widgets.CustomBet.UOFProxy.getProfile | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Entity%20descriptions/competitorInformation. |
addToBetSlip |
addToBetSlip Widgets.CustomBet.CustomBet.addToBetSlip | This function is called when the user clicks "Add to bet slip" button. |
# calculate(args, callback)
Parameters
Name | Type | Description |
---|---|---|
args |
CalculateArgs Widgets.CustomBet.CustomBet.CalculateArgs | Given data needed to call UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/calculateProbability. |
callback |
UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback | Callback function to be executed with data received from UOF api. |
Example
function calculate(args, callback) {
var postContent =
args.selectedOutcomes.length > 0 &&
`<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<filterSelections
xmlns=\"http://schemas.sportradar.com/custombet/v1/endpoints\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://schemas.sportradar.com/custombet/v1/endpoints
http://schemas.sportradar.com/custombet/v1/endpoints/Selections.xsd\">
<selection id="${args.matchId}">
${args.selectedOutcomes.map((outcome) => {
//getSelection function is a helper function that will create the xml object for you
return outcome.getSelection();
}).join(' ')}
</selection>
</filterSelections>`;
//call to backend API, replace apiUrl
fetch('https://${apiUrl}/v1/custombet/calculate-filter', {
headers: { 'Content-Type': 'application/xml' },
method: 'POST',
body: postContent
})
.then( response => {
if (response.ok) {
return response.text()
} else {
throw response;
}
})
.then( xmlString => {
callback(false, xmlString)
})
.catch( error => {
callback(
{
message: 'Could not get fixture data',
error_code: '400'
}
);
})
}
# getAvailableMarkets(args, callback)
Parameters
Name | Type | Description |
---|---|---|
args |
MatchArgs Widgets.CustomBet.CustomBet.MatchArgs | Given data needed to call UOF api data from https://iodocs.betradar.com/#/CustomBet%20API/availableSelections. |
callback |
UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback | Callback function to be executed with data received from UOF api. |
Example
function getAvailableMarkets(args, callback) {
//call to backend API, replace apiUrl and matchId
fetch('$(apiUrl)/v1/custombet/{matchId}/available_selections')
.then( response => {
if (response.ok) {
return response.text()
} else {
throw response;
}
})
.then( xmlString => {
callback(false, xmlString)
})
.catch( error => {
callback(
{
message: 'Could not get fixture data',
error_code: '400'
}
);
})
}
# getFixture(args, callback)
Function called when UOF fixture data is requested. It is given Widgets.CustomBet.CustomBet.MatchArgs and expects callback function Widgets.CustomBet.UOFProxy.UOFDataProviderCallback to be executed with UOF data.
Parameters
Name | Type | Description |
---|---|---|
args |
MatchArgs Widgets.CustomBet.CustomBet.MatchArgs | Given data needed to call UOF api data from https://iodocs.betradar.com/#/Static%20sport%20event%20information/fixturesForEvent. |
callback |
UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback | Callback function to be executed with data received from UOF api. |
Properties:
Name | Type | Description |
---|---|---|
getMarkets |
getMarkets Widgets.CustomBet.UOFProxy.getMarkets | Function called by custom bet widget to get UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets. |
Example
function getFixture(args, callback) {
// call to backend API, replace apiUrl and matchId. MatchId is given in args parameter
fetch('${apiUrl}/v1/sports/{language}/sport_events/{matchId}/fixture.xml')
.then( response => {
if (response.ok) {
return response.text()
} else {
throw response;
}
})
.then( xmlString => {
callback(false, xmlString)
})
.catch( error => {
callback(
{
message: 'Could not get fixture data',
error_code: '400'
}
);
})
}
# getMarkets(args, callback)
Function called when UOF markets data is requested. Expects callback function Widgets.CustomBet.UOFProxy.UOFDataProviderCallback to be executed with UOF data.
Parameters
Name | Type | Description |
---|---|---|
args |
undefined | null | No arguments needed for UOF api data from https://iodocs.betradar.com/#/Betting%20descriptions/markets. |
callback |
UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback | Callback function to be executed with data received from UOF api. |
Example
function getMarkets(args, callback) {
// call to backend API, replace apiUrl
fetch('$(apiUrl)/v1/descriptions/{language}/markets.xml?include_mappings=true')
.then( response => {
if (response.ok) {
return response.text()
} else {
throw response;
}
})
.then( xmlString => {
callback(false, xmlString)
})
.catch( error => {
callback(
{
message: 'Could not get markets data',
error_code: '400'
}
);
})
}
# getProfile(args, callback)
Parameters
Name | Type | Description |
---|---|---|
args |
TeamArgs Widgets.CustomBet.CustomBet.TeamArgs | Given data needed to call UOF api data from https://iodocs.betradar.com/#/Entity%20descriptions/competitorInformation. |
callback |
UOFDataProviderCallback Widgets.CustomBet.UOFProxy.UOFDataProviderCallback | Callback function to be executed with data received from UOF api. |
Example
function getProfile(args, callback) {
// call to backend API, replace apiUrl and teamId
fetch('$(apiUrl)/v1/sports/{language}/competitors/{teamId}/profile.xml')
.then( response => {
if (response.ok) {
return response.text()
} else {
throw response;
}
})
.then( xmlString => {
callback(false, xmlString)
})
.catch( error => {
callback(
{
message: 'Could not get fixture data',
error_code: '400'
}
);
})