export type CreateApiV3MerchantsMIdDiscountsDiscountIdArgs = {'User-Agent': string, mId: string, discountId: string, body: {id?: string | undefined, discount?: ({id?: string | undefined}) | undefined, approver?: ({id?: string | undefined}) | undefined, name: string, amount?: number | undefined, percentage?: number | undefined}}; export type CreateApiV3MerchantsMIdDiscountsDiscountIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update an discount * * POST /v3/merchants/{mId}/discounts/{discountId} */ export const createApiV3MerchantsMIdDiscountsDiscountId = async (args: CreateApiV3MerchantsMIdDiscountsDiscountIdArgs, options?: CreateApiV3MerchantsMIdDiscountsDiscountIdOptions) => { const {baseUrl = "https://apisandbox.dev.clover.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/merchants/${encodeURIComponent(String(args.mId))}/discounts/${encodeURIComponent(String(args.discountId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };