export type BottlePayload = {color?: ('red' | 'white' | 'rose' | 'yellow' | 'sparkling') | undefined, country?: string | undefined, name?: string | undefined, region?: string | undefined, review?: string | undefined, sweetness?: number | undefined, varietal?: string | undefined, vineyard?: string | undefined, vintage?: number | undefined}; export type PatchApiCellarAccountsAccountIDBottlesBottleIDArgs = {accountID: number, bottleID: number, body: BottlePayload}; export type PatchApiCellarAccountsAccountIDBottlesBottleIDOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * update bottle * * PATCH /cellar/accounts/{accountID}/bottles/{bottleID} */ export const patchApiCellarAccountsAccountIDBottlesBottleID = async (args: PatchApiCellarAccountsAccountIDBottlesBottleIDArgs, options?: PatchApiCellarAccountsAccountIDBottlesBottleIDOptions) => { const {baseUrl = "http://localhost:8081", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/cellar/accounts/${encodeURIComponent(String(args.accountID))}/bottles/${encodeURIComponent(String(args.bottleID))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };