/** * Interface of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, RESTCallbacks, RESTConfig, RESTRequestJson, RESTRequestVoid, } from "../rest-tools"; import { z as zod } from "zod" import { Long, Season, SeasonCreate, SeasonUpdate, UUID, ZodSeason, isSeason, } from "../model"; export namespace SeasonResource { /** * Get all season */ export function get({ restConfig, params, }: { restConfig: RESTConfig, params: { id: Long, }, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/{id}", requestType: HTTPRequestModel.GET, contentType: HTTPMimeType.JSON, accept: HTTPMimeType.JSON, }, restConfig, params, }, isSeason); }; export const ZodGetsTypeReturn = zod.array(ZodSeason); export type GetsTypeReturn = zod.infer; export function isGetsTypeReturn(data: any): data is GetsTypeReturn { try { ZodGetsTypeReturn.parse(data); return true; } catch (e: any) { console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`); return false; } } /** * Get a specific Season with his ID */ export function gets({ restConfig, }: { restConfig: RESTConfig, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/", requestType: HTTPRequestModel.GET, accept: HTTPMimeType.JSON, }, restConfig, }, isGetsTypeReturn); }; /** * Modify a specific season */ export function patch({ restConfig, params, data, }: { restConfig: RESTConfig, params: { id: Long, }, data: SeasonUpdate, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/{id}", requestType: HTTPRequestModel.PUT, contentType: HTTPMimeType.JSON, accept: HTTPMimeType.JSON, }, restConfig, params, data, }, isSeason); }; /** * Create a new season */ export function post({ restConfig, data, }: { restConfig: RESTConfig, data: SeasonCreate, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/", requestType: HTTPRequestModel.POST, contentType: HTTPMimeType.JSON, accept: HTTPMimeType.JSON, }, restConfig, data, }, isSeason); }; /** * Remove a specific season */ export function remove({ restConfig, params, }: { restConfig: RESTConfig, params: { id: Long, }, }): Promise { return RESTRequestVoid({ restModel: { endPoint: "/season/{id}", requestType: HTTPRequestModel.DELETE, contentType: HTTPMimeType.TEXT_PLAIN, }, restConfig, params, }); }; /** * Remove a specific cover of a season */ export function removeCover({ restConfig, params, }: { restConfig: RESTConfig, params: { coverId: UUID, id: Long, }, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/{id}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, params, }, isSeason); }; /** * Upload a new season cover season */ export function uploadCover({ restConfig, params, data, callbacks, }: { restConfig: RESTConfig, params: { id: Long, }, data: { file: File, }, callbacks?: RESTCallbacks, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/season/{id}/cover", requestType: HTTPRequestModel.POST, contentType: HTTPMimeType.MULTIPART, accept: HTTPMimeType.JSON, }, restConfig, params, data, callbacks, }, isSeason); }; }