export type DeleteApiFavoritesArgs = {rental_id: number}; export type DeleteApiFavoritesOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete favorite using the rental id * * DELETE /favorites * * Also accepts auth: API-Key */ export const deleteApiFavorites = async (args: DeleteApiFavoritesArgs, options: DeleteApiFavoritesOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.rental_id != null) query.append("rental_id", String(args.rental_id)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/favorites${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };