export type UpdateCouponBatch = {usageLimit?: number | undefined, discountLimit?: number | undefined, reservationLimit?: number | undefined, startDate?: string | undefined, expiryDate?: string | undefined, attributes?: Record | undefined, batchID?: string | undefined}; export type UpdateApiV1ApplicationsApplicationIdCampaignsCampaignIdCouponsArgs = {applicationId: number, campaignId: number, body: UpdateCouponBatch}; export type UpdateApiV1ApplicationsApplicationIdCampaignsCampaignIdCouponsOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update coupons * * PUT /v1/applications/{applicationId}/campaigns/{campaignId}/coupons * * Also accepts auth: management_key */ export const updateApiV1ApplicationsApplicationIdCampaignsCampaignIdCoupons = async (args: UpdateApiV1ApplicationsApplicationIdCampaignsCampaignIdCouponsArgs, options?: UpdateApiV1ApplicationsApplicationIdCampaignsCampaignIdCouponsOptions) => { const {baseUrl = "https://yourbaseurl.talon.one", fetch: fetchFn = fetch, managerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/applications/${encodeURIComponent(String(args.applicationId))}/campaigns/${encodeURIComponent(String(args.campaignId))}/coupons${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };