export type Patch = {op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test', path?: string | undefined, value: unknown, from?: string | undefined}; export type PatchRequest = Array; export type PatchApiV1BillingPlansIdArgs = {'Content-Type': string, id: string, body: PatchRequest}; export type PatchApiV1BillingPlansIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update plan * * PATCH /v1/billing/plans/{id} */ export const patchApiV1BillingPlansId = async (args: PatchApiV1BillingPlansIdArgs, options?: PatchApiV1BillingPlansIdOptions) => { const {baseUrl = "https://api-m.sandbox.paypal.com", fetch: fetchFn = fetch, Oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/billing/plans/${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 };