trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
186 lines (185 loc) • 10.1 kB
TypeScript
import { IHttpServiceConfig, IMapper } from '../../common';
import { LeaguesBodyStructure, LocationsBodyStructure, MarketBodyStructure, SportsBodyStructure } from '../../common/body-entities/responses';
import { IMetadataHttpClient } from '../interfaces';
import { BaseHttpClient } from '../../base-http-client';
import { GetCompetitionsRequestDto, GetLeaguesRequestDto, GetTranslationsRequestDto, GetIncidentsRequestDto, GetVenuesRequestDto, GetCitiesRequestDto, GetStatesRequestDto, GetParticipantsRequestDto } from '../../common/metadata/dtos';
import { CompetitionCollectionResponse, TranslationsCollectionResponse, IncidentsCollectionResponse, VenuesCollectionResponse, CitiesCollectionResponse, StatesCollectionResponse, ParticipantsCollectionResponse } from '../../common/metadata/responses';
/**
* MetadataHttpClient class is responsible for sending requests
* to the metadata API. It extends the BaseHttpClient class and
* contains the logic for sending requests to the metadata API.
* @param packageCredentials The package credentials for the API
* @param restApiBaseUrl The base URL of the customers API
* @param logger The logger instance
* @param mapper The mapper instance
* @returns MetadataHttpClient instance that is responsible for
* sending requests to the metadata API.
* @extends BaseHttpClient class for sending requests to the
* customers API.
* @implements IMetadataHttpClient interface for sending
* requests to the metadata API.
* @see BaseHttpClient class for sending requests to the
* customers API.
* @see IMetadataHttpClient interface for sending requests to
* the metadata API.
* @see IHttpServiceConfig interface for the configuration of
* the HTTP service.
*/
export declare class MetadataHttpClient extends BaseHttpClient implements IMetadataHttpClient {
private readonly mapper;
constructor({ packageCredentials, restApiBaseUrl, logger }: IHttpServiceConfig, mapper: IMapper);
/**
* getLocations method is responsible for sending a request
* to the metadata API to get the locations. It sends a POST
* request to the metadata API with the GET_LOCATIONS_PREFIX_URL
* and LocationsCollectionResponse as the response type.
* If the request is without "languageId" - the response returns
* a list of "id" and "name" in English.
* If The request is with "languagesId" that invalid - ErrorCode
* 400 and error message - "Incorrect request, please enter a
* valid Language and resend your request."
* If the request is with "languageId" and there are some sports
* that don't have a translation in this language - it's not
* returned (without an error).
* @returns A promise that contains the locations.
* @throws Error if mapping configuration is not found or if the
* request is invalid or incorrect.
*/
getLocations(): Promise<LocationsBodyStructure[] | undefined>;
/**
* getSports method is responsible for sending a request
* to the metadata API to get the sports. It sends a POST
* request to the metadata API with the GET_SPORTS_PREFIX_URL
* and SportsCollectionResponse as the response type.
* If the request is without "languageId" - the response
* returns a list of "id" and "name" in English.
* If The request is with "languagesId" that invalid -
* ErrorCode 400 and error message - "Incorrect request,
* please enter a valid Language and resend your request."
* If the request is with "languageId" and there are some
* sports that don't have a translation in this language -
* it's not returned (without an error).
* @returns A promise that contains the sports.
* @throws Error if mapping configuration is not found or
* if the request is invalid or incorrect.
*/
getSports(): Promise<SportsBodyStructure[] | undefined>;
/**
* getLeagues method is responsible for sending a request
* to the metadata API to get the leagues.
* It sends a POST request to the metadata API with the
* GET_LEAGUES_PREFIX_URL and LeaguesCollectionResponse as
* the response type.
* If the request is without "languageId" - the response
* returns a list of "id" and "name" in English.
* If The request is with "languagesId" that invalid -
* ErrorCode 400 and error message - "Incorrect request,
* please enter a valid Language and resend your request."
* If the request is with "LanguageId" and there are some
* sports that don't have a translation in this language -
* it's not returned (without an error).
* @param requestDto The request DTO
* @returns A promise that contains the leagues.
* @throws Error if mapping configuration is not found or
* if the request is invalid or incorrect.
*/
getLeagues(requestDto: GetLeaguesRequestDto): Promise<LeaguesBodyStructure[] | undefined>;
/**
* getMarkets method is responsible for sending a request
* to the metadata API to get the markets. It sends a POST
* request to the metadata API with the GET_MARKETS_PREFIX_URL
* and MarketsCollectionResponse as the response type.
* If the request is without "languageId" - the response
* returns a list of "id" and "name" in English.
* If The request is with "languagesId" that invalid -
* ErrorCode 400 and error message - "Incorrect request,
* please enter a valid Language and resend your request."
* If the request is with "LanguageId" and there are some
* sports that don't have a translation in this language -
* it's not returned (without an error).
* @param requestDto The request DTO for getting markets
* from the metadata API.
* @returns A promise that contains the markets.
* @throws Error if mapping configuration is not found or
* if the request is invalid or incorrect.
*/
getMarkets(requestDto: GetLeaguesRequestDto): Promise<MarketBodyStructure[] | undefined>;
/**
* getTranslations method is responsible for sending a request
* to the metadata API to get the translations. It sends a POST
* request to the metadata API with the GET_TRANSACTIONS_PREFIX_URL
* and TransactionsCollectionResponse as the response type. If the
* request does not have any optional field to translate- the
* response will return an ErrorCode 400 and the message will
* include the error. If the request is without Languages field -
* the response will return an error with an informative message.
*/
getTranslations(requestDto: GetTranslationsRequestDto): Promise<TranslationsCollectionResponse | undefined>;
/**
* getCompetitions method is responsible for sending a request
* to the metadata API to get the competitions. It sends a POST
* request to the metadata API with the GET_COMPETITIONS_PREFIX_URL
* and CompetitionCollectionResponse as the response type.
*/
getCompetitions(requestDto: GetCompetitionsRequestDto): Promise<CompetitionCollectionResponse | undefined>;
/**
* getIncidents method is responsible for sending a request
* to the metadata API to get the incidents.
* It sends a POST request to the metadata API with the
* GET_INCIDENT_PREFIX_URL and IncidentsCollectionResponse
* as the response type.
* @param requestDto The request DTO for getting incidents
* from the metadata API.
* @returns A promise that contains the incidents data and total count.
* @throws Error if the request is invalid or incorrect.
*/
getIncidents(requestDto: GetIncidentsRequestDto): Promise<IncidentsCollectionResponse | undefined>;
/**
* getVenues method is responsible for sending a request
* to the metadata API to get the venues.
* It sends a POST request to the metadata API with the
* GET_VENUES_PREFIX_URL and VenuesCollectionResponse
* as the response type.
* @param requestDto The request DTO for getting venues
* from the metadata API.
* @returns A promise that contains the venues data and total count.
* @throws Error if the request is invalid or incorrect.
*/
getVenues(requestDto: GetVenuesRequestDto): Promise<VenuesCollectionResponse | undefined>;
/**
* getCities method is responsible for sending a request
* to the metadata API to get the cities.
* It sends a POST request to the metadata API with the
* GET_CITIES_PREFIX_URL and CitiesCollectionResponse
* as the response type.
* @param requestDto The request DTO for getting cities
* from the metadata API.
* @returns A promise that contains the cities data and total count.
* @throws Error if the request is invalid or incorrect.
*/
getCities(requestDto: GetCitiesRequestDto): Promise<CitiesCollectionResponse | undefined>;
/**
* getStates method is responsible for sending a request
* to the metadata API to get the states.
* It sends a POST request to the metadata API with the
* GET_STATES_PREFIX_URL and StatesCollectionResponse
* as the response type.
* @param requestDto The request DTO for getting states
* from the metadata API.
* @returns A promise that contains the states data and total count.
* @throws Error if the request is invalid or incorrect.
*/
getStates(requestDto: GetStatesRequestDto): Promise<StatesCollectionResponse | undefined>;
/**
* getParticipants method is responsible for sending a request
* to the metadata API to get the participants.
* It sends a POST request to the metadata API with the
* GET_PARTICIPANTS_PREFIX_URL and ParticipantsCollectionResponse
* as the response type.
* @param requestDto The request DTO for getting participants
* from the metadata API.
* @returns A promise that contains the participants data and total count.
* @throws Error if the request is invalid or incorrect.
*/
getParticipants(requestDto: GetParticipantsRequestDto): Promise<ParticipantsCollectionResponse | undefined>;
}