export type CreateBottlePayload = {color: 'red' | 'white' | 'rose' | 'yellow' | 'sparkling', country?: string | undefined, name: string, region?: string | undefined, review?: string | undefined, sweetness?: number | undefined, varietal: string, vineyard: string, vintage: number}; export type CreateApiCellarAccountsAccountIDBottlesArgs = {accountID: number, body: CreateBottlePayload}; export type CreateApiCellarAccountsAccountIDBottlesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * create bottle * * POST /cellar/accounts/{accountID}/bottles */ export const createApiCellarAccountsAccountIDBottles = async (args: CreateApiCellarAccountsAccountIDBottlesArgs, options?: CreateApiCellarAccountsAccountIDBottlesOptions) => { 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${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };