/* * 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 { AcsSystem } from 'lib/seam/connect/resources/acs-system.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 SeamHttpAcsSystems { 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 = {}, ): SeamHttpAcsSystems { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpAcsSystems(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpAcsSystems { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpAcsSystems(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpAcsSystems { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpAcsSystems(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 SeamHttpAcsSystems.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpAcsSystems.fromClientSessionToken(token, options) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpAcsSystems { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpAcsSystems(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpAcsSystems { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpAcsSystems(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() } /** * Returns a specified [access system](https://docs.seam.co/low-level-apis/access-systems). */ get( parameters: AcsSystemsGetParameters, options: AcsSystemsGetOptions = {}, ): AcsSystemsGetRequest { return new SeamHttpRequest(this, { pathname: '/acs/systems/get', method: 'POST', body: parameters, responseKey: 'acs_system', options, }) } /** * Returns a list of all [access systems](https://docs.seam.co/low-level-apis/access-systems). * * To filter the list of returned access systems by a specific connected account ID, include the `connected_account_id` in the request body. If you omit the `connected_account_id` parameter, the response includes all access systems connected to your workspace. */ list( parameters?: AcsSystemsListParameters, options: AcsSystemsListOptions = {}, ): AcsSystemsListRequest { return new SeamHttpRequest(this, { pathname: '/acs/systems/list', method: 'POST', body: parameters, responseKey: 'acs_systems', options, }) } /** * Returns a list of all credential manager systems that are compatible with a specified [access system](https://docs.seam.co/low-level-apis/access-systems). * * Specify the access system for which you want to retrieve all compatible credential manager systems by including the corresponding `acs_system_id` in the request body. */ listCompatibleCredentialManagerAcsSystems( parameters: AcsSystemsListCompatibleCredentialManagerAcsSystemsParameters, options: AcsSystemsListCompatibleCredentialManagerAcsSystemsOptions = {}, ): AcsSystemsListCompatibleCredentialManagerAcsSystemsRequest { return new SeamHttpRequest(this, { pathname: '/acs/systems/list_compatible_credential_manager_acs_systems', method: 'POST', body: parameters, responseKey: 'acs_systems', options, }) } /** * Reports ACS system device status including encoders and entrances. */ reportDevices( parameters: AcsSystemsReportDevicesParameters, options: AcsSystemsReportDevicesOptions = {}, ): AcsSystemsReportDevicesRequest { return new SeamHttpRequest(this, { pathname: '/acs/systems/report_devices', method: 'POST', body: parameters, responseKey: undefined, options, }) } } export type AcsSystemsGetParameters = { /** * ID of the access system that you want to get. */ acs_system_id: string } /** * @deprecated Use AcsSystemsGetRequest instead. */ export type AcsSystemsGetResponse = { acs_system: AcsSystem } export type AcsSystemsGetRequest = SeamHttpRequest< AcsSystemsGetResponse, 'acs_system' > export interface AcsSystemsGetOptions {} export type AcsSystemsListParameters = { /** * ID of the connected account by which you want to filter the list of access systems. */ connected_account_id?: string | undefined /** * Customer key for which you want to list access systems. */ customer_key?: string | undefined /** * String for which to search. Filters returned access systems to include all records that satisfy a partial match using `name` or `acs_system_id`. */ search?: string | undefined } /** * @deprecated Use AcsSystemsListRequest instead. */ export type AcsSystemsListResponse = { acs_systems: Array } export type AcsSystemsListRequest = SeamHttpRequest< AcsSystemsListResponse, 'acs_systems' > export interface AcsSystemsListOptions {} export type AcsSystemsListCompatibleCredentialManagerAcsSystemsParameters = { /** * ID of the access system for which you want to retrieve all compatible credential manager systems. */ acs_system_id: string } /** * @deprecated Use AcsSystemsListCompatibleCredentialManagerAcsSystemsRequest instead. */ export type AcsSystemsListCompatibleCredentialManagerAcsSystemsResponse = { acs_systems: Array } export type AcsSystemsListCompatibleCredentialManagerAcsSystemsRequest = SeamHttpRequest< AcsSystemsListCompatibleCredentialManagerAcsSystemsResponse, 'acs_systems' > export interface AcsSystemsListCompatibleCredentialManagerAcsSystemsOptions {} export type AcsSystemsReportDevicesParameters = { /** * Array of ACS encoders to report */ acs_encoders?: | Array<{ /** * Hotek-specific metadata associated with the entrance. */ hotek_metadata?: | { /** * The encoder number determined by the USB port connection. */ encoder_number?: string | undefined } | undefined /** * Whether the encoder is removed */ is_removed?: boolean | undefined }> | undefined /** * Array of ACS entrances to report */ acs_entrances?: | Array<{ /** * Hotek-specific metadata associated with the entrance. */ hotek_metadata?: | { /** * The common area name */ common_area_name?: string | undefined /** * The room number identifier */ common_area_number?: string | undefined /** * The room number identifier */ room_number?: string | undefined } | undefined /** * Whether the entrance is removed */ is_removed?: boolean | undefined }> | undefined /** * ID of the ACS system to report resources for */ acs_system_id: string } /** * @deprecated Use AcsSystemsReportDevicesRequest instead. */ export type AcsSystemsReportDevicesResponse = void export type AcsSystemsReportDevicesRequest = SeamHttpRequest export interface AcsSystemsReportDevicesOptions {}