export type PatchApiDeliveryApiV2Args = {'X-Resource-Version': string, body: {enabled?: boolean | undefined, secret?: string | undefined, format?: ('flattened' | 'inlined') | undefined, securedApis?: (Array<'folders' | 'documents' | 'images' | 'assets' | 'openapi'>) | undefined, skipTranslations?: boolean | undefined}}; export type PatchApiDeliveryApiV2Options = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Delivery API V2 Settings * * PATCH /deliveryApiV2 */ export const patchApiDeliveryApiV2 = async (args: PatchApiDeliveryApiV2Args, options?: PatchApiDeliveryApiV2Options) => { const {baseUrl = "https://developers.bloomreach.io/delivery/site/v2/documents", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Resource-Version'] != null) headers.set("X-Resource-Version", String(args['X-Resource-Version'])) const url = `${baseUrl.replace(/\/+$/, '')}/deliveryApiV2${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 };