export type UpdateApiObservationsUuidSubscriptionArgs = {uuid: string}; export type UpdateApiObservationsUuidSubscriptionOptions = {baseUrl?: string | undefined, userJwtRequired?: string | undefined, fetch?: typeof fetch | undefined}; /** * Toggle the authenticated user's subscription to an observation * * PUT /observations/{uuid}/subscription */ export const updateApiObservationsUuidSubscription = async (args: UpdateApiObservationsUuidSubscriptionArgs, options?: UpdateApiObservationsUuidSubscriptionOptions) => { 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(/\/+$/, '')}/observations/${encodeURIComponent(String(args.uuid))}/subscription${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 };