export type CreateApiUsersIdBlockArgs = {id: number}; export type CreateApiUsersIdBlockOptions = {baseUrl?: string | undefined, userJwtRequired?: string | undefined, fetch?: typeof fetch | undefined}; /** * Block a user * * POST /users/{id}/block */ export const createApiUsersIdBlock = async (args: CreateApiUsersIdBlockArgs, options?: CreateApiUsersIdBlockOptions) => { const {baseUrl = "https://api.inaturalist.org/v2", fetch: fetchFn = fetch, userJwtRequired} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (userJwtRequired !== undefined) headers.set("Authorization", userJwtRequired) const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.id))}/block${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };