mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
* start migrating Utils.apiFetch to api class
* move dailyranking to api
* use api in title-ui-handler
* remove: Utils.apiFetch
* migrate `updateSystemSavedata` to api
* migrate clear session savedata to api
* migrate updateAllSavedata to api
* migrate `updateSessionSavedata` to api
* rename `api` to `pokerogue-api`
* migrate unlink discord to pokerogue-api
* migrate unlink google to pokerogue-api
* update pokerogue-api login
* migrate register account to pokerogue-api
* remove Utils.apiPost
* reset overrides.ts
* chore: cleanup
* fix env.development
* fix circular dependencies with api
* fix gamedata verify missing await
* fix daily api calls in daily-run-scorebard
* fix discord-link request body being empty
there was a double `toUrlSearchParams()` call involved
* add pokerogue-api test coverge
* add test-utils `getApiBaseUrl()` method
* add pokerogue-admin-api test coverage
* add pokerogue-account-api test coverage
* add pokerogue-daily-api test coverage
* add pokerogue-savedata-api test coverage
* fix some test describes
* add pokerogue-session-savedata-api test coverage
* add pokerogue-system-savedata-api test coverage
* fix tests
* fix tryExportData
thanks @MokaStitcher
* chore: fix menu-ui-handlers.ts
* fix admin-ui-handler (types)
* extend test-coverage for admin-api
* remove outdated code
* skip some clowning-around-encounter tests if events are active
this is not a permanent solution
* Update src/system/game-data.ts
Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
* Revert "skip some clowning-around-encounter tests if events are active"
This reverts commit a97dafe8b2
.
* mark `localServerUrl` and `apiUrl` as deprecated
in `utils.ts`
---------
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: PigeonBar <56974298+PigeonBar@users.noreply.github.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import type { GetDailyRankingsPageCountRequest, GetDailyRankingsRequest } from "#app/@types/PokerogueDailyApi";
|
|
import { ApiBase } from "#app/plugins/api/api-base";
|
|
import type { RankingEntry } from "#app/ui/daily-run-scoreboard";
|
|
|
|
/**
|
|
* A wrapper for daily-run PokéRogue API requests.
|
|
*/
|
|
export class PokerogueDailyApi extends ApiBase {
|
|
//#region Public
|
|
|
|
/**
|
|
* Request the daily-run seed.
|
|
* @returns The active daily-run seed as `string`.
|
|
*/
|
|
public async getSeed() {
|
|
try {
|
|
const response = await this.doGet("/daily/seed");
|
|
return response.text();
|
|
} catch (err) {
|
|
console.warn("Could not get daily-run seed!", err);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the daily rankings for a {@linkcode ScoreboardCategory}.
|
|
* @param params The {@linkcode GetDailyRankingsRequest} to send
|
|
*/
|
|
public async getRankings(params: GetDailyRankingsRequest) {
|
|
try {
|
|
const urlSearchParams = this.toUrlSearchParams(params);
|
|
const response = await this.doGet(`/daily/rankings?${urlSearchParams}`);
|
|
|
|
return (await response.json()) as RankingEntry[];
|
|
} catch (err) {
|
|
console.warn("Could not get daily rankings!", err);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the page count of the daily rankings for a {@linkcode ScoreboardCategory}.
|
|
* @param params The {@linkcode GetDailyRankingsPageCountRequest} to send.
|
|
*/
|
|
public async getRankingsPageCount(params: GetDailyRankingsPageCountRequest) {
|
|
try {
|
|
const urlSearchParams = this.toUrlSearchParams(params);
|
|
const response = await this.doGet(`/daily/rankingpagecount?${urlSearchParams}`);
|
|
const json = await response.json();
|
|
|
|
return Number(json);
|
|
} catch (err) {
|
|
console.warn("Could not get daily rankings page count!", err);
|
|
return 1;
|
|
}
|
|
}
|
|
}
|