export type Roles = {id?: number | undefined, name?: string | undefined}; export type Users = {id?: number | undefined, emailAddress?: string | undefined, password?: string | undefined, roles?: Array | undefined}; export type CreateApiRestUsersArgs = {body: Users}; export type CreateApiRestUsersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /rest/users */ export const createApiRestUsers = async (args: CreateApiRestUsersArgs, options?: CreateApiRestUsersOptions) => { const {baseUrl = "http://172.18.0.2:3333", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/rest/users${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 res.blob() };