1.1.5 • Published 17 days ago

@mediaplatform/sportal365-odds-utils v1.1.5

Weekly downloads
-
License
MIT
Repository
-
Last release
17 days ago

JavaScript Odds Utils

Installation

Install Odds Utils dependency

npm install @mediaplatform/sportal365-odds-utils --save

or

yarn add @mediaplatform/sportal365-odds-utils

Usage

Import Odds Utils dependency

import Core from "@mediaplatform/sportal365-odds-utils"

Initialize Odds Utils

const oddsUtils = new OddsUtils(odds, sport);

Odds Service

Initialize service

const oddsService = oddsUtils(odds, sport);

odds - the argument is required (odds: any[]). sport - the argument is required (sport: string). (Example: "BASKETBALL","TENNIS")

Usage 1

oddsService
  .mapOddsMarketsWithDifferentKeys()
  .get();

Corresponding output should be:

{
 	 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

oddsService
  .filterOddsByConfig({ bettingId: string })
  .get();

Corresponding output should be:

{
 	 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

Service Errors

If some data is not provided the corresponding service should return an error or warning message.

Example:

{
   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)
   ...
}