### Installation
npm install @mediaplatform/sportal365-odds-utilsInstall Odds Utils dependency
``sh`
npm install @mediaplatform/sportal365-odds-utils --save
or
`sh`
yarn add @mediaplatform/sportal365-odds-utils
Import Odds Utils dependency
`sh`
import Core from "@mediaplatform/sportal365-odds-utils"
Initialize Odds Utils
`sh`
const oddsUtils = new OddsUtils(odds, sport);
Initialize service
`sh`
const oddsService = oddsUtils(odds, sport);
odds - the argument is required (odds: any[]). sport - the argument is required (sport: string). (Example: "BASKETBALL","TENNIS")
`sh`
oddsService
.mapOddsMarketsWithDifferentKeys()
.get();
Corresponding output should be:
`sh`
{
odds: OddsModel
};
Service method
- mapOddsMarketsWithDifferentKeys() - Use this method to format the markets from array to object with type name keys.
- filterOddsByConfig({ bettingId: string })
- bettingId - the argument is a string. If no bettingId is provided, the result will be filtered by the first provider from the response.
### Usage 2
`sh`
oddsService
.filterOddsByConfig({ bettingId: string })
.get();
Corresponding output should be:
`sh`
{
odds: OddsModel
};
Service method
- filterOddsByConfig({ bettingId: string })
- bettingId - the argument is a string. If no bettingId is provided, the result will be filtered by the first provider from the response.
- get() - the method is mandatory - Based on called methods, it returns the built object with all requested information for the odds and
filtered odds by the given providers id
If some data is not provided the corresponding service should return an error or warning message.
Example:
`sh``
{
oddsError: "Odds module initialization failed. You must provide an odds",
(if the odds are missing),
oddsWarning: "Odds module initialization failed. The odds array is empty.",
(if the odds array is empty)
...
}