Example
Data Adapter Integration Example - for dataProviderConfig example check Widgets.CustomBet.DataAdapter.DataAdapterProviderConfig
<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: 'custom',
dataProviderConfig: {
getOffering,
calculate,
addToBetSlip
}
});
</script>
<div id="sr-widget"></div>
Type Definitions
# CalculateResponse
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
cbMarkets |
Array.<CalculationMarket> Array.<Widgets.CustomBet.DataAdapter.CalculationMarket> |
<required> |
Array of available markets based on already selected outcomes |
odds |
string | Calculated odds |
|
error |
string | Error to be displayed instead of odds. |
Example
{
cbMarkets: [
{
// id: 267674245,
id: '1',
status: {
isActive: true
},
srMarket: {
id: '1'
},
outcomes: [
{
// id: 619793109,
srOutcomeId: '1',
status: {
isActive: true
}
},
{
// id: 619793110,
srOutcomeId: '2',
status: {
isActive: true
}
},
{
// id: 619793111,
srOutcomeId: '3',
status: {
isActive: true
}
}
]
}
],
odds: '1.23'
}
# CalculationMarket
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | number | ||
srMarket |
SRMarket Widgets.CustomBet.CustomBet.SRMarket | If you are using srMarket and srOutcome in OfferingResponse then provide this property |
|
status |
Status Widgets.CustomBet.CustomBet.Status |
<required> |
|
outcomes |
Array.<CalculationOutcome> Array.<Widgets.CustomBet.DataAdapter.CalculationOutcome> | Array.<SRCalculationOutcome> Array.<Widgets.CustomBet.DataAdapter.SRCalculationOutcome> |
<required> |
If you are using srMarket and srOutcome in OfferingResponse then provide SRCalculationOutcome type. |
# CalculationOutcome
Properties:
Name | Type | Description |
---|---|---|
id |
string | number | Outcome id you are using in OfferingResponse |
status |
Status Widgets.CustomBet.CustomBet.Status |
# DataAdapterProviderConfig
Collection of functions used for commination between widget and client code. Examples can be found in corresponding type definitions.
Properties:
Name | Type | Description |
---|---|---|
getOffering |
getOffering Widgets.CustomBet.DataAdapter.getOffering | Function called to get market offering. |
calculate |
calculate Widgets.CustomBet.DataAdapter.calculate | Function called to get check for conflicts in selected markets, to get calculated odds for selection amd to get which markets are still available with current selection |
addToBetSlip |
addToBetSlip Widgets.CustomBet.CustomBet.addToBetSlip | This function is called when the user clicks "Add to bet slip" button. |
# Market
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | number |
<required> |
Unique id for category |
|
status |
Status Widgets.CustomBet.CustomBet.Status |
<required> |
||
name |
string |
<required> |
Market name to be displayed |
|
fullName |
string | The full name of the market (usually for player markets) displayed in the tooltip on mouse hover. |
||
outcomes |
Array.<Outcome> Array.<Widgets.CustomBet.DataAdapter.Outcome> |
<required> |
Array of outcomes for market |
|
srMarket |
SRMarket Widgets.CustomBet.CustomBet.SRMarket | If given we will try to match it with recommended configuration |
||
srAllowMultipleOutcomes |
boolean | Set to true if you wish to enable selection of multiple outcomes of this market. CAUTION: Using this setting might not work with custom bet |
||
srMarketLayout |
'list' | 'grid' | 'accordion' | 'list' | Layout used to display outcomes |
|
iconUrl |
string | Url to for custom icon of market |
Example
{
id: oneXtwo,
status: { isActive: true }
name: '1x2',
outcomes: [{ id: 1, status: { isActive: true }, name: 'Luton Town' }, ...]
srMarket: { id: '1' }
}
# MarketCategory
Properties:
Name | Type | Description |
---|---|---|
id |
string | number | Unique id for category |
name |
string | Category name |
cbCategoryItems |
Array.<string> | Array.<number> | Array of market ids for category. |
Example
{
id: 1,
name: 'Top Markets',
cbCategoryItems: ['3way_market_UniqueId', 'doubleChance_market_UniqueId', ...]
}
# MarketMapping
Market mapping is configuration object that combines multiple markets into one view.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | number |
<required> |
Unique id for market mapping and market |
|
status |
Status Widgets.CustomBet.CustomBet.Status |
<required> |
||
name |
string |
<required> |
Displayed market mapping name |
|
marketList |
Array.<string> | Array.<number> |
<required> |
Array of market ids to be combined in this view. |
|
cbViewLayout |
'row' | 'tabs' | 'tabs' | Layout used to display markets listed in marketList |
|
srHideHeader |
string | If set to true it will hide either column or row header depending on the layout |
||
iconUrl |
string | Url to for custom icon of market |
# OfferingResponse
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
markets |
Array.<Market> Array.<Widgets.CustomBet.DataAdapter.Market> |
<required> |
|
matchName |
string | If provided it will replace '{teams.home} vs. {'teams.away'}' derived from teams prop. If nether is present only product name will be displayed. |
|
teams |
object | ||
home |
string |
<required> |
Home team name |
away |
string |
<required> |
Away team name |
marketCategories |
Array.<MarketCategory> Array.<Widgets.CustomBet.DataAdapter.MarketCategory> | Required if you are not using sr ids. If provided it will also replace default settings for category. |
|
metaMarkets |
Array.<MarketMapping> Array.<Widgets.CustomBet.DataAdapter.MarketMapping> | Market categories (metaMarkets) group markets together. |
Example
{
teams: {
home: England,
away: Germany
}
markets: [
{
"id": 267674427,
"status": {
"isActive": true
},
"name": "Exact goals",
"outcomes": [
{
"id": 619793849,
"status": {
"isActive": true
},
"name": "0",
"srOutcomeId": "sr:exact_goals:5+:1336"
},
{
"id": 619793850,
"status": {
"isActive": true
},
"name": "1",
"srOutcomeId": "sr:exact_goals:5+:1337"
},
{
"id": 619793851,
"status": {
"isActive": true
},
"name": "2",
"srOutcomeId": "sr:exact_goals:5+:1338"
},
{
"id": 619793852,
"status": {
"isActive": true
},
"name": "3",
"srOutcomeId": "sr:exact_goals:5+:1339"
},
{
"id": 619793853,
"status": {
"isActive": true
},
"name": "4",
"srOutcomeId": "sr:exact_goals:5+:1340"
},
{
"id": 619793854,
"status": {
"isActive": true
},
"name": "5+",
"srOutcomeId": "sr:exact_goals:5+:1341"
}
],
"srMarket": {
"id": "21",
"specifiers": "sr:exact_goals:5+"
}
},
...
]
}
# Outcome
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | number |
<required> |
Outcome unique id |
status |
Status Widgets.CustomBet.CustomBet.Status |
<required> |
|
name |
string |
<required> |
Outcome name |
cbColumn |
string | If present we will sort the outcomes in the given column, srOutcomeId will be ignored |
|
srOutcomeId |
string | Sportradar outcome id |
Example
Outcome 'Other' will bi placed in draw column:
{
id: 'cs_other',
status: { isActive: true }
name: 'Other',
cbColumn: 'Draw'
srOutcomeId: '324'
}
# SRCalculationOutcome
Properties:
Name | Type | Description |
---|---|---|
srOutcomeId |
string | Sportradar outcome id |
status |
Status Widgets.CustomBet.CustomBet.Status |
# calculate(args, callback)
Parameters
Name | Type | Description |
---|---|---|
args |
CalculateArgs Widgets.CustomBet.CustomBet.CalculateArgs | |
callback |
calculateCallback Widgets.CustomBet.DataAdapter.calculateCallback |
Example
function calculate(args, callback) {
// Args parameter has data needed to call CustomBet calculate api.
// Parse and convert calculate api response.
callback(undefined, dataObject]
});
};
# calculateCallback(error, data)
Parameters
Name | Type | Description |
---|---|---|
error |
CBError Widgets.CustomBet.CustomBet.CBError | string | undefined | Error object or UOF forwarded xml as string. |
data |
CalculateResponse Widgets.CustomBet.DataAdapter.CalculateResponse |
# getOffering(args, callback)
Parameters
Name | Type | Description |
---|---|---|
args |
MatchArgs Widgets.CustomBet.CustomBet.MatchArgs | |
callback |
getOfferingCallback Widgets.CustomBet.DataAdapter.getOfferingCallback |
Example
function getOffering(args, callback) {
// Get and convert data
callback(undefined, dataObject]
});
};
# getOfferingCallback(error, data)
Parameters
Name | Type | Description |
---|---|---|
error |
CBError Widgets.CustomBet.CustomBet.CBError | string | undefined | Error object or UOF forwarded xml as string. |
data |
OfferingResponse Widgets.CustomBet.DataAdapter.OfferingResponse |