export type ScheduleTenantEventRequest = {scheduleId: string, eventTypeId: string, eventTime: string, data: {[key: string]: Record}}; export type ScheduleTenantEventsRequest = {requests: Array}; export type CreateApiConfigTenantLocatorTenantEventsArgs = {tenantLocator: string, body: ScheduleTenantEventsRequest}; export type CreateApiConfigTenantLocatorTenantEventsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /config/{tenantLocator}/tenantEvents */ export const createApiConfigTenantLocatorTenantEvents = async (args: CreateApiConfigTenantLocatorTenantEventsArgs, options: CreateApiConfigTenantLocatorTenantEventsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/config/${encodeURIComponent(String(args.tenantLocator))}/tenantEvents${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 };