export type CreateAdminuserPayload = {email: string, first_name: string, id?: number | undefined, last_name: string, password: string, role: string, tenant_id?: number | undefined, validated?: boolean | undefined, validation_code?: string | undefined}; export type CreateApiAdminUsersArgs = {body: CreateAdminuserPayload}; export type CreateApiAdminUsersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Record new user * * POST /admin/users */ export const createApiAdminUsers = async (args: CreateApiAdminUsersArgs, options?: CreateApiAdminUsersOptions) => { const {baseUrl = "https://congo.gopheracademy.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/admin/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 undefined };