Skip to content

Commit

Permalink
sync with latest api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
myssto committed Nov 30, 2024
1 parent f3dc787 commit e842e4f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 35 deletions.
103 changes: 87 additions & 16 deletions src/clients/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export abstract class OtrApiWrapperBase {
*/
export type BeatmapsGetRequestParams = {
/**
* (required) Search key (o!TR id or osu! id)
* (required) Search key (id or osu! id)
*/
key: number;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ export class BeatmapsWrapper extends OtrApiWrapperBase {
/**
* Get a beatmap
*
* Get a beatmap searching first by id, then by beatmap osu! id
* Get a beatmap searching first by id, then by osu! id
*
* Requires Authorization:
*
Expand Down Expand Up @@ -297,6 +297,74 @@ export class ClientsWrapper extends OtrApiWrapperBase {
}
}

export class DiagnosticsWrapper extends OtrApiWrapperBase {
protected instance: AxiosInstance;
protected baseUrl: string;
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(configuration: IOtrApiWrapperConfiguration) {

super(configuration);

this.instance = axios.create(this.configuration.clientConfiguration);
this.baseUrl = this.getBaseUrl("");

if (this.configuration.postConfigureClientMethod) {
this.configuration.postConfigureClientMethod(this.instance);
}
}

/**
* Undocumented
* @return Success
*/
public ping( cancelToken?: CancelToken): Promise<OtrApiResponse<void>> {

let url_ = this.baseUrl + "/api/v1/diagnostics/ping";
url_ = url_.replace(/[?&]$/, "");

let options_: AxiosRequestConfig = {
method: "GET",
url: url_,
headers: {
},
cancelToken
};
(options_ as any).requiresAuth = false

return this.instance.request(options_).catch((_error: any) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
} else {
throw _error;
}
}).then((_response: AxiosResponse) => {
return this.processPing(_response);
});
}

protected processPing(response: AxiosResponse): Promise<OtrApiResponse<void>> {
const status = response.status;
let _headers: any = {};
if (response.headers && typeof response.headers === "object") {
for (const k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
return Promise.resolve<OtrApiResponse<void>>(new OtrApiResponse<void>(status, _headers, null as any));

} else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve<OtrApiResponse<void>>(new OtrApiResponse(status, _headers, null as any));
}
}

/**
* Request parameters available for use when requesting {@link FilteringWrapper.prototype.filter | api/v1/filtering}
*/
Expand Down Expand Up @@ -1550,19 +1618,23 @@ export type LeaderboardsGetRequestParams = {
*/
chartType?: LeaderboardChartType | undefined;
/**
* (optional) Rank floor
* (optional) Rank floor (The "better" inclusive rank bound.
* If given, only players with a rank greater than or equal to this value will be included)
*/
minRank?: number | undefined;
/**
* (optional) Rank ceiling
* (optional) Rank ceiling (The "worse" inclusive rank bound.
* If given, only players with a rank less than or equal to this value will be included)
*/
maxRank?: number | undefined;
/**
* (optional) Rating floor
* (optional) Rating floor (The "worse" inclusive rating bound.
* If given, only players with a rating greater than or equal to this value will be included)
*/
minRating?: number | undefined;
/**
* (optional) Rating ceiling
* (optional) Rating ceiling (The "better" inclusive rating bound.
* If given, only players with a rating less than or equal to this value will be included)
*/
maxRating?: number | undefined;
/**
Expand Down Expand Up @@ -1870,15 +1942,15 @@ export type MatchesListRequestParams = {
*/
ruleset?: Ruleset | undefined;
/**
* (optional) Filters results for only matches with a partially matching name
* (optional) Filters results for only matches with a partially matching name (case insensitive)
*/
name?: string | undefined;
/**
* (optional) Filters results for only matches that occurred after a specified date
* (optional) Filters results for only matches that occurred on or after a specified date
*/
dateMin?: Date | undefined;
/**
* (optional) Filters results for only matches that occurred before a specified date
* (optional) Filters results for only matches that occurred on or before a specified date
*/
dateMax?: Date | undefined;
/**
Expand Down Expand Up @@ -3348,7 +3420,7 @@ export type PlayersDeleteAdminNoteRequestParams = {
*/
export type PlayersGetRequestParams = {
/**
* (required) Search key (o!TR id, osu! id, or osu! username)
* (required) Search key (id, osu! id, or osu! username)
*/
key: string;
}
Expand Down Expand Up @@ -3783,7 +3855,7 @@ export class PlayersWrapper extends OtrApiWrapperBase {
* Get a player's stats
*
* Gets player by versatile search.
* If no ruleset is provided, the player's default is used. OsuApiClient.Net.Constants.Endpoints.Osu is used as a fallback.
* If no ruleset is provided, the player's default is used. Database.Enums.Ruleset.Osu is used as a fallback.
* If a ruleset is provided but the player has no data for it, all optional fields of the response will be null.
* API.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found.
* If no date range is provided, gets all stats without considering date
Expand Down Expand Up @@ -4866,7 +4938,7 @@ export class TournamentsWrapper extends OtrApiWrapperBase {
/**
* Get all tournaments which fit an optional request query
*
* Will not include match data
* Results will not include match data
* @param params Request parameters (see {@link TournamentsListRequestParams})
* @return Returns all tournaments which fit the request query
*/
Expand Down Expand Up @@ -5878,7 +5950,7 @@ export class UsersWrapper extends OtrApiWrapperBase {
let result404: any = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", status, _responseText, _headers, result404);
return throwException("A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", status, _responseText, _headers, result404);

} else if (status === 400) {
const _responseText = response.data;
Expand Down Expand Up @@ -5958,7 +6030,7 @@ export class UsersWrapper extends OtrApiWrapperBase {
let result404: any = null;
let resultData404 = _responseText;
result404 = JSON.parse(resultData404);
return throwException("A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", status, _responseText, _headers, result404);
return throwException("A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", status, _responseText, _headers, result404);

} else if (status === 200) {
const _responseText = response.data;
Expand Down Expand Up @@ -7432,8 +7504,7 @@ export interface TournamentSearchResultDTO {
export interface TournamentSubmissionDTO {
/** The name of the tournament */
name: string;
/** Acronym / shortened name of the tournament
<example>For osu! World Cup 2023, this value would be "OWC23"</example> */
/** Acronym / shortened name of the tournament */
abbreviation: string;
/** The osu! forum post advertising this tournament */
forumUrl: string;
Expand Down
2 changes: 1 addition & 1 deletion src/clients/ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@osu-tournament-rating/otr-api-client",
"version": "0.0.11",
"version": "0.0.12",
"description": "Client code for interacting with the o!TR API",
"files": [
"index.js",
Expand Down
56 changes: 38 additions & 18 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
"Beatmaps"
],
"summary": "Get a beatmap",
"description": "Get a beatmap searching first by id, then by beatmap osu! id\n\nRequires Authorization:\n\nClaim(s): admin",
"description": "Get a beatmap searching first by id, then by osu! id\n\nRequires Authorization:\n\nClaim(s): admin",
"operationId": "Beatmaps_get",
"parameters": [
{
"name": "key",
"in": "path",
"description": "Search key (o!TR id or osu! id)",
"description": "Search key (id or osu! id)",
"required": true,
"style": "simple",
"schema": {
Expand Down Expand Up @@ -240,6 +240,20 @@
"x-requiresAuthorization": true
}
},
"/api/v1/diagnostics/ping": {
"get": {
"tags": [
"Diagnostics"
],
"operationId": "Diagnostics_ping",
"responses": {
"200": {
"description": "Success"
}
},
"x-requiresAuthorization": false
}
},
"/api/v1/filtering": {
"post": {
"tags": [
Expand Down Expand Up @@ -1605,7 +1619,7 @@
{
"name": "minRank",
"in": "query",
"description": "Rank floor",
"description": "Rank floor (The \"better\" inclusive rank bound.\r\nIf given, only players with a rank greater than or equal to this value will be included)",
"style": "form",
"schema": {
"maximum": 2147483647,
Expand All @@ -1617,7 +1631,7 @@
{
"name": "maxRank",
"in": "query",
"description": "Rank ceiling",
"description": "Rank ceiling (The \"worse\" inclusive rank bound.\r\nIf given, only players with a rank less than or equal to this value will be included)",
"style": "form",
"schema": {
"maximum": 2147483647,
Expand All @@ -1629,7 +1643,7 @@
{
"name": "minRating",
"in": "query",
"description": "Rating floor",
"description": "Rating floor (The \"worse\" inclusive rating bound.\r\nIf given, only players with a rating greater than or equal to this value will be included)",
"style": "form",
"schema": {
"maximum": 2147483647,
Expand All @@ -1641,7 +1655,7 @@
{
"name": "maxRating",
"in": "query",
"description": "Rating ceiling",
"description": "Rating ceiling (The \"better\" inclusive rating bound.\r\nIf given, only players with a rating less than or equal to this value will be included)",
"style": "form",
"schema": {
"maximum": 2147483647,
Expand Down Expand Up @@ -2268,7 +2282,7 @@
{
"name": "name",
"in": "query",
"description": "Filters results for only matches with a partially matching name",
"description": "Filters results for only matches with a partially matching name (case insensitive)",
"style": "form",
"schema": {
"type": "string"
Expand All @@ -2277,7 +2291,7 @@
{
"name": "dateMin",
"in": "query",
"description": "Filters results for only matches that occurred after a specified date",
"description": "Filters results for only matches that occurred on or after a specified date",
"style": "form",
"schema": {
"type": "string",
Expand All @@ -2287,7 +2301,7 @@
{
"name": "dateMax",
"in": "query",
"description": "Filters results for only matches that occurred before a specified date",
"description": "Filters results for only matches that occurred on or before a specified date",
"style": "form",
"schema": {
"type": "string",
Expand Down Expand Up @@ -2363,7 +2377,8 @@
{
"$ref": "#/components/schemas/MatchQuerySortType"
}
]
],
"default": 2
}
},
{
Expand Down Expand Up @@ -3622,7 +3637,7 @@
{
"name": "key",
"in": "path",
"description": "Search key (o!TR id, osu! id, or osu! username)",
"description": "Search key (id, osu! id, or osu! username)",
"required": true,
"style": "simple",
"schema": {
Expand Down Expand Up @@ -3692,7 +3707,7 @@
"Players"
],
"summary": "Get a player's stats",
"description": "Gets player by versatile search.\r\nIf no ruleset is provided, the player's default is used. OsuApiClient.Net.Constants.Endpoints.Osu is used as a fallback.\r\nIf a ruleset is provided but the player has no data for it, all optional fields of the response will be null.\r\nAPI.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found.\r\nIf no date range is provided, gets all stats without considering date\n\nRequires Authorization:\n\nClaim(s): user, client",
"description": "Gets player by versatile search.\r\nIf no ruleset is provided, the player's default is used. Database.Enums.Ruleset.Osu is used as a fallback.\r\nIf a ruleset is provided but the player has no data for it, all optional fields of the response will be null.\r\nAPI.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found.\r\nIf no date range is provided, gets all stats without considering date\n\nRequires Authorization:\n\nClaim(s): user, client",
"operationId": "Players_getStats",
"parameters": [
{
Expand Down Expand Up @@ -4662,7 +4677,7 @@
"Tournaments"
],
"summary": "Get all tournaments which fit an optional request query",
"description": "Will not include match data",
"description": "Results will not include match data",
"operationId": "Tournaments_list",
"parameters": [
{
Expand Down Expand Up @@ -4695,7 +4710,8 @@
"description": "Filters results for only tournaments that are verified",
"style": "form",
"schema": {
"type": "boolean"
"type": "boolean",
"default": true
}
},
{
Expand All @@ -4721,7 +4737,8 @@
{
"$ref": "#/components/schemas/TournamentQuerySortType"
}
]
],
"default": 1
}
},
{
Expand Down Expand Up @@ -5680,7 +5697,7 @@
],
"responses": {
"404": {
"description": "A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user",
"description": "A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user",
"content": {
"text/plain": {
"schema": {
Expand Down Expand Up @@ -5765,7 +5782,7 @@
],
"responses": {
"404": {
"description": "A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user",
"description": "A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user",
"content": {
"text/plain": {
"schema": {
Expand Down Expand Up @@ -8938,14 +8955,17 @@
"type": "object",
"properties": {
"name": {
"minLength": 1,
"type": "string",
"description": "The name of the tournament"
},
"abbreviation": {
"minLength": 1,
"type": "string",
"description": "Acronym / shortened name of the tournament\r\n<example>For osu! World Cup 2023, this value would be \"OWC23\"</example>"
"description": "Acronym / shortened name of the tournament"
},
"forumUrl": {
"minLength": 1,
"type": "string",
"description": "The osu! forum post advertising this tournament"
},
Expand Down

0 comments on commit e842e4f

Please sign in to comment.