export type PatchApiPurchaseOrdersNumberPurchaseArgs = {number: string}; export type PatchApiPurchaseOrdersNumberPurchaseOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, accountToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Purchase Purchase Order * * PATCH /purchase_orders/{number}/purchase */ export const patchApiPurchaseOrdersNumberPurchase = async (args: PatchApiPurchaseOrdersNumberPurchaseArgs, options?: PatchApiPurchaseOrdersNumberPurchaseOptions) => { const {baseUrl = "https://secure.fleetio.com/api", fetch: fetchFn = fetch, apiKey, accountToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("Authorization", apiKey) if (accountToken !== undefined) headers.set("Account-Token", accountToken) const url = `${baseUrl.replace(/\/+$/, '')}/purchase_orders/${encodeURIComponent(String(args.number))}/purchase${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };