ittf-pingpong
Version:
Unofficial API to retrieve player rankings and statistics from ITTF (International Table Tennis Federation) affiliated members and events.
69 lines (68 loc) • 4.26 kB
TypeScript
export * from './getWeek'
export * from './globals'
export declare class ittfPingPong {
private currentRankingsUrl;
private historicalRankingsUrl;
private allPlayersUrl;
private allCountriesUrl;
private playerProfileUrl;
private playerMatchesUrl;
static currentGender: readonly ["M", "W", "X"];
static currentCategory: readonly ["S", "D", "DI"];
static currentType: readonly ["YOU", "SEN"];
static isValidGender(value: any): value is typeof ittfPingPong.currentGender[number];
static isValidCategory(value: any): value is typeof ittfPingPong.currentCategory[number];
static isValidType(value: any): value is typeof ittfPingPong.currentType[number];
private isPositiveInteger;
private isAlphabetic;
/**
* Fetch the current rankings.
* @param {string} type - The type of rankings ('YOU' | 'SEN') All 3 youth competition types lumped together (U15, U18, U21), Seniors
* @param {string} gender - Gender ('M' | 'W' | 'X') Man, woman, mixed (doubles only)
* @param {string} category - Category ('S' | 'D' | 'DI') Singles, doubles ranking (pairs), doubles ranking (individual)
* @param {number | string} topN - Only positive integers (e.g., 1, 2, 3, ...) or 'all'. Defaults to 'all'.
*/
currentRankings(type: typeof ittfPingPong.currentType[number], gender: typeof ittfPingPong.currentGender[number], category: typeof ittfPingPong.currentCategory[number], topN: number | 'all' = 'all'): Promise<Rankings>;
/**
* Fetch the player's ittfId given their name.
* @param playerFullName - Player's family name and given name. Ensure that the family name is capitalized and placed before the given name. (e.g. "FAN Zhendong", "CALDERANO Hugo")
* @param playerGivenName - Player's given name(s) only.
* @param playerFamilyName - Player's family name.
* @param {Object} searchName - The name parameters, all mutually exclusive. I.E., you can only enter playerFullName, playerGivenName, or playerFamilyName.
* @param {string} [searchName.playerFullName] - The full name, mutually exclusive with givenName and familyName.
* @param {string} [searchName.playerGivenName] - Given name, mutually exclusive with fullName.
* @param {string} [searchName.playerFamilyName] - Family name, mutually exclusive with fullName.
*
* @throws {Error} When multiple search methods are used together.
*
* @example
* // Valid:
* playerIttfId({ playerFullName: 'FAN Zhendong' });
* // output: 121404
* playerIttfId({ playerFamilyName: 'Lebrun'});
* // output: [{IttfId:"132992", PlayerGivenName:"Alexis",...},{IttfId:, PlayerGivenName:"Felix",...} ,...]
*
*
* // Invalid:
* playerIttfId({ fullName: 'FAN Zhendong', givenName: 'Zhendong' });
* Input the full name with the family name in all caps first, then the given name with the first letter capitalized. (e.g. "FAN Zhendong", "LEBRUN Alexis")
* If playerFullName is inputted and found, returns ittfId as a string; the same applies for GivenName and FamilyNambe, but if multiple players share the GivenName or FamilyName searched for, an array is returned instead.
*/
playerIttfId(searchName: FullName | GivenName | FamilyName): Promise<number | object[]>;
/**
* Fetch the player's yearly match totals.
* @param playerFullName - Player's family name and given name. Ensure that the family name is capitalized and placed before the given name. (e.g. "FAN Zhendong", "CALDERANO Hugo")
* @param playerIttfId - 0-6 digit integer. (e.g. 121404 - FAN Zhendong)
*
* @throws {Error} When multiple search methods are used together. Only input the playerFullName or the playerIttfId - not both.
*
* @example
* // Valid:
* playerProfile({ playerFullName: 'FAN Zhendong' });
* // output: {player: {IttfId:"121404", Org:"CHN", Gender:"M",...}, ranking: {LastPos:[{...}], BestPos:[{...},{...},...]}, stats: {total:{[...]}, indiv:{[...]}, doubles:{[...]}}}
* playerProfile({ playerIttfId: 121404});
* // output: {player: {IttfId:"121404", Org:"CHN", Gender:"M",...}, ranking: {LastPos:[{...}], BestPos:[{...},{...},...]}, stats: {total:{[...]}, indiv:{[...]}, doubles:{[...]}}}
*
*/
playerProfile(searchMethod: PlayerFullName | IttfId): Promise<Stats>;
}