export type PostApiOrders = {product_id: number, email: string, first_name: string, last_name: string, ticket_date_id?: number | undefined, pid?: number | undefined, prid?: number | undefined}; export type CreateApiApiOrdersArgs = {body: PostApiOrders}; export type CreateApiApiOrdersOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create order * * POST /api/orders */ export const createApiApiOrders = async (args: CreateApiApiOrdersArgs, options: CreateApiApiOrdersOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/orders${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 };