export type ParameterModel = {id?: string | undefined, ownerId?: string | undefined, key?: string | undefined, value?: string | undefined, priority?: number | undefined}; export type RestRuleAction = {owningRule: string, priority?: number | undefined, actionlet?: string | undefined, parameters?: {[key: string]: ParameterModel} | undefined}; export type CreateApiApiV1SitesSiteIdRuleengineActionsArgs = {siteId: string, body: RestRuleAction}; export type CreateApiApiV1SitesSiteIdRuleengineActionsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /api/v1/sites/{siteId}/ruleengine/actions */ export const createApiApiV1SitesSiteIdRuleengineActions = async (args: CreateApiApiV1SitesSiteIdRuleengineActionsArgs, options: CreateApiApiV1SitesSiteIdRuleengineActionsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/sites/${encodeURIComponent(String(args.siteId))}/ruleengine/actions${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 (await res.json()) as unknown };