export type UUID = string; export type OrderDuration = number; export type CreateApiInvoicesCaptureIdExtendDurationArgs = {captureId: UUID, body: {duration: OrderDuration}}; export type CreateApiInvoicesCaptureIdExtendDurationOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Extend Invoice duration * * POST /invoices/{captureId}/extend-duration */ export const createApiInvoicesCaptureIdExtendDuration = async (args: CreateApiInvoicesCaptureIdExtendDurationArgs, options?: CreateApiInvoicesCaptureIdExtendDurationOptions) => { const {baseUrl = "https://paella-sandbox.billie.io/api/v2", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.captureId))}/extend-duration${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 };