feat(ttt): match history done

This commit is contained in:
Maix0 2026-01-06 23:44:02 +01:00 committed by Maix0
parent 8f3ed71d8a
commit 2bf5e6e700
17 changed files with 1185 additions and 18 deletions

View file

@ -66,5 +66,10 @@ models/StatusOtp200ResponseAnyOf1.ts
models/StatusOtp200ResponseAnyOfPayload.ts
models/StatusOtp401Response.ts
models/StatusOtp500Response.ts
models/TttHistory200Response.ts
models/TttHistory200ResponsePayload.ts
models/TttHistory200ResponsePayloadDataInner.ts
models/TttHistory200ResponsePayloadDataInnerPlayerX.ts
models/TttHistory404Response.ts
models/index.ts
runtime.ts

View file

@ -63,6 +63,8 @@ import type {
StatusOtp200Response,
StatusOtp401Response,
StatusOtp500Response,
TttHistory200Response,
TttHistory404Response,
} from '../models/index';
import {
AllowGuestMessage200ResponseFromJSON,
@ -161,6 +163,10 @@ import {
StatusOtp401ResponseToJSON,
StatusOtp500ResponseFromJSON,
StatusOtp500ResponseToJSON,
TttHistory200ResponseFromJSON,
TttHistory200ResponseToJSON,
TttHistory404ResponseFromJSON,
TttHistory404ResponseToJSON,
} from '../models/index';
export interface ChangeDescOperationRequest {
@ -199,6 +205,10 @@ export interface SigninRequest {
loginRequest: LoginRequest;
}
export interface TttHistoryRequest {
user: string;
}
/**
*
*/
@ -1027,4 +1037,58 @@ export class OpenapiOtherApi extends runtime.BaseAPI {
return await response.value();
}
/**
*/
async tttHistoryRaw(requestParameters: TttHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TttHistory200Response | StatusOtp401Response | TttHistory404Response>> {
if (requestParameters['user'] == null) {
throw new runtime.RequiredError(
'user',
'Required parameter "user" was null or undefined when calling tttHistory().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
let urlPath = `/api/ttt/history/{user}`;
urlPath = urlPath.replace(`{${"user"}}`, encodeURIComponent(String(requestParameters['user'])));
const response = await this.request({
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
// CHANGED: Handle all status codes defined in the OpenAPI spec, not just 2xx responses
// This allows typed access to error responses (4xx, 5xx) and other status codes.
// The code routes responses based on the actual HTTP status code and returns
// appropriately typed ApiResponse wrappers for each status code.
if (response.status === 200) {
// Object response for status 200
return new runtime.JSONApiResponse(response, (jsonValue) => TttHistory200ResponseFromJSON(jsonValue));
}
if (response.status === 401) {
// Object response for status 401
return new runtime.JSONApiResponse(response, (jsonValue) => StatusOtp401ResponseFromJSON(jsonValue));
}
if (response.status === 404) {
// Object response for status 404
return new runtime.JSONApiResponse(response, (jsonValue) => TttHistory404ResponseFromJSON(jsonValue));
}
// CHANGED: Throw error if status code is not handled by any of the defined responses
// This ensures all code paths return a value and provides clear error messages for unexpected status codes
// Only throw if responses were defined but none matched the actual status code
throw new runtime.ResponseError(response, `Unexpected status code: ${response.status}. Expected one of: 200, 401, 404`);
}
/**
*/
async tttHistory(requestParameters: TttHistoryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TttHistory200Response | StatusOtp401Response | TttHistory404Response> {
const response = await this.tttHistoryRaw(requestParameters, initOverrides);
return await response.value();
}
}

View file

@ -0,0 +1,110 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { TttHistory200ResponsePayload } from './TttHistory200ResponsePayload';
import {
TttHistory200ResponsePayloadFromJSON,
TttHistory200ResponsePayloadFromJSONTyped,
TttHistory200ResponsePayloadToJSON,
TttHistory200ResponsePayloadToJSONTyped,
} from './TttHistory200ResponsePayload';
/**
*
* @export
* @interface TttHistory200Response
*/
export interface TttHistory200Response {
/**
*
* @type {string}
* @memberof TttHistory200Response
*/
kind: TttHistory200ResponseKindEnum;
/**
*
* @type {string}
* @memberof TttHistory200Response
*/
msg: TttHistory200ResponseMsgEnum;
/**
*
* @type {TttHistory200ResponsePayload}
* @memberof TttHistory200Response
*/
payload: TttHistory200ResponsePayload;
}
/**
* @export
*/
export const TttHistory200ResponseKindEnum = {
Success: 'success'
} as const;
export type TttHistory200ResponseKindEnum = typeof TttHistory200ResponseKindEnum[keyof typeof TttHistory200ResponseKindEnum];
/**
* @export
*/
export const TttHistory200ResponseMsgEnum = {
TtthistorySuccess: 'ttthistory.success'
} as const;
export type TttHistory200ResponseMsgEnum = typeof TttHistory200ResponseMsgEnum[keyof typeof TttHistory200ResponseMsgEnum];
/**
* Check if a given object implements the TttHistory200Response interface.
*/
export function instanceOfTttHistory200Response(value: object): value is TttHistory200Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
if (!('payload' in value) || value['payload'] === undefined) return false;
return true;
}
export function TttHistory200ResponseFromJSON(json: any): TttHistory200Response {
return TttHistory200ResponseFromJSONTyped(json, false);
}
export function TttHistory200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TttHistory200Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
'payload': TttHistory200ResponsePayloadFromJSON(json['payload']),
};
}
export function TttHistory200ResponseToJSON(json: any): TttHistory200Response {
return TttHistory200ResponseToJSONTyped(json, false);
}
export function TttHistory200ResponseToJSONTyped(value?: TttHistory200Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
'payload': TttHistory200ResponsePayloadToJSON(value['payload']),
};
}

View file

@ -0,0 +1,74 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { TttHistory200ResponsePayloadDataInner } from './TttHistory200ResponsePayloadDataInner';
import {
TttHistory200ResponsePayloadDataInnerFromJSON,
TttHistory200ResponsePayloadDataInnerFromJSONTyped,
TttHistory200ResponsePayloadDataInnerToJSON,
TttHistory200ResponsePayloadDataInnerToJSONTyped,
} from './TttHistory200ResponsePayloadDataInner';
/**
*
* @export
* @interface TttHistory200ResponsePayload
*/
export interface TttHistory200ResponsePayload {
/**
*
* @type {Array<TttHistory200ResponsePayloadDataInner>}
* @memberof TttHistory200ResponsePayload
*/
data: Array<TttHistory200ResponsePayloadDataInner>;
}
/**
* Check if a given object implements the TttHistory200ResponsePayload interface.
*/
export function instanceOfTttHistory200ResponsePayload(value: object): value is TttHistory200ResponsePayload {
if (!('data' in value) || value['data'] === undefined) return false;
return true;
}
export function TttHistory200ResponsePayloadFromJSON(json: any): TttHistory200ResponsePayload {
return TttHistory200ResponsePayloadFromJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadFromJSONTyped(json: any, ignoreDiscriminator: boolean): TttHistory200ResponsePayload {
if (json == null) {
return json;
}
return {
'data': ((json['data'] as Array<any>).map(TttHistory200ResponsePayloadDataInnerFromJSON)),
};
}
export function TttHistory200ResponsePayloadToJSON(json: any): TttHistory200ResponsePayload {
return TttHistory200ResponsePayloadToJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadToJSONTyped(value?: TttHistory200ResponsePayload | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'data': ((value['data'] as Array<any>).map(TttHistory200ResponsePayloadDataInnerToJSON)),
};
}

View file

@ -0,0 +1,122 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { TttHistory200ResponsePayloadDataInnerPlayerX } from './TttHistory200ResponsePayloadDataInnerPlayerX';
import {
TttHistory200ResponsePayloadDataInnerPlayerXFromJSON,
TttHistory200ResponsePayloadDataInnerPlayerXFromJSONTyped,
TttHistory200ResponsePayloadDataInnerPlayerXToJSON,
TttHistory200ResponsePayloadDataInnerPlayerXToJSONTyped,
} from './TttHistory200ResponsePayloadDataInnerPlayerX';
/**
*
* @export
* @interface TttHistory200ResponsePayloadDataInner
*/
export interface TttHistory200ResponsePayloadDataInner {
/**
* gameId
* @type {string}
* @memberof TttHistory200ResponsePayloadDataInner
*/
gameId: string;
/**
*
* @type {TttHistory200ResponsePayloadDataInnerPlayerX}
* @memberof TttHistory200ResponsePayloadDataInner
*/
playerX: TttHistory200ResponsePayloadDataInnerPlayerX;
/**
*
* @type {TttHistory200ResponsePayloadDataInnerPlayerX}
* @memberof TttHistory200ResponsePayloadDataInner
*/
playerO: TttHistory200ResponsePayloadDataInnerPlayerX;
/**
*
* @type {string}
* @memberof TttHistory200ResponsePayloadDataInner
*/
date: string;
/**
*
* @type {string}
* @memberof TttHistory200ResponsePayloadDataInner
*/
outcome: TttHistory200ResponsePayloadDataInnerOutcomeEnum;
}
/**
* @export
*/
export const TttHistory200ResponsePayloadDataInnerOutcomeEnum = {
WinX: 'winX',
WinO: 'winO',
Other: 'other'
} as const;
export type TttHistory200ResponsePayloadDataInnerOutcomeEnum = typeof TttHistory200ResponsePayloadDataInnerOutcomeEnum[keyof typeof TttHistory200ResponsePayloadDataInnerOutcomeEnum];
/**
* Check if a given object implements the TttHistory200ResponsePayloadDataInner interface.
*/
export function instanceOfTttHistory200ResponsePayloadDataInner(value: object): value is TttHistory200ResponsePayloadDataInner {
if (!('gameId' in value) || value['gameId'] === undefined) return false;
if (!('playerX' in value) || value['playerX'] === undefined) return false;
if (!('playerO' in value) || value['playerO'] === undefined) return false;
if (!('date' in value) || value['date'] === undefined) return false;
if (!('outcome' in value) || value['outcome'] === undefined) return false;
return true;
}
export function TttHistory200ResponsePayloadDataInnerFromJSON(json: any): TttHistory200ResponsePayloadDataInner {
return TttHistory200ResponsePayloadDataInnerFromJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadDataInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): TttHistory200ResponsePayloadDataInner {
if (json == null) {
return json;
}
return {
'gameId': json['gameId'],
'playerX': TttHistory200ResponsePayloadDataInnerPlayerXFromJSON(json['playerX']),
'playerO': TttHistory200ResponsePayloadDataInnerPlayerXFromJSON(json['playerO']),
'date': json['date'],
'outcome': json['outcome'],
};
}
export function TttHistory200ResponsePayloadDataInnerToJSON(json: any): TttHistory200ResponsePayloadDataInner {
return TttHistory200ResponsePayloadDataInnerToJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadDataInnerToJSONTyped(value?: TttHistory200ResponsePayloadDataInner | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'gameId': value['gameId'],
'playerX': TttHistory200ResponsePayloadDataInnerPlayerXToJSON(value['playerX']),
'playerO': TttHistory200ResponsePayloadDataInnerPlayerXToJSON(value['playerO']),
'date': value['date'],
'outcome': value['outcome'],
};
}

View file

@ -0,0 +1,75 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface TttHistory200ResponsePayloadDataInnerPlayerX
*/
export interface TttHistory200ResponsePayloadDataInnerPlayerX {
/**
*
* @type {string}
* @memberof TttHistory200ResponsePayloadDataInnerPlayerX
*/
id: string;
/**
*
* @type {string}
* @memberof TttHistory200ResponsePayloadDataInnerPlayerX
*/
name: string;
}
/**
* Check if a given object implements the TttHistory200ResponsePayloadDataInnerPlayerX interface.
*/
export function instanceOfTttHistory200ResponsePayloadDataInnerPlayerX(value: object): value is TttHistory200ResponsePayloadDataInnerPlayerX {
if (!('id' in value) || value['id'] === undefined) return false;
if (!('name' in value) || value['name'] === undefined) return false;
return true;
}
export function TttHistory200ResponsePayloadDataInnerPlayerXFromJSON(json: any): TttHistory200ResponsePayloadDataInnerPlayerX {
return TttHistory200ResponsePayloadDataInnerPlayerXFromJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadDataInnerPlayerXFromJSONTyped(json: any, ignoreDiscriminator: boolean): TttHistory200ResponsePayloadDataInnerPlayerX {
if (json == null) {
return json;
}
return {
'id': json['id'],
'name': json['name'],
};
}
export function TttHistory200ResponsePayloadDataInnerPlayerXToJSON(json: any): TttHistory200ResponsePayloadDataInnerPlayerX {
return TttHistory200ResponsePayloadDataInnerPlayerXToJSONTyped(json, false);
}
export function TttHistory200ResponsePayloadDataInnerPlayerXToJSONTyped(value?: TttHistory200ResponsePayloadDataInnerPlayerX | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'id': value['id'],
'name': value['name'],
};
}

View file

@ -0,0 +1,93 @@
/* tslint:disable */
/* eslint-disable */
/**
* @fastify/swagger
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 9.6.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface TttHistory404Response
*/
export interface TttHistory404Response {
/**
*
* @type {string}
* @memberof TttHistory404Response
*/
kind: TttHistory404ResponseKindEnum;
/**
*
* @type {string}
* @memberof TttHistory404Response
*/
msg: TttHistory404ResponseMsgEnum;
}
/**
* @export
*/
export const TttHistory404ResponseKindEnum = {
Failure: 'failure'
} as const;
export type TttHistory404ResponseKindEnum = typeof TttHistory404ResponseKindEnum[keyof typeof TttHistory404ResponseKindEnum];
/**
* @export
*/
export const TttHistory404ResponseMsgEnum = {
TtthistoryFailureNotfound: 'ttthistory.failure.notfound'
} as const;
export type TttHistory404ResponseMsgEnum = typeof TttHistory404ResponseMsgEnum[keyof typeof TttHistory404ResponseMsgEnum];
/**
* Check if a given object implements the TttHistory404Response interface.
*/
export function instanceOfTttHistory404Response(value: object): value is TttHistory404Response {
if (!('kind' in value) || value['kind'] === undefined) return false;
if (!('msg' in value) || value['msg'] === undefined) return false;
return true;
}
export function TttHistory404ResponseFromJSON(json: any): TttHistory404Response {
return TttHistory404ResponseFromJSONTyped(json, false);
}
export function TttHistory404ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TttHistory404Response {
if (json == null) {
return json;
}
return {
'kind': json['kind'],
'msg': json['msg'],
};
}
export function TttHistory404ResponseToJSON(json: any): TttHistory404Response {
return TttHistory404ResponseToJSONTyped(json, false);
}
export function TttHistory404ResponseToJSONTyped(value?: TttHistory404Response | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'kind': value['kind'],
'msg': value['msg'],
};
}

View file

@ -65,3 +65,8 @@ export * from './StatusOtp200ResponseAnyOf1';
export * from './StatusOtp200ResponseAnyOfPayload';
export * from './StatusOtp401Response';
export * from './StatusOtp500Response';
export * from './TttHistory200Response';
export * from './TttHistory200ResponsePayload';
export * from './TttHistory200ResponsePayloadDataInner';
export * from './TttHistory200ResponsePayloadDataInnerPlayerX';
export * from './TttHistory404Response';