export type CreateApiInviteArgs = {body: {organizationId?: string | undefined, token?: string | undefined, expires?: string | undefined, email?: string | undefined, name?: string | undefined, role?: string | undefined}}; export type CreateApiInviteOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Invite a user to the Chloris Web Platform * * POST /invite */ export const createApiInvite = async (args: CreateApiInviteArgs, options?: CreateApiInviteOptions) => { const {baseUrl = "https://app.chloris.earth/api", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/invite${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 };