export type Tag = {key?: string | undefined, type?: string | undefined, value?: string | undefined}; export type BusinessRule = {createTime?: number | undefined, createdBy?: string | undefined, csvData?: string | undefined, name?: string | undefined, tags?: Array | undefined, updateTime?: number | undefined, updatedBy?: string | undefined, version?: number | undefined}; export type CreateApiApiBusinessRulesArgs = {newVersion?: boolean | undefined, body: BusinessRule}; export type CreateApiApiBusinessRulesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save business rule * * POST /api/business-rules */ export const createApiApiBusinessRules = async (args: CreateApiApiBusinessRulesArgs, options?: CreateApiApiBusinessRulesOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.newVersion != null) query.append("newVersion", String(args.newVersion)) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/business-rules${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 };