This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
Files
scoresaber-reloadedv3/projects/common/src/utils/score-utils.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Leaderboards } from "../leaderboard";
import { kyFetch } from "./utils";
import PlayerScoresResponse from "../response/player-scores-response";
import { Config } from "../config";
import { ScoreSort } from "../score/score-sort";
2024-10-17 15:47:20 +01:00
import LeaderboardScoresResponse from "../response/leaderboard-scores-response";
/**
* Fetches the player's scores
*
* @param leaderboard the leaderboard
* @param id the player id
* @param page the page
* @param sort the sort
* @param search the search
*/
export async function fetchPlayerScores<S, L>(
leaderboard: Leaderboards,
id: string,
page: number,
sort: ScoreSort,
search?: string
) {
return kyFetch<PlayerScoresResponse<S, L>>(
`${Config.apiUrl}/scores/player/${leaderboard}/${id}/${page}/${sort}${search ? `?search=${search}` : ""}`
);
}
/**
* Fetches the player's scores
*
* @param leaderboard the leaderboard
* @param id the player id
* @param page the page
*/
export async function fetchLeaderboardScores<S, L>(leaderboard: Leaderboards, id: string, page: number) {
2024-10-17 15:47:20 +01:00
return kyFetch<LeaderboardScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
}