export type DeleteApiV2CommerceProductsProductIdArgs = {productId: string, Authorization: string, 'User-Agent': string}; export type DeleteApiV2CommerceProductsProductIdOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete specified product * * DELETE /v2/commerce/products/{productId} */ export const deleteApiV2CommerceProductsProductId = async (args: DeleteApiV2CommerceProductsProductIdArgs, options?: DeleteApiV2CommerceProductsProductIdOptions) => { const {baseUrl = "https://api.squarespace.com", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (Authorization !== undefined) headers.set('authorization', `Bearer ${Authorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/commerce/products/${encodeURIComponent(String(args.productId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };