/* * Automatically generated by codegen/smith.ts. * Do not edit this file or add other files to this directory. */ import { seamApiLtsVersion } from 'lib/lts-version.js' import { getAuthHeadersForClientSessionToken, warnOnInsecureuserIdentifierKey, } from 'lib/seam/connect/auth.js' import { type Client, createClient } from 'lib/seam/connect/client.js' import { isSeamHttpOptionsWithApiKey, isSeamHttpOptionsWithClient, isSeamHttpOptionsWithClientSessionToken, isSeamHttpOptionsWithConsoleSessionToken, isSeamHttpOptionsWithPersonalAccessToken, type SeamHttpFromPublishableKeyOptions, SeamHttpInvalidOptionsError, type SeamHttpOptions, type SeamHttpOptionsWithApiKey, type SeamHttpOptionsWithClient, type SeamHttpOptionsWithClientSessionToken, type SeamHttpOptionsWithConsoleSessionToken, type SeamHttpOptionsWithPersonalAccessToken, type SeamHttpRequestOptions, } from 'lib/seam/connect/options.js' import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' import type { AcsEntrance } from 'lib/seam/connect/resources/acs-entrance.js' import type { AcsUser } from 'lib/seam/connect/resources/acs-user.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' export class SeamHttpAcsUsers { client: Client readonly defaults: Required readonly ltsVersion = seamApiLtsVersion static ltsVersion = seamApiLtsVersion constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { const options = parseOptions(apiKeyOrOptions) this.client = 'client' in options ? options.client : createClient(options) this.defaults = limitToSeamHttpRequestOptions(options) } static fromClient( client: SeamHttpOptionsWithClient['client'], options: Omit = {}, ): SeamHttpAcsUsers { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpAcsUsers(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpAcsUsers { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpAcsUsers(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpAcsUsers { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpAcsUsers(constructorOptions) } static async fromPublishableKey( publishableKey: string, userIdentifierKey: string, options: SeamHttpFromPublishableKeyOptions = {}, ): Promise { warnOnInsecureuserIdentifierKey(userIdentifierKey) const clientOptions = parseOptions({ ...options, publishableKey }) if (isSeamHttpOptionsWithClient(clientOptions)) { throw new SeamHttpInvalidOptionsError( 'The client option cannot be used with SeamHttpAcsUsers.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpAcsUsers.fromClientSessionToken(token, options) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpAcsUsers { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpAcsUsers(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpAcsUsers { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpAcsUsers(constructorOptions) } createPaginator( request: SeamHttpRequest, ): SeamPaginator { return new SeamPaginator(this, request) } async updateClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], ): Promise { const { headers } = this.client.defaults const authHeaders = getAuthHeadersForClientSessionToken({ clientSessionToken, }) for (const key of Object.keys(authHeaders)) { if (headers[key] == null) { throw new Error( 'Cannot update a clientSessionToken on a client created without a clientSessionToken', ) } } this.client.defaults.headers = { ...headers, ...authHeaders } const clientSessions = SeamHttpClientSessions.fromClient(this.client) await clientSessions.get() } /** * Adds a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) to a specified [access group](https://docs.seam.co/low-level-apis/access-systems/user-management/assigning-users-to-access-groups). */ addToAccessGroup( parameters: AcsUsersAddToAccessGroupParameters, options: AcsUsersAddToAccessGroupOptions = {}, ): AcsUsersAddToAccessGroupRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/add_to_access_group', method: 'PUT', body: parameters, responseKey: undefined, options, }) } /** * Creates a new [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ create( parameters: AcsUsersCreateParameters, options: AcsUsersCreateOptions = {}, ): AcsUsersCreateRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/create', method: 'POST', body: parameters, responseKey: 'acs_user', options, }) } /** * Deletes a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) and invalidates the access system user's [credentials](https://docs.seam.co/low-level-apis/access-systems/managing-credentials). */ delete( parameters?: AcsUsersDeleteParameters, options: AcsUsersDeleteOptions = {}, ): AcsUsersDeleteRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/delete', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * Returns a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ get( parameters?: AcsUsersGetParameters, options: AcsUsersGetOptions = {}, ): AcsUsersGetRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/get', method: 'POST', body: parameters, responseKey: 'acs_user', options, }) } /** * Returns a list of all [access system users](https://docs.seam.co/low-level-apis/access-systems/user-management). */ list( parameters?: AcsUsersListParameters, options: AcsUsersListOptions = {}, ): AcsUsersListRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/list', method: 'POST', body: parameters, responseKey: 'acs_users', options, }) } /** * Lists the [entrances](https://docs.seam.co/api/acs/entrances) to which a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) has access. */ listAccessibleEntrances( parameters?: AcsUsersListAccessibleEntrancesParameters, options: AcsUsersListAccessibleEntrancesOptions = {}, ): AcsUsersListAccessibleEntrancesRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/list_accessible_entrances', method: 'POST', body: parameters, responseKey: 'acs_entrances', options, }) } /** * Removes a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) from a specified [access group](https://docs.seam.co/low-level-apis/access-systems/user-management/assigning-users-to-access-groups). */ removeFromAccessGroup( parameters: AcsUsersRemoveFromAccessGroupParameters, options: AcsUsersRemoveFromAccessGroupOptions = {}, ): AcsUsersRemoveFromAccessGroupRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/remove_from_access_group', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * Revokes access to all [entrances](https://docs.seam.co/api/acs/entrances) for a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ revokeAccessToAllEntrances( parameters?: AcsUsersRevokeAccessToAllEntrancesParameters, options: AcsUsersRevokeAccessToAllEntrancesOptions = {}, ): AcsUsersRevokeAccessToAllEntrancesRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/revoke_access_to_all_entrances', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * [Suspends](https://docs.seam.co/low-level-apis/access-systems/user-management/suspending-and-unsuspending-users#suspend-an-acs-user) a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). Suspending an access system user revokes their access temporarily. To restore an access system user's access, you can [unsuspend](https://docs.seam.co/api/acs/users/unsuspend) them. */ suspend( parameters?: AcsUsersSuspendParameters, options: AcsUsersSuspendOptions = {}, ): AcsUsersSuspendRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/suspend', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * [Unsuspends](https://docs.seam.co/low-level-apis/access-systems/user-management/suspending-and-unsuspending-users#unsuspend-an-acs-user) a specified suspended [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). While [suspending an access system user](https://docs.seam.co/api/acs/users/suspend) revokes their access temporarily, unsuspending the access system user restores their access. */ unsuspend( parameters?: AcsUsersUnsuspendParameters, options: AcsUsersUnsuspendOptions = {}, ): AcsUsersUnsuspendRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/unsuspend', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * Updates the properties of a specified [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ update( parameters?: AcsUsersUpdateParameters, options: AcsUsersUpdateOptions = {}, ): AcsUsersUpdateRequest { return new SeamHttpRequest(this, { pathname: '/acs/users/update', method: 'PATCH', body: parameters, responseKey: undefined, options, }) } } export type AcsUsersAddToAccessGroupParameters = { /** * ID of the access group to which you want to add an access system user. */ acs_access_group_id: string /** * ID of the access system user that you want to add to an access group. */ acs_user_id: string } /** * @deprecated Use AcsUsersAddToAccessGroupRequest instead. */ export type AcsUsersAddToAccessGroupResponse = void export type AcsUsersAddToAccessGroupRequest = SeamHttpRequest export interface AcsUsersAddToAccessGroupOptions {} export type AcsUsersCreateParameters = { /** * `starts_at` and `ends_at` timestamps for the new access system user's access. If you specify an `access_schedule`, you may include both `starts_at` and `ends_at`. If you omit `starts_at`, it defaults to the current time. `ends_at` is optional and must be a time in the future and after `starts_at`. */ access_schedule?: | { /** * Ending timestamp for the new access system user's access. */ ends_at?: string | undefined /** * Starting timestamp for the new access system user's access. */ starts_at?: string | undefined } | undefined /** * Array of access group IDs to indicate the access groups to which you want to add the new access system user. */ acs_access_group_ids?: Array | undefined /** * ID of the access system to which you want to add the new access system user. */ acs_system_id: string /** * @deprecated use email_address. */ email?: string | undefined /** * Email address of the [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ email_address?: string | undefined /** * Full name of the new access system user. */ full_name: string /** * Phone number of the [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) in E.164 format (for example, `+15555550100`). */ phone_number?: string | undefined /** * ID of the user identity with which you want to associate the new access system user. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersCreateRequest instead. */ export type AcsUsersCreateResponse = { acs_user: AcsUser } export type AcsUsersCreateRequest = SeamHttpRequest< AcsUsersCreateResponse, 'acs_user' > export interface AcsUsersCreateOptions {} export type AcsUsersDeleteParameters = { /** * ID of the access system that you want to delete. You must provide acs_system_id with user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user that you want to delete. You must provide either acs_user_id or user_identity_id */ acs_user_id?: string | undefined /** * ID of the user identity that you want to delete. You must provide either acs_user_id or user_identity_id. If you provide user_identity_id, you must also provide acs_system_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersDeleteRequest instead. */ export type AcsUsersDeleteResponse = void export type AcsUsersDeleteRequest = SeamHttpRequest export interface AcsUsersDeleteOptions {} export type AcsUsersGetParameters = { /** * ID of the access system that you want to get. You can only provide acs_user_id or user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user that you want to get. You can only provide acs_user_id or user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity that you want to get. You can only provide acs_user_id or user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersGetRequest instead. */ export type AcsUsersGetResponse = { acs_user: AcsUser } export type AcsUsersGetRequest = SeamHttpRequest< AcsUsersGetResponse, 'acs_user' > export interface AcsUsersGetOptions {} export type AcsUsersListParameters = { /** * ID of the `acs_system` for which you want to retrieve all access system users. */ acs_system_id?: string | undefined /** * Timestamp by which to limit returned access system users. Returns users created before this timestamp. */ created_before?: string | undefined /** * Maximum number of records to return per page. */ limit?: number | undefined /** * Identifies the specific page of results to return, obtained from the previous page's `next_page_cursor`. */ page_cursor?: string | undefined /** * String for which to search. Filters returned access system users to include all records that satisfy a partial match using `full_name`, `phone_number`, `email_address`, `acs_user_id`, `user_identity_id`, `user_identity_full_name` or `user_identity_phone_number`. */ search?: string | undefined /** * Email address of the user identity for which you want to retrieve all access system users. */ user_identity_email_address?: string | undefined /** * ID of the user identity for which you want to retrieve all access system users. */ user_identity_id?: string | undefined /** * Phone number of the user identity for which you want to retrieve all access system users, in [E.164 format](https://www.itu.int/rec/T-REC-E.164/en) (for example, `+15555550100`). */ user_identity_phone_number?: string | undefined } /** * @deprecated Use AcsUsersListRequest instead. */ export type AcsUsersListResponse = { acs_users: Array } export type AcsUsersListRequest = SeamHttpRequest< AcsUsersListResponse, 'acs_users' > export interface AcsUsersListOptions {} export type AcsUsersListAccessibleEntrancesParameters = { /** * ID of the access system for which you want to list accessible entrances. You can only provide acs_system_id with user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user for whom you want to list accessible entrances. You can only provide acs_user_id or user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity for whom you want to list accessible entrances. You can only provide acs_user_id or user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersListAccessibleEntrancesRequest instead. */ export type AcsUsersListAccessibleEntrancesResponse = { acs_entrances: Array } export type AcsUsersListAccessibleEntrancesRequest = SeamHttpRequest< AcsUsersListAccessibleEntrancesResponse, 'acs_entrances' > export interface AcsUsersListAccessibleEntrancesOptions {} export type AcsUsersRemoveFromAccessGroupParameters = { /** * ID of the access group from which you want to remove an access system user. */ acs_access_group_id: string /** * ID of the access system user that you want to remove from an access group. You can only provide acs_user_id or user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity that you want to remove from an access group. You can only provide acs_user_id or user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersRemoveFromAccessGroupRequest instead. */ export type AcsUsersRemoveFromAccessGroupResponse = void export type AcsUsersRemoveFromAccessGroupRequest = SeamHttpRequest< void, undefined > export interface AcsUsersRemoveFromAccessGroupOptions {} export type AcsUsersRevokeAccessToAllEntrancesParameters = { /** * ID of the access system for which you want to revoke access. You can only provide acs_system_id with user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user for whom you want to revoke access. You can only provide acs_user_id or user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity for whom you want to revoke access. You can only provide acs_user_id or user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersRevokeAccessToAllEntrancesRequest instead. */ export type AcsUsersRevokeAccessToAllEntrancesResponse = void export type AcsUsersRevokeAccessToAllEntrancesRequest = SeamHttpRequest< void, undefined > export interface AcsUsersRevokeAccessToAllEntrancesOptions {} export type AcsUsersSuspendParameters = { /** * ID of the access system that you want to suspend. You can only provide acs_user_id or the combination of acs_system_id and user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user that you want to suspend. You can only provide acs_user_id or the combination of acs_system_id and user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity that you want to suspend. You can only provide acs_user_id or the combination of acs_system_id and user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersSuspendRequest instead. */ export type AcsUsersSuspendResponse = void export type AcsUsersSuspendRequest = SeamHttpRequest export interface AcsUsersSuspendOptions {} export type AcsUsersUnsuspendParameters = { /** * ID of the access system of the user that you want to unsuspend. You can only provide acs_system_id with user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user that you want to unsuspend. You can only provide acs_user_id or the combination of acs_system_id and user_identity_id. */ acs_user_id?: string | undefined /** * ID of the user identity that you want to unsuspend. You can only provide acs_user_id or the combination of acs_system_id and user_identity_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersUnsuspendRequest instead. */ export type AcsUsersUnsuspendResponse = void export type AcsUsersUnsuspendRequest = SeamHttpRequest export interface AcsUsersUnsuspendOptions {} export type AcsUsersUpdateParameters = { /** * `starts_at` and `ends_at` timestamps for the access system user's access. If you specify an `access_schedule`, you may include both `starts_at` and `ends_at`. If you omit `starts_at`, it defaults to the current time. `ends_at` is optional and must be a time in the future and after `starts_at`. */ access_schedule?: | { /** * Ending timestamp for the access system user's access. */ ends_at?: string | undefined /** * Starting timestamp for the access system user's access. */ starts_at?: string | undefined } | undefined /** * ID of the access system that you want to update. You can only provide acs_system_id with user_identity_id. */ acs_system_id?: string | undefined /** * ID of the access system user that you want to update. You can only provide acs_user_id or user_identity_id. */ acs_user_id?: string | undefined /** * @deprecated use email_address. */ email?: string | undefined /** * Email address of the [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ email_address?: string | undefined /** * Full name of the [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management). */ full_name?: string | undefined /** * ID of the HID access control system associated with the user. */ hid_acs_system_id?: string | undefined /** * Phone number of the [access system user](https://docs.seam.co/low-level-apis/access-systems/user-management) in E.164 format (for example, `+15555550100`). */ phone_number?: string | undefined /** * ID of the user identity that you want to update. You can only provide acs_user_id or user_identity_id. If you provide user_identity_id, you must also provide acs_system_id. */ user_identity_id?: string | undefined } /** * @deprecated Use AcsUsersUpdateRequest instead. */ export type AcsUsersUpdateResponse = void export type AcsUsersUpdateRequest = SeamHttpRequest export interface AcsUsersUpdateOptions {}