export type UpdateApiCracksApiUpdateGameArgs = {api_key: string, game_id: number, user_id: number, title?: string | undefined, note_staff?: string | undefined, url?: string | undefined, is_online?: boolean | undefined, categories?: Array | undefined, sources?: Array | undefined}; export type UpdateApiCracksApiUpdateGameOptions = {baseUrl?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Modifie un jeu existant dans la base de données. * * PUT /Cracks/api/update-game/ */ export const updateApiCracksApiUpdateGame = async (args: UpdateApiCracksApiUpdateGameArgs, options?: UpdateApiCracksApiUpdateGameOptions) => { const {baseUrl = "https://api.jeuxcracks.fr", fetch: fetchFn = fetch, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.api_key != null) query.append("api_key", String(args.api_key)) if (args.game_id != null) query.append("game_id", String(args.game_id)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.title != null) query.append("title", String(args.title)) if (args.note_staff != null) query.append("note_staff", String(args.note_staff)) if (args.url != null) query.append("url", String(args.url)) if (args.is_online != null) query.append("is_online", String(args.is_online)) for (const item of args.categories ?? []) query.append("categories", String(item)) for (const item of args.sources ?? []) query.append("sources", String(item)) if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/Cracks/api/update-game/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };