export type NewExternalInvitation = {name?: string | undefined, userGroups?: Array | undefined, email: string}; export type CreateApiV1UsersInviteArgs = {body: NewExternalInvitation}; export type CreateApiV1UsersInviteOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Invite user from identity provider * * POST /v1/users/invite * * Also accepts auth: management_key */ export const createApiV1UsersInvite = async (args: CreateApiV1UsersInviteArgs, options?: CreateApiV1UsersInviteOptions) => { const {baseUrl = "https://yourbaseurl.talon.one", fetch: fetchFn = fetch, managerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/users/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 };