export type PatchApiCampaignsCampaignIdRulesRuleIdArgs = {campaign_id: string, rule_id: string, body: {rule_type?: string | undefined, values?: Array | undefined, conditional?: string | undefined, metadata_key?: string | undefined}}; export type PatchApiCampaignsCampaignIdRulesRuleIdOptions = {baseUrl?: string | undefined, publicApiKey?: string | undefined, privateSecretKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * PATCH /campaigns/{campaign_id}/rules/{rule_id} */ export const patchApiCampaignsCampaignIdRulesRuleId = async (args: PatchApiCampaignsCampaignIdRulesRuleIdArgs, options?: PatchApiCampaignsCampaignIdRulesRuleIdOptions) => { const {baseUrl = "https://api-sandbox.y.uno/v1", fetch: fetchFn = fetch, publicApiKey, privateSecretKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (publicApiKey !== undefined) headers.set("PUBLIC-API-KEY", publicApiKey) if (privateSecretKey !== undefined) headers.set("PRIVATE-SECRET-KEY", privateSecretKey) const url = `${baseUrl.replace(/\/+$/, '')}/campaigns/${encodeURIComponent(String(args.campaign_id))}/rules/${encodeURIComponent(String(args.rule_id))}${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 (await res.json()) as unknown };