UNPKG

@theedeer0/battlemetrics-api

Version:

An object-oriented BattleMetrics API wrapper for Node.js developers with TypeScript support.

57 lines (56 loc) 3.43 kB
/** * @fileoverview This file is the primary service for the BattleMetrics API Wrapper. * * The BattleMetrics class is used to interact with the BattleMetrics API. * * Dependencies: * - axios: Used to make HTTP requests to the BattleMetrics API. */ import { Player, PlayerIncludeOptions, Players, PlayersIncludeOptions, RelationIncludeOptions, relatedIdentifiers } from './structure/Player'; import { QuickMatchOptions, QuickMatchResponse } from './structure/QuickMatch'; export default class BattleMetricsClass { private axios; constructor(token: string); /** * Fetches players from the BattleMetrics API. * * @param {string} search - The search query. * @param {PlayersIncludeOptions[]} include - The resources to include in the response. * @param {number} pageSize - The number of results per page. * @returns {Promise<Players>} A Promise that resolves to an object of Players. * @throws {Error} Will throw an error if the request fails. * * For more information, see the [BattleMetrics API documentation](https://www.battlemetrics.com/developers/documentation#link-GET-player-/players)}). */ getPlayers(search?: string, include?: PlayersIncludeOptions[], pageSize?: number): Promise<Players>; /** * Fetches a player's data from the BattleMetrics API by their BM ID. * * @param {string} bmId - The Battlemetrics ID of the player to fetch. * @param {PlayerIncludeOptions[]} [include=[]] - An array of strings specifying additional resources to include in the API response. Valid options are "servers" and "identifiers". * @returns {Promise<Player>} A Promise that resolves to the Player object. * @throws {Error} Will throw an error if the request fails. * * For more information, see the [BattleMetrics API documentation](https://www.battlemetrics.com/developers/documentation#link-GET-player-/players/{(%23%2Fdefinitions%2Fplayer%2Fdefinitions%2Fidentity)}). */ getPlayerById(bmId: string, include?: PlayerIncludeOptions): Promise<Player>; /** * Fetches players from the BattleMetrics API using the quick match feature. * * @param {QuickMatchOptions} options - The options for the quick match feature. This should be an object that conforms to the QuickMatchOptions interface, which includes the type of identifier and the identifier itself. * @returns {Promise<QuickMatchResponse[]>} A Promise that resolves to an array of QuickMatchResponse objects. * @throws {Error} Will throw an error if the request fails. * * For more information, see the [BattleMetrics API documentation](https://www.battlemetrics.com/developers/documentation#link-POST-player-/players/quick-match). */ findPlayersByQuickMatch(options: QuickMatchOptions): Promise<QuickMatchResponse>; /** * Fetches related identifiers for a player from the BattleMetrics API. * * @param {string} bmId - The BattleMetrics ID of the player. * @param {RelationIncludeOptions[]} [include=[]] - An array of strings specifying additional resources to include in the API response. * @returns {Promise<RelatedIdentifiers>} A Promise that resolves to an object of related identifiers. * @throws {Error} Will throw an error if the request fails. */ getRelatedIdentifiersForPlayer(bmId: string, include?: RelationIncludeOptions[]): Promise<relatedIdentifiers>; }