export type StandardHeaderSchema = string; export type Patch = {op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test', path?: string | undefined, value: unknown, from?: string | undefined}; export type PatchRequest = Array; export type PatchApiV2CheckoutOrdersIdArgs = {id: string, Authorization?: StandardHeaderSchema | undefined, 'PayPal-Auth-Assertion'?: string | undefined, body: PatchRequest}; export type PatchApiV2CheckoutOrdersIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update order * * PATCH /v2/checkout/orders/{id} */ export const patchApiV2CheckoutOrdersId = async (args: PatchApiV2CheckoutOrdersIdArgs, options?: PatchApiV2CheckoutOrdersIdOptions) => { const {baseUrl = "https://api-m.paypal.com", fetch: fetchFn = fetch, Oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['PayPal-Auth-Assertion'] != null) headers.set("PayPal-Auth-Assertion", String(args['PayPal-Auth-Assertion'])) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/checkout/orders/${encodeURIComponent(String(args.id))}${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 };