/** * Generated by orval v7.10.0 🍺 * Do not edit manually. * OpenAPI definition * OpenAPI spec version: v0 */ export interface KodikMetadata { title?: string; translations?: KodikTranslation[]; } export interface KodikTranslation { id?: string; title?: string; mediaId?: string; mediaHash?: string; mediaType?: string; translationType?: string; episodeCount?: number; } export interface KodikTranslationDTO { mediaType?: string; mediaId?: string; mediaHash?: string; } export type KodikVideoLinksLinks = {[key: string]: Link[]}; export interface KodikVideoLinks { links?: KodikVideoLinksLinks; } export interface Link { type?: string; src?: string; } export type ShikimoriParams = { id: string; }; export type KodikParams = { id: string; }; export type VideoParams = { translationDTO: KodikTranslationDTO; quality: string; episode: number; }; export type shikimoriResponse200 = { data: KodikMetadata status: 200 } export type shikimoriResponseComposite = shikimoriResponse200; export type shikimoriResponse = shikimoriResponseComposite & { headers: Headers; } export const getShikimoriUrl = (params: ShikimoriParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } }); const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `http://localhost:8081/metadata/shikimori?${stringifiedParams}` : `http://localhost:8081/metadata/shikimori` } export const shikimori = async (params: ShikimoriParams, options?: RequestInit): Promise => { const res = await fetch(getShikimoriUrl(params), { ...options, method: 'GET' } ) const body = [204, 205, 304].includes(res.status) ? null : await res.text() const data: shikimoriResponse['data'] = body ? JSON.parse(body) : {} return { data, status: res.status, headers: res.headers } as shikimoriResponse } export type kodikResponse200 = { data: KodikMetadata status: 200 } export type kodikResponseComposite = kodikResponse200; export type kodikResponse = kodikResponseComposite & { headers: Headers; } export const getKodikUrl = (params: KodikParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } }); const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `http://localhost:8081/metadata/kodik?${stringifiedParams}` : `http://localhost:8081/metadata/kodik` } export const kodik = async (params: KodikParams, options?: RequestInit): Promise => { const res = await fetch(getKodikUrl(params), { ...options, method: 'GET' } ) const body = [204, 205, 304].includes(res.status) ? null : await res.text() const data: kodikResponse['data'] = body ? JSON.parse(body) : {} return { data, status: res.status, headers: res.headers } as kodikResponse } export type videoResponse200 = { data: KodikVideoLinks status: 200 } export type videoResponseComposite = videoResponse200; export type videoResponse = videoResponseComposite & { headers: Headers; } export const getVideoUrl = (params: VideoParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } }); const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `http://localhost:8081/extract/video?${stringifiedParams}` : `http://localhost:8081/extract/video` } export const video = async (params: VideoParams, options?: RequestInit): Promise => { const res = await fetch(getVideoUrl(params), { ...options, method: 'GET' } ) const body = [204, 205, 304].includes(res.status) ? null : await res.text() const data: videoResponse['data'] = body ? JSON.parse(body) : {} return { data, status: res.status, headers: res.headers } as videoResponse }