npm package: @mediaplatform/sportal365-multisport-sdk
Description: ### Installation
Author: smp@sportal.bg
Latest version: 1.3.1

# JavaScript Multisport SDK

### Installation

Install Multisport SDK dependency

```sh
npm install @mediaplatform/sportal365-multisport-sdk --save
```

or

```sh
yarn add @mediaplatform/sportal365-multisport-sdk
```

### Usage

Import Multisport SDK dependency

```sh
import Core from "@mediaplatform/sportal365-multisport-sdk"
```

Initialize Multisport SDK

```sh
const SDK = new Core(config);
```

The **config** argument is an object with the following properties:

- **dataConfigApiUrl** - API URL (required)
- **dataConfigApiKey** - API KEY (required)
- **dataConfigLang** - example: 'en'
- **dataConfigProject** - Project name (required)
- **dataConfigOddClient** - default value: 'sportal' (optional)
- **dataConfigTimezone** - example: 'Europe/Sofia' (required)
- **dataConfigCompetitionList** - example: 'default' (required)

## Competitions Module

Initialize module

```sh
const competitionsModule = SDK.competitions();
```

### Usage

```sh
competitionsModule
  .getDate(date: string)
  .get();
```

Corresponding output should be:

```sh
{
 	 competitions: CompetitionsМоdule
};
```

Module methods

- **getDate(date: string)**
  - date - the argument is a string. Format for date is - yyyy-mm-dd. - is required

- **get()** - the method is mandatory - Based on called methods, it returns the built object with all requested competitions information
  and filtered depending on the passed sport and date.

## Events Module

Initialize module

```sh
const eventsModule = SDK.events();
```

### Usage

```sh
eventsModule
  .getDate(date: string)
  .getSport(sport?: SportTypes)
  .withOdds({ bettingId: 'string', market: 'string', oddFormat: 'string', preEventOddsOnly: 'boolean' })
  .getCompetitionIds(competitionIds: string)
  .get();
```

Corresponding output should be:

```sh
{
 	 events: EventsМоdule
};
```

Module methods

- **getSport(sport: SportTypes)** - Use this method to get competitions only for a specific sport.
  - sport example: "tennis". - is optional

- **getDate(date: string)**
  - date - the argument is a string. Format for date is - yyyy-mm-dd. - is required

- **getCompetitionIds(competitionIds: string)**
  - competitionIds - the argument is a string. Pass the id's of the competitions you want to get the events for by concatenating the id's
    with a comma and passing them as a single string. - is optional

- **withOdds({ bettingId: string, market: string, oddFormat: string, preEventOddsOnly: boolean })**
  - bettingId - the argument is a string. If no bettingId is provided, the result will be filtered by the first provider from the response
  - market - the argument is a string. Example: "1x2"- will return only "1x2" markets data (if there is one).
  - oddFormat - the argument is a string ( FRACTIONAL, DECIMAL, MONEYLINE ). Default value: "DECIMAL". You could pass an odds format to
    format odds values.
  - preEventOddsOnly - the argument is a boolean which shows odds only when the game has not started yet. The default value of the argument
    is **false**.

- **get()** - the method is mandatory - Based on called methods, it returns the built object with all requested events information
  and filtered depending on the passed sport, date and competitionIds.

## Handlers

**_Note 1:_** Status text is handled on the front end because different sports have different status finished texts - this status which comes from the API is used only for business logic and not as a text, but as a type instead

**_Note 2:_** Results is ignored if the event hasn’t started

**_Note 3:_** Because of the different types of sports different name prop is being returned - some sports require three_letter_code and if no three_letter_code is available the name of the same is being returned (basketball and football for example)

**_Note 4:_** Placeholders are handled on the front end. Reason for this is because there are different placeholders depending of the sport being displayed