diff --git a/README.md b/README.md index d64e003c..7e1dd23f 100644 --- a/README.md +++ b/README.md @@ -512,6 +512,18 @@ const devices = await seam.client.get('/devices/list') An Axios compatible client may be provided to create a `SeamHttp` instance. This API is used internally and is not directly supported. +#### Alternative endpoint path interface + +The `SeamHttpEndpoints` class offers an alternative path-based interface to every API endpoint. +Each endpoint is exposed as simple property that returns the corresponding method from `SeamHttp`. + +```ts +import { SeamHttpEndpoints } from '@seamapi/http/connect' + +const seam = new SeamHttpEndpoints() +const devices = await seam['/devices/list']() +``` + #### Inspecting the Request All client methods return an instance of `SeamHttpRequest`. diff --git a/codegen/layouts/endpoints.hbs b/codegen/layouts/endpoints.hbs new file mode 100644 index 00000000..7166fcdf --- /dev/null +++ b/codegen/layouts/endpoints.hbs @@ -0,0 +1,32 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +{{> route-imports }} + +{{#each routeImports}} +import { +{{className}}, +{{#each typeNames}} + type {{.}}, +{{/each}} +} from './{{fileName}}' +{{/each}} + +export class SeamHttpEndpoints { + {{> route-class-methods }} + + {{#each endpoints}} + get['{{path}}'](): {{className}}['{{methodName}}'] + { + const { client, defaults } = this + return function {{functionName}} (...args: Parameters<{{className}}['{{methodName}}']>): ReturnType<{{className}}['{{methodName}}']> + { + const seam = {{className}}.fromClient(client, defaults) + return seam.{{methodName}}(...args) + } + } + + {{/each}} +} diff --git a/codegen/lib/connect.ts b/codegen/lib/connect.ts index 0bbc7ca5..9f7ea484 100644 --- a/codegen/lib/connect.ts +++ b/codegen/lib/connect.ts @@ -2,17 +2,24 @@ import type { Blueprint } from '@seamapi/blueprint' import { kebabCase } from 'change-case' import type Metalsmith from 'metalsmith' +import { + type EndpointsLayoutContext, + setEndpointsLayoutContext, +} from './layouts/endpoints.js' import { type RouteIndexLayoutContext, type RouteLayoutContext, setRouteLayoutContext, + toFilePath, } from './layouts/route.js' interface Metadata { blueprint: Blueprint } -type File = RouteLayoutContext & RouteIndexLayoutContext & { layout: string } +type File = RouteLayoutContext & + RouteIndexLayoutContext & + EndpointsLayoutContext & { layout: string } const rootPath = 'src/lib/seam/connect/routes' @@ -34,15 +41,22 @@ export const connect = ( const routeIndexes: Record> = {} - const rootRouteKey = `${rootPath}/seam-http.ts` - files[rootRouteKey] = { contents: Buffer.from('\n') } - const file = files[rootRouteKey] as unknown as File + const k = `${rootPath}/seam-http.ts` + files[k] = { contents: Buffer.from('\n') } + const file = files[k] as unknown as File file.layout = 'route.hbs' setRouteLayoutContext(file, null, nodes) routeIndexes[''] ??= new Set() routeIndexes['']?.add('seam-http.js') + const endpointsKey = `${rootPath}/seam-http-endpoints.ts` + files[endpointsKey] = { contents: Buffer.from('\n') } + const endpointFile = files[endpointsKey] as unknown as File + endpointFile.layout = 'endpoints.hbs' + setEndpointsLayoutContext(endpointFile, routes) + routeIndexes['']?.add('seam-http-endpoints.js') + for (const node of nodes) { const path = toFilePath(node.path) const name = kebabCase(node.name) @@ -75,10 +89,3 @@ export const connect = ( file.routes = [...routes] } } - -const toFilePath = (path: string): string => - path - .slice(1) - .split('/') - .map((p) => kebabCase(p)) - .join('/') diff --git a/codegen/lib/layouts/endpoints.ts b/codegen/lib/layouts/endpoints.ts new file mode 100644 index 00000000..549b4c76 --- /dev/null +++ b/codegen/lib/layouts/endpoints.ts @@ -0,0 +1,35 @@ +import type { Route } from '@seamapi/blueprint' + +import { + type EndpointLayoutContext, + getClassName, + getEndpointLayoutContext, + type SubrouteLayoutContext, + toFilePath, +} from './route.js' + +export interface EndpointsLayoutContext { + className: string + endpoints: EndpointLayoutContext[] + routeImports: Array> + skipClientSessionImport: boolean +} + +export const setEndpointsLayoutContext = ( + file: Partial, + routes: Route[], +): void => { + file.className = getClassName('Endpoints') + file.skipClientSessionImport = true + file.endpoints = routes.flatMap((route) => + route.endpoints + .filter(({ isUndocumented }) => !isUndocumented) + .map((endpoint) => getEndpointLayoutContext(endpoint, route)), + ) + file.routeImports = routes.map((route) => { + return { + className: getClassName(route.path), + fileName: `${toFilePath(route.path)}/index.js`, + } + }) +} diff --git a/codegen/lib/layouts/route.ts b/codegen/lib/layouts/route.ts index 76ec54b4..17ad3645 100644 --- a/codegen/lib/layouts/route.ts +++ b/codegen/lib/layouts/route.ts @@ -13,9 +13,11 @@ export interface RouteIndexLayoutContext { routes: string[] } -interface EndpointLayoutContext { +export interface EndpointLayoutContext { path: string methodName: string + functionName: string + className: string method: Method hasOptions: boolean responseKey: string @@ -30,7 +32,7 @@ interface EndpointLayoutContext { isOptionalParamsOk: boolean } -interface SubrouteLayoutContext { +export interface SubrouteLayoutContext { methodName: string className: string fileName: string @@ -71,7 +73,7 @@ const getSubrouteLayoutContext = ( } } -const getEndpointLayoutContext = ( +export const getEndpointLayoutContext = ( endpoint: Endpoint, route: Pick, ): EndpointLayoutContext => { @@ -95,11 +97,15 @@ const getEndpointLayoutContext = ( endpoint.response.responseType === 'resource' && endpoint.response.resourceType === 'action_attempt' + const methodName = camelCase(endpoint.name) + return { path: endpoint.path, - methodName: camelCase(endpoint.name), + methodName, + functionName: camelCase(prefix), method: endpoint.request.preferredMethod, hasOptions: returnsActionAttempt, + className: getClassName(route.path), methodParamName, requestFormat, requestFormatSuffix, @@ -129,5 +135,12 @@ const getResponseContext = ( } } -const getClassName = (name: string | null): string => - `SeamHttp${pascalCase(name ?? '')}` +export const getClassName = (path: string | null): string => + `SeamHttp${pascalCase(path ?? '')}` + +export const toFilePath = (path: string): string => + path + .slice(1) + .split('/') + .map((p) => kebabCase(p)) + .join('/') diff --git a/src/lib/seam/connect/routes/index.ts b/src/lib/seam/connect/routes/index.ts index 2a33b3e8..cab4d39e 100644 --- a/src/lib/seam/connect/routes/index.ts +++ b/src/lib/seam/connect/routes/index.ts @@ -17,6 +17,7 @@ export * from './locks/index.js' export * from './noise-sensors/index.js' export * from './phones/index.js' export * from './seam-http.js' +export * from './seam-http-endpoints.js' export * from './spaces/index.js' export * from './thermostats/index.js' export * from './user-identities/index.js' diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts new file mode 100644 index 00000000..406b60c2 --- /dev/null +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -0,0 +1,1942 @@ +/* + * 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 { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpAccessCodes } from './access-codes/index.js' +import { SeamHttpAccessCodesSimulate } from './access-codes/simulate/index.js' +import { SeamHttpAccessCodesUnmanaged } from './access-codes/unmanaged/index.js' +import { SeamHttpAccessGrants } from './access-grants/index.js' +import { SeamHttpAccessMethods } from './access-methods/index.js' +import { SeamHttpAcsAccessGroups } from './acs/access-groups/index.js' +import { SeamHttpAcsCredentials } from './acs/credentials/index.js' +import { SeamHttpAcsEncoders } from './acs/encoders/index.js' +import { SeamHttpAcsEncodersSimulate } from './acs/encoders/simulate/index.js' +import { SeamHttpAcsEntrances } from './acs/entrances/index.js' +import { SeamHttpAcsSystems } from './acs/systems/index.js' +import { SeamHttpAcsUsers } from './acs/users/index.js' +import { SeamHttpActionAttempts } from './action-attempts/index.js' +import { SeamHttpClientSessions } from './client-sessions/index.js' +import { SeamHttpConnectWebviews } from './connect-webviews/index.js' +import { SeamHttpConnectedAccounts } from './connected-accounts/index.js' +import { SeamHttpDevices } from './devices/index.js' +import { SeamHttpDevicesSimulate } from './devices/simulate/index.js' +import { SeamHttpDevicesUnmanaged } from './devices/unmanaged/index.js' +import { SeamHttpEvents } from './events/index.js' +import { SeamHttpLocks } from './locks/index.js' +import { SeamHttpNoiseSensors } from './noise-sensors/index.js' +import { SeamHttpNoiseSensorsNoiseThresholds } from './noise-sensors/noise-thresholds/index.js' +import { SeamHttpNoiseSensorsSimulate } from './noise-sensors/simulate/index.js' +import { SeamHttpPhones } from './phones/index.js' +import { SeamHttpPhonesSimulate } from './phones/simulate/index.js' +import { SeamHttpSpaces } from './spaces/index.js' +import { SeamHttpThermostatsDailyPrograms } from './thermostats/daily-programs/index.js' +import { SeamHttpThermostats } from './thermostats/index.js' +import { SeamHttpThermostatsSchedules } from './thermostats/schedules/index.js' +import { SeamHttpThermostatsSimulate } from './thermostats/simulate/index.js' +import { SeamHttpUserIdentitiesEnrollmentAutomations } from './user-identities/enrollment-automations/index.js' +import { SeamHttpUserIdentities } from './user-identities/index.js' +import { SeamHttpWebhooks } from './webhooks/index.js' +import { SeamHttpWorkspaces } from './workspaces/index.js' + +export class SeamHttpEndpoints { + 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 = {}, + ): SeamHttpEndpoints { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpEndpoints(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpEndpoints { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpEndpoints(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpEndpoints { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpEndpoints(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 SeamHttpEndpoints.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpEndpoints.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpEndpoints { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpEndpoints(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpEndpoints { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpEndpoints(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() + } + + get ['/access_codes/create'](): SeamHttpAccessCodes['create'] { + const { client, defaults } = this + return function accessCodesCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/access_codes/create_multiple'](): SeamHttpAccessCodes['createMultiple'] { + const { client, defaults } = this + return function accessCodesCreateMultiple( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.createMultiple(...args) + } + } + + get ['/access_codes/delete'](): SeamHttpAccessCodes['delete'] { + const { client, defaults } = this + return function accessCodesDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/access_codes/generate_code'](): SeamHttpAccessCodes['generateCode'] { + const { client, defaults } = this + return function accessCodesGenerateCode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.generateCode(...args) + } + } + + get ['/access_codes/get'](): SeamHttpAccessCodes['get'] { + const { client, defaults } = this + return function accessCodesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/access_codes/list'](): SeamHttpAccessCodes['list'] { + const { client, defaults } = this + return function accessCodesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/access_codes/pull_backup_access_code'](): SeamHttpAccessCodes['pullBackupAccessCode'] { + const { client, defaults } = this + return function accessCodesPullBackupAccessCode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.pullBackupAccessCode(...args) + } + } + + get ['/access_codes/report_device_constraints'](): SeamHttpAccessCodes['reportDeviceConstraints'] { + const { client, defaults } = this + return function accessCodesReportDeviceConstraints( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.reportDeviceConstraints(...args) + } + } + + get ['/access_codes/update'](): SeamHttpAccessCodes['update'] { + const { client, defaults } = this + return function accessCodesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/access_codes/update_multiple'](): SeamHttpAccessCodes['updateMultiple'] { + const { client, defaults } = this + return function accessCodesUpdateMultiple( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodes.fromClient(client, defaults) + return seam.updateMultiple(...args) + } + } + + get ['/access_codes/simulate/create_unmanaged_access_code'](): SeamHttpAccessCodesSimulate['createUnmanagedAccessCode'] { + const { client, defaults } = this + return function accessCodesSimulateCreateUnmanagedAccessCode( + ...args: Parameters< + SeamHttpAccessCodesSimulate['createUnmanagedAccessCode'] + > + ): ReturnType { + const seam = SeamHttpAccessCodesSimulate.fromClient(client, defaults) + return seam.createUnmanagedAccessCode(...args) + } + } + + get ['/access_codes/unmanaged/convert_to_managed'](): SeamHttpAccessCodesUnmanaged['convertToManaged'] { + const { client, defaults } = this + return function accessCodesUnmanagedConvertToManaged( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodesUnmanaged.fromClient(client, defaults) + return seam.convertToManaged(...args) + } + } + + get ['/access_codes/unmanaged/delete'](): SeamHttpAccessCodesUnmanaged['delete'] { + const { client, defaults } = this + return function accessCodesUnmanagedDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodesUnmanaged.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/access_codes/unmanaged/get'](): SeamHttpAccessCodesUnmanaged['get'] { + const { client, defaults } = this + return function accessCodesUnmanagedGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodesUnmanaged.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/access_codes/unmanaged/list'](): SeamHttpAccessCodesUnmanaged['list'] { + const { client, defaults } = this + return function accessCodesUnmanagedList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodesUnmanaged.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/access_codes/unmanaged/update'](): SeamHttpAccessCodesUnmanaged['update'] { + const { client, defaults } = this + return function accessCodesUnmanagedUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessCodesUnmanaged.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/access_grants/create'](): SeamHttpAccessGrants['create'] { + const { client, defaults } = this + return function accessGrantsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessGrants.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/access_grants/delete'](): SeamHttpAccessGrants['delete'] { + const { client, defaults } = this + return function accessGrantsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessGrants.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/access_grants/get'](): SeamHttpAccessGrants['get'] { + const { client, defaults } = this + return function accessGrantsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessGrants.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/access_grants/list'](): SeamHttpAccessGrants['list'] { + const { client, defaults } = this + return function accessGrantsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessGrants.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/access_grants/update'](): SeamHttpAccessGrants['update'] { + const { client, defaults } = this + return function accessGrantsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessGrants.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/access_methods/delete'](): SeamHttpAccessMethods['delete'] { + const { client, defaults } = this + return function accessMethodsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessMethods.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/access_methods/get'](): SeamHttpAccessMethods['get'] { + const { client, defaults } = this + return function accessMethodsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessMethods.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/access_methods/list'](): SeamHttpAccessMethods['list'] { + const { client, defaults } = this + return function accessMethodsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessMethods.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/access_groups/add_user'](): SeamHttpAcsAccessGroups['addUser'] { + const { client, defaults } = this + return function acsAccessGroupsAddUser( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.addUser(...args) + } + } + + get ['/acs/access_groups/get'](): SeamHttpAcsAccessGroups['get'] { + const { client, defaults } = this + return function acsAccessGroupsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/access_groups/list'](): SeamHttpAcsAccessGroups['list'] { + const { client, defaults } = this + return function acsAccessGroupsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/access_groups/list_accessible_entrances'](): SeamHttpAcsAccessGroups['listAccessibleEntrances'] { + const { client, defaults } = this + return function acsAccessGroupsListAccessibleEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.listAccessibleEntrances(...args) + } + } + + get ['/acs/access_groups/list_users'](): SeamHttpAcsAccessGroups['listUsers'] { + const { client, defaults } = this + return function acsAccessGroupsListUsers( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.listUsers(...args) + } + } + + get ['/acs/access_groups/remove_user'](): SeamHttpAcsAccessGroups['removeUser'] { + const { client, defaults } = this + return function acsAccessGroupsRemoveUser( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroups.fromClient(client, defaults) + return seam.removeUser(...args) + } + } + + get ['/acs/credentials/assign'](): SeamHttpAcsCredentials['assign'] { + const { client, defaults } = this + return function acsCredentialsAssign( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.assign(...args) + } + } + + get ['/acs/credentials/create'](): SeamHttpAcsCredentials['create'] { + const { client, defaults } = this + return function acsCredentialsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/acs/credentials/delete'](): SeamHttpAcsCredentials['delete'] { + const { client, defaults } = this + return function acsCredentialsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/acs/credentials/get'](): SeamHttpAcsCredentials['get'] { + const { client, defaults } = this + return function acsCredentialsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/credentials/list'](): SeamHttpAcsCredentials['list'] { + const { client, defaults } = this + return function acsCredentialsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/credentials/list_accessible_entrances'](): SeamHttpAcsCredentials['listAccessibleEntrances'] { + const { client, defaults } = this + return function acsCredentialsListAccessibleEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.listAccessibleEntrances(...args) + } + } + + get ['/acs/credentials/unassign'](): SeamHttpAcsCredentials['unassign'] { + const { client, defaults } = this + return function acsCredentialsUnassign( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.unassign(...args) + } + } + + get ['/acs/credentials/update'](): SeamHttpAcsCredentials['update'] { + const { client, defaults } = this + return function acsCredentialsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/acs/encoders/encode_access_method'](): SeamHttpAcsEncoders['encodeAccessMethod'] { + const { client, defaults } = this + return function acsEncodersEncodeAccessMethod( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEncoders.fromClient(client, defaults) + return seam.encodeAccessMethod(...args) + } + } + + get ['/acs/encoders/encode_credential'](): SeamHttpAcsEncoders['encodeCredential'] { + const { client, defaults } = this + return function acsEncodersEncodeCredential( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEncoders.fromClient(client, defaults) + return seam.encodeCredential(...args) + } + } + + get ['/acs/encoders/get'](): SeamHttpAcsEncoders['get'] { + const { client, defaults } = this + return function acsEncodersGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEncoders.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/encoders/list'](): SeamHttpAcsEncoders['list'] { + const { client, defaults } = this + return function acsEncodersList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEncoders.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/encoders/scan_credential'](): SeamHttpAcsEncoders['scanCredential'] { + const { client, defaults } = this + return function acsEncodersScanCredential( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEncoders.fromClient(client, defaults) + return seam.scanCredential(...args) + } + } + + get ['/acs/encoders/simulate/next_credential_encode_will_fail'](): SeamHttpAcsEncodersSimulate['nextCredentialEncodeWillFail'] { + const { client, defaults } = this + return function acsEncodersSimulateNextCredentialEncodeWillFail( + ...args: Parameters< + SeamHttpAcsEncodersSimulate['nextCredentialEncodeWillFail'] + > + ): ReturnType { + const seam = SeamHttpAcsEncodersSimulate.fromClient(client, defaults) + return seam.nextCredentialEncodeWillFail(...args) + } + } + + get ['/acs/encoders/simulate/next_credential_encode_will_succeed'](): SeamHttpAcsEncodersSimulate['nextCredentialEncodeWillSucceed'] { + const { client, defaults } = this + return function acsEncodersSimulateNextCredentialEncodeWillSucceed( + ...args: Parameters< + SeamHttpAcsEncodersSimulate['nextCredentialEncodeWillSucceed'] + > + ): ReturnType< + SeamHttpAcsEncodersSimulate['nextCredentialEncodeWillSucceed'] + > { + const seam = SeamHttpAcsEncodersSimulate.fromClient(client, defaults) + return seam.nextCredentialEncodeWillSucceed(...args) + } + } + + get ['/acs/encoders/simulate/next_credential_scan_will_fail'](): SeamHttpAcsEncodersSimulate['nextCredentialScanWillFail'] { + const { client, defaults } = this + return function acsEncodersSimulateNextCredentialScanWillFail( + ...args: Parameters< + SeamHttpAcsEncodersSimulate['nextCredentialScanWillFail'] + > + ): ReturnType { + const seam = SeamHttpAcsEncodersSimulate.fromClient(client, defaults) + return seam.nextCredentialScanWillFail(...args) + } + } + + get ['/acs/encoders/simulate/next_credential_scan_will_succeed'](): SeamHttpAcsEncodersSimulate['nextCredentialScanWillSucceed'] { + const { client, defaults } = this + return function acsEncodersSimulateNextCredentialScanWillSucceed( + ...args: Parameters< + SeamHttpAcsEncodersSimulate['nextCredentialScanWillSucceed'] + > + ): ReturnType< + SeamHttpAcsEncodersSimulate['nextCredentialScanWillSucceed'] + > { + const seam = SeamHttpAcsEncodersSimulate.fromClient(client, defaults) + return seam.nextCredentialScanWillSucceed(...args) + } + } + + get ['/acs/entrances/get'](): SeamHttpAcsEntrances['get'] { + const { client, defaults } = this + return function acsEntrancesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEntrances.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/entrances/grant_access'](): SeamHttpAcsEntrances['grantAccess'] { + const { client, defaults } = this + return function acsEntrancesGrantAccess( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEntrances.fromClient(client, defaults) + return seam.grantAccess(...args) + } + } + + get ['/acs/entrances/list'](): SeamHttpAcsEntrances['list'] { + const { client, defaults } = this + return function acsEntrancesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEntrances.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/entrances/list_credentials_with_access'](): SeamHttpAcsEntrances['listCredentialsWithAccess'] { + const { client, defaults } = this + return function acsEntrancesListCredentialsWithAccess( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsEntrances.fromClient(client, defaults) + return seam.listCredentialsWithAccess(...args) + } + } + + get ['/acs/systems/get'](): SeamHttpAcsSystems['get'] { + const { client, defaults } = this + return function acsSystemsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsSystems.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/systems/list'](): SeamHttpAcsSystems['list'] { + const { client, defaults } = this + return function acsSystemsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsSystems.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/systems/list_compatible_credential_manager_acs_systems'](): SeamHttpAcsSystems['listCompatibleCredentialManagerAcsSystems'] { + const { client, defaults } = this + return function acsSystemsListCompatibleCredentialManagerAcsSystems( + ...args: Parameters< + SeamHttpAcsSystems['listCompatibleCredentialManagerAcsSystems'] + > + ): ReturnType< + SeamHttpAcsSystems['listCompatibleCredentialManagerAcsSystems'] + > { + const seam = SeamHttpAcsSystems.fromClient(client, defaults) + return seam.listCompatibleCredentialManagerAcsSystems(...args) + } + } + + get ['/acs/users/add_to_access_group'](): SeamHttpAcsUsers['addToAccessGroup'] { + const { client, defaults } = this + return function acsUsersAddToAccessGroup( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.addToAccessGroup(...args) + } + } + + get ['/acs/users/create'](): SeamHttpAcsUsers['create'] { + const { client, defaults } = this + return function acsUsersCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/acs/users/delete'](): SeamHttpAcsUsers['delete'] { + const { client, defaults } = this + return function acsUsersDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/acs/users/get'](): SeamHttpAcsUsers['get'] { + const { client, defaults } = this + return function acsUsersGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/users/list'](): SeamHttpAcsUsers['list'] { + const { client, defaults } = this + return function acsUsersList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/users/list_accessible_entrances'](): SeamHttpAcsUsers['listAccessibleEntrances'] { + const { client, defaults } = this + return function acsUsersListAccessibleEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.listAccessibleEntrances(...args) + } + } + + get ['/acs/users/remove_from_access_group'](): SeamHttpAcsUsers['removeFromAccessGroup'] { + const { client, defaults } = this + return function acsUsersRemoveFromAccessGroup( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.removeFromAccessGroup(...args) + } + } + + get ['/acs/users/revoke_access_to_all_entrances'](): SeamHttpAcsUsers['revokeAccessToAllEntrances'] { + const { client, defaults } = this + return function acsUsersRevokeAccessToAllEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.revokeAccessToAllEntrances(...args) + } + } + + get ['/acs/users/suspend'](): SeamHttpAcsUsers['suspend'] { + const { client, defaults } = this + return function acsUsersSuspend( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.suspend(...args) + } + } + + get ['/acs/users/unsuspend'](): SeamHttpAcsUsers['unsuspend'] { + const { client, defaults } = this + return function acsUsersUnsuspend( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.unsuspend(...args) + } + } + + get ['/acs/users/update'](): SeamHttpAcsUsers['update'] { + const { client, defaults } = this + return function acsUsersUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsers.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/action_attempts/get'](): SeamHttpActionAttempts['get'] { + const { client, defaults } = this + return function actionAttemptsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpActionAttempts.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/action_attempts/list'](): SeamHttpActionAttempts['list'] { + const { client, defaults } = this + return function actionAttemptsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpActionAttempts.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/client_sessions/create'](): SeamHttpClientSessions['create'] { + const { client, defaults } = this + return function clientSessionsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/client_sessions/delete'](): SeamHttpClientSessions['delete'] { + const { client, defaults } = this + return function clientSessionsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/client_sessions/get'](): SeamHttpClientSessions['get'] { + const { client, defaults } = this + return function clientSessionsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/client_sessions/get_or_create'](): SeamHttpClientSessions['getOrCreate'] { + const { client, defaults } = this + return function clientSessionsGetOrCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.getOrCreate(...args) + } + } + + get ['/client_sessions/grant_access'](): SeamHttpClientSessions['grantAccess'] { + const { client, defaults } = this + return function clientSessionsGrantAccess( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.grantAccess(...args) + } + } + + get ['/client_sessions/list'](): SeamHttpClientSessions['list'] { + const { client, defaults } = this + return function clientSessionsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/client_sessions/revoke'](): SeamHttpClientSessions['revoke'] { + const { client, defaults } = this + return function clientSessionsRevoke( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpClientSessions.fromClient(client, defaults) + return seam.revoke(...args) + } + } + + get ['/connect_webviews/create'](): SeamHttpConnectWebviews['create'] { + const { client, defaults } = this + return function connectWebviewsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectWebviews.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/connect_webviews/delete'](): SeamHttpConnectWebviews['delete'] { + const { client, defaults } = this + return function connectWebviewsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectWebviews.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/connect_webviews/get'](): SeamHttpConnectWebviews['get'] { + const { client, defaults } = this + return function connectWebviewsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectWebviews.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/connect_webviews/list'](): SeamHttpConnectWebviews['list'] { + const { client, defaults } = this + return function connectWebviewsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectWebviews.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/connected_accounts/delete'](): SeamHttpConnectedAccounts['delete'] { + const { client, defaults } = this + return function connectedAccountsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectedAccounts.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/connected_accounts/get'](): SeamHttpConnectedAccounts['get'] { + const { client, defaults } = this + return function connectedAccountsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectedAccounts.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/connected_accounts/list'](): SeamHttpConnectedAccounts['list'] { + const { client, defaults } = this + return function connectedAccountsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectedAccounts.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/connected_accounts/sync'](): SeamHttpConnectedAccounts['sync'] { + const { client, defaults } = this + return function connectedAccountsSync( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectedAccounts.fromClient(client, defaults) + return seam.sync(...args) + } + } + + get ['/connected_accounts/update'](): SeamHttpConnectedAccounts['update'] { + const { client, defaults } = this + return function connectedAccountsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpConnectedAccounts.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/devices/get'](): SeamHttpDevices['get'] { + const { client, defaults } = this + return function devicesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevices.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/devices/list'](): SeamHttpDevices['list'] { + const { client, defaults } = this + return function devicesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevices.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/devices/list_device_providers'](): SeamHttpDevices['listDeviceProviders'] { + const { client, defaults } = this + return function devicesListDeviceProviders( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevices.fromClient(client, defaults) + return seam.listDeviceProviders(...args) + } + } + + get ['/devices/update'](): SeamHttpDevices['update'] { + const { client, defaults } = this + return function devicesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevices.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/devices/simulate/connect'](): SeamHttpDevicesSimulate['connect'] { + const { client, defaults } = this + return function devicesSimulateConnect( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesSimulate.fromClient(client, defaults) + return seam.connect(...args) + } + } + + get ['/devices/simulate/disconnect'](): SeamHttpDevicesSimulate['disconnect'] { + const { client, defaults } = this + return function devicesSimulateDisconnect( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesSimulate.fromClient(client, defaults) + return seam.disconnect(...args) + } + } + + get ['/devices/simulate/remove'](): SeamHttpDevicesSimulate['remove'] { + const { client, defaults } = this + return function devicesSimulateRemove( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesSimulate.fromClient(client, defaults) + return seam.remove(...args) + } + } + + get ['/devices/unmanaged/get'](): SeamHttpDevicesUnmanaged['get'] { + const { client, defaults } = this + return function devicesUnmanagedGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesUnmanaged.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/devices/unmanaged/list'](): SeamHttpDevicesUnmanaged['list'] { + const { client, defaults } = this + return function devicesUnmanagedList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesUnmanaged.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/devices/unmanaged/update'](): SeamHttpDevicesUnmanaged['update'] { + const { client, defaults } = this + return function devicesUnmanagedUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevicesUnmanaged.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/events/get'](): SeamHttpEvents['get'] { + const { client, defaults } = this + return function eventsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpEvents.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/events/list'](): SeamHttpEvents['list'] { + const { client, defaults } = this + return function eventsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpEvents.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/locks/get'](): SeamHttpLocks['get'] { + const { client, defaults } = this + return function locksGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocks.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/locks/list'](): SeamHttpLocks['list'] { + const { client, defaults } = this + return function locksList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocks.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/locks/lock_door'](): SeamHttpLocks['lockDoor'] { + const { client, defaults } = this + return function locksLockDoor( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocks.fromClient(client, defaults) + return seam.lockDoor(...args) + } + } + + get ['/locks/unlock_door'](): SeamHttpLocks['unlockDoor'] { + const { client, defaults } = this + return function locksUnlockDoor( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocks.fromClient(client, defaults) + return seam.unlockDoor(...args) + } + } + + get ['/noise_sensors/list'](): SeamHttpNoiseSensors['list'] { + const { client, defaults } = this + return function noiseSensorsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensors.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/noise_sensors/noise_thresholds/create'](): SeamHttpNoiseSensorsNoiseThresholds['create'] { + const { client, defaults } = this + return function noiseSensorsNoiseThresholdsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsNoiseThresholds.fromClient( + client, + defaults, + ) + return seam.create(...args) + } + } + + get ['/noise_sensors/noise_thresholds/delete'](): SeamHttpNoiseSensorsNoiseThresholds['delete'] { + const { client, defaults } = this + return function noiseSensorsNoiseThresholdsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsNoiseThresholds.fromClient( + client, + defaults, + ) + return seam.delete(...args) + } + } + + get ['/noise_sensors/noise_thresholds/get'](): SeamHttpNoiseSensorsNoiseThresholds['get'] { + const { client, defaults } = this + return function noiseSensorsNoiseThresholdsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsNoiseThresholds.fromClient( + client, + defaults, + ) + return seam.get(...args) + } + } + + get ['/noise_sensors/noise_thresholds/list'](): SeamHttpNoiseSensorsNoiseThresholds['list'] { + const { client, defaults } = this + return function noiseSensorsNoiseThresholdsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsNoiseThresholds.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + + get ['/noise_sensors/noise_thresholds/update'](): SeamHttpNoiseSensorsNoiseThresholds['update'] { + const { client, defaults } = this + return function noiseSensorsNoiseThresholdsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsNoiseThresholds.fromClient( + client, + defaults, + ) + return seam.update(...args) + } + } + + get ['/noise_sensors/simulate/trigger_noise_threshold'](): SeamHttpNoiseSensorsSimulate['triggerNoiseThreshold'] { + const { client, defaults } = this + return function noiseSensorsSimulateTriggerNoiseThreshold( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNoiseSensorsSimulate.fromClient(client, defaults) + return seam.triggerNoiseThreshold(...args) + } + } + + get ['/phones/deactivate'](): SeamHttpPhones['deactivate'] { + const { client, defaults } = this + return function phonesDeactivate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpPhones.fromClient(client, defaults) + return seam.deactivate(...args) + } + } + + get ['/phones/get'](): SeamHttpPhones['get'] { + const { client, defaults } = this + return function phonesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpPhones.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/phones/list'](): SeamHttpPhones['list'] { + const { client, defaults } = this + return function phonesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpPhones.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/phones/simulate/create_sandbox_phone'](): SeamHttpPhonesSimulate['createSandboxPhone'] { + const { client, defaults } = this + return function phonesSimulateCreateSandboxPhone( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpPhonesSimulate.fromClient(client, defaults) + return seam.createSandboxPhone(...args) + } + } + + get ['/spaces/add_acs_entrances'](): SeamHttpSpaces['addAcsEntrances'] { + const { client, defaults } = this + return function spacesAddAcsEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.addAcsEntrances(...args) + } + } + + get ['/spaces/add_devices'](): SeamHttpSpaces['addDevices'] { + const { client, defaults } = this + return function spacesAddDevices( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.addDevices(...args) + } + } + + get ['/spaces/create'](): SeamHttpSpaces['create'] { + const { client, defaults } = this + return function spacesCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/spaces/delete'](): SeamHttpSpaces['delete'] { + const { client, defaults } = this + return function spacesDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/spaces/get'](): SeamHttpSpaces['get'] { + const { client, defaults } = this + return function spacesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/spaces/list'](): SeamHttpSpaces['list'] { + const { client, defaults } = this + return function spacesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/spaces/remove_acs_entrances'](): SeamHttpSpaces['removeAcsEntrances'] { + const { client, defaults } = this + return function spacesRemoveAcsEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.removeAcsEntrances(...args) + } + } + + get ['/spaces/remove_devices'](): SeamHttpSpaces['removeDevices'] { + const { client, defaults } = this + return function spacesRemoveDevices( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.removeDevices(...args) + } + } + + get ['/spaces/update'](): SeamHttpSpaces['update'] { + const { client, defaults } = this + return function spacesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSpaces.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/thermostats/activate_climate_preset'](): SeamHttpThermostats['activateClimatePreset'] { + const { client, defaults } = this + return function thermostatsActivateClimatePreset( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.activateClimatePreset(...args) + } + } + + get ['/thermostats/cool'](): SeamHttpThermostats['cool'] { + const { client, defaults } = this + return function thermostatsCool( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.cool(...args) + } + } + + get ['/thermostats/create_climate_preset'](): SeamHttpThermostats['createClimatePreset'] { + const { client, defaults } = this + return function thermostatsCreateClimatePreset( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.createClimatePreset(...args) + } + } + + get ['/thermostats/delete_climate_preset'](): SeamHttpThermostats['deleteClimatePreset'] { + const { client, defaults } = this + return function thermostatsDeleteClimatePreset( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.deleteClimatePreset(...args) + } + } + + get ['/thermostats/heat'](): SeamHttpThermostats['heat'] { + const { client, defaults } = this + return function thermostatsHeat( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.heat(...args) + } + } + + get ['/thermostats/heat_cool'](): SeamHttpThermostats['heatCool'] { + const { client, defaults } = this + return function thermostatsHeatCool( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.heatCool(...args) + } + } + + get ['/thermostats/list'](): SeamHttpThermostats['list'] { + const { client, defaults } = this + return function thermostatsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/thermostats/off'](): SeamHttpThermostats['off'] { + const { client, defaults } = this + return function thermostatsOff( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.off(...args) + } + } + + get ['/thermostats/set_fallback_climate_preset'](): SeamHttpThermostats['setFallbackClimatePreset'] { + const { client, defaults } = this + return function thermostatsSetFallbackClimatePreset( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.setFallbackClimatePreset(...args) + } + } + + get ['/thermostats/set_fan_mode'](): SeamHttpThermostats['setFanMode'] { + const { client, defaults } = this + return function thermostatsSetFanMode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.setFanMode(...args) + } + } + + get ['/thermostats/set_hvac_mode'](): SeamHttpThermostats['setHvacMode'] { + const { client, defaults } = this + return function thermostatsSetHvacMode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.setHvacMode(...args) + } + } + + get ['/thermostats/set_temperature_threshold'](): SeamHttpThermostats['setTemperatureThreshold'] { + const { client, defaults } = this + return function thermostatsSetTemperatureThreshold( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.setTemperatureThreshold(...args) + } + } + + get ['/thermostats/update_climate_preset'](): SeamHttpThermostats['updateClimatePreset'] { + const { client, defaults } = this + return function thermostatsUpdateClimatePreset( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.updateClimatePreset(...args) + } + } + + get ['/thermostats/update_weekly_program'](): SeamHttpThermostats['updateWeeklyProgram'] { + const { client, defaults } = this + return function thermostatsUpdateWeeklyProgram( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.updateWeeklyProgram(...args) + } + } + + get ['/thermostats/daily_programs/create'](): SeamHttpThermostatsDailyPrograms['create'] { + const { client, defaults } = this + return function thermostatsDailyProgramsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsDailyPrograms.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/thermostats/daily_programs/delete'](): SeamHttpThermostatsDailyPrograms['delete'] { + const { client, defaults } = this + return function thermostatsDailyProgramsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsDailyPrograms.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/thermostats/daily_programs/update'](): SeamHttpThermostatsDailyPrograms['update'] { + const { client, defaults } = this + return function thermostatsDailyProgramsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsDailyPrograms.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/thermostats/schedules/create'](): SeamHttpThermostatsSchedules['create'] { + const { client, defaults } = this + return function thermostatsSchedulesCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSchedules.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/thermostats/schedules/delete'](): SeamHttpThermostatsSchedules['delete'] { + const { client, defaults } = this + return function thermostatsSchedulesDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSchedules.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/thermostats/schedules/get'](): SeamHttpThermostatsSchedules['get'] { + const { client, defaults } = this + return function thermostatsSchedulesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSchedules.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/thermostats/schedules/list'](): SeamHttpThermostatsSchedules['list'] { + const { client, defaults } = this + return function thermostatsSchedulesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSchedules.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/thermostats/schedules/update'](): SeamHttpThermostatsSchedules['update'] { + const { client, defaults } = this + return function thermostatsSchedulesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSchedules.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/thermostats/simulate/hvac_mode_adjusted'](): SeamHttpThermostatsSimulate['hvacModeAdjusted'] { + const { client, defaults } = this + return function thermostatsSimulateHvacModeAdjusted( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSimulate.fromClient(client, defaults) + return seam.hvacModeAdjusted(...args) + } + } + + get ['/thermostats/simulate/temperature_reached'](): SeamHttpThermostatsSimulate['temperatureReached'] { + const { client, defaults } = this + return function thermostatsSimulateTemperatureReached( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostatsSimulate.fromClient(client, defaults) + return seam.temperatureReached(...args) + } + } + + get ['/user_identities/add_acs_user'](): SeamHttpUserIdentities['addAcsUser'] { + const { client, defaults } = this + return function userIdentitiesAddAcsUser( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.addAcsUser(...args) + } + } + + get ['/user_identities/create'](): SeamHttpUserIdentities['create'] { + const { client, defaults } = this + return function userIdentitiesCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/user_identities/delete'](): SeamHttpUserIdentities['delete'] { + const { client, defaults } = this + return function userIdentitiesDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/user_identities/generate_instant_key'](): SeamHttpUserIdentities['generateInstantKey'] { + const { client, defaults } = this + return function userIdentitiesGenerateInstantKey( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.generateInstantKey(...args) + } + } + + get ['/user_identities/get'](): SeamHttpUserIdentities['get'] { + const { client, defaults } = this + return function userIdentitiesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/user_identities/grant_access_to_device'](): SeamHttpUserIdentities['grantAccessToDevice'] { + const { client, defaults } = this + return function userIdentitiesGrantAccessToDevice( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.grantAccessToDevice(...args) + } + } + + get ['/user_identities/list'](): SeamHttpUserIdentities['list'] { + const { client, defaults } = this + return function userIdentitiesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/user_identities/list_accessible_devices'](): SeamHttpUserIdentities['listAccessibleDevices'] { + const { client, defaults } = this + return function userIdentitiesListAccessibleDevices( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.listAccessibleDevices(...args) + } + } + + get ['/user_identities/list_acs_systems'](): SeamHttpUserIdentities['listAcsSystems'] { + const { client, defaults } = this + return function userIdentitiesListAcsSystems( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.listAcsSystems(...args) + } + } + + get ['/user_identities/list_acs_users'](): SeamHttpUserIdentities['listAcsUsers'] { + const { client, defaults } = this + return function userIdentitiesListAcsUsers( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.listAcsUsers(...args) + } + } + + get ['/user_identities/remove_acs_user'](): SeamHttpUserIdentities['removeAcsUser'] { + const { client, defaults } = this + return function userIdentitiesRemoveAcsUser( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.removeAcsUser(...args) + } + } + + get ['/user_identities/revoke_access_to_device'](): SeamHttpUserIdentities['revokeAccessToDevice'] { + const { client, defaults } = this + return function userIdentitiesRevokeAccessToDevice( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.revokeAccessToDevice(...args) + } + } + + get ['/user_identities/update'](): SeamHttpUserIdentities['update'] { + const { client, defaults } = this + return function userIdentitiesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentities.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/user_identities/enrollment_automations/delete'](): SeamHttpUserIdentitiesEnrollmentAutomations['delete'] { + const { client, defaults } = this + return function userIdentitiesEnrollmentAutomationsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentitiesEnrollmentAutomations.fromClient( + client, + defaults, + ) + return seam.delete(...args) + } + } + + get ['/user_identities/enrollment_automations/get'](): SeamHttpUserIdentitiesEnrollmentAutomations['get'] { + const { client, defaults } = this + return function userIdentitiesEnrollmentAutomationsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentitiesEnrollmentAutomations.fromClient( + client, + defaults, + ) + return seam.get(...args) + } + } + + get ['/user_identities/enrollment_automations/launch'](): SeamHttpUserIdentitiesEnrollmentAutomations['launch'] { + const { client, defaults } = this + return function userIdentitiesEnrollmentAutomationsLaunch( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentitiesEnrollmentAutomations.fromClient( + client, + defaults, + ) + return seam.launch(...args) + } + } + + get ['/user_identities/enrollment_automations/list'](): SeamHttpUserIdentitiesEnrollmentAutomations['list'] { + const { client, defaults } = this + return function userIdentitiesEnrollmentAutomationsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUserIdentitiesEnrollmentAutomations.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + + get ['/webhooks/create'](): SeamHttpWebhooks['create'] { + const { client, defaults } = this + return function webhooksCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWebhooks.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/webhooks/delete'](): SeamHttpWebhooks['delete'] { + const { client, defaults } = this + return function webhooksDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWebhooks.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/webhooks/get'](): SeamHttpWebhooks['get'] { + const { client, defaults } = this + return function webhooksGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWebhooks.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/webhooks/list'](): SeamHttpWebhooks['list'] { + const { client, defaults } = this + return function webhooksList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWebhooks.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/webhooks/update'](): SeamHttpWebhooks['update'] { + const { client, defaults } = this + return function webhooksUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWebhooks.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/workspaces/create'](): SeamHttpWorkspaces['create'] { + const { client, defaults } = this + return function workspacesCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWorkspaces.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/workspaces/get'](): SeamHttpWorkspaces['get'] { + const { client, defaults } = this + return function workspacesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWorkspaces.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/workspaces/list'](): SeamHttpWorkspaces['list'] { + const { client, defaults } = this + return function workspacesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWorkspaces.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/workspaces/reset_sandbox'](): SeamHttpWorkspaces['resetSandbox'] { + const { client, defaults } = this + return function workspacesResetSandbox( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWorkspaces.fromClient(client, defaults) + return seam.resetSandbox(...args) + } + } + + get ['/workspaces/update'](): SeamHttpWorkspaces['update'] { + const { client, defaults } = this + return function workspacesUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpWorkspaces.fromClient(client, defaults) + return seam.update(...args) + } + } +} diff --git a/test/seam/connect/api-key.test.ts b/test/seam/connect/api-key.test.ts index 90eee926..7895e479 100644 --- a/test/seam/connect/api-key.test.ts +++ b/test/seam/connect/api-key.test.ts @@ -1,7 +1,11 @@ import test from 'ava' import { getTestServer } from 'fixtures/seam/connect/api.js' -import { SeamHttp, SeamHttpInvalidTokenError } from '@seamapi/http/connect' +import { + SeamHttp, + SeamHttpEndpoints, + SeamHttpInvalidTokenError, +} from '@seamapi/http/connect' test('SeamHttp: fromApiKey returns instance authorized with apiKey', async (t) => { const { seed, endpoint } = await getTestServer(t) @@ -50,3 +54,15 @@ test('SeamHttp: checks apiKey format', (t) => { message: /Access Token/, }) }) + +test('SeamHttpEndpoints: fromApiKey returns instance authorized with apiKey', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttpEndpoints.fromApiKey(seed.seam_apikey1_token, { + endpoint, + }) + const device = await seam['/devices/get']({ + device_id: seed.august_device_1, + }) + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) +})