export type CreateUserRequest = {email: string, password?: string | undefined, code: string, allow_us_storage?: boolean | undefined}; export type CreateApiCompaniesIdentifierUsersArgs = {identifier: string, body: CreateUserRequest}; export type CreateApiCompaniesIdentifierUsersOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create a new user. * * POST /companies/{identifier}/users */ export const createApiCompaniesIdentifierUsers = async (args: CreateApiCompaniesIdentifierUsersArgs, options: CreateApiCompaniesIdentifierUsersOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.identifier))}/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 };