export type DeleteApiV1CommerceDiscountsDiscountIdArgs = {discountId: string, Authorization: string, 'User-Agent': string}; export type DeleteApiV1CommerceDiscountsDiscountIdOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete discount * * DELETE /v1/commerce/discounts/{discountId} */ export const deleteApiV1CommerceDiscountsDiscountId = async (args: DeleteApiV1CommerceDiscountsDiscountIdArgs, options?: DeleteApiV1CommerceDiscountsDiscountIdOptions) => { 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(/\/+$/, '')}/v1/commerce/discounts/${encodeURIComponent(String(args.discountId))}${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 };