export type UpdateRuleRequest = {ruleName: string, startUtcDate?: string | undefined, endUtcDate?: string | undefined}; export type PatchApiV2UserAnalyticsStoreIdRulesRuleIdArgs = {storeId: unknown, ruleId: unknown, body: UpdateRuleRequest}; export type PatchApiV2UserAnalyticsStoreIdRulesRuleIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Rule * * PATCH /v2/user/analytics/{storeId}/rules/{ruleId} */ export const patchApiV2UserAnalyticsStoreIdRulesRuleId = async (args: PatchApiV2UserAnalyticsStoreIdRulesRuleIdArgs, options?: PatchApiV2UserAnalyticsStoreIdRulesRuleIdOptions) => { const {baseUrl = "https://api.beezup.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/analytics/${encodeURIComponent(String(args.storeId))}/rules/${encodeURIComponent(String(args.ruleId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };