From 55f4f8c4873b512200caf1e3bec5274e43268804 Mon Sep 17 00:00:00 2001 From: David Naranjo Date: Mon, 19 Aug 2024 01:26:09 +0200 Subject: [PATCH] Move letter draw to TS --- sdk/.openapi-generator/FILES | 3 + sdk/src/apis/LetterApi.ts | 15 +++-- sdk/src/models/CreateLetterPayload.ts | 85 +++++++++++++++++++++++++++ sdk/src/models/GroupsFields.ts | 77 ++++++++++++++++++++++++ sdk/src/models/Letter.ts | 15 +++-- sdk/src/models/LetterFields.ts | 70 ++++++++++++++++++++++ sdk/src/models/index.ts | 3 + swagger.yaml | 38 ++++++++---- 8 files changed, 281 insertions(+), 25 deletions(-) create mode 100644 sdk/src/models/CreateLetterPayload.ts create mode 100644 sdk/src/models/GroupsFields.ts create mode 100644 sdk/src/models/LetterFields.ts diff --git a/sdk/.openapi-generator/FILES b/sdk/.openapi-generator/FILES index 5b2a83af..38aa3880 100644 --- a/sdk/.openapi-generator/FILES +++ b/sdk/.openapi-generator/FILES @@ -26,16 +26,19 @@ src/models/BaseResult.ts src/models/Coin.ts src/models/CoinResult.ts src/models/CreateGroupsPayload.ts +src/models/CreateLetterPayload.ts src/models/DrawMetadata.ts src/models/DrawReTossPayload.ts src/models/DrawTossPayload.ts src/models/Groups.ts +src/models/GroupsFields.ts src/models/GroupsResult.ts src/models/Instagram.ts src/models/InstagramResult.ts src/models/InstagramResultAllOfComment.ts src/models/InstagramResultAllOfValue.ts src/models/Letter.ts +src/models/LetterFields.ts src/models/LetterResult.ts src/models/Link.ts src/models/LinkResult.ts diff --git a/sdk/src/apis/LetterApi.ts b/sdk/src/apis/LetterApi.ts index 0806337d..ab21ae18 100644 --- a/sdk/src/apis/LetterApi.ts +++ b/sdk/src/apis/LetterApi.ts @@ -15,11 +15,14 @@ import * as runtime from '../runtime'; import type { + CreateLetterPayload, DrawTossPayload, Letter, LetterResult, } from '../models/index'; import { + CreateLetterPayloadFromJSON, + CreateLetterPayloadToJSON, DrawTossPayloadFromJSON, DrawTossPayloadToJSON, LetterFromJSON, @@ -29,7 +32,7 @@ import { } from '../models/index'; export interface LetterCreateRequest { - letter: Letter; + createLetterPayload: CreateLetterPayload; } export interface LetterReadRequest { @@ -50,7 +53,7 @@ export interface LetterTossRequest { export interface LetterApiInterface { /** * - * @param {Letter} letter + * @param {CreateLetterPayload} createLetterPayload * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof LetterApiInterface @@ -98,10 +101,10 @@ export class LetterApi extends runtime.BaseAPI implements LetterApiInterface { /** */ async letterCreateRaw(requestParameters: LetterCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters['letter'] == null) { + if (requestParameters['createLetterPayload'] == null) { throw new runtime.RequiredError( - 'letter', - 'Required parameter "letter" was null or undefined when calling letterCreate().' + 'createLetterPayload', + 'Required parameter "createLetterPayload" was null or undefined when calling letterCreate().' ); } @@ -116,7 +119,7 @@ export class LetterApi extends runtime.BaseAPI implements LetterApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: LetterToJSON(requestParameters['letter']), + body: CreateLetterPayloadToJSON(requestParameters['createLetterPayload']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => LetterFromJSON(jsonValue)); diff --git a/sdk/src/models/CreateLetterPayload.ts b/sdk/src/models/CreateLetterPayload.ts new file mode 100644 index 00000000..2feeefcb --- /dev/null +++ b/sdk/src/models/CreateLetterPayload.ts @@ -0,0 +1,85 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * EAS API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 { DrawMetadata } from './DrawMetadata'; +import { + DrawMetadataFromJSON, + DrawMetadataFromJSONTyped, + DrawMetadataToJSON, +} from './DrawMetadata'; +import type { BaseFields } from './BaseFields'; +import { + BaseFieldsFromJSON, + BaseFieldsFromJSONTyped, + BaseFieldsToJSON, +} from './BaseFields'; + +/** + * + * @export + * @interface CreateLetterPayload + */ +export interface CreateLetterPayload extends BaseFields { + /** + * + * @type {number} + * @memberof CreateLetterPayload + */ + numberOfResults: number; + /** + * + * @type {boolean} + * @memberof CreateLetterPayload + */ + allowRepeatedResults: boolean; +} + + + +/** + * Check if a given object implements the CreateLetterPayload interface. + */ +export function instanceOfCreateLetterPayload(value: object): value is CreateLetterPayload { + if (!('numberOfResults' in value) || value['numberOfResults'] === undefined) return false; + if (!('allowRepeatedResults' in value) || value['allowRepeatedResults'] === undefined) return false; + return true; +} + +export function CreateLetterPayloadFromJSON(json: any): CreateLetterPayload { + return CreateLetterPayloadFromJSONTyped(json, false); +} + +export function CreateLetterPayloadFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateLetterPayload { + if (json == null) { + return json; + } + return { + ...BaseFieldsFromJSONTyped(json, ignoreDiscriminator), + 'numberOfResults': json['number_of_results'], + 'allowRepeatedResults': json['allow_repeated_results'], + }; +} + +export function CreateLetterPayloadToJSON(value?: CreateLetterPayload | null): any { + if (value == null) { + return value; + } + return { + ...BaseFieldsToJSON(value), + 'number_of_results': value['numberOfResults'], + 'allow_repeated_results': value['allowRepeatedResults'], + }; +} + diff --git a/sdk/src/models/GroupsFields.ts b/sdk/src/models/GroupsFields.ts new file mode 100644 index 00000000..bdf59cc6 --- /dev/null +++ b/sdk/src/models/GroupsFields.ts @@ -0,0 +1,77 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * EAS API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 { Participant } from './Participant'; +import { + ParticipantFromJSON, + ParticipantFromJSONTyped, + ParticipantToJSON, +} from './Participant'; + +/** + * + * @export + * @interface GroupsFields + */ +export interface GroupsFields { + /** + * + * @type {Array} + * @memberof GroupsFields + */ + participants: Array; + /** + * + * @type {number} + * @memberof GroupsFields + */ + numberOfGroups: number; +} + +/** + * Check if a given object implements the GroupsFields interface. + */ +export function instanceOfGroupsFields(value: object): value is GroupsFields { + if (!('participants' in value) || value['participants'] === undefined) return false; + if (!('numberOfGroups' in value) || value['numberOfGroups'] === undefined) return false; + return true; +} + +export function GroupsFieldsFromJSON(json: any): GroupsFields { + return GroupsFieldsFromJSONTyped(json, false); +} + +export function GroupsFieldsFromJSONTyped(json: any, ignoreDiscriminator: boolean): GroupsFields { + if (json == null) { + return json; + } + return { + + 'participants': ((json['participants'] as Array).map(ParticipantFromJSON)), + 'numberOfGroups': json['number_of_groups'], + }; +} + +export function GroupsFieldsToJSON(value?: GroupsFields | null): any { + if (value == null) { + return value; + } + return { + + 'participants': ((value['participants'] as Array).map(ParticipantToJSON)), + 'number_of_groups': value['numberOfGroups'], + }; +} + diff --git a/sdk/src/models/Letter.ts b/sdk/src/models/Letter.ts index 4d373e2e..7a2829df 100644 --- a/sdk/src/models/Letter.ts +++ b/sdk/src/models/Letter.ts @@ -43,19 +43,19 @@ export interface Letter extends BaseDraw { * @type {number} * @memberof Letter */ - numberOfResults?: number; + numberOfResults: number; /** * * @type {boolean} * @memberof Letter */ - allowRepeatedResults?: boolean; + allowRepeatedResults: boolean; /** * * @type {Array} * @memberof Letter */ - readonly results?: Array; + readonly results: Array; } @@ -64,6 +64,9 @@ export interface Letter extends BaseDraw { * Check if a given object implements the Letter interface. */ export function instanceOfLetter(value: object): value is Letter { + if (!('numberOfResults' in value) || value['numberOfResults'] === undefined) return false; + if (!('allowRepeatedResults' in value) || value['allowRepeatedResults'] === undefined) return false; + if (!('results' in value) || value['results'] === undefined) return false; return true; } @@ -77,9 +80,9 @@ export function LetterFromJSONTyped(json: any, ignoreDiscriminator: boolean): Le } return { ...BaseDrawFromJSONTyped(json, ignoreDiscriminator), - 'numberOfResults': json['number_of_results'] == null ? undefined : json['number_of_results'], - 'allowRepeatedResults': json['allow_repeated_results'] == null ? undefined : json['allow_repeated_results'], - 'results': json['results'] == null ? undefined : ((json['results'] as Array).map(LetterResultFromJSON)), + 'numberOfResults': json['number_of_results'], + 'allowRepeatedResults': json['allow_repeated_results'], + 'results': ((json['results'] as Array).map(LetterResultFromJSON)), }; } diff --git a/sdk/src/models/LetterFields.ts b/sdk/src/models/LetterFields.ts new file mode 100644 index 00000000..27726826 --- /dev/null +++ b/sdk/src/models/LetterFields.ts @@ -0,0 +1,70 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * EAS API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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 LetterFields + */ +export interface LetterFields { + /** + * + * @type {number} + * @memberof LetterFields + */ + numberOfResults: number; + /** + * + * @type {boolean} + * @memberof LetterFields + */ + allowRepeatedResults: boolean; +} + +/** + * Check if a given object implements the LetterFields interface. + */ +export function instanceOfLetterFields(value: object): value is LetterFields { + if (!('numberOfResults' in value) || value['numberOfResults'] === undefined) return false; + if (!('allowRepeatedResults' in value) || value['allowRepeatedResults'] === undefined) return false; + return true; +} + +export function LetterFieldsFromJSON(json: any): LetterFields { + return LetterFieldsFromJSONTyped(json, false); +} + +export function LetterFieldsFromJSONTyped(json: any, ignoreDiscriminator: boolean): LetterFields { + if (json == null) { + return json; + } + return { + + 'numberOfResults': json['number_of_results'], + 'allowRepeatedResults': json['allow_repeated_results'], + }; +} + +export function LetterFieldsToJSON(value?: LetterFields | null): any { + if (value == null) { + return value; + } + return { + + 'number_of_results': value['numberOfResults'], + 'allow_repeated_results': value['allowRepeatedResults'], + }; +} + diff --git a/sdk/src/models/index.ts b/sdk/src/models/index.ts index 18b0c3d4..b902fa2e 100644 --- a/sdk/src/models/index.ts +++ b/sdk/src/models/index.ts @@ -7,16 +7,19 @@ export * from './BaseResult'; export * from './Coin'; export * from './CoinResult'; export * from './CreateGroupsPayload'; +export * from './CreateLetterPayload'; export * from './DrawMetadata'; export * from './DrawReTossPayload'; export * from './DrawTossPayload'; export * from './Groups'; +export * from './GroupsFields'; export * from './GroupsResult'; export * from './Instagram'; export * from './InstagramResult'; export * from './InstagramResultAllOfComment'; export * from './InstagramResultAllOfValue'; export * from './Letter'; +export * from './LetterFields'; export * from './LetterResult'; export * from './Link'; export * from './LinkResult'; diff --git a/swagger.yaml b/swagger.yaml index 73878db6..22614bcd 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -337,7 +337,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Letter' + $ref: '#/components/schemas/CreateLetterPayload' required: true parameters: [] '/letter/{id}/': @@ -1209,9 +1209,8 @@ components: items: $ref: '#/components/schemas/TournamentResult' readOnly: true - CreateGroupsPayload: + GroupsFields: allOf: - - $ref: '#/components/schemas/BaseFields' - type: object required: - participants @@ -1223,20 +1222,19 @@ components: $ref: '#/components/schemas/Participant' number_of_groups: type: integer + + CreateGroupsPayload: + allOf: + - $ref: '#/components/schemas/BaseFields' + - $ref: '#/components/schemas/GroupsFields' Groups: allOf: - $ref: '#/components/schemas/BaseDraw' + - $ref: '#/components/schemas/GroupsFields' - type: object required: - - participants - - number_of_groups + - resutls properties: - participants: - type: array - items: - $ref: '#/components/schemas/Participant' - number_of_groups: - type: integer results: type: array items: @@ -1265,10 +1263,12 @@ components: items: $ref: '#/components/schemas/RandomNumberResult' readOnly: true - Letter: + LetterFields: allOf: - - $ref: '#/components/schemas/BaseDraw' - type: object + required: + - number_of_results + - allow_repeated_results properties: number_of_results: type: integer @@ -1276,6 +1276,18 @@ components: allow_repeated_results: type: boolean default: true + CreateLetterPayload: + allOf: + - $ref: '#/components/schemas/BaseFields' + - $ref: '#/components/schemas/LetterFields' + Letter: + allOf: + - $ref: '#/components/schemas/BaseDraw' + - $ref: '#/components/schemas/LetterFields' + - type: object + required: + - results + properties: results: type: array items: