export type NewCampaignStoreBudgetStoreLimit = {storeId: number, limit: number}; export type NewCampaignStoreBudget = {action: 'setDiscount', storeLimits: Array, period?: ('daily' | 'weekly' | 'monthly' | 'yearly') | undefined}; export type CreateApiV1ApplicationsApplicationIdCampaignsCampaignIdStoresBudgetsArgs = {applicationId: number, campaignId: number, body: NewCampaignStoreBudget}; export type CreateApiV1ApplicationsApplicationIdCampaignsCampaignIdStoresBudgetsOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create campaign store budget * * POST /v1/applications/{applicationId}/campaigns/{campaignId}/stores/budgets * * Also accepts auth: management_key */ export const createApiV1ApplicationsApplicationIdCampaignsCampaignIdStoresBudgets = async (args: CreateApiV1ApplicationsApplicationIdCampaignsCampaignIdStoresBudgetsArgs, options?: CreateApiV1ApplicationsApplicationIdCampaignsCampaignIdStoresBudgetsOptions) => { 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))}/stores/budgets${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 };