export type UpdateApiTopicsIdStateStateArgs = {id: string, state: string}; export type UpdateApiTopicsIdStateStateOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update the topic state * * PUT /topics/{id}/state/{state} */ export const updateApiTopicsIdStateState = async (args: UpdateApiTopicsIdStateStateArgs, options: UpdateApiTopicsIdStateStateOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/topics/${encodeURIComponent(String(args.id))}/state/${encodeURIComponent(String(args.state))}${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 };