export type Category = {id?: number | undefined, name: string, slug: unknown, icon?: string | undefined, games_count?: string | undefined}; export type Tag = {id?: number | undefined, name: string}; export type GameVersionPublic = {id?: number | undefined, source: 'onlinefix' | 'steamrip' | 'dodi' | 'fitgirl' | 'other', version?: string | undefined, size?: number | undefined, size_formatted?: string | undefined, size_raw?: string | undefined, is_online?: boolean | undefined, created_at?: string | undefined}; export type GameDetail = {id?: number | undefined, steam_id?: (string | null) | undefined, title: string, slug: unknown, description?: string | undefined, description_short?: string | undefined, description_fr?: string | undefined, header?: (string | null) | undefined, background?: (string | null) | undefined, video?: string | undefined, screenshots?: Record | undefined, categories?: Array | undefined, tags?: Array | undefined, developer?: string | undefined, publisher?: string | undefined, requirements?: Record | undefined, source?: Record | undefined, views?: number | undefined, likes?: number | undefined, favorites_count?: number | undefined, downloads_count?: number | undefined, release_date?: (string | null) | undefined, published_at?: string | undefined, updated_at?: string | undefined, is_liked?: string | undefined, is_favorited?: string | undefined, versions?: Array | undefined}; export type CreateApiApiAppGamesIdViewArgs = {body: GameDetail}; export type CreateApiApiAppGamesIdViewOptions = {baseUrl?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Incrémenter les vues (1 par user/24h) * * POST /api/app/games/{id}/view/ */ export const createApiApiAppGamesIdView = async (args: CreateApiApiAppGamesIdViewArgs, options?: CreateApiApiAppGamesIdViewOptions) => { const {baseUrl = "https://api.jeuxcracks.fr", fetch: fetchFn = fetch, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/app/games/${encodeURIComponent(String(args.id))}/view/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };