@mediaplatform/sportal365-playoff-utils
v1.0.16
Published
### Installation
Downloads
567
Readme
JavaScript Playoff Utils
Installation
Install Playoff Utils dependency
npm install @mediaplatform/sportal365-playoff-utils --save
or
yarn add @mediaplatform/sportal365-playoff-utils
Usage
Import Playoff Utils dependency
import PlayoffUtils from "@mediaplatform/sportal365-playoff-utils"
Initialize Playoff Utils
const playoffUtils = new PlayoffUtils(sport, configObj);
Playoff Service
Initialize service
const playoffService = PlayoffUtils(sport, configObj);
sport - the argument is required (sport: string). (Example: "basketball","tennis") configObj - the argument is required (configObj: Object). (Example: { apiUrl: 'https://playoffs.api.integration.sportal365.com/playoffs', authorization: 'Basic XXXX', stageId: 'XXX-XX-XX', project: 'sportal' })
** Usage 1**
playoffService
.get();
Corresponding output should be:
{
playoff: ResponseModel
};
** Usage 2**
playoffService
.formatPlayoff()
.get();
Corresponding output should be:
{
playoff: RemappedStageModel
};
** Usage 3**
playoffService
.formatPlayoff()
.formatRounds()
.get();
Corresponding output should be:
{
playoff: RemappedStageModel
};
Service method
formatPlayoff() - the method is NOT mandatory - It's formatting the api call response
formatRounds() - the method is NOT mandatory - It's formatting the rounds array into an object with round name keys.
get() - the method is mandatory - Based on called methods, it returns the built object with all requested information for the playoff
Service Errors
If some data is not provided the corresponding service should return an error or warning message.
Example:
{
NOT_VALID_SPORT = 'Playoff module initialization failed. You must provide valid sport.',
NOT_VALID_CONFIGURATION_OBJECT = 'Playoff module initialization failed. You must provide valid configuration object.',
NO_AUTHORIZATION_DATA = 'Playoff module initialization failed. You must provide authorization data.',
NO_PROJECT_DATA = 'Playoff module initialization failed. You must provide project config data.',
NO_TOURNAMENT_DATA = 'Playoff module initialization failed. You must provide competition config data (competitionId and status) or stageId.',
NO_API_URL = 'Playoff module initialization failed. You must provide playoff api url.',
}