From 8446bfe7a36440c0625cb64d87df80848598b01c Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Mon, 25 Mar 2024 12:03:23 +0000 Subject: [PATCH 01/29] Add SeamApiRequest --- src/lib/seam/connect/seam-api-request.ts | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/lib/seam/connect/seam-api-request.ts diff --git a/src/lib/seam/connect/seam-api-request.ts b/src/lib/seam/connect/seam-api-request.ts new file mode 100644 index 00000000..94e8121a --- /dev/null +++ b/src/lib/seam/connect/seam-api-request.ts @@ -0,0 +1,95 @@ +import type { AxiosRequestConfig } from 'axios' +import type { Client } from './client.js' +import type { SeamHttpRequestOptions } from './options.js' +import { resolveActionAttempt } from './resolve-action-attempt.js' +import { SeamHttpActionAttempts } from './index.js' + +export interface SeamApiRequestParent { + readonly client: Client + readonly defaults: Required +} + +export type ResponseFromSeamApiRequest = + T extends SeamApiRequest + ? TResourceKey extends keyof TResponse + ? TResponse[TResourceKey] + : void + : never + +export class SeamApiRequest< + const TBody, + const TResponse, + const TResourceKey extends keyof TResponse | undefined, +> implements + PromiseLike< + TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined + > +{ + readonly parent: SeamApiRequestParent + readonly requestConfig: AxiosRequestConfig + readonly resourceKey: TResourceKey + readonly options: Pick + + constructor( + parent: SeamApiRequestParent, + requestConfig: AxiosRequestConfig, + resourceKey: TResourceKey, + options: Pick = {}, + ) { + this.parent = parent + this.requestConfig = requestConfig + this.resourceKey = resourceKey + this.options = options + } + + async execute(): Promise< + TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined + > { + const { client } = this.parent + const response = await client.request(this.requestConfig) + if (this.resourceKey === undefined) { + return undefined as TResourceKey extends keyof TResponse + ? TResponse[TResourceKey] + : undefined + } + const data = response.data[this.resourceKey] + if (this.resourceKey === 'action_attempt') { + const waitForActionAttempt = + this.options.waitForActionAttempt ?? + this.parent.defaults.waitForActionAttempt + if (waitForActionAttempt !== false) { + return resolveActionAttempt( + data, + SeamHttpActionAttempts.fromClient(client, { + ...this.parent.defaults, + waitForActionAttempt: false, + }), + typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, + ) + } + } + return data + } + + then< + TResult1 = TResourceKey extends keyof TResponse + ? TResponse[TResourceKey] + : undefined, + TResult2 = never, + >( + onfulfilled?: + | (( + value: TResourceKey extends keyof TResponse + ? TResponse[TResourceKey] + : undefined, + ) => TResult1 | PromiseLike) + | null + | undefined, + onrejected?: + | ((reason: any) => TResult2 | PromiseLike) + | null + | undefined, + ): PromiseLike { + return this.execute().then(onfulfilled, onrejected) + } +} From d61f5282d1395de53a6e5a99831c24d754933675 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Mon, 25 Mar 2024 12:03:41 +0000 Subject: [PATCH 02/29] Use SeamApiRequest for api responses --- generate-routes.ts | 36 +-- .../connect/routes/access-codes-unmanaged.ts | 100 ++++--- src/lib/seam/connect/routes/access-codes.ts | 161 +++++++---- .../seam/connect/routes/acs-access-groups.ts | 108 +++++--- .../connect/routes/acs-credential-pools.ts | 25 +- ...acs-credential-provisioning-automations.ts | 28 +- .../seam/connect/routes/acs-credentials.ts | 163 +++++++----- src/lib/seam/connect/routes/acs-entrances.ts | 86 +++--- src/lib/seam/connect/routes/acs-systems.ts | 49 ++-- src/lib/seam/connect/routes/acs-users.ts | 226 ++++++++++------ .../seam/connect/routes/action-attempts.ts | 62 ++--- .../seam/connect/routes/client-sessions.ts | 147 ++++++---- .../seam/connect/routes/connect-webviews.ts | 109 +++++--- .../seam/connect/routes/connected-accounts.ts | 81 ++++-- .../seam/connect/routes/devices-simulate.ts | 19 +- .../seam/connect/routes/devices-unmanaged.ts | 67 +++-- src/lib/seam/connect/routes/devices.ts | 104 +++++--- src/lib/seam/connect/routes/events.ts | 45 ++-- src/lib/seam/connect/routes/locks.ts | 115 ++++---- src/lib/seam/connect/routes/networks.ts | 49 ++-- .../routes/noise-sensors-noise-thresholds.ts | 102 ++++--- .../seam/connect/routes/phones-simulate.ts | 20 +- src/lib/seam/connect/routes/phones.ts | 43 ++- .../thermostats-climate-setting-schedules.ts | 98 ++++--- src/lib/seam/connect/routes/thermostats.ts | 249 +++++++++-------- .../user-identities-enrollment-automations.ts | 94 ++++--- .../seam/connect/routes/user-identities.ts | 250 ++++++++++++------ src/lib/seam/connect/routes/webhooks.ts | 109 +++++--- src/lib/seam/connect/routes/workspaces.ts | 91 ++++--- test/seam/connect/client.test.ts | 33 +++ 30 files changed, 1782 insertions(+), 1087 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index 1e0078cc..c1186024 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -295,6 +295,7 @@ import { import { resolveActionAttempt, } from 'lib/seam/connect/resolve-action-attempt.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' ${ namespace === 'client_sessions' @@ -354,41 +355,28 @@ const renderClassMethod = ({ path, isRequestParamOptional, }: Endpoint): string => ` - async ${camelCase(name)}( + ${camelCase(name)}( ${requestFormat}${isRequestParamOptional ? '?' : ''}: ${renderRequestType({ name, namespace, })}, ${renderClassMethodOptions({ resource })} - ): Promise<${ - resource === null - ? 'void' - : `${renderResponseType({ name, namespace })}['${resource}']` - }> { - ${ - resource === null ? '' : 'const { data } = ' - }await this.client.request<${renderResponseType({ + ): SeamApiRequest<${isRequestParamOptional ? 'undefined | ' : ''}${renderRequestType( + { name, namespace, - })}>({ + }, + )}, ${ + resource === null + ? 'void, undefined' + : `${renderResponseType({ name, namespace })}, '${resource}'` + }> { + return new SeamApiRequest(this, { url: '${path}', method: '${snakeCase(method)}', ${ requestFormat === 'params' ? 'params,' : '' } ${requestFormat === 'body' ? 'data: body,' : ''} - }) - ${ - resource === 'action_attempt' - ? `const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return resolveActionAttempt( - data.${resource}, - SeamHttpActionAttempts.fromClient(this.client, { ...this.defaults, waitForActionAttempt: false }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - }` - : '' - } - ${resource === null ? '' : `return data.${resource}`} + }, ${resource === null ? 'undefined' : `'${resource}'`}${resource === 'action_attempt' ? ', options' : ''}) } ` diff --git a/src/lib/seam/connect/routes/access-codes-unmanaged.ts b/src/lib/seam/connect/routes/access-codes-unmanaged.ts index 7935541b..1b38efc9 100644 --- a/src/lib/seam/connect/routes/access-codes-unmanaged.ts +++ b/src/lib/seam/connect/routes/access-codes-unmanaged.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,57 +154,94 @@ export class SeamHttpAccessCodesUnmanaged { await clientSessions.get() } - async convertToManaged( + convertToManaged( body?: AccessCodesUnmanagedConvertToManagedBody, - ): Promise { - await this.client.request({ - url: '/access_codes/unmanaged/convert_to_managed', - method: 'post', - data: body, - }) + ): SeamApiRequest< + undefined | AccessCodesUnmanagedConvertToManagedBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/unmanaged/convert_to_managed', + method: 'post', + data: body, + }, + undefined, + ) } - async delete(body?: AccessCodesUnmanagedDeleteBody): Promise { - await this.client.request({ - url: '/access_codes/unmanaged/delete', - method: 'post', - data: body, - }) + delete( + body?: AccessCodesUnmanagedDeleteBody, + ): SeamApiRequest< + undefined | AccessCodesUnmanagedDeleteBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/unmanaged/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: AccessCodesUnmanagedGetParams, - ): Promise { - const { data } = await this.client.request( + ): SeamApiRequest< + undefined | AccessCodesUnmanagedGetParams, + AccessCodesUnmanagedGetResponse, + 'access_code' + > { + return new SeamApiRequest( + this, { url: '/access_codes/unmanaged/get', method: 'post', data: body, }, + 'access_code', ) - - return data.access_code } - async list( + list( body?: AccessCodesUnmanagedListParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AccessCodesUnmanagedListParams, + AccessCodesUnmanagedListResponse, + 'access_codes' + > { + return new SeamApiRequest( + this, + { url: '/access_codes/unmanaged/list', method: 'post', data: body, - }) - - return data.access_codes + }, + 'access_codes', + ) } - async update(body?: AccessCodesUnmanagedUpdateBody): Promise { - await this.client.request({ - url: '/access_codes/unmanaged/update', - method: 'post', - data: body, - }) + update( + body?: AccessCodesUnmanagedUpdateBody, + ): SeamApiRequest< + undefined | AccessCodesUnmanagedUpdateBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/unmanaged/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/access-codes.ts b/src/lib/seam/connect/routes/access-codes.ts index fd9a8ec1..c7a47a8d 100644 --- a/src/lib/seam/connect/routes/access-codes.ts +++ b/src/lib/seam/connect/routes/access-codes.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpAccessCodesUnmanaged } from './access-codes-unmanaged.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -158,96 +159,140 @@ export class SeamHttpAccessCodes { return SeamHttpAccessCodesUnmanaged.fromClient(this.client, this.defaults) } - async create( + create( body?: AccessCodesCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/access_codes/create', - method: 'post', - data: body, - }) - - return data.access_code + ): SeamApiRequest< + undefined | AccessCodesCreateBody, + AccessCodesCreateResponse, + 'access_code' + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/create', + method: 'post', + data: body, + }, + 'access_code', + ) } - async createMultiple( + createMultiple( body?: AccessCodesCreateMultipleBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AccessCodesCreateMultipleBody, + AccessCodesCreateMultipleResponse, + 'access_codes' + > { + return new SeamApiRequest( + this, + { url: '/access_codes/create_multiple', method: 'post', data: body, - }) - - return data.access_codes + }, + 'access_codes', + ) } - async delete(body?: AccessCodesDeleteBody): Promise { - await this.client.request({ - url: '/access_codes/delete', - method: 'post', - data: body, - }) + delete( + body?: AccessCodesDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/access_codes/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async generateCode( + generateCode( body?: AccessCodesGenerateCodeBody, - ): Promise { - const { data } = await this.client.request( + ): SeamApiRequest< + undefined | AccessCodesGenerateCodeBody, + AccessCodesGenerateCodeResponse, + 'generated_code' + > { + return new SeamApiRequest( + this, { url: '/access_codes/generate_code', method: 'post', data: body, }, + 'generated_code', ) - - return data.generated_code } - async get( + get( body?: AccessCodesGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/access_codes/get', - method: 'post', - data: body, - }) - - return data.access_code + ): SeamApiRequest< + undefined | AccessCodesGetParams, + AccessCodesGetResponse, + 'access_code' + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/get', + method: 'post', + data: body, + }, + 'access_code', + ) } - async list( + list( body?: AccessCodesListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/access_codes/list', - method: 'post', - data: body, - }) - - return data.access_codes + ): SeamApiRequest< + undefined | AccessCodesListParams, + AccessCodesListResponse, + 'access_codes' + > { + return new SeamApiRequest( + this, + { + url: '/access_codes/list', + method: 'post', + data: body, + }, + 'access_codes', + ) } - async pullBackupAccessCode( + pullBackupAccessCode( body?: AccessCodesPullBackupAccessCodeBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AccessCodesPullBackupAccessCodeBody, + AccessCodesPullBackupAccessCodeResponse, + 'backup_access_code' + > { + return new SeamApiRequest( + this, + { url: '/access_codes/pull_backup_access_code', method: 'post', data: body, - }) - - return data.backup_access_code + }, + 'backup_access_code', + ) } - async update(body?: AccessCodesUpdateBody): Promise { - await this.client.request({ - url: '/access_codes/update', - method: 'post', - data: body, - }) + update( + body?: AccessCodesUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/access_codes/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index 7aa024f1..32177462 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,57 +154,90 @@ export class SeamHttpAcsAccessGroups { await clientSessions.get() } - async addUser(body?: AcsAccessGroupsAddUserBody): Promise { - await this.client.request({ - url: '/acs/access_groups/add_user', - method: 'post', - data: body, - }) + addUser( + body?: AcsAccessGroupsAddUserBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/access_groups/add_user', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: AcsAccessGroupsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/access_groups/get', - method: 'post', - data: body, - }) - - return data.acs_access_group + ): SeamApiRequest< + undefined | AcsAccessGroupsGetParams, + AcsAccessGroupsGetResponse, + 'acs_access_group' + > { + return new SeamApiRequest( + this, + { + url: '/acs/access_groups/get', + method: 'post', + data: body, + }, + 'acs_access_group', + ) } - async list( + list( body?: AcsAccessGroupsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/access_groups/list', - method: 'post', - data: body, - }) - - return data.acs_access_groups + ): SeamApiRequest< + undefined | AcsAccessGroupsListParams, + AcsAccessGroupsListResponse, + 'acs_access_groups' + > { + return new SeamApiRequest( + this, + { + url: '/acs/access_groups/list', + method: 'post', + data: body, + }, + 'acs_access_groups', + ) } - async listUsers( + listUsers( body?: AcsAccessGroupsListUsersParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AcsAccessGroupsListUsersParams, + AcsAccessGroupsListUsersResponse, + 'acs_users' + > { + return new SeamApiRequest( + this, + { url: '/acs/access_groups/list_users', method: 'post', data: body, - }) - - return data.acs_users + }, + 'acs_users', + ) } - async removeUser(body?: AcsAccessGroupsRemoveUserBody): Promise { - await this.client.request({ - url: '/acs/access_groups/remove_user', - method: 'post', - data: body, - }) + removeUser( + body?: AcsAccessGroupsRemoveUserBody, + ): SeamApiRequest< + undefined | AcsAccessGroupsRemoveUserBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/acs/access_groups/remove_user', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/acs-credential-pools.ts b/src/lib/seam/connect/routes/acs-credential-pools.ts index 0e6783c9..f718427a 100644 --- a/src/lib/seam/connect/routes/acs-credential-pools.ts +++ b/src/lib/seam/connect/routes/acs-credential-pools.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,16 +154,22 @@ export class SeamHttpAcsCredentialPools { await clientSessions.get() } - async list( + list( body?: AcsCredentialPoolsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credential_pools/list', - method: 'post', - data: body, - }) - - return data.acs_credential_pools + ): SeamApiRequest< + undefined | AcsCredentialPoolsListParams, + AcsCredentialPoolsListResponse, + 'acs_credential_pools' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credential_pools/list', + method: 'post', + data: body, + }, + 'acs_credential_pools', + ) } } diff --git a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts index 188e1f2e..76a977df 100644 --- a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +++ b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,21 +157,22 @@ export class SeamHttpAcsCredentialProvisioningAutomations { await clientSessions.get() } - async launch( + launch( body?: AcsCredentialProvisioningAutomationsLaunchBody, - ): Promise< - AcsCredentialProvisioningAutomationsLaunchResponse['acs_credential_provisioning_automation'] + ): SeamApiRequest< + undefined | AcsCredentialProvisioningAutomationsLaunchBody, + AcsCredentialProvisioningAutomationsLaunchResponse, + 'acs_credential_provisioning_automation' > { - const { data } = - await this.client.request( - { - url: '/acs/credential_provisioning_automations/launch', - method: 'post', - data: body, - }, - ) - - return data.acs_credential_provisioning_automation + return new SeamApiRequest( + this, + { + url: '/acs/credential_provisioning_automations/launch', + method: 'post', + data: body, + }, + 'acs_credential_provisioning_automation', + ) } } diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index f55f5722..54ef5b4d 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,84 +154,126 @@ export class SeamHttpAcsCredentials { await clientSessions.get() } - async assign( + assign( body?: AcsCredentialsAssignBody, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/assign', - method: 'post', - data: body, - }) - - return data.acs_credential + ): SeamApiRequest< + undefined | AcsCredentialsAssignBody, + AcsCredentialsAssignResponse, + 'acs_credential' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/assign', + method: 'post', + data: body, + }, + 'acs_credential', + ) } - async create( + create( body?: AcsCredentialsCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/create', - method: 'post', - data: body, - }) - - return data.acs_credential + ): SeamApiRequest< + undefined | AcsCredentialsCreateBody, + AcsCredentialsCreateResponse, + 'acs_credential' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/create', + method: 'post', + data: body, + }, + 'acs_credential', + ) } - async delete(body?: AcsCredentialsDeleteBody): Promise { - await this.client.request({ - url: '/acs/credentials/delete', - method: 'post', - data: body, - }) + delete( + body?: AcsCredentialsDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: AcsCredentialsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/get', - method: 'post', - data: body, - }) - - return data.acs_credential + ): SeamApiRequest< + undefined | AcsCredentialsGetParams, + AcsCredentialsGetResponse, + 'acs_credential' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/get', + method: 'post', + data: body, + }, + 'acs_credential', + ) } - async list( + list( body?: AcsCredentialsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/list', - method: 'post', - data: body, - }) - - return data.acs_credentials + ): SeamApiRequest< + undefined | AcsCredentialsListParams, + AcsCredentialsListResponse, + 'acs_credentials' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/list', + method: 'post', + data: body, + }, + 'acs_credentials', + ) } - async unassign( + unassign( body?: AcsCredentialsUnassignBody, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/unassign', - method: 'post', - data: body, - }) - - return data.acs_credential + ): SeamApiRequest< + undefined | AcsCredentialsUnassignBody, + AcsCredentialsUnassignResponse, + 'acs_credential' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/unassign', + method: 'post', + data: body, + }, + 'acs_credential', + ) } - async update( + update( body?: AcsCredentialsUpdateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/credentials/update', - method: 'post', - data: body, - }) - - return data.acs_credential + ): SeamApiRequest< + undefined | AcsCredentialsUpdateBody, + AcsCredentialsUpdateResponse, + 'acs_credential' + > { + return new SeamApiRequest( + this, + { + url: '/acs/credentials/update', + method: 'post', + data: body, + }, + 'acs_credential', + ) } } diff --git a/src/lib/seam/connect/routes/acs-entrances.ts b/src/lib/seam/connect/routes/acs-entrances.ts index a0c6c68d..2e33e497 100644 --- a/src/lib/seam/connect/routes/acs-entrances.ts +++ b/src/lib/seam/connect/routes/acs-entrances.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,49 +154,72 @@ export class SeamHttpAcsEntrances { await clientSessions.get() } - async get( + get( body?: AcsEntrancesGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/entrances/get', - method: 'post', - data: body, - }) - - return data.acs_entrance + ): SeamApiRequest< + undefined | AcsEntrancesGetParams, + AcsEntrancesGetResponse, + 'acs_entrance' + > { + return new SeamApiRequest( + this, + { + url: '/acs/entrances/get', + method: 'post', + data: body, + }, + 'acs_entrance', + ) } - async grantAccess(body?: AcsEntrancesGrantAccessBody): Promise { - await this.client.request({ - url: '/acs/entrances/grant_access', - method: 'post', - data: body, - }) + grantAccess( + body?: AcsEntrancesGrantAccessBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/entrances/grant_access', + method: 'post', + data: body, + }, + undefined, + ) } - async list( + list( body?: AcsEntrancesListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/entrances/list', - method: 'post', - data: body, - }) - - return data.acs_entrances + ): SeamApiRequest< + undefined | AcsEntrancesListParams, + AcsEntrancesListResponse, + 'acs_entrances' + > { + return new SeamApiRequest( + this, + { + url: '/acs/entrances/list', + method: 'post', + data: body, + }, + 'acs_entrances', + ) } - async listCredentialsWithAccess( + listCredentialsWithAccess( body?: AcsEntrancesListCredentialsWithAccessParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AcsEntrancesListCredentialsWithAccessParams, + AcsEntrancesListCredentialsWithAccessResponse, + 'acs_credentials' + > { + return new SeamApiRequest( + this, + { url: '/acs/entrances/list_credentials_with_access', method: 'post', data: body, - }) - - return data.acs_credentials + }, + 'acs_credentials', + ) } } diff --git a/src/lib/seam/connect/routes/acs-systems.ts b/src/lib/seam/connect/routes/acs-systems.ts index 5403df63..29533899 100644 --- a/src/lib/seam/connect/routes/acs-systems.ts +++ b/src/lib/seam/connect/routes/acs-systems.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,28 +154,40 @@ export class SeamHttpAcsSystems { await clientSessions.get() } - async get( + get( body?: AcsSystemsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/systems/get', - method: 'post', - data: body, - }) - - return data.acs_system + ): SeamApiRequest< + undefined | AcsSystemsGetParams, + AcsSystemsGetResponse, + 'acs_system' + > { + return new SeamApiRequest( + this, + { + url: '/acs/systems/get', + method: 'post', + data: body, + }, + 'acs_system', + ) } - async list( + list( body?: AcsSystemsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/systems/list', - method: 'post', - data: body, - }) - - return data.acs_systems + ): SeamApiRequest< + undefined | AcsSystemsListParams, + AcsSystemsListResponse, + 'acs_systems' + > { + return new SeamApiRequest( + this, + { + url: '/acs/systems/list', + method: 'post', + data: body, + }, + 'acs_systems', + ) } } diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index 51ffd54d..99412fd9 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,113 +154,182 @@ export class SeamHttpAcsUsers { await clientSessions.get() } - async addToAccessGroup(body?: AcsUsersAddToAccessGroupBody): Promise { - await this.client.request({ - url: '/acs/users/add_to_access_group', - method: 'post', - data: body, - }) + addToAccessGroup( + body?: AcsUsersAddToAccessGroupBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/users/add_to_access_group', + method: 'post', + data: body, + }, + undefined, + ) } - async create( + create( body?: AcsUsersCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/users/create', - method: 'post', - data: body, - }) - - return data.acs_user + ): SeamApiRequest< + undefined | AcsUsersCreateBody, + AcsUsersCreateResponse, + 'acs_user' + > { + return new SeamApiRequest( + this, + { + url: '/acs/users/create', + method: 'post', + data: body, + }, + 'acs_user', + ) } - async delete(body?: AcsUsersDeleteBody): Promise { - await this.client.request({ - url: '/acs/users/delete', - method: 'post', - data: body, - }) + delete( + body?: AcsUsersDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/users/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: AcsUsersGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/users/get', - method: 'post', - data: body, - }) - - return data.acs_user + ): SeamApiRequest< + undefined | AcsUsersGetParams, + AcsUsersGetResponse, + 'acs_user' + > { + return new SeamApiRequest( + this, + { + url: '/acs/users/get', + method: 'post', + data: body, + }, + 'acs_user', + ) } - async list( + list( body?: AcsUsersListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/acs/users/list', - method: 'post', - data: body, - }) - - return data.acs_users + ): SeamApiRequest< + undefined | AcsUsersListParams, + AcsUsersListResponse, + 'acs_users' + > { + return new SeamApiRequest( + this, + { + url: '/acs/users/list', + method: 'post', + data: body, + }, + 'acs_users', + ) } - async listAccessibleEntrances( + listAccessibleEntrances( body?: AcsUsersListAccessibleEntrancesParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | AcsUsersListAccessibleEntrancesParams, + AcsUsersListAccessibleEntrancesResponse, + 'acs_entrances' + > { + return new SeamApiRequest( + this, + { url: '/acs/users/list_accessible_entrances', method: 'post', data: body, - }) - - return data.acs_entrances + }, + 'acs_entrances', + ) } - async removeFromAccessGroup( + removeFromAccessGroup( body?: AcsUsersRemoveFromAccessGroupBody, - ): Promise { - await this.client.request({ - url: '/acs/users/remove_from_access_group', - method: 'post', - data: body, - }) + ): SeamApiRequest< + undefined | AcsUsersRemoveFromAccessGroupBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/acs/users/remove_from_access_group', + method: 'post', + data: body, + }, + undefined, + ) } - async revokeAccessToAllEntrances( + revokeAccessToAllEntrances( body?: AcsUsersRevokeAccessToAllEntrancesBody, - ): Promise { - await this.client.request({ - url: '/acs/users/revoke_access_to_all_entrances', - method: 'post', - data: body, - }) + ): SeamApiRequest< + undefined | AcsUsersRevokeAccessToAllEntrancesBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/acs/users/revoke_access_to_all_entrances', + method: 'post', + data: body, + }, + undefined, + ) } - async suspend(body?: AcsUsersSuspendBody): Promise { - await this.client.request({ - url: '/acs/users/suspend', - method: 'post', - data: body, - }) + suspend( + body?: AcsUsersSuspendBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/users/suspend', + method: 'post', + data: body, + }, + undefined, + ) } - async unsuspend(body?: AcsUsersUnsuspendBody): Promise { - await this.client.request({ - url: '/acs/users/unsuspend', - method: 'post', - data: body, - }) + unsuspend( + body?: AcsUsersUnsuspendBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/users/unsuspend', + method: 'post', + data: body, + }, + undefined, + ) } - async update(body?: AcsUsersUpdateBody): Promise { - await this.client.request({ - url: '/acs/users/update', - method: 'post', - data: body, - }) + update( + body?: AcsUsersUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/acs/users/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts.ts index ca70e78e..44dcbb6f 100644 --- a/src/lib/seam/connect/routes/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -154,40 +154,42 @@ export class SeamHttpActionAttempts { await clientSessions.get() } - async get( + get( body?: ActionAttemptsGetParams, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/action_attempts/get', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ActionAttemptsGetParams, + ActionAttemptsGetResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/action_attempts/get', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async list( + list( body?: ActionAttemptsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/action_attempts/list', - method: 'post', - data: body, - }) - - return data.action_attempts + ): SeamApiRequest< + undefined | ActionAttemptsListParams, + ActionAttemptsListResponse, + 'action_attempts' + > { + return new SeamApiRequest( + this, + { + url: '/action_attempts/list', + method: 'post', + data: body, + }, + 'action_attempts', + ) } } diff --git a/src/lib/seam/connect/routes/client-sessions.ts b/src/lib/seam/connect/routes/client-sessions.ts index 495fb802..9315e865 100644 --- a/src/lib/seam/connect/routes/client-sessions.ts +++ b/src/lib/seam/connect/routes/client-sessions.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' export class SeamHttpClientSessions { client: Client @@ -151,82 +152,122 @@ export class SeamHttpClientSessions { await clientSessions.get() } - async create( + create( body?: ClientSessionsCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/client_sessions/create', - method: 'post', - data: body, - }) - - return data.client_session + ): SeamApiRequest< + undefined | ClientSessionsCreateBody, + ClientSessionsCreateResponse, + 'client_session' + > { + return new SeamApiRequest( + this, + { + url: '/client_sessions/create', + method: 'post', + data: body, + }, + 'client_session', + ) } - async delete(body?: ClientSessionsDeleteBody): Promise { - await this.client.request({ - url: '/client_sessions/delete', - method: 'post', - data: body, - }) + delete( + body?: ClientSessionsDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/client_sessions/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: ClientSessionsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/client_sessions/get', - method: 'post', - data: body, - }) - - return data.client_session + ): SeamApiRequest< + undefined | ClientSessionsGetParams, + ClientSessionsGetResponse, + 'client_session' + > { + return new SeamApiRequest( + this, + { + url: '/client_sessions/get', + method: 'post', + data: body, + }, + 'client_session', + ) } - async getOrCreate( + getOrCreate( body?: ClientSessionsGetOrCreateBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | ClientSessionsGetOrCreateBody, + ClientSessionsGetOrCreateResponse, + 'client_session' + > { + return new SeamApiRequest( + this, + { url: '/client_sessions/get_or_create', method: 'post', data: body, - }) - - return data.client_session + }, + 'client_session', + ) } - async grantAccess( + grantAccess( body?: ClientSessionsGrantAccessBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | ClientSessionsGrantAccessBody, + ClientSessionsGrantAccessResponse, + 'client_session' + > { + return new SeamApiRequest( + this, + { url: '/client_sessions/grant_access', method: 'post', data: body, - }) - - return data.client_session + }, + 'client_session', + ) } - async list( + list( body?: ClientSessionsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/client_sessions/list', - method: 'post', - data: body, - }) - - return data.client_sessions + ): SeamApiRequest< + undefined | ClientSessionsListParams, + ClientSessionsListResponse, + 'client_sessions' + > { + return new SeamApiRequest( + this, + { + url: '/client_sessions/list', + method: 'post', + data: body, + }, + 'client_sessions', + ) } - async revoke(body?: ClientSessionsRevokeBody): Promise { - await this.client.request({ - url: '/client_sessions/revoke', - method: 'post', - data: body, - }) + revoke( + body?: ClientSessionsRevokeBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/client_sessions/revoke', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index 389f3384..a711b9e2 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -35,6 +35,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -157,56 +158,86 @@ export class SeamHttpConnectWebviews { await clientSessions.get() } - async create( + create( body?: ConnectWebviewsCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/connect_webviews/create', - method: 'post', - data: body, - }) - - return data.connect_webview + ): SeamApiRequest< + undefined | ConnectWebviewsCreateBody, + ConnectWebviewsCreateResponse, + 'connect_webview' + > { + return new SeamApiRequest( + this, + { + url: '/connect_webviews/create', + method: 'post', + data: body, + }, + 'connect_webview', + ) } - async delete(body?: ConnectWebviewsDeleteBody): Promise { - await this.client.request({ - url: '/connect_webviews/delete', - method: 'post', - data: body, - }) + delete( + body?: ConnectWebviewsDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/connect_webviews/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: ConnectWebviewsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/connect_webviews/get', - method: 'post', - data: body, - }) - - return data.connect_webview + ): SeamApiRequest< + undefined | ConnectWebviewsGetParams, + ConnectWebviewsGetResponse, + 'connect_webview' + > { + return new SeamApiRequest( + this, + { + url: '/connect_webviews/get', + method: 'post', + data: body, + }, + 'connect_webview', + ) } - async list( + list( body?: ConnectWebviewsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/connect_webviews/list', - method: 'post', - data: body, - }) - - return data.connect_webviews + ): SeamApiRequest< + undefined | ConnectWebviewsListParams, + ConnectWebviewsListResponse, + 'connect_webviews' + > { + return new SeamApiRequest( + this, + { + url: '/connect_webviews/list', + method: 'post', + data: body, + }, + 'connect_webviews', + ) } - async view(params?: ConnectWebviewsViewParams): Promise { - await this.client.request({ - url: '/connect_webviews/view', - method: 'get', - params, - }) + view( + params?: ConnectWebviewsViewParams, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/connect_webviews/view', + method: 'get', + params, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/connected-accounts.ts b/src/lib/seam/connect/routes/connected-accounts.ts index a88a29cf..a653bb3f 100644 --- a/src/lib/seam/connect/routes/connected-accounts.ts +++ b/src/lib/seam/connect/routes/connected-accounts.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,50 +154,72 @@ export class SeamHttpConnectedAccounts { await clientSessions.get() } - async delete(body?: ConnectedAccountsDeleteBody): Promise { - await this.client.request({ - url: '/connected_accounts/delete', - method: 'post', - data: body, - }) + delete( + body?: ConnectedAccountsDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/connected_accounts/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: ConnectedAccountsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/connected_accounts/get', - method: 'post', - data: body, - }) - - return data.connected_account + ): SeamApiRequest< + undefined | ConnectedAccountsGetParams, + ConnectedAccountsGetResponse, + 'connected_account' + > { + return new SeamApiRequest( + this, + { + url: '/connected_accounts/get', + method: 'post', + data: body, + }, + 'connected_account', + ) } - async list( + list( body?: ConnectedAccountsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/connected_accounts/list', - method: 'post', - data: body, - }) - - return data.connected_accounts + ): SeamApiRequest< + undefined | ConnectedAccountsListParams, + ConnectedAccountsListResponse, + 'connected_accounts' + > { + return new SeamApiRequest( + this, + { + url: '/connected_accounts/list', + method: 'post', + data: body, + }, + 'connected_accounts', + ) } - async update( + update( body?: ConnectedAccountsUpdateBody, - ): Promise { - const { data } = await this.client.request( + ): SeamApiRequest< + undefined | ConnectedAccountsUpdateBody, + ConnectedAccountsUpdateResponse, + 'connected_account' + > { + return new SeamApiRequest( + this, { url: '/connected_accounts/update', method: 'post', data: body, }, + 'connected_account', ) - - return data.connected_account } } diff --git a/src/lib/seam/connect/routes/devices-simulate.ts b/src/lib/seam/connect/routes/devices-simulate.ts index c0b934fe..afaf2707 100644 --- a/src/lib/seam/connect/routes/devices-simulate.ts +++ b/src/lib/seam/connect/routes/devices-simulate.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,12 +154,18 @@ export class SeamHttpDevicesSimulate { await clientSessions.get() } - async remove(body?: DevicesSimulateRemoveBody): Promise { - await this.client.request({ - url: '/devices/simulate/remove', - method: 'post', - data: body, - }) + remove( + body?: DevicesSimulateRemoveBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/devices/simulate/remove', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/devices-unmanaged.ts b/src/lib/seam/connect/routes/devices-unmanaged.ts index f255cb25..181aad0e 100644 --- a/src/lib/seam/connect/routes/devices-unmanaged.ts +++ b/src/lib/seam/connect/routes/devices-unmanaged.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,36 +154,54 @@ export class SeamHttpDevicesUnmanaged { await clientSessions.get() } - async get( + get( body?: DevicesUnmanagedGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/devices/unmanaged/get', - method: 'post', - data: body, - }) - - return data.device + ): SeamApiRequest< + undefined | DevicesUnmanagedGetParams, + DevicesUnmanagedGetResponse, + 'device' + > { + return new SeamApiRequest( + this, + { + url: '/devices/unmanaged/get', + method: 'post', + data: body, + }, + 'device', + ) } - async list( + list( body?: DevicesUnmanagedListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/devices/unmanaged/list', - method: 'post', - data: body, - }) - - return data.devices + ): SeamApiRequest< + undefined | DevicesUnmanagedListParams, + DevicesUnmanagedListResponse, + 'devices' + > { + return new SeamApiRequest( + this, + { + url: '/devices/unmanaged/list', + method: 'post', + data: body, + }, + 'devices', + ) } - async update(body?: DevicesUnmanagedUpdateBody): Promise { - await this.client.request({ - url: '/devices/unmanaged/update', - method: 'post', - data: body, - }) + update( + body?: DevicesUnmanagedUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/devices/unmanaged/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 98ac0f91..4ffff986 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpDevicesSimulate } from './devices-simulate.js' @@ -163,55 +164,86 @@ export class SeamHttpDevices { return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults) } - async delete(body?: DevicesDeleteBody): Promise { - await this.client.request({ - url: '/devices/delete', - method: 'post', - data: body, - }) + delete( + body?: DevicesDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/devices/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get(body?: DevicesGetParams): Promise { - const { data } = await this.client.request({ - url: '/devices/get', - method: 'post', - data: body, - }) - - return data.device + get( + body?: DevicesGetParams, + ): SeamApiRequest< + undefined | DevicesGetParams, + DevicesGetResponse, + 'device' + > { + return new SeamApiRequest( + this, + { + url: '/devices/get', + method: 'post', + data: body, + }, + 'device', + ) } - async list( + list( body?: DevicesListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/devices/list', - method: 'post', - data: body, - }) - - return data.devices + ): SeamApiRequest< + undefined | DevicesListParams, + DevicesListResponse, + 'devices' + > { + return new SeamApiRequest( + this, + { + url: '/devices/list', + method: 'post', + data: body, + }, + 'devices', + ) } - async listDeviceProviders( + listDeviceProviders( body?: DevicesListDeviceProvidersParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | DevicesListDeviceProvidersParams, + DevicesListDeviceProvidersResponse, + 'device_providers' + > { + return new SeamApiRequest( + this, + { url: '/devices/list_device_providers', method: 'post', data: body, - }) - - return data.device_providers + }, + 'device_providers', + ) } - async update(body?: DevicesUpdateBody): Promise { - await this.client.request({ - url: '/devices/update', - method: 'post', - data: body, - }) + update( + body?: DevicesUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/devices/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/events.ts b/src/lib/seam/connect/routes/events.ts index b24f07f3..7be5d624 100644 --- a/src/lib/seam/connect/routes/events.ts +++ b/src/lib/seam/connect/routes/events.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,24 +154,36 @@ export class SeamHttpEvents { await clientSessions.get() } - async get(body?: EventsGetParams): Promise { - const { data } = await this.client.request({ - url: '/events/get', - method: 'post', - data: body, - }) - - return data.event + get( + body?: EventsGetParams, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/events/get', + method: 'post', + data: body, + }, + 'event', + ) } - async list(body?: EventsListParams): Promise { - const { data } = await this.client.request({ - url: '/events/list', - method: 'post', - data: body, - }) - - return data.events + list( + body?: EventsListParams, + ): SeamApiRequest< + undefined | EventsListParams, + EventsListResponse, + 'events' + > { + return new SeamApiRequest( + this, + { + url: '/events/list', + method: 'post', + data: body, + }, + 'events', + ) } } diff --git a/src/lib/seam/connect/routes/locks.ts b/src/lib/seam/connect/routes/locks.ts index 2ede8942..8a81171e 100644 --- a/src/lib/seam/connect/routes/locks.ts +++ b/src/lib/seam/connect/routes/locks.ts @@ -31,9 +31,8 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' -import { SeamHttpActionAttempts } from './action-attempts.js' import { SeamHttpClientSessions } from './client-sessions.js' export class SeamHttpLocks { @@ -155,72 +154,72 @@ export class SeamHttpLocks { await clientSessions.get() } - async get(body?: LocksGetParams): Promise { - const { data } = await this.client.request({ - url: '/locks/get', - method: 'post', - data: body, - }) - - return data.device + get( + body?: LocksGetParams, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/locks/get', + method: 'post', + data: body, + }, + 'device', + ) } - async list(body?: LocksListParams): Promise { - const { data } = await this.client.request({ - url: '/locks/list', - method: 'post', - data: body, - }) - - return data.devices + list( + body?: LocksListParams, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/locks/list', + method: 'post', + data: body, + }, + 'devices', + ) } - async lockDoor( + lockDoor( body?: LocksLockDoorBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/locks/lock_door', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | LocksLockDoorBody, + LocksLockDoorResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/locks/lock_door', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async unlockDoor( + unlockDoor( body?: LocksUnlockDoorBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/locks/unlock_door', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | LocksUnlockDoorBody, + LocksUnlockDoorResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/locks/unlock_door', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } } diff --git a/src/lib/seam/connect/routes/networks.ts b/src/lib/seam/connect/routes/networks.ts index 66958d23..d241f1a9 100644 --- a/src/lib/seam/connect/routes/networks.ts +++ b/src/lib/seam/connect/routes/networks.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,26 +154,40 @@ export class SeamHttpNetworks { await clientSessions.get() } - async get(body?: NetworksGetParams): Promise { - const { data } = await this.client.request({ - url: '/networks/get', - method: 'post', - data: body, - }) - - return data.network + get( + body?: NetworksGetParams, + ): SeamApiRequest< + undefined | NetworksGetParams, + NetworksGetResponse, + 'network' + > { + return new SeamApiRequest( + this, + { + url: '/networks/get', + method: 'post', + data: body, + }, + 'network', + ) } - async list( + list( body?: NetworksListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/networks/list', - method: 'post', - data: body, - }) - - return data.networks + ): SeamApiRequest< + undefined | NetworksListParams, + NetworksListResponse, + 'networks' + > { + return new SeamApiRequest( + this, + { + url: '/networks/list', + method: 'post', + data: body, + }, + 'networks', + ) } } diff --git a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts index 7a8a3f27..a5f14871 100644 --- a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +++ b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,59 +157,94 @@ export class SeamHttpNoiseSensorsNoiseThresholds { await clientSessions.get() } - async create( + create( body?: NoiseSensorsNoiseThresholdsCreateBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | NoiseSensorsNoiseThresholdsCreateBody, + NoiseSensorsNoiseThresholdsCreateResponse, + 'noise_threshold' + > { + return new SeamApiRequest( + this, + { url: '/noise_sensors/noise_thresholds/create', method: 'post', data: body, - }) - - return data.noise_threshold + }, + 'noise_threshold', + ) } - async delete(body?: NoiseSensorsNoiseThresholdsDeleteBody): Promise { - await this.client.request({ - url: '/noise_sensors/noise_thresholds/delete', - method: 'post', - data: body, - }) + delete( + body?: NoiseSensorsNoiseThresholdsDeleteBody, + ): SeamApiRequest< + undefined | NoiseSensorsNoiseThresholdsDeleteBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/noise_sensors/noise_thresholds/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: NoiseSensorsNoiseThresholdsGetParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | NoiseSensorsNoiseThresholdsGetParams, + NoiseSensorsNoiseThresholdsGetResponse, + 'noise_threshold' + > { + return new SeamApiRequest( + this, + { url: '/noise_sensors/noise_thresholds/get', method: 'post', data: body, - }) - - return data.noise_threshold + }, + 'noise_threshold', + ) } - async list( + list( body?: NoiseSensorsNoiseThresholdsListParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | NoiseSensorsNoiseThresholdsListParams, + NoiseSensorsNoiseThresholdsListResponse, + 'noise_thresholds' + > { + return new SeamApiRequest( + this, + { url: '/noise_sensors/noise_thresholds/list', method: 'post', data: body, - }) - - return data.noise_thresholds + }, + 'noise_thresholds', + ) } - async update(body?: NoiseSensorsNoiseThresholdsUpdateBody): Promise { - await this.client.request({ - url: '/noise_sensors/noise_thresholds/update', - method: 'post', - data: body, - }) + update( + body?: NoiseSensorsNoiseThresholdsUpdateBody, + ): SeamApiRequest< + undefined | NoiseSensorsNoiseThresholdsUpdateBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/noise_sensors/noise_thresholds/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/phones-simulate.ts b/src/lib/seam/connect/routes/phones-simulate.ts index c75450ad..89714bd0 100644 --- a/src/lib/seam/connect/routes/phones-simulate.ts +++ b/src/lib/seam/connect/routes/phones-simulate.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,17 +154,22 @@ export class SeamHttpPhonesSimulate { await clientSessions.get() } - async createSandboxPhone( + createSandboxPhone( body?: PhonesSimulateCreateSandboxPhoneBody, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | PhonesSimulateCreateSandboxPhoneBody, + PhonesSimulateCreateSandboxPhoneResponse, + 'phone' + > { + return new SeamApiRequest( + this, + { url: '/phones/simulate/create_sandbox_phone', method: 'post', data: body, - }) - - return data.phone + }, + 'phone', + ) } } diff --git a/src/lib/seam/connect/routes/phones.ts b/src/lib/seam/connect/routes/phones.ts index 526ec7ce..a530bd12 100644 --- a/src/lib/seam/connect/routes/phones.ts +++ b/src/lib/seam/connect/routes/phones.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpPhonesSimulate } from './phones-simulate.js' @@ -158,22 +159,36 @@ export class SeamHttpPhones { return SeamHttpPhonesSimulate.fromClient(this.client, this.defaults) } - async deactivate(body?: PhonesDeactivateBody): Promise { - await this.client.request({ - url: '/phones/deactivate', - method: 'post', - data: body, - }) + deactivate( + body?: PhonesDeactivateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/phones/deactivate', + method: 'post', + data: body, + }, + undefined, + ) } - async list(body?: PhonesListParams): Promise { - const { data } = await this.client.request({ - url: '/phones/list', - method: 'post', - data: body, - }) - - return data.phones + list( + body?: PhonesListParams, + ): SeamApiRequest< + undefined | PhonesListParams, + PhonesListResponse, + 'phones' + > { + return new SeamApiRequest( + this, + { + url: '/phones/list', + method: 'post', + data: body, + }, + 'phones', + ) } } diff --git a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts index d6039b7e..219d1a79 100644 --- a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +++ b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,76 +157,93 @@ export class SeamHttpThermostatsClimateSettingSchedules { await clientSessions.get() } - async create( + create( body?: ThermostatsClimateSettingSchedulesCreateBody, - ): Promise< - ThermostatsClimateSettingSchedulesCreateResponse['climate_setting_schedule'] + ): SeamApiRequest< + undefined | ThermostatsClimateSettingSchedulesCreateBody, + ThermostatsClimateSettingSchedulesCreateResponse, + 'climate_setting_schedule' > { - const { data } = - await this.client.request( - { - url: '/thermostats/climate_setting_schedules/create', - method: 'post', - data: body, - }, - ) - - return data.climate_setting_schedule + return new SeamApiRequest( + this, + { + url: '/thermostats/climate_setting_schedules/create', + method: 'post', + data: body, + }, + 'climate_setting_schedule', + ) } - async delete( + delete( body?: ThermostatsClimateSettingSchedulesDeleteBody, - ): Promise { - await this.client.request( + ): SeamApiRequest< + undefined | ThermostatsClimateSettingSchedulesDeleteBody, + void, + undefined + > { + return new SeamApiRequest( + this, { url: '/thermostats/climate_setting_schedules/delete', method: 'post', data: body, }, + undefined, ) } - async get( + get( body?: ThermostatsClimateSettingSchedulesGetParams, - ): Promise< - ThermostatsClimateSettingSchedulesGetResponse['climate_setting_schedule'] + ): SeamApiRequest< + undefined | ThermostatsClimateSettingSchedulesGetParams, + ThermostatsClimateSettingSchedulesGetResponse, + 'climate_setting_schedule' > { - const { data } = - await this.client.request({ + return new SeamApiRequest( + this, + { url: '/thermostats/climate_setting_schedules/get', method: 'post', data: body, - }) - - return data.climate_setting_schedule + }, + 'climate_setting_schedule', + ) } - async list( + list( body?: ThermostatsClimateSettingSchedulesListParams, - ): Promise< - ThermostatsClimateSettingSchedulesListResponse['climate_setting_schedules'] + ): SeamApiRequest< + undefined | ThermostatsClimateSettingSchedulesListParams, + ThermostatsClimateSettingSchedulesListResponse, + 'climate_setting_schedules' > { - const { data } = - await this.client.request( - { - url: '/thermostats/climate_setting_schedules/list', - method: 'post', - data: body, - }, - ) - - return data.climate_setting_schedules + return new SeamApiRequest( + this, + { + url: '/thermostats/climate_setting_schedules/list', + method: 'post', + data: body, + }, + 'climate_setting_schedules', + ) } - async update( + update( body?: ThermostatsClimateSettingSchedulesUpdateBody, - ): Promise { - await this.client.request( + ): SeamApiRequest< + undefined | ThermostatsClimateSettingSchedulesUpdateBody, + void, + undefined + > { + return new SeamApiRequest( + this, { url: '/thermostats/climate_setting_schedules/update', method: 'post', data: body, }, + undefined, ) } } diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index 25f81c6f..0af154ac 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -31,9 +31,8 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' -import { SeamHttpActionAttempts } from './action-attempts.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpThermostatsClimateSettingSchedules } from './thermostats-climate-setting-schedules.js' @@ -163,156 +162,154 @@ export class SeamHttpThermostats { ) } - async cool( + cool( body?: ThermostatsCoolBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/cool', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ThermostatsCoolBody, + ThermostatsCoolResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/cool', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async get( + get( body?: ThermostatsGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/get', - method: 'post', - data: body, - }) - - return data.thermostat + ): SeamApiRequest< + undefined | ThermostatsGetParams, + ThermostatsGetResponse, + 'thermostat' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/get', + method: 'post', + data: body, + }, + 'thermostat', + ) } - async heat( + heat( body?: ThermostatsHeatBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/heat', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ThermostatsHeatBody, + ThermostatsHeatResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/heat', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async heatCool( + heatCool( body?: ThermostatsHeatCoolBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/heat_cool', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ThermostatsHeatCoolBody, + ThermostatsHeatCoolResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/heat_cool', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async list( + list( body?: ThermostatsListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/list', - method: 'post', - data: body, - }) - - return data.thermostats + ): SeamApiRequest< + undefined | ThermostatsListParams, + ThermostatsListResponse, + 'thermostats' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/list', + method: 'post', + data: body, + }, + 'thermostats', + ) } - async off( + off( body?: ThermostatsOffBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/off', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ThermostatsOffBody, + ThermostatsOffResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/off', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async setFanMode( + setFanMode( body?: ThermostatsSetFanModeBody, options: Pick = {}, - ): Promise { - const { data } = await this.client.request({ - url: '/thermostats/set_fan_mode', - method: 'post', - data: body, - }) - const waitForActionAttempt = - options.waitForActionAttempt ?? this.defaults.waitForActionAttempt - if (waitForActionAttempt !== false) { - return await resolveActionAttempt( - data.action_attempt, - SeamHttpActionAttempts.fromClient(this.client, { - ...this.defaults, - waitForActionAttempt: false, - }), - typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, - ) - } - return data.action_attempt + ): SeamApiRequest< + undefined | ThermostatsSetFanModeBody, + ThermostatsSetFanModeResponse, + 'action_attempt' + > { + return new SeamApiRequest( + this, + { + url: '/thermostats/set_fan_mode', + method: 'post', + data: body, + }, + 'action_attempt', + options, + ) } - async update(body?: ThermostatsUpdateBody): Promise { - await this.client.request({ - url: '/thermostats/update', - method: 'post', - data: body, - }) + update( + body?: ThermostatsUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/thermostats/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts index 3bc85d7f..09c836e1 100644 --- a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +++ b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,67 +157,76 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { await clientSessions.get() } - async delete( + delete( body?: UserIdentitiesEnrollmentAutomationsDeleteBody, - ): Promise { - await this.client.request( + ): SeamApiRequest< + undefined | UserIdentitiesEnrollmentAutomationsDeleteBody, + void, + undefined + > { + return new SeamApiRequest( + this, { url: '/user_identities/enrollment_automations/delete', method: 'post', data: body, }, + undefined, ) } - async get( + get( body?: UserIdentitiesEnrollmentAutomationsGetParams, - ): Promise< - UserIdentitiesEnrollmentAutomationsGetResponse['enrollment_automation'] + ): SeamApiRequest< + undefined | UserIdentitiesEnrollmentAutomationsGetParams, + UserIdentitiesEnrollmentAutomationsGetResponse, + 'enrollment_automation' > { - const { data } = - await this.client.request( - { - url: '/user_identities/enrollment_automations/get', - method: 'post', - data: body, - }, - ) - - return data.enrollment_automation + return new SeamApiRequest( + this, + { + url: '/user_identities/enrollment_automations/get', + method: 'post', + data: body, + }, + 'enrollment_automation', + ) } - async launch( + launch( body?: UserIdentitiesEnrollmentAutomationsLaunchBody, - ): Promise< - UserIdentitiesEnrollmentAutomationsLaunchResponse['enrollment_automation'] + ): SeamApiRequest< + undefined | UserIdentitiesEnrollmentAutomationsLaunchBody, + UserIdentitiesEnrollmentAutomationsLaunchResponse, + 'enrollment_automation' > { - const { data } = - await this.client.request( - { - url: '/user_identities/enrollment_automations/launch', - method: 'post', - data: body, - }, - ) - - return data.enrollment_automation + return new SeamApiRequest( + this, + { + url: '/user_identities/enrollment_automations/launch', + method: 'post', + data: body, + }, + 'enrollment_automation', + ) } - async list( + list( body?: UserIdentitiesEnrollmentAutomationsListParams, - ): Promise< - UserIdentitiesEnrollmentAutomationsListResponse['enrollment_automations'] + ): SeamApiRequest< + undefined | UserIdentitiesEnrollmentAutomationsListParams, + UserIdentitiesEnrollmentAutomationsListResponse, + 'enrollment_automations' > { - const { data } = - await this.client.request( - { - url: '/user_identities/enrollment_automations/list', - method: 'post', - data: body, - }, - ) - - return data.enrollment_automations + return new SeamApiRequest( + this, + { + url: '/user_identities/enrollment_automations/list', + method: 'post', + data: body, + }, + 'enrollment_automations', + ) } } diff --git a/src/lib/seam/connect/routes/user-identities.ts b/src/lib/seam/connect/routes/user-identities.ts index 51d5525b..d19fd10a 100644 --- a/src/lib/seam/connect/routes/user-identities.ts +++ b/src/lib/seam/connect/routes/user-identities.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpUserIdentitiesEnrollmentAutomations } from './user-identities-enrollment-automations.js' @@ -161,133 +162,208 @@ export class SeamHttpUserIdentities { ) } - async addAcsUser(body?: UserIdentitiesAddAcsUserBody): Promise { - await this.client.request({ - url: '/user_identities/add_acs_user', - method: 'post', - data: body, - }) + addAcsUser( + body?: UserIdentitiesAddAcsUserBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/user_identities/add_acs_user', + method: 'post', + data: body, + }, + undefined, + ) } - async create( + create( body?: UserIdentitiesCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/user_identities/create', - method: 'post', - data: body, - }) - - return data.user_identity + ): SeamApiRequest< + undefined | UserIdentitiesCreateBody, + UserIdentitiesCreateResponse, + 'user_identity' + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/create', + method: 'post', + data: body, + }, + 'user_identity', + ) } - async delete(body?: UserIdentitiesDeleteBody): Promise { - await this.client.request({ - url: '/user_identities/delete', - method: 'post', - data: body, - }) + delete( + body?: UserIdentitiesDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/user_identities/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get( + get( body?: UserIdentitiesGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/user_identities/get', - method: 'post', - data: body, - }) - - return data.user_identity + ): SeamApiRequest< + undefined | UserIdentitiesGetParams, + UserIdentitiesGetResponse, + 'user_identity' + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/get', + method: 'post', + data: body, + }, + 'user_identity', + ) } - async grantAccessToDevice( + grantAccessToDevice( body?: UserIdentitiesGrantAccessToDeviceBody, - ): Promise { - await this.client.request({ - url: '/user_identities/grant_access_to_device', - method: 'post', - data: body, - }) + ): SeamApiRequest< + undefined | UserIdentitiesGrantAccessToDeviceBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/grant_access_to_device', + method: 'post', + data: body, + }, + undefined, + ) } - async list( + list( body?: UserIdentitiesListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/user_identities/list', - method: 'post', - data: body, - }) - - return data.user_identities + ): SeamApiRequest< + undefined | UserIdentitiesListParams, + UserIdentitiesListResponse, + 'user_identities' + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/list', + method: 'post', + data: body, + }, + 'user_identities', + ) } - async listAccessibleDevices( + listAccessibleDevices( body?: UserIdentitiesListAccessibleDevicesParams, - ): Promise< - UserIdentitiesListAccessibleDevicesResponse['accessible_devices'] + ): SeamApiRequest< + undefined | UserIdentitiesListAccessibleDevicesParams, + UserIdentitiesListAccessibleDevicesResponse, + 'accessible_devices' > { - const { data } = - await this.client.request({ + return new SeamApiRequest( + this, + { url: '/user_identities/list_accessible_devices', method: 'post', data: body, - }) - - return data.accessible_devices + }, + 'accessible_devices', + ) } - async listAcsSystems( + listAcsSystems( body?: UserIdentitiesListAcsSystemsParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | UserIdentitiesListAcsSystemsParams, + UserIdentitiesListAcsSystemsResponse, + 'acs_systems' + > { + return new SeamApiRequest( + this, + { url: '/user_identities/list_acs_systems', method: 'post', data: body, - }) - - return data.acs_systems + }, + 'acs_systems', + ) } - async listAcsUsers( + listAcsUsers( body?: UserIdentitiesListAcsUsersParams, - ): Promise { - const { data } = - await this.client.request({ + ): SeamApiRequest< + undefined | UserIdentitiesListAcsUsersParams, + UserIdentitiesListAcsUsersResponse, + 'acs_users' + > { + return new SeamApiRequest( + this, + { url: '/user_identities/list_acs_users', method: 'post', data: body, - }) - - return data.acs_users + }, + 'acs_users', + ) } - async removeAcsUser(body?: UserIdentitiesRemoveAcsUserBody): Promise { - await this.client.request({ - url: '/user_identities/remove_acs_user', - method: 'post', - data: body, - }) + removeAcsUser( + body?: UserIdentitiesRemoveAcsUserBody, + ): SeamApiRequest< + undefined | UserIdentitiesRemoveAcsUserBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/remove_acs_user', + method: 'post', + data: body, + }, + undefined, + ) } - async revokeAccessToDevice( + revokeAccessToDevice( body?: UserIdentitiesRevokeAccessToDeviceBody, - ): Promise { - await this.client.request({ - url: '/user_identities/revoke_access_to_device', - method: 'post', - data: body, - }) + ): SeamApiRequest< + undefined | UserIdentitiesRevokeAccessToDeviceBody, + void, + undefined + > { + return new SeamApiRequest( + this, + { + url: '/user_identities/revoke_access_to_device', + method: 'post', + data: body, + }, + undefined, + ) } - async update(body?: UserIdentitiesUpdateBody): Promise { - await this.client.request({ - url: '/user_identities/update', - method: 'post', - data: body, - }) + update( + body?: UserIdentitiesUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/user_identities/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/webhooks.ts b/src/lib/seam/connect/routes/webhooks.ts index 59d14565..48ab419a 100644 --- a/src/lib/seam/connect/routes/webhooks.ts +++ b/src/lib/seam/connect/routes/webhooks.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,54 +154,86 @@ export class SeamHttpWebhooks { await clientSessions.get() } - async create( + create( body?: WebhooksCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/webhooks/create', - method: 'post', - data: body, - }) - - return data.webhook + ): SeamApiRequest< + undefined | WebhooksCreateBody, + WebhooksCreateResponse, + 'webhook' + > { + return new SeamApiRequest( + this, + { + url: '/webhooks/create', + method: 'post', + data: body, + }, + 'webhook', + ) } - async delete(body?: WebhooksDeleteBody): Promise { - await this.client.request({ - url: '/webhooks/delete', - method: 'post', - data: body, - }) + delete( + body?: WebhooksDeleteBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/webhooks/delete', + method: 'post', + data: body, + }, + undefined, + ) } - async get(body?: WebhooksGetParams): Promise { - const { data } = await this.client.request({ - url: '/webhooks/get', - method: 'post', - data: body, - }) - - return data.webhook + get( + body?: WebhooksGetParams, + ): SeamApiRequest< + undefined | WebhooksGetParams, + WebhooksGetResponse, + 'webhook' + > { + return new SeamApiRequest( + this, + { + url: '/webhooks/get', + method: 'post', + data: body, + }, + 'webhook', + ) } - async list( + list( body?: WebhooksListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/webhooks/list', - method: 'post', - data: body, - }) - - return data.webhooks + ): SeamApiRequest< + undefined | WebhooksListParams, + WebhooksListResponse, + 'webhooks' + > { + return new SeamApiRequest( + this, + { + url: '/webhooks/list', + method: 'post', + data: body, + }, + 'webhooks', + ) } - async update(body?: WebhooksUpdateBody): Promise { - await this.client.request({ - url: '/webhooks/update', - method: 'post', - data: body, - }) + update( + body?: WebhooksUpdateBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/webhooks/update', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/src/lib/seam/connect/routes/workspaces.ts b/src/lib/seam/connect/routes/workspaces.ts index 1773a116..b96c4f97 100644 --- a/src/lib/seam/connect/routes/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces.ts @@ -31,6 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' +import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -153,48 +154,72 @@ export class SeamHttpWorkspaces { await clientSessions.get() } - async create( + create( body?: WorkspacesCreateBody, - ): Promise { - const { data } = await this.client.request({ - url: '/workspaces/create', - method: 'post', - data: body, - }) - - return data.workspace + ): SeamApiRequest< + undefined | WorkspacesCreateBody, + WorkspacesCreateResponse, + 'workspace' + > { + return new SeamApiRequest( + this, + { + url: '/workspaces/create', + method: 'post', + data: body, + }, + 'workspace', + ) } - async get( + get( body?: WorkspacesGetParams, - ): Promise { - const { data } = await this.client.request({ - url: '/workspaces/get', - method: 'post', - data: body, - }) - - return data.workspace + ): SeamApiRequest< + undefined | WorkspacesGetParams, + WorkspacesGetResponse, + 'workspace' + > { + return new SeamApiRequest( + this, + { + url: '/workspaces/get', + method: 'post', + data: body, + }, + 'workspace', + ) } - async list( + list( body?: WorkspacesListParams, - ): Promise { - const { data } = await this.client.request({ - url: '/workspaces/list', - method: 'post', - data: body, - }) - - return data.workspaces + ): SeamApiRequest< + undefined | WorkspacesListParams, + WorkspacesListResponse, + 'workspaces' + > { + return new SeamApiRequest( + this, + { + url: '/workspaces/list', + method: 'post', + data: body, + }, + 'workspaces', + ) } - async resetSandbox(body?: WorkspacesResetSandboxBody): Promise { - await this.client.request({ - url: '/workspaces/reset_sandbox', - method: 'post', - data: body, - }) + resetSandbox( + body?: WorkspacesResetSandboxBody, + ): SeamApiRequest { + return new SeamApiRequest( + this, + { + url: '/workspaces/reset_sandbox', + method: 'post', + data: body, + }, + undefined, + ) } } diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 737063e6..e2dc7936 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -9,6 +9,10 @@ import { SeamHttpMultiWorkspace, type WorkspacesListResponse, } from '@seamapi/http/connect' +import { + SeamApiRequest, + type ResponseFromSeamApiRequest, +} from 'lib/seam/connect/seam-api-request.js' test('SeamHttp: fromClient returns instance that uses client', async (t) => { const { seed, endpoint } = await getTestServer(t) @@ -159,3 +163,32 @@ test.failing( t.true(workspaces.length > 0) }, ) + +test('SeamHttp: request methods return a SeamApiRequest object', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = new SeamHttp({ + client: SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client, + }) + + const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) + + t.true(deviceRequest instanceof SeamApiRequest) + t.is(deviceRequest.requestConfig.url, '/devices/get') + t.deepEqual(deviceRequest.requestConfig.data, { + device_id: seed.august_device_1, + }) + t.is(deviceRequest.resourceKey, 'device') + const device = await deviceRequest + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) + + // Ensure that the type of the response is correct. + type Expected = ResponseFromSeamApiRequest + + const valid_device_type: Expected['device_type'] = 'august_lock' + t.truthy(valid_device_type) + + // @ts-expect-error because it's an invalid device type. + const invalid_device_type: Expected['device_type'] = 'invalid_device_type' + t.truthy(invalid_device_type) +}) From 38c760ab288cdadbf992ca35b3d057a57a47d9b0 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Mon, 25 Mar 2024 12:04:16 +0000 Subject: [PATCH 03/29] ci: Format code --- src/lib/seam/connect/seam-api-request.ts | 5 +++-- test/seam/connect/client.test.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/seam/connect/seam-api-request.ts b/src/lib/seam/connect/seam-api-request.ts index 94e8121a..34413cf2 100644 --- a/src/lib/seam/connect/seam-api-request.ts +++ b/src/lib/seam/connect/seam-api-request.ts @@ -1,8 +1,9 @@ import type { AxiosRequestConfig } from 'axios' + import type { Client } from './client.js' +import { SeamHttpActionAttempts } from './index.js' import type { SeamHttpRequestOptions } from './options.js' import { resolveActionAttempt } from './resolve-action-attempt.js' -import { SeamHttpActionAttempts } from './index.js' export interface SeamApiRequestParent { readonly client: Client @@ -58,7 +59,7 @@ export class SeamApiRequest< this.options.waitForActionAttempt ?? this.parent.defaults.waitForActionAttempt if (waitForActionAttempt !== false) { - return resolveActionAttempt( + return await resolveActionAttempt( data, SeamHttpActionAttempts.fromClient(client, { ...this.parent.defaults, diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index e2dc7936..bb3f58f2 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -9,9 +9,10 @@ import { SeamHttpMultiWorkspace, type WorkspacesListResponse, } from '@seamapi/http/connect' + import { - SeamApiRequest, type ResponseFromSeamApiRequest, + SeamApiRequest, } from 'lib/seam/connect/seam-api-request.js' test('SeamHttp: fromClient returns instance that uses client', async (t) => { From 05df01d14b8a71a114945a8373580aad8f5ff370 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Mon, 25 Mar 2024 12:05:54 +0000 Subject: [PATCH 04/29] Lint fixes --- src/lib/seam/connect/seam-api-request.ts | 7 ++++--- test/seam/connect/client.test.ts | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/seam/connect/seam-api-request.ts b/src/lib/seam/connect/seam-api-request.ts index 94e8121a..456c0c8d 100644 --- a/src/lib/seam/connect/seam-api-request.ts +++ b/src/lib/seam/connect/seam-api-request.ts @@ -1,8 +1,9 @@ import type { AxiosRequestConfig } from 'axios' + import type { Client } from './client.js' +import { SeamHttpActionAttempts } from './index.js' import type { SeamHttpRequestOptions } from './options.js' import { resolveActionAttempt } from './resolve-action-attempt.js' -import { SeamHttpActionAttempts } from './index.js' export interface SeamApiRequestParent { readonly client: Client @@ -13,7 +14,7 @@ export type ResponseFromSeamApiRequest = T extends SeamApiRequest ? TResourceKey extends keyof TResponse ? TResponse[TResourceKey] - : void + : undefined : never export class SeamApiRequest< @@ -58,7 +59,7 @@ export class SeamApiRequest< this.options.waitForActionAttempt ?? this.parent.defaults.waitForActionAttempt if (waitForActionAttempt !== false) { - return resolveActionAttempt( + return await resolveActionAttempt( data, SeamHttpActionAttempts.fromClient(client, { ...this.parent.defaults, diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index e2dc7936..520c9eae 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -9,9 +9,10 @@ import { SeamHttpMultiWorkspace, type WorkspacesListResponse, } from '@seamapi/http/connect' + import { - SeamApiRequest, type ResponseFromSeamApiRequest, + SeamApiRequest, } from 'lib/seam/connect/seam-api-request.js' test('SeamHttp: fromClient returns instance that uses client', async (t) => { @@ -185,10 +186,10 @@ test('SeamHttp: request methods return a SeamApiRequest object', async (t) => { // Ensure that the type of the response is correct. type Expected = ResponseFromSeamApiRequest - const valid_device_type: Expected['device_type'] = 'august_lock' - t.truthy(valid_device_type) + const validDeviceType: Expected['device_type'] = 'august_lock' + t.truthy(validDeviceType) // @ts-expect-error because it's an invalid device type. - const invalid_device_type: Expected['device_type'] = 'invalid_device_type' - t.truthy(invalid_device_type) + const invalidDeviceType: Expected['device_type'] = 'invalid_device_type' + t.truthy(invalidDeviceType) }) From c65c834c04d4e1475ac4e7deee4b0079a687f3d5 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 09:54:30 +0000 Subject: [PATCH 05/29] SeamApiRequest -> SeamHttpRequest --- .../connect/routes/access-codes-unmanaged.ts | 22 ++++---- src/lib/seam/connect/routes/access-codes.ts | 34 ++++++------ .../seam/connect/routes/acs-access-groups.ts | 22 ++++---- .../connect/routes/acs-credential-pools.ts | 6 +-- ...acs-credential-provisioning-automations.ts | 6 +-- .../seam/connect/routes/acs-credentials.ts | 30 +++++------ src/lib/seam/connect/routes/acs-entrances.ts | 18 +++---- src/lib/seam/connect/routes/acs-systems.ts | 10 ++-- src/lib/seam/connect/routes/acs-users.ts | 50 +++++++++-------- .../seam/connect/routes/action-attempts.ts | 10 ++-- .../seam/connect/routes/client-sessions.ts | 30 +++++------ .../seam/connect/routes/connect-webviews.ts | 22 ++++---- .../seam/connect/routes/connected-accounts.ts | 18 +++---- .../seam/connect/routes/devices-simulate.ts | 6 +-- .../seam/connect/routes/devices-unmanaged.ts | 14 ++--- src/lib/seam/connect/routes/devices.ts | 22 ++++---- src/lib/seam/connect/routes/events.ts | 10 ++-- src/lib/seam/connect/routes/locks.ts | 22 ++++---- src/lib/seam/connect/routes/networks.ts | 10 ++-- .../routes/noise-sensors-noise-thresholds.ts | 22 ++++---- .../seam/connect/routes/phones-simulate.ts | 6 +-- src/lib/seam/connect/routes/phones.ts | 10 ++-- .../thermostats-climate-setting-schedules.ts | 22 ++++---- src/lib/seam/connect/routes/thermostats.ts | 34 ++++++------ .../user-identities-enrollment-automations.ts | 18 +++---- .../seam/connect/routes/user-identities.ts | 54 ++++++++++--------- src/lib/seam/connect/routes/webhooks.ts | 22 ++++---- src/lib/seam/connect/routes/workspaces.ts | 18 +++---- ...am-api-request.ts => seam-http-request.ts} | 12 ++--- test/seam/connect/client.test.ts | 2 +- 30 files changed, 297 insertions(+), 285 deletions(-) rename src/lib/seam/connect/{seam-api-request.ts => seam-http-request.ts} (91%) diff --git a/src/lib/seam/connect/routes/access-codes-unmanaged.ts b/src/lib/seam/connect/routes/access-codes-unmanaged.ts index 1b38efc9..2b3a7ced 100644 --- a/src/lib/seam/connect/routes/access-codes-unmanaged.ts +++ b/src/lib/seam/connect/routes/access-codes-unmanaged.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpAccessCodesUnmanaged { convertToManaged( body?: AccessCodesUnmanagedConvertToManagedBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesUnmanagedConvertToManagedBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/unmanaged/convert_to_managed', @@ -174,12 +174,12 @@ export class SeamHttpAccessCodesUnmanaged { delete( body?: AccessCodesUnmanagedDeleteBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesUnmanagedDeleteBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/unmanaged/delete', @@ -192,12 +192,12 @@ export class SeamHttpAccessCodesUnmanaged { get( body?: AccessCodesUnmanagedGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesUnmanagedGetParams, AccessCodesUnmanagedGetResponse, 'access_code' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/unmanaged/get', @@ -210,12 +210,12 @@ export class SeamHttpAccessCodesUnmanaged { list( body?: AccessCodesUnmanagedListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesUnmanagedListParams, AccessCodesUnmanagedListResponse, 'access_codes' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/unmanaged/list', @@ -228,12 +228,12 @@ export class SeamHttpAccessCodesUnmanaged { update( body?: AccessCodesUnmanagedUpdateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesUnmanagedUpdateBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/unmanaged/update', diff --git a/src/lib/seam/connect/routes/access-codes.ts b/src/lib/seam/connect/routes/access-codes.ts index c7a47a8d..76468888 100644 --- a/src/lib/seam/connect/routes/access-codes.ts +++ b/src/lib/seam/connect/routes/access-codes.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpAccessCodesUnmanaged } from './access-codes-unmanaged.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -161,12 +161,12 @@ export class SeamHttpAccessCodes { create( body?: AccessCodesCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesCreateBody, AccessCodesCreateResponse, 'access_code' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/create', @@ -179,12 +179,12 @@ export class SeamHttpAccessCodes { createMultiple( body?: AccessCodesCreateMultipleBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesCreateMultipleBody, AccessCodesCreateMultipleResponse, 'access_codes' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/create_multiple', @@ -197,8 +197,8 @@ export class SeamHttpAccessCodes { delete( body?: AccessCodesDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/access_codes/delete', @@ -211,12 +211,12 @@ export class SeamHttpAccessCodes { generateCode( body?: AccessCodesGenerateCodeBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesGenerateCodeBody, AccessCodesGenerateCodeResponse, 'generated_code' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/generate_code', @@ -229,12 +229,12 @@ export class SeamHttpAccessCodes { get( body?: AccessCodesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesGetParams, AccessCodesGetResponse, 'access_code' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/get', @@ -247,12 +247,12 @@ export class SeamHttpAccessCodes { list( body?: AccessCodesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesListParams, AccessCodesListResponse, 'access_codes' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/list', @@ -265,12 +265,12 @@ export class SeamHttpAccessCodes { pullBackupAccessCode( body?: AccessCodesPullBackupAccessCodeBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AccessCodesPullBackupAccessCodeBody, AccessCodesPullBackupAccessCodeResponse, 'backup_access_code' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/access_codes/pull_backup_access_code', @@ -283,8 +283,8 @@ export class SeamHttpAccessCodes { update( body?: AccessCodesUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/access_codes/update', diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index 32177462..840b016f 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,8 @@ export class SeamHttpAcsAccessGroups { addUser( body?: AcsAccessGroupsAddUserBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/access_groups/add_user', @@ -170,12 +170,12 @@ export class SeamHttpAcsAccessGroups { get( body?: AcsAccessGroupsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsAccessGroupsGetParams, AcsAccessGroupsGetResponse, 'acs_access_group' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/access_groups/get', @@ -188,12 +188,12 @@ export class SeamHttpAcsAccessGroups { list( body?: AcsAccessGroupsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsAccessGroupsListParams, AcsAccessGroupsListResponse, 'acs_access_groups' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/access_groups/list', @@ -206,12 +206,12 @@ export class SeamHttpAcsAccessGroups { listUsers( body?: AcsAccessGroupsListUsersParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsAccessGroupsListUsersParams, AcsAccessGroupsListUsersResponse, 'acs_users' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/access_groups/list_users', @@ -224,12 +224,12 @@ export class SeamHttpAcsAccessGroups { removeUser( body?: AcsAccessGroupsRemoveUserBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsAccessGroupsRemoveUserBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/access_groups/remove_user', diff --git a/src/lib/seam/connect/routes/acs-credential-pools.ts b/src/lib/seam/connect/routes/acs-credential-pools.ts index f718427a..843024d1 100644 --- a/src/lib/seam/connect/routes/acs-credential-pools.ts +++ b/src/lib/seam/connect/routes/acs-credential-pools.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpAcsCredentialPools { list( body?: AcsCredentialPoolsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialPoolsListParams, AcsCredentialPoolsListResponse, 'acs_credential_pools' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credential_pools/list', diff --git a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts index 76a977df..2f40d2fa 100644 --- a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +++ b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -159,12 +159,12 @@ export class SeamHttpAcsCredentialProvisioningAutomations { launch( body?: AcsCredentialProvisioningAutomationsLaunchBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialProvisioningAutomationsLaunchBody, AcsCredentialProvisioningAutomationsLaunchResponse, 'acs_credential_provisioning_automation' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credential_provisioning_automations/launch', diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index 54ef5b4d..7e38ab2f 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpAcsCredentials { assign( body?: AcsCredentialsAssignBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsAssignBody, AcsCredentialsAssignResponse, 'acs_credential' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/assign', @@ -174,12 +174,12 @@ export class SeamHttpAcsCredentials { create( body?: AcsCredentialsCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsCreateBody, AcsCredentialsCreateResponse, 'acs_credential' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/create', @@ -192,8 +192,8 @@ export class SeamHttpAcsCredentials { delete( body?: AcsCredentialsDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/credentials/delete', @@ -206,12 +206,12 @@ export class SeamHttpAcsCredentials { get( body?: AcsCredentialsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsGetParams, AcsCredentialsGetResponse, 'acs_credential' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/get', @@ -224,12 +224,12 @@ export class SeamHttpAcsCredentials { list( body?: AcsCredentialsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsListParams, AcsCredentialsListResponse, 'acs_credentials' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/list', @@ -242,12 +242,12 @@ export class SeamHttpAcsCredentials { unassign( body?: AcsCredentialsUnassignBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsUnassignBody, AcsCredentialsUnassignResponse, 'acs_credential' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/unassign', @@ -260,12 +260,12 @@ export class SeamHttpAcsCredentials { update( body?: AcsCredentialsUpdateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsCredentialsUpdateBody, AcsCredentialsUpdateResponse, 'acs_credential' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/credentials/update', diff --git a/src/lib/seam/connect/routes/acs-entrances.ts b/src/lib/seam/connect/routes/acs-entrances.ts index 2e33e497..aafdbfc3 100644 --- a/src/lib/seam/connect/routes/acs-entrances.ts +++ b/src/lib/seam/connect/routes/acs-entrances.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpAcsEntrances { get( body?: AcsEntrancesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsEntrancesGetParams, AcsEntrancesGetResponse, 'acs_entrance' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/entrances/get', @@ -174,8 +174,8 @@ export class SeamHttpAcsEntrances { grantAccess( body?: AcsEntrancesGrantAccessBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/entrances/grant_access', @@ -188,12 +188,12 @@ export class SeamHttpAcsEntrances { list( body?: AcsEntrancesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsEntrancesListParams, AcsEntrancesListResponse, 'acs_entrances' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/entrances/list', @@ -206,12 +206,12 @@ export class SeamHttpAcsEntrances { listCredentialsWithAccess( body?: AcsEntrancesListCredentialsWithAccessParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsEntrancesListCredentialsWithAccessParams, AcsEntrancesListCredentialsWithAccessResponse, 'acs_credentials' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/entrances/list_credentials_with_access', diff --git a/src/lib/seam/connect/routes/acs-systems.ts b/src/lib/seam/connect/routes/acs-systems.ts index 29533899..d894cc1a 100644 --- a/src/lib/seam/connect/routes/acs-systems.ts +++ b/src/lib/seam/connect/routes/acs-systems.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpAcsSystems { get( body?: AcsSystemsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsSystemsGetParams, AcsSystemsGetResponse, 'acs_system' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/systems/get', @@ -174,12 +174,12 @@ export class SeamHttpAcsSystems { list( body?: AcsSystemsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsSystemsListParams, AcsSystemsListResponse, 'acs_systems' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/systems/list', diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index 99412fd9..e562b1a8 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,12 @@ export class SeamHttpAcsUsers { addToAccessGroup( body?: AcsUsersAddToAccessGroupBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest< + undefined | AcsUsersAddToAccessGroupBody, + void, + undefined + > { + return new SeamHttpRequest( this, { url: '/acs/users/add_to_access_group', @@ -170,12 +174,12 @@ export class SeamHttpAcsUsers { create( body?: AcsUsersCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersCreateBody, AcsUsersCreateResponse, 'acs_user' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/create', @@ -188,8 +192,8 @@ export class SeamHttpAcsUsers { delete( body?: AcsUsersDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/users/delete', @@ -202,12 +206,12 @@ export class SeamHttpAcsUsers { get( body?: AcsUsersGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersGetParams, AcsUsersGetResponse, 'acs_user' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/get', @@ -220,12 +224,12 @@ export class SeamHttpAcsUsers { list( body?: AcsUsersListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersListParams, AcsUsersListResponse, 'acs_users' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/list', @@ -238,12 +242,12 @@ export class SeamHttpAcsUsers { listAccessibleEntrances( body?: AcsUsersListAccessibleEntrancesParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersListAccessibleEntrancesParams, AcsUsersListAccessibleEntrancesResponse, 'acs_entrances' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/list_accessible_entrances', @@ -256,12 +260,12 @@ export class SeamHttpAcsUsers { removeFromAccessGroup( body?: AcsUsersRemoveFromAccessGroupBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersRemoveFromAccessGroupBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/remove_from_access_group', @@ -274,12 +278,12 @@ export class SeamHttpAcsUsers { revokeAccessToAllEntrances( body?: AcsUsersRevokeAccessToAllEntrancesBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | AcsUsersRevokeAccessToAllEntrancesBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/acs/users/revoke_access_to_all_entrances', @@ -292,8 +296,8 @@ export class SeamHttpAcsUsers { suspend( body?: AcsUsersSuspendBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/users/suspend', @@ -306,8 +310,8 @@ export class SeamHttpAcsUsers { unsuspend( body?: AcsUsersUnsuspendBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/users/unsuspend', @@ -320,8 +324,8 @@ export class SeamHttpAcsUsers { update( body?: AcsUsersUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/acs/users/update', diff --git a/src/lib/seam/connect/routes/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts.ts index 44dcbb6f..e576b18e 100644 --- a/src/lib/seam/connect/routes/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -157,12 +157,12 @@ export class SeamHttpActionAttempts { get( body?: ActionAttemptsGetParams, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ActionAttemptsGetParams, ActionAttemptsGetResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/action_attempts/get', @@ -176,12 +176,12 @@ export class SeamHttpActionAttempts { list( body?: ActionAttemptsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ActionAttemptsListParams, ActionAttemptsListResponse, 'action_attempts' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/action_attempts/list', diff --git a/src/lib/seam/connect/routes/client-sessions.ts b/src/lib/seam/connect/routes/client-sessions.ts index 9315e865..b42a4f9a 100644 --- a/src/lib/seam/connect/routes/client-sessions.ts +++ b/src/lib/seam/connect/routes/client-sessions.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' export class SeamHttpClientSessions { client: Client @@ -154,12 +154,12 @@ export class SeamHttpClientSessions { create( body?: ClientSessionsCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ClientSessionsCreateBody, ClientSessionsCreateResponse, 'client_session' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/client_sessions/create', @@ -172,8 +172,8 @@ export class SeamHttpClientSessions { delete( body?: ClientSessionsDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/client_sessions/delete', @@ -186,12 +186,12 @@ export class SeamHttpClientSessions { get( body?: ClientSessionsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ClientSessionsGetParams, ClientSessionsGetResponse, 'client_session' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/client_sessions/get', @@ -204,12 +204,12 @@ export class SeamHttpClientSessions { getOrCreate( body?: ClientSessionsGetOrCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ClientSessionsGetOrCreateBody, ClientSessionsGetOrCreateResponse, 'client_session' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/client_sessions/get_or_create', @@ -222,12 +222,12 @@ export class SeamHttpClientSessions { grantAccess( body?: ClientSessionsGrantAccessBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ClientSessionsGrantAccessBody, ClientSessionsGrantAccessResponse, 'client_session' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/client_sessions/grant_access', @@ -240,12 +240,12 @@ export class SeamHttpClientSessions { list( body?: ClientSessionsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ClientSessionsListParams, ClientSessionsListResponse, 'client_sessions' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/client_sessions/list', @@ -258,8 +258,8 @@ export class SeamHttpClientSessions { revoke( body?: ClientSessionsRevokeBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/client_sessions/revoke', diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index a711b9e2..34a31db0 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -35,7 +35,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -160,12 +160,12 @@ export class SeamHttpConnectWebviews { create( body?: ConnectWebviewsCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectWebviewsCreateBody, ConnectWebviewsCreateResponse, 'connect_webview' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connect_webviews/create', @@ -178,8 +178,8 @@ export class SeamHttpConnectWebviews { delete( body?: ConnectWebviewsDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/connect_webviews/delete', @@ -192,12 +192,12 @@ export class SeamHttpConnectWebviews { get( body?: ConnectWebviewsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectWebviewsGetParams, ConnectWebviewsGetResponse, 'connect_webview' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connect_webviews/get', @@ -210,12 +210,12 @@ export class SeamHttpConnectWebviews { list( body?: ConnectWebviewsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectWebviewsListParams, ConnectWebviewsListResponse, 'connect_webviews' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connect_webviews/list', @@ -228,8 +228,8 @@ export class SeamHttpConnectWebviews { view( params?: ConnectWebviewsViewParams, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/connect_webviews/view', diff --git a/src/lib/seam/connect/routes/connected-accounts.ts b/src/lib/seam/connect/routes/connected-accounts.ts index a653bb3f..f75fe227 100644 --- a/src/lib/seam/connect/routes/connected-accounts.ts +++ b/src/lib/seam/connect/routes/connected-accounts.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,8 @@ export class SeamHttpConnectedAccounts { delete( body?: ConnectedAccountsDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/connected_accounts/delete', @@ -170,12 +170,12 @@ export class SeamHttpConnectedAccounts { get( body?: ConnectedAccountsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectedAccountsGetParams, ConnectedAccountsGetResponse, 'connected_account' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connected_accounts/get', @@ -188,12 +188,12 @@ export class SeamHttpConnectedAccounts { list( body?: ConnectedAccountsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectedAccountsListParams, ConnectedAccountsListResponse, 'connected_accounts' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connected_accounts/list', @@ -206,12 +206,12 @@ export class SeamHttpConnectedAccounts { update( body?: ConnectedAccountsUpdateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ConnectedAccountsUpdateBody, ConnectedAccountsUpdateResponse, 'connected_account' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/connected_accounts/update', diff --git a/src/lib/seam/connect/routes/devices-simulate.ts b/src/lib/seam/connect/routes/devices-simulate.ts index afaf2707..92315722 100644 --- a/src/lib/seam/connect/routes/devices-simulate.ts +++ b/src/lib/seam/connect/routes/devices-simulate.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,8 @@ export class SeamHttpDevicesSimulate { remove( body?: DevicesSimulateRemoveBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/devices/simulate/remove', diff --git a/src/lib/seam/connect/routes/devices-unmanaged.ts b/src/lib/seam/connect/routes/devices-unmanaged.ts index 181aad0e..2dd61871 100644 --- a/src/lib/seam/connect/routes/devices-unmanaged.ts +++ b/src/lib/seam/connect/routes/devices-unmanaged.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpDevicesUnmanaged { get( body?: DevicesUnmanagedGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | DevicesUnmanagedGetParams, DevicesUnmanagedGetResponse, 'device' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/devices/unmanaged/get', @@ -174,12 +174,12 @@ export class SeamHttpDevicesUnmanaged { list( body?: DevicesUnmanagedListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | DevicesUnmanagedListParams, DevicesUnmanagedListResponse, 'devices' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/devices/unmanaged/list', @@ -192,8 +192,8 @@ export class SeamHttpDevicesUnmanaged { update( body?: DevicesUnmanagedUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/devices/unmanaged/update', diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 4ffff986..9249086e 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpDevicesSimulate } from './devices-simulate.js' @@ -166,8 +166,8 @@ export class SeamHttpDevices { delete( body?: DevicesDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/devices/delete', @@ -180,12 +180,12 @@ export class SeamHttpDevices { get( body?: DevicesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | DevicesGetParams, DevicesGetResponse, 'device' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/devices/get', @@ -198,12 +198,12 @@ export class SeamHttpDevices { list( body?: DevicesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | DevicesListParams, DevicesListResponse, 'devices' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/devices/list', @@ -216,12 +216,12 @@ export class SeamHttpDevices { listDeviceProviders( body?: DevicesListDeviceProvidersParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | DevicesListDeviceProvidersParams, DevicesListDeviceProvidersResponse, 'device_providers' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/devices/list_device_providers', @@ -234,8 +234,8 @@ export class SeamHttpDevices { update( body?: DevicesUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/devices/update', diff --git a/src/lib/seam/connect/routes/events.ts b/src/lib/seam/connect/routes/events.ts index 7be5d624..f89b617d 100644 --- a/src/lib/seam/connect/routes/events.ts +++ b/src/lib/seam/connect/routes/events.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,8 @@ export class SeamHttpEvents { get( body?: EventsGetParams, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/events/get', @@ -170,12 +170,12 @@ export class SeamHttpEvents { list( body?: EventsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | EventsListParams, EventsListResponse, 'events' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/events/list', diff --git a/src/lib/seam/connect/routes/locks.ts b/src/lib/seam/connect/routes/locks.ts index 8a81171e..82971548 100644 --- a/src/lib/seam/connect/routes/locks.ts +++ b/src/lib/seam/connect/routes/locks.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,8 +156,8 @@ export class SeamHttpLocks { get( body?: LocksGetParams, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/locks/get', @@ -170,8 +170,12 @@ export class SeamHttpLocks { list( body?: LocksListParams, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest< + undefined | LocksListParams, + LocksListResponse, + 'devices' + > { + return new SeamHttpRequest( this, { url: '/locks/list', @@ -185,12 +189,12 @@ export class SeamHttpLocks { lockDoor( body?: LocksLockDoorBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | LocksLockDoorBody, LocksLockDoorResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/locks/lock_door', @@ -205,12 +209,12 @@ export class SeamHttpLocks { unlockDoor( body?: LocksUnlockDoorBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | LocksUnlockDoorBody, LocksUnlockDoorResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/locks/unlock_door', diff --git a/src/lib/seam/connect/routes/networks.ts b/src/lib/seam/connect/routes/networks.ts index d241f1a9..cc42d347 100644 --- a/src/lib/seam/connect/routes/networks.ts +++ b/src/lib/seam/connect/routes/networks.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpNetworks { get( body?: NetworksGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NetworksGetParams, NetworksGetResponse, 'network' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/networks/get', @@ -174,12 +174,12 @@ export class SeamHttpNetworks { list( body?: NetworksListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NetworksListParams, NetworksListResponse, 'networks' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/networks/list', diff --git a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts index a5f14871..ff0ed22b 100644 --- a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +++ b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -159,12 +159,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { create( body?: NoiseSensorsNoiseThresholdsCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NoiseSensorsNoiseThresholdsCreateBody, NoiseSensorsNoiseThresholdsCreateResponse, 'noise_threshold' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/noise_sensors/noise_thresholds/create', @@ -177,12 +177,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { delete( body?: NoiseSensorsNoiseThresholdsDeleteBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NoiseSensorsNoiseThresholdsDeleteBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/noise_sensors/noise_thresholds/delete', @@ -195,12 +195,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { get( body?: NoiseSensorsNoiseThresholdsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NoiseSensorsNoiseThresholdsGetParams, NoiseSensorsNoiseThresholdsGetResponse, 'noise_threshold' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/noise_sensors/noise_thresholds/get', @@ -213,12 +213,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { list( body?: NoiseSensorsNoiseThresholdsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NoiseSensorsNoiseThresholdsListParams, NoiseSensorsNoiseThresholdsListResponse, 'noise_thresholds' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/noise_sensors/noise_thresholds/list', @@ -231,12 +231,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { update( body?: NoiseSensorsNoiseThresholdsUpdateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | NoiseSensorsNoiseThresholdsUpdateBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/noise_sensors/noise_thresholds/update', diff --git a/src/lib/seam/connect/routes/phones-simulate.ts b/src/lib/seam/connect/routes/phones-simulate.ts index 89714bd0..e0bdd918 100644 --- a/src/lib/seam/connect/routes/phones-simulate.ts +++ b/src/lib/seam/connect/routes/phones-simulate.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpPhonesSimulate { createSandboxPhone( body?: PhonesSimulateCreateSandboxPhoneBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | PhonesSimulateCreateSandboxPhoneBody, PhonesSimulateCreateSandboxPhoneResponse, 'phone' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/phones/simulate/create_sandbox_phone', diff --git a/src/lib/seam/connect/routes/phones.ts b/src/lib/seam/connect/routes/phones.ts index a530bd12..efab9759 100644 --- a/src/lib/seam/connect/routes/phones.ts +++ b/src/lib/seam/connect/routes/phones.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpPhonesSimulate } from './phones-simulate.js' @@ -161,8 +161,8 @@ export class SeamHttpPhones { deactivate( body?: PhonesDeactivateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/phones/deactivate', @@ -175,12 +175,12 @@ export class SeamHttpPhones { list( body?: PhonesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | PhonesListParams, PhonesListResponse, 'phones' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/phones/list', diff --git a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts index 219d1a79..549a9b52 100644 --- a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +++ b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -159,12 +159,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { create( body?: ThermostatsClimateSettingSchedulesCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsClimateSettingSchedulesCreateBody, ThermostatsClimateSettingSchedulesCreateResponse, 'climate_setting_schedule' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/climate_setting_schedules/create', @@ -177,12 +177,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { delete( body?: ThermostatsClimateSettingSchedulesDeleteBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsClimateSettingSchedulesDeleteBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/climate_setting_schedules/delete', @@ -195,12 +195,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { get( body?: ThermostatsClimateSettingSchedulesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsClimateSettingSchedulesGetParams, ThermostatsClimateSettingSchedulesGetResponse, 'climate_setting_schedule' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/climate_setting_schedules/get', @@ -213,12 +213,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { list( body?: ThermostatsClimateSettingSchedulesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsClimateSettingSchedulesListParams, ThermostatsClimateSettingSchedulesListResponse, 'climate_setting_schedules' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/climate_setting_schedules/list', @@ -231,12 +231,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { update( body?: ThermostatsClimateSettingSchedulesUpdateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsClimateSettingSchedulesUpdateBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/climate_setting_schedules/update', diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index 0af154ac..962fec02 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpThermostatsClimateSettingSchedules } from './thermostats-climate-setting-schedules.js' @@ -165,12 +165,12 @@ export class SeamHttpThermostats { cool( body?: ThermostatsCoolBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsCoolBody, ThermostatsCoolResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/cool', @@ -184,12 +184,12 @@ export class SeamHttpThermostats { get( body?: ThermostatsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsGetParams, ThermostatsGetResponse, 'thermostat' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/get', @@ -203,12 +203,12 @@ export class SeamHttpThermostats { heat( body?: ThermostatsHeatBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsHeatBody, ThermostatsHeatResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/heat', @@ -223,12 +223,12 @@ export class SeamHttpThermostats { heatCool( body?: ThermostatsHeatCoolBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsHeatCoolBody, ThermostatsHeatCoolResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/heat_cool', @@ -242,12 +242,12 @@ export class SeamHttpThermostats { list( body?: ThermostatsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsListParams, ThermostatsListResponse, 'thermostats' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/list', @@ -261,12 +261,12 @@ export class SeamHttpThermostats { off( body?: ThermostatsOffBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsOffBody, ThermostatsOffResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/off', @@ -281,12 +281,12 @@ export class SeamHttpThermostats { setFanMode( body?: ThermostatsSetFanModeBody, options: Pick = {}, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | ThermostatsSetFanModeBody, ThermostatsSetFanModeResponse, 'action_attempt' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/thermostats/set_fan_mode', @@ -300,8 +300,8 @@ export class SeamHttpThermostats { update( body?: ThermostatsUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/thermostats/update', diff --git a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts index 09c836e1..f28d47d9 100644 --- a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +++ b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -159,12 +159,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { delete( body?: UserIdentitiesEnrollmentAutomationsDeleteBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesEnrollmentAutomationsDeleteBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/enrollment_automations/delete', @@ -177,12 +177,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { get( body?: UserIdentitiesEnrollmentAutomationsGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesEnrollmentAutomationsGetParams, UserIdentitiesEnrollmentAutomationsGetResponse, 'enrollment_automation' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/enrollment_automations/get', @@ -195,12 +195,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { launch( body?: UserIdentitiesEnrollmentAutomationsLaunchBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesEnrollmentAutomationsLaunchBody, UserIdentitiesEnrollmentAutomationsLaunchResponse, 'enrollment_automation' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/enrollment_automations/launch', @@ -213,12 +213,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { list( body?: UserIdentitiesEnrollmentAutomationsListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesEnrollmentAutomationsListParams, UserIdentitiesEnrollmentAutomationsListResponse, 'enrollment_automations' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/enrollment_automations/list', diff --git a/src/lib/seam/connect/routes/user-identities.ts b/src/lib/seam/connect/routes/user-identities.ts index d19fd10a..f249d51d 100644 --- a/src/lib/seam/connect/routes/user-identities.ts +++ b/src/lib/seam/connect/routes/user-identities.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' import { SeamHttpUserIdentitiesEnrollmentAutomations } from './user-identities-enrollment-automations.js' @@ -164,8 +164,12 @@ export class SeamHttpUserIdentities { addAcsUser( body?: UserIdentitiesAddAcsUserBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest< + undefined | UserIdentitiesAddAcsUserBody, + void, + undefined + > { + return new SeamHttpRequest( this, { url: '/user_identities/add_acs_user', @@ -178,12 +182,12 @@ export class SeamHttpUserIdentities { create( body?: UserIdentitiesCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesCreateBody, UserIdentitiesCreateResponse, 'user_identity' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/create', @@ -196,8 +200,8 @@ export class SeamHttpUserIdentities { delete( body?: UserIdentitiesDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/user_identities/delete', @@ -210,12 +214,12 @@ export class SeamHttpUserIdentities { get( body?: UserIdentitiesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesGetParams, UserIdentitiesGetResponse, 'user_identity' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/get', @@ -228,12 +232,12 @@ export class SeamHttpUserIdentities { grantAccessToDevice( body?: UserIdentitiesGrantAccessToDeviceBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesGrantAccessToDeviceBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/grant_access_to_device', @@ -246,12 +250,12 @@ export class SeamHttpUserIdentities { list( body?: UserIdentitiesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesListParams, UserIdentitiesListResponse, 'user_identities' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/list', @@ -264,12 +268,12 @@ export class SeamHttpUserIdentities { listAccessibleDevices( body?: UserIdentitiesListAccessibleDevicesParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesListAccessibleDevicesParams, UserIdentitiesListAccessibleDevicesResponse, 'accessible_devices' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/list_accessible_devices', @@ -282,12 +286,12 @@ export class SeamHttpUserIdentities { listAcsSystems( body?: UserIdentitiesListAcsSystemsParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesListAcsSystemsParams, UserIdentitiesListAcsSystemsResponse, 'acs_systems' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/list_acs_systems', @@ -300,12 +304,12 @@ export class SeamHttpUserIdentities { listAcsUsers( body?: UserIdentitiesListAcsUsersParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesListAcsUsersParams, UserIdentitiesListAcsUsersResponse, 'acs_users' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/list_acs_users', @@ -318,12 +322,12 @@ export class SeamHttpUserIdentities { removeAcsUser( body?: UserIdentitiesRemoveAcsUserBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesRemoveAcsUserBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/remove_acs_user', @@ -336,12 +340,12 @@ export class SeamHttpUserIdentities { revokeAccessToDevice( body?: UserIdentitiesRevokeAccessToDeviceBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | UserIdentitiesRevokeAccessToDeviceBody, void, undefined > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/user_identities/revoke_access_to_device', @@ -354,8 +358,8 @@ export class SeamHttpUserIdentities { update( body?: UserIdentitiesUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/user_identities/update', diff --git a/src/lib/seam/connect/routes/webhooks.ts b/src/lib/seam/connect/routes/webhooks.ts index 48ab419a..a60f8ff2 100644 --- a/src/lib/seam/connect/routes/webhooks.ts +++ b/src/lib/seam/connect/routes/webhooks.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpWebhooks { create( body?: WebhooksCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WebhooksCreateBody, WebhooksCreateResponse, 'webhook' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/webhooks/create', @@ -174,8 +174,8 @@ export class SeamHttpWebhooks { delete( body?: WebhooksDeleteBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/webhooks/delete', @@ -188,12 +188,12 @@ export class SeamHttpWebhooks { get( body?: WebhooksGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WebhooksGetParams, WebhooksGetResponse, 'webhook' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/webhooks/get', @@ -206,12 +206,12 @@ export class SeamHttpWebhooks { list( body?: WebhooksListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WebhooksListParams, WebhooksListResponse, 'webhooks' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/webhooks/list', @@ -224,8 +224,8 @@ export class SeamHttpWebhooks { update( body?: WebhooksUpdateBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/webhooks/update', diff --git a/src/lib/seam/connect/routes/workspaces.ts b/src/lib/seam/connect/routes/workspaces.ts index b96c4f97..36772c46 100644 --- a/src/lib/seam/connect/routes/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces.ts @@ -31,7 +31,7 @@ import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamHttpClientSessions } from './client-sessions.js' @@ -156,12 +156,12 @@ export class SeamHttpWorkspaces { create( body?: WorkspacesCreateBody, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WorkspacesCreateBody, WorkspacesCreateResponse, 'workspace' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/workspaces/create', @@ -174,12 +174,12 @@ export class SeamHttpWorkspaces { get( body?: WorkspacesGetParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WorkspacesGetParams, WorkspacesGetResponse, 'workspace' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/workspaces/get', @@ -192,12 +192,12 @@ export class SeamHttpWorkspaces { list( body?: WorkspacesListParams, - ): SeamApiRequest< + ): SeamHttpRequest< undefined | WorkspacesListParams, WorkspacesListResponse, 'workspaces' > { - return new SeamApiRequest( + return new SeamHttpRequest( this, { url: '/workspaces/list', @@ -210,8 +210,8 @@ export class SeamHttpWorkspaces { resetSandbox( body?: WorkspacesResetSandboxBody, - ): SeamApiRequest { - return new SeamApiRequest( + ): SeamHttpRequest { + return new SeamHttpRequest( this, { url: '/workspaces/reset_sandbox', diff --git a/src/lib/seam/connect/seam-api-request.ts b/src/lib/seam/connect/seam-http-request.ts similarity index 91% rename from src/lib/seam/connect/seam-api-request.ts rename to src/lib/seam/connect/seam-http-request.ts index 456c0c8d..8415aa34 100644 --- a/src/lib/seam/connect/seam-api-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -5,19 +5,19 @@ import { SeamHttpActionAttempts } from './index.js' import type { SeamHttpRequestOptions } from './options.js' import { resolveActionAttempt } from './resolve-action-attempt.js' -export interface SeamApiRequestParent { +export interface SeamHttpRequestParent { readonly client: Client readonly defaults: Required } -export type ResponseFromSeamApiRequest = - T extends SeamApiRequest +export type ResponseFromSeamHttpRequest = + T extends SeamHttpRequest ? TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined : never -export class SeamApiRequest< +export class SeamHttpRequest< const TBody, const TResponse, const TResourceKey extends keyof TResponse | undefined, @@ -26,13 +26,13 @@ export class SeamApiRequest< TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined > { - readonly parent: SeamApiRequestParent + readonly parent: SeamHttpRequestParent readonly requestConfig: AxiosRequestConfig readonly resourceKey: TResourceKey readonly options: Pick constructor( - parent: SeamApiRequestParent, + parent: SeamHttpRequestParent, requestConfig: AxiosRequestConfig, resourceKey: TResourceKey, options: Pick = {}, diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 520c9eae..4773ed88 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -13,7 +13,7 @@ import { import { type ResponseFromSeamApiRequest, SeamApiRequest, -} from 'lib/seam/connect/seam-api-request.js' +} from 'lib/seam/connect/seam-http-request.js' test('SeamHttp: fromClient returns instance that uses client', async (t) => { const { seed, endpoint } = await getTestServer(t) From 4ba810d571909e6a612e042565e98cd436f45511 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 10:05:45 +0000 Subject: [PATCH 06/29] Make url, method, data properties of SeamHttpRequest --- src/lib/seam/connect/seam-http-request.ts | 29 +++++++++++++++++++---- test/seam/connect/client.test.ts | 14 +++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 8415aa34..0479e110 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -1,4 +1,4 @@ -import type { AxiosRequestConfig } from 'axios' +import type { Method } from 'axios' import type { Client } from './client.js' import { SeamHttpActionAttempts } from './index.js' @@ -10,6 +10,13 @@ export interface SeamHttpRequestParent { readonly defaults: Required } +export interface SeamHttpRequestConfig { + url?: string + method?: Method + params?: any + data?: TBody +} + export type ResponseFromSeamHttpRequest = T extends SeamHttpRequest ? TResourceKey extends keyof TResponse @@ -27,27 +34,39 @@ export class SeamHttpRequest< > { readonly parent: SeamHttpRequestParent - readonly requestConfig: AxiosRequestConfig + readonly config: SeamHttpRequestConfig readonly resourceKey: TResourceKey readonly options: Pick constructor( parent: SeamHttpRequestParent, - requestConfig: AxiosRequestConfig, + config: SeamHttpRequestConfig, resourceKey: TResourceKey, options: Pick = {}, ) { this.parent = parent - this.requestConfig = requestConfig + this.config = config this.resourceKey = resourceKey this.options = options } + public get url(): string { + return this.config.url ?? '' + } + + public get method(): Method { + return this.config.method ?? 'get' + } + + public get data(): TBody { + return this.config.data as TBody + } + async execute(): Promise< TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined > { const { client } = this.parent - const response = await client.request(this.requestConfig) + const response = await client.request(this.config) if (this.resourceKey === undefined) { return undefined as TResourceKey extends keyof TResponse ? TResponse[TResourceKey] diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 4773ed88..2dbc797b 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -11,8 +11,8 @@ import { } from '@seamapi/http/connect' import { - type ResponseFromSeamApiRequest, - SeamApiRequest, + type ResponseFromSeamHttpRequest, + SeamHttpRequest, } from 'lib/seam/connect/seam-http-request.js' test('SeamHttp: fromClient returns instance that uses client', async (t) => { @@ -165,7 +165,7 @@ test.failing( }, ) -test('SeamHttp: request methods return a SeamApiRequest object', async (t) => { +test('SeamHttp: request methods return a SeamHttpRequest object', async (t) => { const { seed, endpoint } = await getTestServer(t) const seam = new SeamHttp({ client: SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client, @@ -173,9 +173,9 @@ test('SeamHttp: request methods return a SeamApiRequest object', async (t) => { const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) - t.true(deviceRequest instanceof SeamApiRequest) - t.is(deviceRequest.requestConfig.url, '/devices/get') - t.deepEqual(deviceRequest.requestConfig.data, { + t.true(deviceRequest instanceof SeamHttpRequest) + t.is(deviceRequest.url, '/devices/get') + t.deepEqual(deviceRequest.data, { device_id: seed.august_device_1, }) t.is(deviceRequest.resourceKey, 'device') @@ -184,7 +184,7 @@ test('SeamHttp: request methods return a SeamApiRequest object', async (t) => { t.is(device.device_id, seed.august_device_1) // Ensure that the type of the response is correct. - type Expected = ResponseFromSeamApiRequest + type Expected = ResponseFromSeamHttpRequest const validDeviceType: Expected['device_type'] = 'august_lock' t.truthy(validDeviceType) From bc1340c4bd8e4aa18be0f55529ed94490686f7db Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 10:12:03 +0000 Subject: [PATCH 07/29] Fix generate-routes --- generate-routes.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index c1186024..8a3d8778 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -295,7 +295,7 @@ import { import { resolveActionAttempt, } from 'lib/seam/connect/resolve-action-attempt.js' -import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' ${ namespace === 'client_sessions' @@ -361,7 +361,7 @@ const renderClassMethod = ({ namespace, })}, ${renderClassMethodOptions({ resource })} - ): SeamApiRequest<${isRequestParamOptional ? 'undefined | ' : ''}${renderRequestType( + ): SeamHttpRequest<${isRequestParamOptional ? 'undefined | ' : ''}${renderRequestType( { name, namespace, @@ -371,7 +371,7 @@ const renderClassMethod = ({ ? 'void, undefined' : `${renderResponseType({ name, namespace })}, '${resource}'` }> { - return new SeamApiRequest(this, { + return new SeamHttpRequest(this, { url: '${path}', method: '${snakeCase(method)}', ${ requestFormat === 'params' ? 'params,' : '' From 5a75eaefbf3978d0583dd367d4d9add80464e4db Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 10:14:25 +0000 Subject: [PATCH 08/29] Move test for SeamHttpRequest into its own file --- test/seam/connect/client.test.ts | 29 ----------------- test/seam/connect/seam-http-request.test.ts | 35 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 test/seam/connect/seam-http-request.test.ts diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 2dbc797b..6307d141 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -164,32 +164,3 @@ test.failing( t.true(workspaces.length > 0) }, ) - -test('SeamHttp: request methods return a SeamHttpRequest object', async (t) => { - const { seed, endpoint } = await getTestServer(t) - const seam = new SeamHttp({ - client: SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client, - }) - - const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) - - t.true(deviceRequest instanceof SeamHttpRequest) - t.is(deviceRequest.url, '/devices/get') - t.deepEqual(deviceRequest.data, { - device_id: seed.august_device_1, - }) - t.is(deviceRequest.resourceKey, 'device') - const device = await deviceRequest - t.is(device.workspace_id, seed.seed_workspace_1) - t.is(device.device_id, seed.august_device_1) - - // Ensure that the type of the response is correct. - type Expected = ResponseFromSeamHttpRequest - - const validDeviceType: Expected['device_type'] = 'august_lock' - t.truthy(validDeviceType) - - // @ts-expect-error because it's an invalid device type. - const invalidDeviceType: Expected['device_type'] = 'invalid_device_type' - t.truthy(invalidDeviceType) -}) diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts new file mode 100644 index 00000000..f93fcc2f --- /dev/null +++ b/test/seam/connect/seam-http-request.test.ts @@ -0,0 +1,35 @@ +import test from 'ava' +import { getTestServer } from 'fixtures/seam/connect/api.js' + +import { SeamHttp } from '@seamapi/http/connect' +import { + SeamHttpRequest, + type ResponseFromSeamHttpRequest, +} from 'lib/seam/connect/seam-http-request.js' + +test('serializes array params when undefined', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) + + const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) + + t.true(deviceRequest instanceof SeamHttpRequest) + t.is(deviceRequest.url, '/devices/get') + t.deepEqual(deviceRequest.data, { + device_id: seed.august_device_1, + }) + t.is(deviceRequest.resourceKey, 'device') + const device = await deviceRequest + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) + + // Ensure that the type of the response is correct. + type Expected = ResponseFromSeamHttpRequest + + const validDeviceType: Expected['device_type'] = 'august_lock' + t.truthy(validDeviceType) + + // @ts-expect-error because it's an invalid device type. + const invalidDeviceType: Expected['device_type'] = 'invalid_device_type' + t.truthy(invalidDeviceType) +}) From d8d3722020c095ef812301cf2ae25cf2994ae8d4 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Tue, 26 Mar 2024 10:15:05 +0000 Subject: [PATCH 09/29] ci: Format code --- test/seam/connect/client.test.ts | 6 ++---- test/seam/connect/seam-http-request.test.ts | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 6307d141..38f94950 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -10,10 +10,8 @@ import { type WorkspacesListResponse, } from '@seamapi/http/connect' -import { - type ResponseFromSeamHttpRequest, - SeamHttpRequest, -} from 'lib/seam/connect/seam-http-request.js' + + test('SeamHttp: fromClient returns instance that uses client', async (t) => { const { seed, endpoint } = await getTestServer(t) diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index f93fcc2f..4fbefbfe 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -2,9 +2,10 @@ import test from 'ava' import { getTestServer } from 'fixtures/seam/connect/api.js' import { SeamHttp } from '@seamapi/http/connect' + import { - SeamHttpRequest, type ResponseFromSeamHttpRequest, + SeamHttpRequest, } from 'lib/seam/connect/seam-http-request.js' test('serializes array params when undefined', async (t) => { From 5b49368bec44d9950f55d3e98acd43212fa4ad10 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Tue, 26 Mar 2024 10:15:35 +0000 Subject: [PATCH 10/29] ci: Format code --- test/seam/connect/client.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 38f94950..737063e6 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -10,9 +10,6 @@ import { type WorkspacesListResponse, } from '@seamapi/http/connect' - - - test('SeamHttp: fromClient returns instance that uses client', async (t) => { const { seed, endpoint } = await getTestServer(t) const seam = SeamHttp.fromClient( From 28589a3bcbbb2a2d60abc526b7994acbece558fa Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 16:10:19 +0000 Subject: [PATCH 11/29] Add 'Inspecting The Request' to the README --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index ac28e1a6..eb0b4f6a 100644 --- a/README.md +++ b/README.md @@ -394,16 +394,34 @@ 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. +#### Inspecting the Request + +It is possible to inspect a request before it is sent. All of the client methods return an instance of `SeamHttpRequest` which has `url`, `method` and `data` properties. The request is only sent to the server when the `SeamHttpRequest` is awaited. + +```ts +const seam = new SeamHttp('your-api-key') + +const request = seam.devices.list() + +console.log('Sending request', request.url, request.method, request.data) + +const devices = await request // or `await request.execute()` if you prefer + +console.log(devices) +``` + ## Development and Testing ### Quickstart ``` + $ git clone https://github.com/seamapi/javascript-http.git $ cd javascript-http $ nvm install $ npm install $ npm run test:watch + ``` Primary development tasks are defined under `scripts` in `package.json` @@ -411,7 +429,9 @@ and available via `npm run`. View them with ``` + $ npm run + ``` ### Source code @@ -420,7 +440,9 @@ The [source code] is hosted on GitHub. Clone the project with ``` + $ git clone git@github.com:seamapi/javascript-http.git + ``` [source code]: https://github.com/seamapi/javascript-http @@ -433,19 +455,25 @@ Be sure that all commands run under the correct Node version, e.g., if using [nvm], install the correct version with ``` + $ nvm install + ``` Set the active version for each shell session with ``` + $ nvm use + ``` Install the development dependencies with ``` + $ npm install + ``` [Node.js]: https://nodejs.org/ @@ -471,7 +499,9 @@ The `version` input will be passed as the first argument to [npm-version]. This may be done on the web or using the [GitHub CLI] with ``` + $ gh workflow run version.yml --raw-field version= + ``` [GitHub CLI]: https://cli.github.com/ @@ -528,3 +558,7 @@ loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. + +``` + +``` From 9633c143d8e5aac7192cfa9c7c83cfea8287ce2a Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 17:04:01 +0000 Subject: [PATCH 12/29] Fix whitespace in README --- README.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/README.md b/README.md index eb0b4f6a..de0d4b70 100644 --- a/README.md +++ b/README.md @@ -415,13 +415,11 @@ console.log(devices) ### Quickstart ``` - $ git clone https://github.com/seamapi/javascript-http.git $ cd javascript-http $ nvm install $ npm install $ npm run test:watch - ``` Primary development tasks are defined under `scripts` in `package.json` @@ -429,9 +427,7 @@ and available via `npm run`. View them with ``` - $ npm run - ``` ### Source code @@ -440,9 +436,7 @@ The [source code] is hosted on GitHub. Clone the project with ``` - $ git clone git@github.com:seamapi/javascript-http.git - ``` [source code]: https://github.com/seamapi/javascript-http @@ -455,25 +449,19 @@ Be sure that all commands run under the correct Node version, e.g., if using [nvm], install the correct version with ``` - $ nvm install - ``` Set the active version for each shell session with ``` - $ nvm use - ``` Install the development dependencies with ``` - $ npm install - ``` [Node.js]: https://nodejs.org/ @@ -499,9 +487,7 @@ The `version` input will be passed as the first argument to [npm-version]. This may be done on the web or using the [GitHub CLI] with ``` - $ gh workflow run version.yml --raw-field version= - ``` [GitHub CLI]: https://cli.github.com/ @@ -558,7 +544,3 @@ loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. - -``` - -``` From 724ad99243e739d5b6ac06943c88718b316542fd Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 17:13:12 +0000 Subject: [PATCH 13/29] Consolidate config into SeamHttpRequestConfig --- generate-routes.ts | 6 +- src/lib/seam/connect/seam-http-request.ts | 89 ++++++++++++--------- test/seam/connect/seam-http-request.test.ts | 2 +- 3 files changed, 54 insertions(+), 43 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index 8a3d8778..c45b44b3 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -375,8 +375,10 @@ const renderClassMethod = ({ url: '${path}', method: '${snakeCase(method)}', ${ requestFormat === 'params' ? 'params,' : '' - } ${requestFormat === 'body' ? 'data: body,' : ''} - }, ${resource === null ? 'undefined' : `'${resource}'`}${resource === 'action_attempt' ? ', options' : ''}) + } ${requestFormat === 'body' ? 'data: body,' : ''}, + responseKey: ${resource === null ? 'undefined' : `'${resource}'`}, + ${resource === 'action_attempt' ? 'options' : ''} + }) } ` diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 0479e110..919e03f1 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -5,83 +5,92 @@ import { SeamHttpActionAttempts } from './index.js' import type { SeamHttpRequestOptions } from './options.js' import { resolveActionAttempt } from './resolve-action-attempt.js' -export interface SeamHttpRequestParent { +interface SeamHttpRequestParent { readonly client: Client readonly defaults: Required } -export interface SeamHttpRequestConfig { - url?: string - method?: Method - params?: any - data?: TBody +export interface SeamHttpRequestConfig { + readonly url?: string + readonly method?: Method + readonly params?: any + readonly data?: TBody + readonly responseKey: TResponseKey + readonly options: Pick } export type ResponseFromSeamHttpRequest = - T extends SeamHttpRequest - ? TResourceKey extends keyof TResponse - ? TResponse[TResourceKey] + T extends SeamHttpRequest + ? TResponseKey extends keyof TResponse + ? TResponse[TResponseKey] : undefined : never export class SeamHttpRequest< const TBody, const TResponse, - const TResourceKey extends keyof TResponse | undefined, + const TResponseKey extends keyof TResponse | undefined, > implements PromiseLike< - TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined + TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined > { - readonly parent: SeamHttpRequestParent - readonly config: SeamHttpRequestConfig - readonly resourceKey: TResourceKey - readonly options: Pick + readonly #parent: SeamHttpRequestParent + readonly #config: SeamHttpRequestConfig constructor( parent: SeamHttpRequestParent, - config: SeamHttpRequestConfig, - resourceKey: TResourceKey, - options: Pick = {}, + config: SeamHttpRequestConfig, ) { - this.parent = parent - this.config = config - this.resourceKey = resourceKey - this.options = options + this.#parent = parent + this.#config = config + } + + public get responseKey(): TResponseKey { + return this.#config.responseKey } public get url(): string { - return this.config.url ?? '' + return this.#config.url ?? '' } public get method(): Method { - return this.config.method ?? 'get' + return this.#config.method ?? 'get' + } + + public get params() { + return this.#config.params } public get data(): TBody { - return this.config.data as TBody + return this.#config.data as TBody } async execute(): Promise< - TResourceKey extends keyof TResponse ? TResponse[TResourceKey] : undefined + TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined > { - const { client } = this.parent - const response = await client.request(this.config) - if (this.resourceKey === undefined) { - return undefined as TResourceKey extends keyof TResponse - ? TResponse[TResourceKey] + const { client } = this.#parent + const response = await client.request({ + url: this.url, + method: this.method, + params: this.params, + data: this.data, + }) + if (this.responseKey === undefined) { + return undefined as TResponseKey extends keyof TResponse + ? TResponse[TResponseKey] : undefined } - const data = response.data[this.resourceKey] - if (this.resourceKey === 'action_attempt') { + const data = response.data[this.responseKey] + if (this.responseKey === 'action_attempt') { const waitForActionAttempt = - this.options.waitForActionAttempt ?? - this.parent.defaults.waitForActionAttempt + this.#config.options.waitForActionAttempt ?? + this.#parent.defaults.waitForActionAttempt if (waitForActionAttempt !== false) { return await resolveActionAttempt( data, SeamHttpActionAttempts.fromClient(client, { - ...this.parent.defaults, + ...this.#parent.defaults, waitForActionAttempt: false, }), typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, @@ -92,15 +101,15 @@ export class SeamHttpRequest< } then< - TResult1 = TResourceKey extends keyof TResponse - ? TResponse[TResourceKey] + TResult1 = TResponseKey extends keyof TResponse + ? TResponse[TResponseKey] : undefined, TResult2 = never, >( onfulfilled?: | (( - value: TResourceKey extends keyof TResponse - ? TResponse[TResourceKey] + value: TResponseKey extends keyof TResponse + ? TResponse[TResponseKey] : undefined, ) => TResult1 | PromiseLike) | null diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 4fbefbfe..ee3e508b 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -19,7 +19,7 @@ test('serializes array params when undefined', async (t) => { t.deepEqual(deviceRequest.data, { device_id: seed.august_device_1, }) - t.is(deviceRequest.resourceKey, 'device') + t.is(deviceRequest.responseKey, 'device') const device = await deviceRequest t.is(device.workspace_id, seed.seed_workspace_1) t.is(device.device_id, seed.august_device_1) From d8863db2ab2f1b776577194b388f7f17f450215b Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 17:21:07 +0000 Subject: [PATCH 14/29] Move ResponseFromSeamHttpRequest to test --- src/lib/seam/connect/seam-http-request.ts | 13 +++---------- test/seam/connect/seam-http-request.test.ts | 14 +++++++++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 919e03f1..98c7cf73 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -16,16 +16,9 @@ export interface SeamHttpRequestConfig { readonly params?: any readonly data?: TBody readonly responseKey: TResponseKey - readonly options: Pick + readonly options?: Pick } -export type ResponseFromSeamHttpRequest = - T extends SeamHttpRequest - ? TResponseKey extends keyof TResponse - ? TResponse[TResponseKey] - : undefined - : never - export class SeamHttpRequest< const TBody, const TResponse, @@ -58,7 +51,7 @@ export class SeamHttpRequest< return this.#config.method ?? 'get' } - public get params() { + public get params(): any { return this.#config.params } @@ -84,7 +77,7 @@ export class SeamHttpRequest< const data = response.data[this.responseKey] if (this.responseKey === 'action_attempt') { const waitForActionAttempt = - this.#config.options.waitForActionAttempt ?? + this.#config.options?.waitForActionAttempt ?? this.#parent.defaults.waitForActionAttempt if (waitForActionAttempt !== false) { return await resolveActionAttempt( diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index ee3e508b..33e5381f 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -3,12 +3,9 @@ import { getTestServer } from 'fixtures/seam/connect/api.js' import { SeamHttp } from '@seamapi/http/connect' -import { - type ResponseFromSeamHttpRequest, - SeamHttpRequest, -} from 'lib/seam/connect/seam-http-request.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' -test('serializes array params when undefined', async (t) => { +test('returns a SeamHttpRequest', async (t) => { const { seed, endpoint } = await getTestServer(t) const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) @@ -34,3 +31,10 @@ test('serializes array params when undefined', async (t) => { const invalidDeviceType: Expected['device_type'] = 'invalid_device_type' t.truthy(invalidDeviceType) }) + +type ResponseFromSeamHttpRequest = + T extends SeamHttpRequest + ? TResponseKey extends keyof TResponse + ? TResponse[TResponseKey] + : undefined + : never From 955ae8e69e55fbef1ee53a6804e278fdc4c28dce Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 17:23:33 +0000 Subject: [PATCH 15/29] Align request properties with URL spec --- src/lib/seam/connect/seam-http-request.ts | 14 ++++---------- test/seam/connect/seam-http-request.test.ts | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 98c7cf73..cb242258 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -11,9 +11,8 @@ interface SeamHttpRequestParent { } export interface SeamHttpRequestConfig { - readonly url?: string + readonly path?: string readonly method?: Method - readonly params?: any readonly data?: TBody readonly responseKey: TResponseKey readonly options?: Pick @@ -43,18 +42,14 @@ export class SeamHttpRequest< return this.#config.responseKey } - public get url(): string { - return this.#config.url ?? '' + public get path(): string { + return this.#config.path ?? '' } public get method(): Method { return this.#config.method ?? 'get' } - public get params(): any { - return this.#config.params - } - public get data(): TBody { return this.#config.data as TBody } @@ -64,9 +59,8 @@ export class SeamHttpRequest< > { const { client } = this.#parent const response = await client.request({ - url: this.url, + url: this.path, method: this.method, - params: this.params, data: this.data, }) if (this.responseKey === undefined) { diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 33e5381f..8c67874d 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -12,7 +12,7 @@ test('returns a SeamHttpRequest', async (t) => { const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) t.true(deviceRequest instanceof SeamHttpRequest) - t.is(deviceRequest.url, '/devices/get') + t.is(deviceRequest.path, '/devices/get') t.deepEqual(deviceRequest.data, { device_id: seed.august_device_1, }) From c265dfbce1b322d6373cb24afe5e8c2a5e91fefe Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 18:49:44 +0000 Subject: [PATCH 16/29] Add url property to SeamHttpRequest --- generate-routes.ts | 6 +- .../connect/routes/access-codes-unmanaged.ts | 75 +++----- src/lib/seam/connect/routes/access-codes.ts | 120 +++++------- .../seam/connect/routes/acs-access-groups.ts | 75 +++----- .../connect/routes/acs-credential-pools.ts | 15 +- ...acs-credential-provisioning-automations.ts | 15 +- .../seam/connect/routes/acs-credentials.ts | 105 ++++------ src/lib/seam/connect/routes/acs-entrances.ts | 60 +++--- src/lib/seam/connect/routes/acs-systems.ts | 30 ++- src/lib/seam/connect/routes/acs-users.ts | 165 +++++++--------- .../seam/connect/routes/action-attempts.ts | 30 ++- .../seam/connect/routes/client-sessions.ts | 105 ++++------ .../seam/connect/routes/connect-webviews.ts | 75 +++----- .../seam/connect/routes/connected-accounts.ts | 60 +++--- .../seam/connect/routes/devices-simulate.ts | 15 +- .../seam/connect/routes/devices-unmanaged.ts | 45 ++--- src/lib/seam/connect/routes/devices.ts | 75 +++----- src/lib/seam/connect/routes/events.ts | 30 ++- src/lib/seam/connect/routes/locks.ts | 60 +++--- src/lib/seam/connect/routes/networks.ts | 30 ++- .../routes/noise-sensors-noise-thresholds.ts | 75 +++----- .../seam/connect/routes/phones-simulate.ts | 15 +- src/lib/seam/connect/routes/phones.ts | 30 ++- .../thermostats-climate-setting-schedules.ts | 75 +++----- src/lib/seam/connect/routes/thermostats.ts | 120 +++++------- .../user-identities-enrollment-automations.ts | 60 +++--- .../seam/connect/routes/user-identities.ts | 180 +++++++----------- src/lib/seam/connect/routes/webhooks.ts | 75 +++----- src/lib/seam/connect/routes/workspaces.ts | 60 +++--- src/lib/seam/connect/seam-http-request.ts | 38 ++-- test/seam/connect/seam-http-request.test.ts | 26 ++- 31 files changed, 804 insertions(+), 1141 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index c45b44b3..70cd6ebd 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -372,10 +372,10 @@ const renderClassMethod = ({ : `${renderResponseType({ name, namespace })}, '${resource}'` }> { return new SeamHttpRequest(this, { - url: '${path}', + path: '${path}', method: '${snakeCase(method)}', ${ - requestFormat === 'params' ? 'params,' : '' - } ${requestFormat === 'body' ? 'data: body,' : ''}, + requestFormat === 'params' ? 'query: params,' : '' + } ${requestFormat === 'body' ? 'body: body,' : ''} responseKey: ${resource === null ? 'undefined' : `'${resource}'`}, ${resource === 'action_attempt' ? 'options' : ''} }) diff --git a/src/lib/seam/connect/routes/access-codes-unmanaged.ts b/src/lib/seam/connect/routes/access-codes-unmanaged.ts index 2b3a7ced..9b35bc11 100644 --- a/src/lib/seam/connect/routes/access-codes-unmanaged.ts +++ b/src/lib/seam/connect/routes/access-codes-unmanaged.ts @@ -161,15 +161,12 @@ export class SeamHttpAccessCodesUnmanaged { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/unmanaged/convert_to_managed', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/access_codes/unmanaged/convert_to_managed', + method: 'post', + body, + responseKey: undefined, + }) } delete( @@ -179,15 +176,12 @@ export class SeamHttpAccessCodesUnmanaged { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/unmanaged/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/access_codes/unmanaged/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -197,15 +191,12 @@ export class SeamHttpAccessCodesUnmanaged { AccessCodesUnmanagedGetResponse, 'access_code' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/unmanaged/get', - method: 'post', - data: body, - }, - 'access_code', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/unmanaged/get', + method: 'post', + body, + responseKey: 'access_code', + }) } list( @@ -215,15 +206,12 @@ export class SeamHttpAccessCodesUnmanaged { AccessCodesUnmanagedListResponse, 'access_codes' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/unmanaged/list', - method: 'post', - data: body, - }, - 'access_codes', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/unmanaged/list', + method: 'post', + body, + responseKey: 'access_codes', + }) } update( @@ -233,15 +221,12 @@ export class SeamHttpAccessCodesUnmanaged { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/unmanaged/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/access_codes/unmanaged/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/access-codes.ts b/src/lib/seam/connect/routes/access-codes.ts index 76468888..50305b31 100644 --- a/src/lib/seam/connect/routes/access-codes.ts +++ b/src/lib/seam/connect/routes/access-codes.ts @@ -166,15 +166,12 @@ export class SeamHttpAccessCodes { AccessCodesCreateResponse, 'access_code' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/create', - method: 'post', - data: body, - }, - 'access_code', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/create', + method: 'post', + body, + responseKey: 'access_code', + }) } createMultiple( @@ -184,29 +181,23 @@ export class SeamHttpAccessCodes { AccessCodesCreateMultipleResponse, 'access_codes' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/create_multiple', - method: 'post', - data: body, - }, - 'access_codes', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/create_multiple', + method: 'post', + body, + responseKey: 'access_codes', + }) } delete( body?: AccessCodesDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/access_codes/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/access_codes/delete', + method: 'post', + body, + responseKey: undefined, + }) } generateCode( @@ -216,15 +207,12 @@ export class SeamHttpAccessCodes { AccessCodesGenerateCodeResponse, 'generated_code' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/generate_code', - method: 'post', - data: body, - }, - 'generated_code', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/generate_code', + method: 'post', + body, + responseKey: 'generated_code', + }) } get( @@ -234,15 +222,12 @@ export class SeamHttpAccessCodes { AccessCodesGetResponse, 'access_code' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/get', - method: 'post', - data: body, - }, - 'access_code', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/get', + method: 'post', + body, + responseKey: 'access_code', + }) } list( @@ -252,15 +237,12 @@ export class SeamHttpAccessCodes { AccessCodesListResponse, 'access_codes' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/list', - method: 'post', - data: body, - }, - 'access_codes', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/list', + method: 'post', + body, + responseKey: 'access_codes', + }) } pullBackupAccessCode( @@ -270,29 +252,23 @@ export class SeamHttpAccessCodes { AccessCodesPullBackupAccessCodeResponse, 'backup_access_code' > { - return new SeamHttpRequest( - this, - { - url: '/access_codes/pull_backup_access_code', - method: 'post', - data: body, - }, - 'backup_access_code', - ) + return new SeamHttpRequest(this, { + path: '/access_codes/pull_backup_access_code', + method: 'post', + body, + responseKey: 'backup_access_code', + }) } update( body?: AccessCodesUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/access_codes/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/access_codes/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index 840b016f..6da2dda1 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -157,15 +157,12 @@ export class SeamHttpAcsAccessGroups { addUser( body?: AcsAccessGroupsAddUserBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/access_groups/add_user', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/access_groups/add_user', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -175,15 +172,12 @@ export class SeamHttpAcsAccessGroups { AcsAccessGroupsGetResponse, 'acs_access_group' > { - return new SeamHttpRequest( - this, - { - url: '/acs/access_groups/get', - method: 'post', - data: body, - }, - 'acs_access_group', - ) + return new SeamHttpRequest(this, { + path: '/acs/access_groups/get', + method: 'post', + body, + responseKey: 'acs_access_group', + }) } list( @@ -193,15 +187,12 @@ export class SeamHttpAcsAccessGroups { AcsAccessGroupsListResponse, 'acs_access_groups' > { - return new SeamHttpRequest( - this, - { - url: '/acs/access_groups/list', - method: 'post', - data: body, - }, - 'acs_access_groups', - ) + return new SeamHttpRequest(this, { + path: '/acs/access_groups/list', + method: 'post', + body, + responseKey: 'acs_access_groups', + }) } listUsers( @@ -211,15 +202,12 @@ export class SeamHttpAcsAccessGroups { AcsAccessGroupsListUsersResponse, 'acs_users' > { - return new SeamHttpRequest( - this, - { - url: '/acs/access_groups/list_users', - method: 'post', - data: body, - }, - 'acs_users', - ) + return new SeamHttpRequest(this, { + path: '/acs/access_groups/list_users', + method: 'post', + body, + responseKey: 'acs_users', + }) } removeUser( @@ -229,15 +217,12 @@ export class SeamHttpAcsAccessGroups { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/acs/access_groups/remove_user', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/access_groups/remove_user', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/acs-credential-pools.ts b/src/lib/seam/connect/routes/acs-credential-pools.ts index 843024d1..eed89fe1 100644 --- a/src/lib/seam/connect/routes/acs-credential-pools.ts +++ b/src/lib/seam/connect/routes/acs-credential-pools.ts @@ -161,15 +161,12 @@ export class SeamHttpAcsCredentialPools { AcsCredentialPoolsListResponse, 'acs_credential_pools' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credential_pools/list', - method: 'post', - data: body, - }, - 'acs_credential_pools', - ) + return new SeamHttpRequest(this, { + path: '/acs/credential_pools/list', + method: 'post', + body, + responseKey: 'acs_credential_pools', + }) } } diff --git a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts index 2f40d2fa..8bbefe08 100644 --- a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +++ b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts @@ -164,15 +164,12 @@ export class SeamHttpAcsCredentialProvisioningAutomations { AcsCredentialProvisioningAutomationsLaunchResponse, 'acs_credential_provisioning_automation' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credential_provisioning_automations/launch', - method: 'post', - data: body, - }, - 'acs_credential_provisioning_automation', - ) + return new SeamHttpRequest(this, { + path: '/acs/credential_provisioning_automations/launch', + method: 'post', + body, + responseKey: 'acs_credential_provisioning_automation', + }) } } diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index 7e38ab2f..45d69197 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -161,15 +161,12 @@ export class SeamHttpAcsCredentials { AcsCredentialsAssignResponse, 'acs_credential' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/assign', - method: 'post', - data: body, - }, - 'acs_credential', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/assign', + method: 'post', + body, + responseKey: 'acs_credential', + }) } create( @@ -179,29 +176,23 @@ export class SeamHttpAcsCredentials { AcsCredentialsCreateResponse, 'acs_credential' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/create', - method: 'post', - data: body, - }, - 'acs_credential', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/create', + method: 'post', + body, + responseKey: 'acs_credential', + }) } delete( body?: AcsCredentialsDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -211,15 +202,12 @@ export class SeamHttpAcsCredentials { AcsCredentialsGetResponse, 'acs_credential' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/get', - method: 'post', - data: body, - }, - 'acs_credential', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/get', + method: 'post', + body, + responseKey: 'acs_credential', + }) } list( @@ -229,15 +217,12 @@ export class SeamHttpAcsCredentials { AcsCredentialsListResponse, 'acs_credentials' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/list', - method: 'post', - data: body, - }, - 'acs_credentials', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/list', + method: 'post', + body, + responseKey: 'acs_credentials', + }) } unassign( @@ -247,15 +232,12 @@ export class SeamHttpAcsCredentials { AcsCredentialsUnassignResponse, 'acs_credential' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/unassign', - method: 'post', - data: body, - }, - 'acs_credential', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/unassign', + method: 'post', + body, + responseKey: 'acs_credential', + }) } update( @@ -265,15 +247,12 @@ export class SeamHttpAcsCredentials { AcsCredentialsUpdateResponse, 'acs_credential' > { - return new SeamHttpRequest( - this, - { - url: '/acs/credentials/update', - method: 'post', - data: body, - }, - 'acs_credential', - ) + return new SeamHttpRequest(this, { + path: '/acs/credentials/update', + method: 'post', + body, + responseKey: 'acs_credential', + }) } } diff --git a/src/lib/seam/connect/routes/acs-entrances.ts b/src/lib/seam/connect/routes/acs-entrances.ts index aafdbfc3..10d7e1db 100644 --- a/src/lib/seam/connect/routes/acs-entrances.ts +++ b/src/lib/seam/connect/routes/acs-entrances.ts @@ -161,29 +161,23 @@ export class SeamHttpAcsEntrances { AcsEntrancesGetResponse, 'acs_entrance' > { - return new SeamHttpRequest( - this, - { - url: '/acs/entrances/get', - method: 'post', - data: body, - }, - 'acs_entrance', - ) + return new SeamHttpRequest(this, { + path: '/acs/entrances/get', + method: 'post', + body, + responseKey: 'acs_entrance', + }) } grantAccess( body?: AcsEntrancesGrantAccessBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/entrances/grant_access', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/entrances/grant_access', + method: 'post', + body, + responseKey: undefined, + }) } list( @@ -193,15 +187,12 @@ export class SeamHttpAcsEntrances { AcsEntrancesListResponse, 'acs_entrances' > { - return new SeamHttpRequest( - this, - { - url: '/acs/entrances/list', - method: 'post', - data: body, - }, - 'acs_entrances', - ) + return new SeamHttpRequest(this, { + path: '/acs/entrances/list', + method: 'post', + body, + responseKey: 'acs_entrances', + }) } listCredentialsWithAccess( @@ -211,15 +202,12 @@ export class SeamHttpAcsEntrances { AcsEntrancesListCredentialsWithAccessResponse, 'acs_credentials' > { - return new SeamHttpRequest( - this, - { - url: '/acs/entrances/list_credentials_with_access', - method: 'post', - data: body, - }, - 'acs_credentials', - ) + return new SeamHttpRequest(this, { + path: '/acs/entrances/list_credentials_with_access', + method: 'post', + body, + responseKey: 'acs_credentials', + }) } } diff --git a/src/lib/seam/connect/routes/acs-systems.ts b/src/lib/seam/connect/routes/acs-systems.ts index d894cc1a..b2f65d0a 100644 --- a/src/lib/seam/connect/routes/acs-systems.ts +++ b/src/lib/seam/connect/routes/acs-systems.ts @@ -161,15 +161,12 @@ export class SeamHttpAcsSystems { AcsSystemsGetResponse, 'acs_system' > { - return new SeamHttpRequest( - this, - { - url: '/acs/systems/get', - method: 'post', - data: body, - }, - 'acs_system', - ) + return new SeamHttpRequest(this, { + path: '/acs/systems/get', + method: 'post', + body, + responseKey: 'acs_system', + }) } list( @@ -179,15 +176,12 @@ export class SeamHttpAcsSystems { AcsSystemsListResponse, 'acs_systems' > { - return new SeamHttpRequest( - this, - { - url: '/acs/systems/list', - method: 'post', - data: body, - }, - 'acs_systems', - ) + return new SeamHttpRequest(this, { + path: '/acs/systems/list', + method: 'post', + body, + responseKey: 'acs_systems', + }) } } diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index e562b1a8..e536f12f 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -161,15 +161,12 @@ export class SeamHttpAcsUsers { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/add_to_access_group', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/add_to_access_group', + method: 'post', + body, + responseKey: undefined, + }) } create( @@ -179,29 +176,23 @@ export class SeamHttpAcsUsers { AcsUsersCreateResponse, 'acs_user' > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/create', - method: 'post', - data: body, - }, - 'acs_user', - ) + return new SeamHttpRequest(this, { + path: '/acs/users/create', + method: 'post', + body, + responseKey: 'acs_user', + }) } delete( body?: AcsUsersDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/users/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -211,15 +202,12 @@ export class SeamHttpAcsUsers { AcsUsersGetResponse, 'acs_user' > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/get', - method: 'post', - data: body, - }, - 'acs_user', - ) + return new SeamHttpRequest(this, { + path: '/acs/users/get', + method: 'post', + body, + responseKey: 'acs_user', + }) } list( @@ -229,15 +217,12 @@ export class SeamHttpAcsUsers { AcsUsersListResponse, 'acs_users' > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/list', - method: 'post', - data: body, - }, - 'acs_users', - ) + return new SeamHttpRequest(this, { + path: '/acs/users/list', + method: 'post', + body, + responseKey: 'acs_users', + }) } listAccessibleEntrances( @@ -247,15 +232,12 @@ export class SeamHttpAcsUsers { AcsUsersListAccessibleEntrancesResponse, 'acs_entrances' > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/list_accessible_entrances', - method: 'post', - data: body, - }, - 'acs_entrances', - ) + return new SeamHttpRequest(this, { + path: '/acs/users/list_accessible_entrances', + method: 'post', + body, + responseKey: 'acs_entrances', + }) } removeFromAccessGroup( @@ -265,15 +247,12 @@ export class SeamHttpAcsUsers { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/remove_from_access_group', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/remove_from_access_group', + method: 'post', + body, + responseKey: undefined, + }) } revokeAccessToAllEntrances( @@ -283,57 +262,45 @@ export class SeamHttpAcsUsers { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/acs/users/revoke_access_to_all_entrances', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/revoke_access_to_all_entrances', + method: 'post', + body, + responseKey: undefined, + }) } suspend( body?: AcsUsersSuspendBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/users/suspend', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/suspend', + method: 'post', + body, + responseKey: undefined, + }) } unsuspend( body?: AcsUsersUnsuspendBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/users/unsuspend', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/unsuspend', + method: 'post', + body, + responseKey: undefined, + }) } update( body?: AcsUsersUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/acs/users/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/acs/users/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts.ts index e576b18e..1d510a27 100644 --- a/src/lib/seam/connect/routes/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts.ts @@ -162,16 +162,13 @@ export class SeamHttpActionAttempts { ActionAttemptsGetResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/action_attempts/get', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/action_attempts/get', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } list( @@ -181,15 +178,12 @@ export class SeamHttpActionAttempts { ActionAttemptsListResponse, 'action_attempts' > { - return new SeamHttpRequest( - this, - { - url: '/action_attempts/list', - method: 'post', - data: body, - }, - 'action_attempts', - ) + return new SeamHttpRequest(this, { + path: '/action_attempts/list', + method: 'post', + body, + responseKey: 'action_attempts', + }) } } diff --git a/src/lib/seam/connect/routes/client-sessions.ts b/src/lib/seam/connect/routes/client-sessions.ts index b42a4f9a..dd986144 100644 --- a/src/lib/seam/connect/routes/client-sessions.ts +++ b/src/lib/seam/connect/routes/client-sessions.ts @@ -159,29 +159,23 @@ export class SeamHttpClientSessions { ClientSessionsCreateResponse, 'client_session' > { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/create', - method: 'post', - data: body, - }, - 'client_session', - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/create', + method: 'post', + body, + responseKey: 'client_session', + }) } delete( body?: ClientSessionsDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -191,15 +185,12 @@ export class SeamHttpClientSessions { ClientSessionsGetResponse, 'client_session' > { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/get', - method: 'post', - data: body, - }, - 'client_session', - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/get', + method: 'post', + body, + responseKey: 'client_session', + }) } getOrCreate( @@ -209,15 +200,12 @@ export class SeamHttpClientSessions { ClientSessionsGetOrCreateResponse, 'client_session' > { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/get_or_create', - method: 'post', - data: body, - }, - 'client_session', - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/get_or_create', + method: 'post', + body, + responseKey: 'client_session', + }) } grantAccess( @@ -227,15 +215,12 @@ export class SeamHttpClientSessions { ClientSessionsGrantAccessResponse, 'client_session' > { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/grant_access', - method: 'post', - data: body, - }, - 'client_session', - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/grant_access', + method: 'post', + body, + responseKey: 'client_session', + }) } list( @@ -245,29 +230,23 @@ export class SeamHttpClientSessions { ClientSessionsListResponse, 'client_sessions' > { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/list', - method: 'post', - data: body, - }, - 'client_sessions', - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/list', + method: 'post', + body, + responseKey: 'client_sessions', + }) } revoke( body?: ClientSessionsRevokeBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/client_sessions/revoke', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/client_sessions/revoke', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index 34a31db0..cb63c945 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -165,29 +165,23 @@ export class SeamHttpConnectWebviews { ConnectWebviewsCreateResponse, 'connect_webview' > { - return new SeamHttpRequest( - this, - { - url: '/connect_webviews/create', - method: 'post', - data: body, - }, - 'connect_webview', - ) + return new SeamHttpRequest(this, { + path: '/connect_webviews/create', + method: 'post', + body, + responseKey: 'connect_webview', + }) } delete( body?: ConnectWebviewsDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/connect_webviews/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/connect_webviews/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -197,15 +191,12 @@ export class SeamHttpConnectWebviews { ConnectWebviewsGetResponse, 'connect_webview' > { - return new SeamHttpRequest( - this, - { - url: '/connect_webviews/get', - method: 'post', - data: body, - }, - 'connect_webview', - ) + return new SeamHttpRequest(this, { + path: '/connect_webviews/get', + method: 'post', + body, + responseKey: 'connect_webview', + }) } list( @@ -215,29 +206,23 @@ export class SeamHttpConnectWebviews { ConnectWebviewsListResponse, 'connect_webviews' > { - return new SeamHttpRequest( - this, - { - url: '/connect_webviews/list', - method: 'post', - data: body, - }, - 'connect_webviews', - ) + return new SeamHttpRequest(this, { + path: '/connect_webviews/list', + method: 'post', + body, + responseKey: 'connect_webviews', + }) } view( params?: ConnectWebviewsViewParams, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/connect_webviews/view', - method: 'get', - params, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/connect_webviews/view', + method: 'get', + query: params, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/connected-accounts.ts b/src/lib/seam/connect/routes/connected-accounts.ts index f75fe227..c485518b 100644 --- a/src/lib/seam/connect/routes/connected-accounts.ts +++ b/src/lib/seam/connect/routes/connected-accounts.ts @@ -157,15 +157,12 @@ export class SeamHttpConnectedAccounts { delete( body?: ConnectedAccountsDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/connected_accounts/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/connected_accounts/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -175,15 +172,12 @@ export class SeamHttpConnectedAccounts { ConnectedAccountsGetResponse, 'connected_account' > { - return new SeamHttpRequest( - this, - { - url: '/connected_accounts/get', - method: 'post', - data: body, - }, - 'connected_account', - ) + return new SeamHttpRequest(this, { + path: '/connected_accounts/get', + method: 'post', + body, + responseKey: 'connected_account', + }) } list( @@ -193,15 +187,12 @@ export class SeamHttpConnectedAccounts { ConnectedAccountsListResponse, 'connected_accounts' > { - return new SeamHttpRequest( - this, - { - url: '/connected_accounts/list', - method: 'post', - data: body, - }, - 'connected_accounts', - ) + return new SeamHttpRequest(this, { + path: '/connected_accounts/list', + method: 'post', + body, + responseKey: 'connected_accounts', + }) } update( @@ -211,15 +202,12 @@ export class SeamHttpConnectedAccounts { ConnectedAccountsUpdateResponse, 'connected_account' > { - return new SeamHttpRequest( - this, - { - url: '/connected_accounts/update', - method: 'post', - data: body, - }, - 'connected_account', - ) + return new SeamHttpRequest(this, { + path: '/connected_accounts/update', + method: 'post', + body, + responseKey: 'connected_account', + }) } } diff --git a/src/lib/seam/connect/routes/devices-simulate.ts b/src/lib/seam/connect/routes/devices-simulate.ts index 92315722..27065d95 100644 --- a/src/lib/seam/connect/routes/devices-simulate.ts +++ b/src/lib/seam/connect/routes/devices-simulate.ts @@ -157,15 +157,12 @@ export class SeamHttpDevicesSimulate { remove( body?: DevicesSimulateRemoveBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/devices/simulate/remove', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/devices/simulate/remove', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/devices-unmanaged.ts b/src/lib/seam/connect/routes/devices-unmanaged.ts index 2dd61871..f9ace170 100644 --- a/src/lib/seam/connect/routes/devices-unmanaged.ts +++ b/src/lib/seam/connect/routes/devices-unmanaged.ts @@ -161,15 +161,12 @@ export class SeamHttpDevicesUnmanaged { DevicesUnmanagedGetResponse, 'device' > { - return new SeamHttpRequest( - this, - { - url: '/devices/unmanaged/get', - method: 'post', - data: body, - }, - 'device', - ) + return new SeamHttpRequest(this, { + path: '/devices/unmanaged/get', + method: 'post', + body, + responseKey: 'device', + }) } list( @@ -179,29 +176,23 @@ export class SeamHttpDevicesUnmanaged { DevicesUnmanagedListResponse, 'devices' > { - return new SeamHttpRequest( - this, - { - url: '/devices/unmanaged/list', - method: 'post', - data: body, - }, - 'devices', - ) + return new SeamHttpRequest(this, { + path: '/devices/unmanaged/list', + method: 'post', + body, + responseKey: 'devices', + }) } update( body?: DevicesUnmanagedUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/devices/unmanaged/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/devices/unmanaged/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 9249086e..3163edcf 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -167,15 +167,12 @@ export class SeamHttpDevices { delete( body?: DevicesDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/devices/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/devices/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -185,15 +182,12 @@ export class SeamHttpDevices { DevicesGetResponse, 'device' > { - return new SeamHttpRequest( - this, - { - url: '/devices/get', - method: 'post', - data: body, - }, - 'device', - ) + return new SeamHttpRequest(this, { + path: '/devices/get', + method: 'post', + body, + responseKey: 'device', + }) } list( @@ -203,15 +197,12 @@ export class SeamHttpDevices { DevicesListResponse, 'devices' > { - return new SeamHttpRequest( - this, - { - url: '/devices/list', - method: 'post', - data: body, - }, - 'devices', - ) + return new SeamHttpRequest(this, { + path: '/devices/list', + method: 'post', + body, + responseKey: 'devices', + }) } listDeviceProviders( @@ -221,29 +212,23 @@ export class SeamHttpDevices { DevicesListDeviceProvidersResponse, 'device_providers' > { - return new SeamHttpRequest( - this, - { - url: '/devices/list_device_providers', - method: 'post', - data: body, - }, - 'device_providers', - ) + return new SeamHttpRequest(this, { + path: '/devices/list_device_providers', + method: 'post', + body, + responseKey: 'device_providers', + }) } update( body?: DevicesUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/devices/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/devices/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/events.ts b/src/lib/seam/connect/routes/events.ts index f89b617d..623eee7f 100644 --- a/src/lib/seam/connect/routes/events.ts +++ b/src/lib/seam/connect/routes/events.ts @@ -157,15 +157,12 @@ export class SeamHttpEvents { get( body?: EventsGetParams, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/events/get', - method: 'post', - data: body, - }, - 'event', - ) + return new SeamHttpRequest(this, { + path: '/events/get', + method: 'post', + body, + responseKey: 'event', + }) } list( @@ -175,15 +172,12 @@ export class SeamHttpEvents { EventsListResponse, 'events' > { - return new SeamHttpRequest( - this, - { - url: '/events/list', - method: 'post', - data: body, - }, - 'events', - ) + return new SeamHttpRequest(this, { + path: '/events/list', + method: 'post', + body, + responseKey: 'events', + }) } } diff --git a/src/lib/seam/connect/routes/locks.ts b/src/lib/seam/connect/routes/locks.ts index 82971548..aa5ce367 100644 --- a/src/lib/seam/connect/routes/locks.ts +++ b/src/lib/seam/connect/routes/locks.ts @@ -157,15 +157,12 @@ export class SeamHttpLocks { get( body?: LocksGetParams, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/locks/get', - method: 'post', - data: body, - }, - 'device', - ) + return new SeamHttpRequest(this, { + path: '/locks/get', + method: 'post', + body, + responseKey: 'device', + }) } list( @@ -175,15 +172,12 @@ export class SeamHttpLocks { LocksListResponse, 'devices' > { - return new SeamHttpRequest( - this, - { - url: '/locks/list', - method: 'post', - data: body, - }, - 'devices', - ) + return new SeamHttpRequest(this, { + path: '/locks/list', + method: 'post', + body, + responseKey: 'devices', + }) } lockDoor( @@ -194,16 +188,13 @@ export class SeamHttpLocks { LocksLockDoorResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/locks/lock_door', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/locks/lock_door', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } unlockDoor( @@ -214,16 +205,13 @@ export class SeamHttpLocks { LocksUnlockDoorResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/locks/unlock_door', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/locks/unlock_door', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } } diff --git a/src/lib/seam/connect/routes/networks.ts b/src/lib/seam/connect/routes/networks.ts index cc42d347..67b15536 100644 --- a/src/lib/seam/connect/routes/networks.ts +++ b/src/lib/seam/connect/routes/networks.ts @@ -161,15 +161,12 @@ export class SeamHttpNetworks { NetworksGetResponse, 'network' > { - return new SeamHttpRequest( - this, - { - url: '/networks/get', - method: 'post', - data: body, - }, - 'network', - ) + return new SeamHttpRequest(this, { + path: '/networks/get', + method: 'post', + body, + responseKey: 'network', + }) } list( @@ -179,15 +176,12 @@ export class SeamHttpNetworks { NetworksListResponse, 'networks' > { - return new SeamHttpRequest( - this, - { - url: '/networks/list', - method: 'post', - data: body, - }, - 'networks', - ) + return new SeamHttpRequest(this, { + path: '/networks/list', + method: 'post', + body, + responseKey: 'networks', + }) } } diff --git a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts index ff0ed22b..0e41dcd4 100644 --- a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +++ b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts @@ -164,15 +164,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { NoiseSensorsNoiseThresholdsCreateResponse, 'noise_threshold' > { - return new SeamHttpRequest( - this, - { - url: '/noise_sensors/noise_thresholds/create', - method: 'post', - data: body, - }, - 'noise_threshold', - ) + return new SeamHttpRequest(this, { + path: '/noise_sensors/noise_thresholds/create', + method: 'post', + body, + responseKey: 'noise_threshold', + }) } delete( @@ -182,15 +179,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/noise_sensors/noise_thresholds/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/noise_sensors/noise_thresholds/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -200,15 +194,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { NoiseSensorsNoiseThresholdsGetResponse, 'noise_threshold' > { - return new SeamHttpRequest( - this, - { - url: '/noise_sensors/noise_thresholds/get', - method: 'post', - data: body, - }, - 'noise_threshold', - ) + return new SeamHttpRequest(this, { + path: '/noise_sensors/noise_thresholds/get', + method: 'post', + body, + responseKey: 'noise_threshold', + }) } list( @@ -218,15 +209,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { NoiseSensorsNoiseThresholdsListResponse, 'noise_thresholds' > { - return new SeamHttpRequest( - this, - { - url: '/noise_sensors/noise_thresholds/list', - method: 'post', - data: body, - }, - 'noise_thresholds', - ) + return new SeamHttpRequest(this, { + path: '/noise_sensors/noise_thresholds/list', + method: 'post', + body, + responseKey: 'noise_thresholds', + }) } update( @@ -236,15 +224,12 @@ export class SeamHttpNoiseSensorsNoiseThresholds { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/noise_sensors/noise_thresholds/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/noise_sensors/noise_thresholds/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/phones-simulate.ts b/src/lib/seam/connect/routes/phones-simulate.ts index e0bdd918..7baed20d 100644 --- a/src/lib/seam/connect/routes/phones-simulate.ts +++ b/src/lib/seam/connect/routes/phones-simulate.ts @@ -161,15 +161,12 @@ export class SeamHttpPhonesSimulate { PhonesSimulateCreateSandboxPhoneResponse, 'phone' > { - return new SeamHttpRequest( - this, - { - url: '/phones/simulate/create_sandbox_phone', - method: 'post', - data: body, - }, - 'phone', - ) + return new SeamHttpRequest(this, { + path: '/phones/simulate/create_sandbox_phone', + method: 'post', + body, + responseKey: 'phone', + }) } } diff --git a/src/lib/seam/connect/routes/phones.ts b/src/lib/seam/connect/routes/phones.ts index efab9759..89c017e8 100644 --- a/src/lib/seam/connect/routes/phones.ts +++ b/src/lib/seam/connect/routes/phones.ts @@ -162,15 +162,12 @@ export class SeamHttpPhones { deactivate( body?: PhonesDeactivateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/phones/deactivate', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/phones/deactivate', + method: 'post', + body, + responseKey: undefined, + }) } list( @@ -180,15 +177,12 @@ export class SeamHttpPhones { PhonesListResponse, 'phones' > { - return new SeamHttpRequest( - this, - { - url: '/phones/list', - method: 'post', - data: body, - }, - 'phones', - ) + return new SeamHttpRequest(this, { + path: '/phones/list', + method: 'post', + body, + responseKey: 'phones', + }) } } diff --git a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts index 549a9b52..9042f4a1 100644 --- a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +++ b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts @@ -164,15 +164,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { ThermostatsClimateSettingSchedulesCreateResponse, 'climate_setting_schedule' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/climate_setting_schedules/create', - method: 'post', - data: body, - }, - 'climate_setting_schedule', - ) + return new SeamHttpRequest(this, { + path: '/thermostats/climate_setting_schedules/create', + method: 'post', + body, + responseKey: 'climate_setting_schedule', + }) } delete( @@ -182,15 +179,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/climate_setting_schedules/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/thermostats/climate_setting_schedules/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -200,15 +194,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { ThermostatsClimateSettingSchedulesGetResponse, 'climate_setting_schedule' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/climate_setting_schedules/get', - method: 'post', - data: body, - }, - 'climate_setting_schedule', - ) + return new SeamHttpRequest(this, { + path: '/thermostats/climate_setting_schedules/get', + method: 'post', + body, + responseKey: 'climate_setting_schedule', + }) } list( @@ -218,15 +209,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { ThermostatsClimateSettingSchedulesListResponse, 'climate_setting_schedules' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/climate_setting_schedules/list', - method: 'post', - data: body, - }, - 'climate_setting_schedules', - ) + return new SeamHttpRequest(this, { + path: '/thermostats/climate_setting_schedules/list', + method: 'post', + body, + responseKey: 'climate_setting_schedules', + }) } update( @@ -236,15 +224,12 @@ export class SeamHttpThermostatsClimateSettingSchedules { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/climate_setting_schedules/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/thermostats/climate_setting_schedules/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index 962fec02..c483f647 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -170,16 +170,13 @@ export class SeamHttpThermostats { ThermostatsCoolResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/cool', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/thermostats/cool', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } get( @@ -189,15 +186,12 @@ export class SeamHttpThermostats { ThermostatsGetResponse, 'thermostat' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/get', - method: 'post', - data: body, - }, - 'thermostat', - ) + return new SeamHttpRequest(this, { + path: '/thermostats/get', + method: 'post', + body, + responseKey: 'thermostat', + }) } heat( @@ -208,16 +202,13 @@ export class SeamHttpThermostats { ThermostatsHeatResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/heat', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/thermostats/heat', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } heatCool( @@ -228,16 +219,13 @@ export class SeamHttpThermostats { ThermostatsHeatCoolResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/heat_cool', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/thermostats/heat_cool', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } list( @@ -247,15 +235,12 @@ export class SeamHttpThermostats { ThermostatsListResponse, 'thermostats' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/list', - method: 'post', - data: body, - }, - 'thermostats', - ) + return new SeamHttpRequest(this, { + path: '/thermostats/list', + method: 'post', + body, + responseKey: 'thermostats', + }) } off( @@ -266,16 +251,13 @@ export class SeamHttpThermostats { ThermostatsOffResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/off', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/thermostats/off', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } setFanMode( @@ -286,30 +268,24 @@ export class SeamHttpThermostats { ThermostatsSetFanModeResponse, 'action_attempt' > { - return new SeamHttpRequest( - this, - { - url: '/thermostats/set_fan_mode', - method: 'post', - data: body, - }, - 'action_attempt', + return new SeamHttpRequest(this, { + path: '/thermostats/set_fan_mode', + method: 'post', + body, + responseKey: 'action_attempt', options, - ) + }) } update( body?: ThermostatsUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/thermostats/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/thermostats/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts index f28d47d9..18ec126e 100644 --- a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +++ b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts @@ -164,15 +164,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/enrollment_automations/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/enrollment_automations/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -182,15 +179,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { UserIdentitiesEnrollmentAutomationsGetResponse, 'enrollment_automation' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/enrollment_automations/get', - method: 'post', - data: body, - }, - 'enrollment_automation', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/enrollment_automations/get', + method: 'post', + body, + responseKey: 'enrollment_automation', + }) } launch( @@ -200,15 +194,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { UserIdentitiesEnrollmentAutomationsLaunchResponse, 'enrollment_automation' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/enrollment_automations/launch', - method: 'post', - data: body, - }, - 'enrollment_automation', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/enrollment_automations/launch', + method: 'post', + body, + responseKey: 'enrollment_automation', + }) } list( @@ -218,15 +209,12 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { UserIdentitiesEnrollmentAutomationsListResponse, 'enrollment_automations' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/enrollment_automations/list', - method: 'post', - data: body, - }, - 'enrollment_automations', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/enrollment_automations/list', + method: 'post', + body, + responseKey: 'enrollment_automations', + }) } } diff --git a/src/lib/seam/connect/routes/user-identities.ts b/src/lib/seam/connect/routes/user-identities.ts index f249d51d..8acb09f1 100644 --- a/src/lib/seam/connect/routes/user-identities.ts +++ b/src/lib/seam/connect/routes/user-identities.ts @@ -169,15 +169,12 @@ export class SeamHttpUserIdentities { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/add_acs_user', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/add_acs_user', + method: 'post', + body, + responseKey: undefined, + }) } create( @@ -187,29 +184,23 @@ export class SeamHttpUserIdentities { UserIdentitiesCreateResponse, 'user_identity' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/create', - method: 'post', - data: body, - }, - 'user_identity', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/create', + method: 'post', + body, + responseKey: 'user_identity', + }) } delete( body?: UserIdentitiesDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/user_identities/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -219,15 +210,12 @@ export class SeamHttpUserIdentities { UserIdentitiesGetResponse, 'user_identity' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/get', - method: 'post', - data: body, - }, - 'user_identity', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/get', + method: 'post', + body, + responseKey: 'user_identity', + }) } grantAccessToDevice( @@ -237,15 +225,12 @@ export class SeamHttpUserIdentities { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/grant_access_to_device', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/grant_access_to_device', + method: 'post', + body, + responseKey: undefined, + }) } list( @@ -255,15 +240,12 @@ export class SeamHttpUserIdentities { UserIdentitiesListResponse, 'user_identities' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/list', - method: 'post', - data: body, - }, - 'user_identities', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/list', + method: 'post', + body, + responseKey: 'user_identities', + }) } listAccessibleDevices( @@ -273,15 +255,12 @@ export class SeamHttpUserIdentities { UserIdentitiesListAccessibleDevicesResponse, 'accessible_devices' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/list_accessible_devices', - method: 'post', - data: body, - }, - 'accessible_devices', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/list_accessible_devices', + method: 'post', + body, + responseKey: 'accessible_devices', + }) } listAcsSystems( @@ -291,15 +270,12 @@ export class SeamHttpUserIdentities { UserIdentitiesListAcsSystemsResponse, 'acs_systems' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/list_acs_systems', - method: 'post', - data: body, - }, - 'acs_systems', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/list_acs_systems', + method: 'post', + body, + responseKey: 'acs_systems', + }) } listAcsUsers( @@ -309,15 +285,12 @@ export class SeamHttpUserIdentities { UserIdentitiesListAcsUsersResponse, 'acs_users' > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/list_acs_users', - method: 'post', - data: body, - }, - 'acs_users', - ) + return new SeamHttpRequest(this, { + path: '/user_identities/list_acs_users', + method: 'post', + body, + responseKey: 'acs_users', + }) } removeAcsUser( @@ -327,15 +300,12 @@ export class SeamHttpUserIdentities { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/remove_acs_user', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/remove_acs_user', + method: 'post', + body, + responseKey: undefined, + }) } revokeAccessToDevice( @@ -345,29 +315,23 @@ export class SeamHttpUserIdentities { void, undefined > { - return new SeamHttpRequest( - this, - { - url: '/user_identities/revoke_access_to_device', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/revoke_access_to_device', + method: 'post', + body, + responseKey: undefined, + }) } update( body?: UserIdentitiesUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/user_identities/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/user_identities/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/webhooks.ts b/src/lib/seam/connect/routes/webhooks.ts index a60f8ff2..13f7e512 100644 --- a/src/lib/seam/connect/routes/webhooks.ts +++ b/src/lib/seam/connect/routes/webhooks.ts @@ -161,29 +161,23 @@ export class SeamHttpWebhooks { WebhooksCreateResponse, 'webhook' > { - return new SeamHttpRequest( - this, - { - url: '/webhooks/create', - method: 'post', - data: body, - }, - 'webhook', - ) + return new SeamHttpRequest(this, { + path: '/webhooks/create', + method: 'post', + body, + responseKey: 'webhook', + }) } delete( body?: WebhooksDeleteBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/webhooks/delete', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/webhooks/delete', + method: 'post', + body, + responseKey: undefined, + }) } get( @@ -193,15 +187,12 @@ export class SeamHttpWebhooks { WebhooksGetResponse, 'webhook' > { - return new SeamHttpRequest( - this, - { - url: '/webhooks/get', - method: 'post', - data: body, - }, - 'webhook', - ) + return new SeamHttpRequest(this, { + path: '/webhooks/get', + method: 'post', + body, + responseKey: 'webhook', + }) } list( @@ -211,29 +202,23 @@ export class SeamHttpWebhooks { WebhooksListResponse, 'webhooks' > { - return new SeamHttpRequest( - this, - { - url: '/webhooks/list', - method: 'post', - data: body, - }, - 'webhooks', - ) + return new SeamHttpRequest(this, { + path: '/webhooks/list', + method: 'post', + body, + responseKey: 'webhooks', + }) } update( body?: WebhooksUpdateBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/webhooks/update', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/webhooks/update', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/routes/workspaces.ts b/src/lib/seam/connect/routes/workspaces.ts index 36772c46..2bce1435 100644 --- a/src/lib/seam/connect/routes/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces.ts @@ -161,15 +161,12 @@ export class SeamHttpWorkspaces { WorkspacesCreateResponse, 'workspace' > { - return new SeamHttpRequest( - this, - { - url: '/workspaces/create', - method: 'post', - data: body, - }, - 'workspace', - ) + return new SeamHttpRequest(this, { + path: '/workspaces/create', + method: 'post', + body, + responseKey: 'workspace', + }) } get( @@ -179,15 +176,12 @@ export class SeamHttpWorkspaces { WorkspacesGetResponse, 'workspace' > { - return new SeamHttpRequest( - this, - { - url: '/workspaces/get', - method: 'post', - data: body, - }, - 'workspace', - ) + return new SeamHttpRequest(this, { + path: '/workspaces/get', + method: 'post', + body, + responseKey: 'workspace', + }) } list( @@ -197,29 +191,23 @@ export class SeamHttpWorkspaces { WorkspacesListResponse, 'workspaces' > { - return new SeamHttpRequest( - this, - { - url: '/workspaces/list', - method: 'post', - data: body, - }, - 'workspaces', - ) + return new SeamHttpRequest(this, { + path: '/workspaces/list', + method: 'post', + body, + responseKey: 'workspaces', + }) } resetSandbox( body?: WorkspacesResetSandboxBody, ): SeamHttpRequest { - return new SeamHttpRequest( - this, - { - url: '/workspaces/reset_sandbox', - method: 'post', - data: body, - }, - undefined, - ) + return new SeamHttpRequest(this, { + path: '/workspaces/reset_sandbox', + method: 'post', + body, + responseKey: undefined, + }) } } diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index cb242258..72bf7c34 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -1,9 +1,10 @@ +import { serializeUrlSearchParams } from '@seamapi/url-search-params-serializer' import type { Method } from 'axios' import type { Client } from './client.js' -import { SeamHttpActionAttempts } from './index.js' import type { SeamHttpRequestOptions } from './options.js' import { resolveActionAttempt } from './resolve-action-attempt.js' +import { SeamHttpActionAttempts } from './routes/index.js' interface SeamHttpRequestParent { readonly client: Client @@ -11,9 +12,10 @@ interface SeamHttpRequestParent { } export interface SeamHttpRequestConfig { - readonly path?: string - readonly method?: Method - readonly data?: TBody + readonly path: string + readonly method: Method + readonly body?: TBody + readonly query?: undefined | Record readonly responseKey: TResponseKey readonly options?: Pick } @@ -42,16 +44,29 @@ export class SeamHttpRequest< return this.#config.responseKey } - public get path(): string { - return this.#config.path ?? '' + public get url(): URL { + const { client } = this.#parent + const baseUrl = client.defaults.baseURL + if (baseUrl === undefined) { + throw new Error('baseUrl is required') + } + + const query = this.#config.query + if (query === undefined) { + return new URL(this.#config.path, baseUrl) + } + return new URL( + `${this.#config.path}?${serializeUrlSearchParams(query)}`, + baseUrl, + ) } public get method(): Method { return this.#config.method ?? 'get' } - public get data(): TBody { - return this.#config.data as TBody + public get body(): TBody { + return this.#config.body as TBody } async execute(): Promise< @@ -59,9 +74,10 @@ export class SeamHttpRequest< > { const { client } = this.#parent const response = await client.request({ - url: this.path, - method: this.method, - data: this.data, + url: this.#config.path, + method: this.#config.method, + data: this.#config.body as TBody, + params: this.#config.query, }) if (this.responseKey === undefined) { return undefined as TResponseKey extends keyof TResponse diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 8c67874d..e9bfa3d1 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -12,8 +12,8 @@ test('returns a SeamHttpRequest', async (t) => { const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) t.true(deviceRequest instanceof SeamHttpRequest) - t.is(deviceRequest.path, '/devices/get') - t.deepEqual(deviceRequest.data, { + t.is(deviceRequest.url.pathname, '/devices/get') + t.deepEqual(deviceRequest.body, { device_id: seed.august_device_1, }) t.is(deviceRequest.responseKey, 'device') @@ -32,6 +32,28 @@ test('returns a SeamHttpRequest', async (t) => { t.truthy(invalidDeviceType) }) +test("populates SeamHttpRequest's url property", async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) + + const deviceRequest = seam.devices.get({ device_id: 'abc123' }) + + t.is(deviceRequest.url.pathname, '/devices/get') + t.is(deviceRequest.url.search, '') + + const connectWebviewsViewRequest = seam.connectWebviews.view({ + connect_webview_id: 'abc123', + auth_token: 'invalid', + }) + + t.is(connectWebviewsViewRequest.url.pathname, '/connect_webviews/view') + t.is(connectWebviewsViewRequest.url.searchParams.get('auth_token'), 'invalid') + t.is( + connectWebviewsViewRequest.url.searchParams.get('connect_webview_id'), + 'abc123', + ) +}) + type ResponseFromSeamHttpRequest = T extends SeamHttpRequest ? TResponseKey extends keyof TResponse From 93eb85eef85882ea533611e65345de9518e30689 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 18:51:26 +0000 Subject: [PATCH 17/29] Rename data -> body --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de0d4b70..98b22bee 100644 --- a/README.md +++ b/README.md @@ -396,14 +396,14 @@ This API is used internally and is not directly supported. #### Inspecting the Request -It is possible to inspect a request before it is sent. All of the client methods return an instance of `SeamHttpRequest` which has `url`, `method` and `data` properties. The request is only sent to the server when the `SeamHttpRequest` is awaited. +It is possible to inspect a request before it is sent. All of the client methods return an instance of `SeamHttpRequest` which has `url`, `method` and `body` properties. The request is only sent to the server when the `SeamHttpRequest` is awaited. ```ts const seam = new SeamHttp('your-api-key') const request = seam.devices.list() -console.log('Sending request', request.url, request.method, request.data) +console.log('Sending request', request.url, request.method, request.body) const devices = await request // or `await request.execute()` if you prefer From a4c3266a049ecb07cb8b456436a8b75b0e9df91d Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 18:59:18 +0000 Subject: [PATCH 18/29] Method is not nullable --- src/lib/seam/connect/seam-http-request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 72bf7c34..a1ecccf3 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -62,7 +62,7 @@ export class SeamHttpRequest< } public get method(): Method { - return this.#config.method ?? 'get' + return this.#config.method } public get body(): TBody { From af32603fe6c0feaa4763eecf6809f9a4d0d11b50 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 19:09:39 +0000 Subject: [PATCH 19/29] Update README after Evan's suggestion --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 98b22bee..17c76868 100644 --- a/README.md +++ b/README.md @@ -396,18 +396,17 @@ This API is used internally and is not directly supported. #### Inspecting the Request -It is possible to inspect a request before it is sent. All of the client methods return an instance of `SeamHttpRequest` which has `url`, `method` and `body` properties. The request is only sent to the server when the `SeamHttpRequest` is awaited. +All client methods return an instance of `SeamHttpRequest`. +Inspect the request before it is sent to the server by intentionally not awaiting the `SeamHttpRequest`; ```ts const seam = new SeamHttp('your-api-key') const request = seam.devices.list() -console.log('Sending request', request.url, request.method, request.body) +console.log(`${request.method} ${request.url}`, JSON.stringify(request.body)) -const devices = await request // or `await request.execute()` if you prefer - -console.log(devices) +const devices = await request.execute() ``` ## Development and Testing From d5de77d86378821575118867a33a99cee064261b Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 19:10:55 +0000 Subject: [PATCH 20/29] Update README.md Co-authored-by: Evan Sosenko --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17c76868..114bdb11 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ This API is used internally and is not directly supported. #### Inspecting the Request All client methods return an instance of `SeamHttpRequest`. -Inspect the request before it is sent to the server by intentionally not awaiting the `SeamHttpRequest`; +Inspect the request before it is sent to the server by intentionally not awaiting the `SeamHttpRequest`: ```ts const seam = new SeamHttp('your-api-key') From f963b61520851e5402535f0f84b15d9d2dc2c038 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 19:15:30 +0000 Subject: [PATCH 21/29] Rename query -> params because it's more inline with our naming --- generate-routes.ts | 4 ++-- src/lib/seam/connect/routes/connect-webviews.ts | 2 +- src/lib/seam/connect/seam-http-request.ts | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index 70cd6ebd..1ff846b4 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -374,8 +374,8 @@ const renderClassMethod = ({ return new SeamHttpRequest(this, { path: '${path}', method: '${snakeCase(method)}', ${ - requestFormat === 'params' ? 'query: params,' : '' - } ${requestFormat === 'body' ? 'body: body,' : ''} + requestFormat === 'params' ? 'params,' : '' + } ${requestFormat === 'body' ? 'body,' : ''} responseKey: ${resource === null ? 'undefined' : `'${resource}'`}, ${resource === 'action_attempt' ? 'options' : ''} }) diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index cb63c945..00e5c801 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -220,7 +220,7 @@ export class SeamHttpConnectWebviews { return new SeamHttpRequest(this, { path: '/connect_webviews/view', method: 'get', - query: params, + params, responseKey: undefined, }) } diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index a1ecccf3..bc3045d5 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -15,7 +15,7 @@ export interface SeamHttpRequestConfig { readonly path: string readonly method: Method readonly body?: TBody - readonly query?: undefined | Record + readonly params?: undefined | Record readonly responseKey: TResponseKey readonly options?: Pick } @@ -51,12 +51,12 @@ export class SeamHttpRequest< throw new Error('baseUrl is required') } - const query = this.#config.query - if (query === undefined) { + const params = this.#config.params + if (params === undefined) { return new URL(this.#config.path, baseUrl) } return new URL( - `${this.#config.path}?${serializeUrlSearchParams(query)}`, + `${this.#config.path}?${serializeUrlSearchParams(params)}`, baseUrl, ) } @@ -77,7 +77,7 @@ export class SeamHttpRequest< url: this.#config.path, method: this.#config.method, data: this.#config.body as TBody, - params: this.#config.query, + params: this.#config.params, }) if (this.responseKey === undefined) { return undefined as TResponseKey extends keyof TResponse From 088414a38cd4367d1985f526f92173eb792bc820 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 19:30:02 +0000 Subject: [PATCH 22/29] Update src/lib/seam/connect/seam-http-request.ts Co-authored-by: Evan Sosenko --- src/lib/seam/connect/seam-http-request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index bc3045d5..b489b091 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -11,7 +11,7 @@ interface SeamHttpRequestParent { readonly defaults: Required } -export interface SeamHttpRequestConfig { +interface SeamHttpRequestConfig { readonly path: string readonly method: Method readonly body?: TBody From 951856e47cc8a1a36a76642e082c52947e848ca3 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Tue, 26 Mar 2024 19:36:48 +0000 Subject: [PATCH 23/29] Use client.defaults.paramsSerializer if possible --- src/lib/seam/connect/seam-http-request.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index bc3045d5..7831fb06 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -55,10 +55,13 @@ export class SeamHttpRequest< if (params === undefined) { return new URL(this.#config.path, baseUrl) } - return new URL( - `${this.#config.path}?${serializeUrlSearchParams(params)}`, - baseUrl, - ) + + const serializer = + typeof client.defaults.paramsSerializer === 'function' + ? client.defaults.paramsSerializer + : serializeUrlSearchParams + + return new URL(`${this.#config.path}?${serializer(params)}`, baseUrl) } public get method(): Method { From c15771701a78a47df3de3fdb5779d38ab8a50463 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 26 Mar 2024 15:30:54 -0700 Subject: [PATCH 24/29] Test for URL object property matches --- test/seam/connect/seam-http-request.test.ts | 71 ++++++++++++++------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index e9bfa3d1..3c67a89e 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -5,55 +5,82 @@ import { SeamHttp } from '@seamapi/http/connect' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' -test('returns a SeamHttpRequest', async (t) => { +test('SeamHttp: returns a SeamHttpRequest', async (t) => { const { seed, endpoint } = await getTestServer(t) const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) - const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 }) + const request = seam.devices.get({ device_id: seed.august_device_1 }) - t.true(deviceRequest instanceof SeamHttpRequest) - t.is(deviceRequest.url.pathname, '/devices/get') - t.deepEqual(deviceRequest.body, { + t.true(request instanceof SeamHttpRequest) + t.truthy(request.url) + t.is(request.responseKey, 'device') + t.deepEqual(request.body, { device_id: seed.august_device_1, }) - t.is(deviceRequest.responseKey, 'device') - const device = await deviceRequest + + const device = await request t.is(device.workspace_id, seed.seed_workspace_1) t.is(device.device_id, seed.august_device_1) // Ensure that the type of the response is correct. - type Expected = ResponseFromSeamHttpRequest - + type Expected = ResponseFromSeamHttpRequest const validDeviceType: Expected['device_type'] = 'august_lock' t.truthy(validDeviceType) - // @ts-expect-error because it's an invalid device type. + // @ts-expect-error invalid device type. const invalidDeviceType: Expected['device_type'] = 'invalid_device_type' t.truthy(invalidDeviceType) }) -test("populates SeamHttpRequest's url property", async (t) => { +test('SeamHttpRequest: url is a URL for post requests', async (t) => { const { seed, endpoint } = await getTestServer(t) const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) - const deviceRequest = seam.devices.get({ device_id: 'abc123' }) + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject(new URL(`${endpoint}/devices/get`)), + ) +}) - t.is(deviceRequest.url.pathname, '/devices/get') - t.is(deviceRequest.url.search, '') +test('SeamHttpRequest: url is a URL for get requests', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) - const connectWebviewsViewRequest = seam.connectWebviews.view({ - connect_webview_id: 'abc123', - auth_token: 'invalid', + const { url } = seam.connectWebviews.view({ + connect_webview_id: 'connect_webview_1', + auth_token: 'auth_token_1', }) - t.is(connectWebviewsViewRequest.url.pathname, '/connect_webviews/view') - t.is(connectWebviewsViewRequest.url.searchParams.get('auth_token'), 'invalid') - t.is( - connectWebviewsViewRequest.url.searchParams.get('connect_webview_id'), - 'abc123', + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject( + new URL( + `${endpoint}/connect_webviews/view?auth_token=auth_token_1&connect_webview_id=connect_webview_1`, + ), + ), ) }) +const toPlainUrlObject = (url: URL): Omit => { + return { + pathname: url.pathname, + hash: url.hash, + hostname: url.hostname, + protocol: url.protocol, + username: url.username, + port: url.port, + password: url.password, + host: url.host, + href: url.href, + origin: url.origin, + search: url.search, + } +} + type ResponseFromSeamHttpRequest = T extends SeamHttpRequest ? TResponseKey extends keyof TResponse From b3de0cdf42f4856db0c5358f4e1e662b9d571a36 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 26 Mar 2024 16:09:24 -0700 Subject: [PATCH 25/29] Add tests for endpoints with and without origins --- src/lib/seam/connect/seam-http-request.ts | 35 ++++++--- test/seam/connect/seam-http-request.test.ts | 81 +++++++++++++++++++++ 2 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index e5b64bbd..80f69820 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -46,22 +46,23 @@ export class SeamHttpRequest< public get url(): URL { const { client } = this.#parent - const baseUrl = client.defaults.baseURL - if (baseUrl === undefined) { - throw new Error('baseUrl is required') - } - - const params = this.#config.params - if (params === undefined) { - return new URL(this.#config.path, baseUrl) - } + const { params } = this.#config const serializer = typeof client.defaults.paramsSerializer === 'function' ? client.defaults.paramsSerializer : serializeUrlSearchParams - return new URL(`${this.#config.path}?${serializer(params)}`, baseUrl) + const origin = getUrlPrefix(client.defaults.baseURL ?? '') + + const pathname = this.#config.path.startsWith('/') + ? this.#config.path + : `/${this.#config.path}` + + const path = + params == null ? pathname : [pathname, serializer(params)].join('?') + + return new URL([origin, path].join('')) } public get method(): Method { @@ -128,3 +129,17 @@ export class SeamHttpRequest< return this.execute().then(onfulfilled, onrejected) } } + +const getUrlPrefix = (input: string): string => { + try { + const url = new URL(input).toString() + if (url.endsWith('/')) return url.slice(0, -1) + return url + } catch (err: unknown) { + if (globalThis.location != null) { + const pathname = input.startsWith('/') ? input : `/${input}` + return new URL([globalThis.location.origin, pathname].join('')).toString() + } + throw err + } +} diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 3c67a89e..b8253f76 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -65,6 +65,87 @@ test('SeamHttpRequest: url is a URL for get requests', async (t) => { ) }) +test('SeamHttpRequest: url is a URL when endpoint is a url without a path', async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: 'https://example.com', + }) + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject(new URL('https://example.com/devices/get')), + ) +}) + +test('SeamHttpRequest: url is a URL when endpoint is a url with a path', async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: 'https://example.com/some/sub/path', + }) + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject(new URL('https://example.com/some/sub/path/devices/get')), + ) +}) + +test.failing( + 'SeamHttpRequest: url is a URL when endpoint is path', + async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: '/some/sub/path', + }) + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject( + new URL('https://example.com/some/sub/path/devices/get'), + ), + ) + }, +) + +test.failing( + 'SeamHttpRequest: url is a URL when endpoint is empty', + async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: '', + }) + + // TODO: Set globalThis.location.origin = 'https://example.com' + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.true(url instanceof URL) + t.deepEqual( + toPlainUrlObject(url), + toPlainUrlObject(new URL('https://example.com/devices/get')), + ) + }, +) + +test('SeamHttpRequest: url throws if unable to resolve origin', async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: '', + }) + + const request = seam.devices.get({ device_id: 'abc123' }) + + t.throws(() => request.url, { code: 'ERR_INVALID_URL' }) +}) + const toPlainUrlObject = (url: URL): Omit => { return { pathname: url.pathname, From 871474ae4a27a36468107e4a0d38fffbf336d3b5 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 26 Mar 2024 18:12:13 -0700 Subject: [PATCH 26/29] Use template literal over join Co-authored-by: Charles Pick --- src/lib/seam/connect/seam-http-request.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 80f69820..5f5b45f6 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -60,9 +60,9 @@ export class SeamHttpRequest< : `/${this.#config.path}` const path = - params == null ? pathname : [pathname, serializer(params)].join('?') + params == null ? pathname : `${pathname}?${serializer(params)}` - return new URL([origin, path].join('')) + return new URL(`${origin}${path}`) } public get method(): Method { @@ -138,7 +138,7 @@ const getUrlPrefix = (input: string): string => { } catch (err: unknown) { if (globalThis.location != null) { const pathname = input.startsWith('/') ? input : `/${input}` - return new URL([globalThis.location.origin, pathname].join('')).toString() + return new URL(`${globalThis.location.origin}${pathname}`).toString() } throw err } From 4da3af6fc30d4f4ba1c2e25a090b236b943ddc59 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Wed, 27 Mar 2024 01:12:43 +0000 Subject: [PATCH 27/29] ci: Format code --- src/lib/seam/connect/seam-http-request.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 5f5b45f6..3b405fe2 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -59,8 +59,7 @@ export class SeamHttpRequest< ? this.#config.path : `/${this.#config.path}` - const path = - params == null ? pathname : `${pathname}?${serializer(params)}` + const path = params == null ? pathname : `${pathname}?${serializer(params)}` return new URL(`${origin}${path}`) } From 34efe7de4611be368f29d5c4bcd9428035cf6ea0 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 26 Mar 2024 18:21:36 -0700 Subject: [PATCH 28/29] Use URL.canParse --- src/lib/seam/connect/seam-http-request.ts | 15 ++++++++------- test/seam/connect/seam-http-request.test.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 3b405fe2..357914db 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -130,15 +130,16 @@ export class SeamHttpRequest< } const getUrlPrefix = (input: string): string => { - try { + if (URL.canParse(input)) { const url = new URL(input).toString() if (url.endsWith('/')) return url.slice(0, -1) return url - } catch (err: unknown) { - if (globalThis.location != null) { - const pathname = input.startsWith('/') ? input : `/${input}` - return new URL(`${globalThis.location.origin}${pathname}`).toString() - } - throw err } + if (globalThis.location != null) { + const pathname = input.startsWith('/') ? input : `/${input}` + return new URL(`${globalThis.location.origin}${pathname}`).toString() + } + throw new Error( + `Cannot resolve origin from ${input} in a non-browser environment`, + ) } diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index b8253f76..073d6c2a 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -143,7 +143,7 @@ test('SeamHttpRequest: url throws if unable to resolve origin', async (t) => { const request = seam.devices.get({ device_id: 'abc123' }) - t.throws(() => request.url, { code: 'ERR_INVALID_URL' }) + t.throws(() => request.url, { message: /Cannot resolve origin/ }) }) const toPlainUrlObject = (url: URL): Omit => { From 65021e486cfea2ff6a9c643b946a4e1ed65573f9 Mon Sep 17 00:00:00 2001 From: Charles Pick Date: Wed, 27 Mar 2024 10:38:42 +0000 Subject: [PATCH 29/29] Remove TBody type parameter --- generate-routes.ts | 7 +-- .../connect/routes/access-codes-unmanaged.ts | 30 ++------- src/lib/seam/connect/routes/access-codes.ts | 39 +++--------- .../seam/connect/routes/acs-access-groups.ts | 28 ++------- .../connect/routes/acs-credential-pools.ts | 6 +- ...acs-credential-provisioning-automations.ts | 1 - .../seam/connect/routes/acs-credentials.ts | 40 +++--------- src/lib/seam/connect/routes/acs-entrances.ts | 15 +---- src/lib/seam/connect/routes/acs-systems.ts | 12 +--- src/lib/seam/connect/routes/acs-users.ts | 58 ++++------------- .../seam/connect/routes/action-attempts.ts | 12 +--- .../seam/connect/routes/client-sessions.ts | 38 +++-------- .../seam/connect/routes/connect-webviews.ts | 26 ++------ .../seam/connect/routes/connected-accounts.ts | 22 ++----- .../seam/connect/routes/devices-simulate.ts | 4 +- .../seam/connect/routes/devices-unmanaged.ts | 16 +---- src/lib/seam/connect/routes/devices.ts | 28 ++------- src/lib/seam/connect/routes/events.ts | 12 +--- src/lib/seam/connect/routes/locks.ts | 24 ++----- src/lib/seam/connect/routes/networks.ts | 12 +--- .../routes/noise-sensors-noise-thresholds.ts | 15 +---- .../seam/connect/routes/phones-simulate.ts | 6 +- src/lib/seam/connect/routes/phones.ts | 12 +--- .../thermostats-climate-setting-schedules.ts | 15 +---- src/lib/seam/connect/routes/thermostats.ts | 46 +++----------- .../user-identities-enrollment-automations.ts | 9 +-- .../seam/connect/routes/user-identities.ts | 63 ++++--------------- src/lib/seam/connect/routes/webhooks.ts | 26 ++------ src/lib/seam/connect/routes/workspaces.ts | 20 ++---- src/lib/seam/connect/seam-http-request.ts | 15 +++-- test/seam/connect/seam-http-request.test.ts | 2 +- 31 files changed, 121 insertions(+), 538 deletions(-) diff --git a/generate-routes.ts b/generate-routes.ts index 1ff846b4..6d4c091f 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -361,12 +361,7 @@ const renderClassMethod = ({ namespace, })}, ${renderClassMethodOptions({ resource })} - ): SeamHttpRequest<${isRequestParamOptional ? 'undefined | ' : ''}${renderRequestType( - { - name, - namespace, - }, - )}, ${ + ): SeamHttpRequest<${ resource === null ? 'void, undefined' : `${renderResponseType({ name, namespace })}, '${resource}'` diff --git a/src/lib/seam/connect/routes/access-codes-unmanaged.ts b/src/lib/seam/connect/routes/access-codes-unmanaged.ts index 9b35bc11..813eff99 100644 --- a/src/lib/seam/connect/routes/access-codes-unmanaged.ts +++ b/src/lib/seam/connect/routes/access-codes-unmanaged.ts @@ -156,11 +156,7 @@ export class SeamHttpAccessCodesUnmanaged { convertToManaged( body?: AccessCodesUnmanagedConvertToManagedBody, - ): SeamHttpRequest< - undefined | AccessCodesUnmanagedConvertToManagedBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/unmanaged/convert_to_managed', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpAccessCodesUnmanaged { delete( body?: AccessCodesUnmanagedDeleteBody, - ): SeamHttpRequest< - undefined | AccessCodesUnmanagedDeleteBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/unmanaged/delete', method: 'post', @@ -186,11 +178,7 @@ export class SeamHttpAccessCodesUnmanaged { get( body?: AccessCodesUnmanagedGetParams, - ): SeamHttpRequest< - undefined | AccessCodesUnmanagedGetParams, - AccessCodesUnmanagedGetResponse, - 'access_code' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/unmanaged/get', method: 'post', @@ -201,11 +189,7 @@ export class SeamHttpAccessCodesUnmanaged { list( body?: AccessCodesUnmanagedListParams, - ): SeamHttpRequest< - undefined | AccessCodesUnmanagedListParams, - AccessCodesUnmanagedListResponse, - 'access_codes' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/unmanaged/list', method: 'post', @@ -216,11 +200,7 @@ export class SeamHttpAccessCodesUnmanaged { update( body?: AccessCodesUnmanagedUpdateBody, - ): SeamHttpRequest< - undefined | AccessCodesUnmanagedUpdateBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/unmanaged/update', method: 'post', diff --git a/src/lib/seam/connect/routes/access-codes.ts b/src/lib/seam/connect/routes/access-codes.ts index 50305b31..968bcab4 100644 --- a/src/lib/seam/connect/routes/access-codes.ts +++ b/src/lib/seam/connect/routes/access-codes.ts @@ -161,11 +161,7 @@ export class SeamHttpAccessCodes { create( body?: AccessCodesCreateBody, - ): SeamHttpRequest< - undefined | AccessCodesCreateBody, - AccessCodesCreateResponse, - 'access_code' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/create', method: 'post', @@ -176,11 +172,7 @@ export class SeamHttpAccessCodes { createMultiple( body?: AccessCodesCreateMultipleBody, - ): SeamHttpRequest< - undefined | AccessCodesCreateMultipleBody, - AccessCodesCreateMultipleResponse, - 'access_codes' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/create_multiple', method: 'post', @@ -189,9 +181,7 @@ export class SeamHttpAccessCodes { }) } - delete( - body?: AccessCodesDeleteBody, - ): SeamHttpRequest { + delete(body?: AccessCodesDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/delete', method: 'post', @@ -202,11 +192,7 @@ export class SeamHttpAccessCodes { generateCode( body?: AccessCodesGenerateCodeBody, - ): SeamHttpRequest< - undefined | AccessCodesGenerateCodeBody, - AccessCodesGenerateCodeResponse, - 'generated_code' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/generate_code', method: 'post', @@ -217,11 +203,7 @@ export class SeamHttpAccessCodes { get( body?: AccessCodesGetParams, - ): SeamHttpRequest< - undefined | AccessCodesGetParams, - AccessCodesGetResponse, - 'access_code' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/get', method: 'post', @@ -232,11 +214,7 @@ export class SeamHttpAccessCodes { list( body?: AccessCodesListParams, - ): SeamHttpRequest< - undefined | AccessCodesListParams, - AccessCodesListResponse, - 'access_codes' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/list', method: 'post', @@ -248,7 +226,6 @@ export class SeamHttpAccessCodes { pullBackupAccessCode( body?: AccessCodesPullBackupAccessCodeBody, ): SeamHttpRequest< - undefined | AccessCodesPullBackupAccessCodeBody, AccessCodesPullBackupAccessCodeResponse, 'backup_access_code' > { @@ -260,9 +237,7 @@ export class SeamHttpAccessCodes { }) } - update( - body?: AccessCodesUpdateBody, - ): SeamHttpRequest { + update(body?: AccessCodesUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/access_codes/update', method: 'post', diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index 6da2dda1..71f93cb0 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -154,9 +154,7 @@ export class SeamHttpAcsAccessGroups { await clientSessions.get() } - addUser( - body?: AcsAccessGroupsAddUserBody, - ): SeamHttpRequest { + addUser(body?: AcsAccessGroupsAddUserBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/access_groups/add_user', method: 'post', @@ -167,11 +165,7 @@ export class SeamHttpAcsAccessGroups { get( body?: AcsAccessGroupsGetParams, - ): SeamHttpRequest< - undefined | AcsAccessGroupsGetParams, - AcsAccessGroupsGetResponse, - 'acs_access_group' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/access_groups/get', method: 'post', @@ -182,11 +176,7 @@ export class SeamHttpAcsAccessGroups { list( body?: AcsAccessGroupsListParams, - ): SeamHttpRequest< - undefined | AcsAccessGroupsListParams, - AcsAccessGroupsListResponse, - 'acs_access_groups' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/access_groups/list', method: 'post', @@ -197,11 +187,7 @@ export class SeamHttpAcsAccessGroups { listUsers( body?: AcsAccessGroupsListUsersParams, - ): SeamHttpRequest< - undefined | AcsAccessGroupsListUsersParams, - AcsAccessGroupsListUsersResponse, - 'acs_users' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/access_groups/list_users', method: 'post', @@ -212,11 +198,7 @@ export class SeamHttpAcsAccessGroups { removeUser( body?: AcsAccessGroupsRemoveUserBody, - ): SeamHttpRequest< - undefined | AcsAccessGroupsRemoveUserBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/access_groups/remove_user', method: 'post', diff --git a/src/lib/seam/connect/routes/acs-credential-pools.ts b/src/lib/seam/connect/routes/acs-credential-pools.ts index eed89fe1..d812efa6 100644 --- a/src/lib/seam/connect/routes/acs-credential-pools.ts +++ b/src/lib/seam/connect/routes/acs-credential-pools.ts @@ -156,11 +156,7 @@ export class SeamHttpAcsCredentialPools { list( body?: AcsCredentialPoolsListParams, - ): SeamHttpRequest< - undefined | AcsCredentialPoolsListParams, - AcsCredentialPoolsListResponse, - 'acs_credential_pools' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credential_pools/list', method: 'post', diff --git a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts index 8bbefe08..3c8736ea 100644 --- a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +++ b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts @@ -160,7 +160,6 @@ export class SeamHttpAcsCredentialProvisioningAutomations { launch( body?: AcsCredentialProvisioningAutomationsLaunchBody, ): SeamHttpRequest< - undefined | AcsCredentialProvisioningAutomationsLaunchBody, AcsCredentialProvisioningAutomationsLaunchResponse, 'acs_credential_provisioning_automation' > { diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index 45d69197..f8c03175 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -156,11 +156,7 @@ export class SeamHttpAcsCredentials { assign( body?: AcsCredentialsAssignBody, - ): SeamHttpRequest< - undefined | AcsCredentialsAssignBody, - AcsCredentialsAssignResponse, - 'acs_credential' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/assign', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpAcsCredentials { create( body?: AcsCredentialsCreateBody, - ): SeamHttpRequest< - undefined | AcsCredentialsCreateBody, - AcsCredentialsCreateResponse, - 'acs_credential' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/create', method: 'post', @@ -184,9 +176,7 @@ export class SeamHttpAcsCredentials { }) } - delete( - body?: AcsCredentialsDeleteBody, - ): SeamHttpRequest { + delete(body?: AcsCredentialsDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/delete', method: 'post', @@ -197,11 +187,7 @@ export class SeamHttpAcsCredentials { get( body?: AcsCredentialsGetParams, - ): SeamHttpRequest< - undefined | AcsCredentialsGetParams, - AcsCredentialsGetResponse, - 'acs_credential' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/get', method: 'post', @@ -212,11 +198,7 @@ export class SeamHttpAcsCredentials { list( body?: AcsCredentialsListParams, - ): SeamHttpRequest< - undefined | AcsCredentialsListParams, - AcsCredentialsListResponse, - 'acs_credentials' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/list', method: 'post', @@ -227,11 +209,7 @@ export class SeamHttpAcsCredentials { unassign( body?: AcsCredentialsUnassignBody, - ): SeamHttpRequest< - undefined | AcsCredentialsUnassignBody, - AcsCredentialsUnassignResponse, - 'acs_credential' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/unassign', method: 'post', @@ -242,11 +220,7 @@ export class SeamHttpAcsCredentials { update( body?: AcsCredentialsUpdateBody, - ): SeamHttpRequest< - undefined | AcsCredentialsUpdateBody, - AcsCredentialsUpdateResponse, - 'acs_credential' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/credentials/update', method: 'post', diff --git a/src/lib/seam/connect/routes/acs-entrances.ts b/src/lib/seam/connect/routes/acs-entrances.ts index 10d7e1db..bdb3cb3e 100644 --- a/src/lib/seam/connect/routes/acs-entrances.ts +++ b/src/lib/seam/connect/routes/acs-entrances.ts @@ -156,11 +156,7 @@ export class SeamHttpAcsEntrances { get( body?: AcsEntrancesGetParams, - ): SeamHttpRequest< - undefined | AcsEntrancesGetParams, - AcsEntrancesGetResponse, - 'acs_entrance' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/entrances/get', method: 'post', @@ -171,7 +167,7 @@ export class SeamHttpAcsEntrances { grantAccess( body?: AcsEntrancesGrantAccessBody, - ): SeamHttpRequest { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/entrances/grant_access', method: 'post', @@ -182,11 +178,7 @@ export class SeamHttpAcsEntrances { list( body?: AcsEntrancesListParams, - ): SeamHttpRequest< - undefined | AcsEntrancesListParams, - AcsEntrancesListResponse, - 'acs_entrances' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/entrances/list', method: 'post', @@ -198,7 +190,6 @@ export class SeamHttpAcsEntrances { listCredentialsWithAccess( body?: AcsEntrancesListCredentialsWithAccessParams, ): SeamHttpRequest< - undefined | AcsEntrancesListCredentialsWithAccessParams, AcsEntrancesListCredentialsWithAccessResponse, 'acs_credentials' > { diff --git a/src/lib/seam/connect/routes/acs-systems.ts b/src/lib/seam/connect/routes/acs-systems.ts index b2f65d0a..bd79b213 100644 --- a/src/lib/seam/connect/routes/acs-systems.ts +++ b/src/lib/seam/connect/routes/acs-systems.ts @@ -156,11 +156,7 @@ export class SeamHttpAcsSystems { get( body?: AcsSystemsGetParams, - ): SeamHttpRequest< - undefined | AcsSystemsGetParams, - AcsSystemsGetResponse, - 'acs_system' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/systems/get', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpAcsSystems { list( body?: AcsSystemsListParams, - ): SeamHttpRequest< - undefined | AcsSystemsListParams, - AcsSystemsListResponse, - 'acs_systems' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/systems/list', method: 'post', diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index e536f12f..67418c56 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -156,11 +156,7 @@ export class SeamHttpAcsUsers { addToAccessGroup( body?: AcsUsersAddToAccessGroupBody, - ): SeamHttpRequest< - undefined | AcsUsersAddToAccessGroupBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/add_to_access_group', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpAcsUsers { create( body?: AcsUsersCreateBody, - ): SeamHttpRequest< - undefined | AcsUsersCreateBody, - AcsUsersCreateResponse, - 'acs_user' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/create', method: 'post', @@ -184,9 +176,7 @@ export class SeamHttpAcsUsers { }) } - delete( - body?: AcsUsersDeleteBody, - ): SeamHttpRequest { + delete(body?: AcsUsersDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/delete', method: 'post', @@ -197,11 +187,7 @@ export class SeamHttpAcsUsers { get( body?: AcsUsersGetParams, - ): SeamHttpRequest< - undefined | AcsUsersGetParams, - AcsUsersGetResponse, - 'acs_user' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/get', method: 'post', @@ -212,11 +198,7 @@ export class SeamHttpAcsUsers { list( body?: AcsUsersListParams, - ): SeamHttpRequest< - undefined | AcsUsersListParams, - AcsUsersListResponse, - 'acs_users' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/list', method: 'post', @@ -227,11 +209,7 @@ export class SeamHttpAcsUsers { listAccessibleEntrances( body?: AcsUsersListAccessibleEntrancesParams, - ): SeamHttpRequest< - undefined | AcsUsersListAccessibleEntrancesParams, - AcsUsersListAccessibleEntrancesResponse, - 'acs_entrances' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/list_accessible_entrances', method: 'post', @@ -242,11 +220,7 @@ export class SeamHttpAcsUsers { removeFromAccessGroup( body?: AcsUsersRemoveFromAccessGroupBody, - ): SeamHttpRequest< - undefined | AcsUsersRemoveFromAccessGroupBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/remove_from_access_group', method: 'post', @@ -257,11 +231,7 @@ export class SeamHttpAcsUsers { revokeAccessToAllEntrances( body?: AcsUsersRevokeAccessToAllEntrancesBody, - ): SeamHttpRequest< - undefined | AcsUsersRevokeAccessToAllEntrancesBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/revoke_access_to_all_entrances', method: 'post', @@ -270,9 +240,7 @@ export class SeamHttpAcsUsers { }) } - suspend( - body?: AcsUsersSuspendBody, - ): SeamHttpRequest { + suspend(body?: AcsUsersSuspendBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/suspend', method: 'post', @@ -281,9 +249,7 @@ export class SeamHttpAcsUsers { }) } - unsuspend( - body?: AcsUsersUnsuspendBody, - ): SeamHttpRequest { + unsuspend(body?: AcsUsersUnsuspendBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/unsuspend', method: 'post', @@ -292,9 +258,7 @@ export class SeamHttpAcsUsers { }) } - update( - body?: AcsUsersUpdateBody, - ): SeamHttpRequest { + update(body?: AcsUsersUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/acs/users/update', method: 'post', diff --git a/src/lib/seam/connect/routes/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts.ts index 1d510a27..e81c2bef 100644 --- a/src/lib/seam/connect/routes/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts.ts @@ -157,11 +157,7 @@ export class SeamHttpActionAttempts { get( body?: ActionAttemptsGetParams, options: Pick = {}, - ): SeamHttpRequest< - undefined | ActionAttemptsGetParams, - ActionAttemptsGetResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/action_attempts/get', method: 'post', @@ -173,11 +169,7 @@ export class SeamHttpActionAttempts { list( body?: ActionAttemptsListParams, - ): SeamHttpRequest< - undefined | ActionAttemptsListParams, - ActionAttemptsListResponse, - 'action_attempts' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/action_attempts/list', method: 'post', diff --git a/src/lib/seam/connect/routes/client-sessions.ts b/src/lib/seam/connect/routes/client-sessions.ts index dd986144..13912df8 100644 --- a/src/lib/seam/connect/routes/client-sessions.ts +++ b/src/lib/seam/connect/routes/client-sessions.ts @@ -154,11 +154,7 @@ export class SeamHttpClientSessions { create( body?: ClientSessionsCreateBody, - ): SeamHttpRequest< - undefined | ClientSessionsCreateBody, - ClientSessionsCreateResponse, - 'client_session' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/create', method: 'post', @@ -167,9 +163,7 @@ export class SeamHttpClientSessions { }) } - delete( - body?: ClientSessionsDeleteBody, - ): SeamHttpRequest { + delete(body?: ClientSessionsDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/delete', method: 'post', @@ -180,11 +174,7 @@ export class SeamHttpClientSessions { get( body?: ClientSessionsGetParams, - ): SeamHttpRequest< - undefined | ClientSessionsGetParams, - ClientSessionsGetResponse, - 'client_session' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/get', method: 'post', @@ -195,11 +185,7 @@ export class SeamHttpClientSessions { getOrCreate( body?: ClientSessionsGetOrCreateBody, - ): SeamHttpRequest< - undefined | ClientSessionsGetOrCreateBody, - ClientSessionsGetOrCreateResponse, - 'client_session' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/get_or_create', method: 'post', @@ -210,11 +196,7 @@ export class SeamHttpClientSessions { grantAccess( body?: ClientSessionsGrantAccessBody, - ): SeamHttpRequest< - undefined | ClientSessionsGrantAccessBody, - ClientSessionsGrantAccessResponse, - 'client_session' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/grant_access', method: 'post', @@ -225,11 +207,7 @@ export class SeamHttpClientSessions { list( body?: ClientSessionsListParams, - ): SeamHttpRequest< - undefined | ClientSessionsListParams, - ClientSessionsListResponse, - 'client_sessions' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/list', method: 'post', @@ -238,9 +216,7 @@ export class SeamHttpClientSessions { }) } - revoke( - body?: ClientSessionsRevokeBody, - ): SeamHttpRequest { + revoke(body?: ClientSessionsRevokeBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/client_sessions/revoke', method: 'post', diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index 00e5c801..99be2c74 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -160,11 +160,7 @@ export class SeamHttpConnectWebviews { create( body?: ConnectWebviewsCreateBody, - ): SeamHttpRequest< - undefined | ConnectWebviewsCreateBody, - ConnectWebviewsCreateResponse, - 'connect_webview' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connect_webviews/create', method: 'post', @@ -173,9 +169,7 @@ export class SeamHttpConnectWebviews { }) } - delete( - body?: ConnectWebviewsDeleteBody, - ): SeamHttpRequest { + delete(body?: ConnectWebviewsDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connect_webviews/delete', method: 'post', @@ -186,11 +180,7 @@ export class SeamHttpConnectWebviews { get( body?: ConnectWebviewsGetParams, - ): SeamHttpRequest< - undefined | ConnectWebviewsGetParams, - ConnectWebviewsGetResponse, - 'connect_webview' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connect_webviews/get', method: 'post', @@ -201,11 +191,7 @@ export class SeamHttpConnectWebviews { list( body?: ConnectWebviewsListParams, - ): SeamHttpRequest< - undefined | ConnectWebviewsListParams, - ConnectWebviewsListResponse, - 'connect_webviews' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connect_webviews/list', method: 'post', @@ -214,9 +200,7 @@ export class SeamHttpConnectWebviews { }) } - view( - params?: ConnectWebviewsViewParams, - ): SeamHttpRequest { + view(params?: ConnectWebviewsViewParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connect_webviews/view', method: 'get', diff --git a/src/lib/seam/connect/routes/connected-accounts.ts b/src/lib/seam/connect/routes/connected-accounts.ts index c485518b..2d82aca7 100644 --- a/src/lib/seam/connect/routes/connected-accounts.ts +++ b/src/lib/seam/connect/routes/connected-accounts.ts @@ -154,9 +154,7 @@ export class SeamHttpConnectedAccounts { await clientSessions.get() } - delete( - body?: ConnectedAccountsDeleteBody, - ): SeamHttpRequest { + delete(body?: ConnectedAccountsDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connected_accounts/delete', method: 'post', @@ -167,11 +165,7 @@ export class SeamHttpConnectedAccounts { get( body?: ConnectedAccountsGetParams, - ): SeamHttpRequest< - undefined | ConnectedAccountsGetParams, - ConnectedAccountsGetResponse, - 'connected_account' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connected_accounts/get', method: 'post', @@ -182,11 +176,7 @@ export class SeamHttpConnectedAccounts { list( body?: ConnectedAccountsListParams, - ): SeamHttpRequest< - undefined | ConnectedAccountsListParams, - ConnectedAccountsListResponse, - 'connected_accounts' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connected_accounts/list', method: 'post', @@ -197,11 +187,7 @@ export class SeamHttpConnectedAccounts { update( body?: ConnectedAccountsUpdateBody, - ): SeamHttpRequest< - undefined | ConnectedAccountsUpdateBody, - ConnectedAccountsUpdateResponse, - 'connected_account' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/connected_accounts/update', method: 'post', diff --git a/src/lib/seam/connect/routes/devices-simulate.ts b/src/lib/seam/connect/routes/devices-simulate.ts index 27065d95..dd840c44 100644 --- a/src/lib/seam/connect/routes/devices-simulate.ts +++ b/src/lib/seam/connect/routes/devices-simulate.ts @@ -154,9 +154,7 @@ export class SeamHttpDevicesSimulate { await clientSessions.get() } - remove( - body?: DevicesSimulateRemoveBody, - ): SeamHttpRequest { + remove(body?: DevicesSimulateRemoveBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/simulate/remove', method: 'post', diff --git a/src/lib/seam/connect/routes/devices-unmanaged.ts b/src/lib/seam/connect/routes/devices-unmanaged.ts index f9ace170..84c205bc 100644 --- a/src/lib/seam/connect/routes/devices-unmanaged.ts +++ b/src/lib/seam/connect/routes/devices-unmanaged.ts @@ -156,11 +156,7 @@ export class SeamHttpDevicesUnmanaged { get( body?: DevicesUnmanagedGetParams, - ): SeamHttpRequest< - undefined | DevicesUnmanagedGetParams, - DevicesUnmanagedGetResponse, - 'device' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/unmanaged/get', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpDevicesUnmanaged { list( body?: DevicesUnmanagedListParams, - ): SeamHttpRequest< - undefined | DevicesUnmanagedListParams, - DevicesUnmanagedListResponse, - 'devices' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/unmanaged/list', method: 'post', @@ -184,9 +176,7 @@ export class SeamHttpDevicesUnmanaged { }) } - update( - body?: DevicesUnmanagedUpdateBody, - ): SeamHttpRequest { + update(body?: DevicesUnmanagedUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/unmanaged/update', method: 'post', diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 3163edcf..e09f6be0 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -164,9 +164,7 @@ export class SeamHttpDevices { return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults) } - delete( - body?: DevicesDeleteBody, - ): SeamHttpRequest { + delete(body?: DevicesDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/delete', method: 'post', @@ -175,13 +173,7 @@ export class SeamHttpDevices { }) } - get( - body?: DevicesGetParams, - ): SeamHttpRequest< - undefined | DevicesGetParams, - DevicesGetResponse, - 'device' - > { + get(body?: DevicesGetParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/get', method: 'post', @@ -192,11 +184,7 @@ export class SeamHttpDevices { list( body?: DevicesListParams, - ): SeamHttpRequest< - undefined | DevicesListParams, - DevicesListResponse, - 'devices' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/list', method: 'post', @@ -207,11 +195,7 @@ export class SeamHttpDevices { listDeviceProviders( body?: DevicesListDeviceProvidersParams, - ): SeamHttpRequest< - undefined | DevicesListDeviceProvidersParams, - DevicesListDeviceProvidersResponse, - 'device_providers' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/list_device_providers', method: 'post', @@ -220,9 +204,7 @@ export class SeamHttpDevices { }) } - update( - body?: DevicesUpdateBody, - ): SeamHttpRequest { + update(body?: DevicesUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/devices/update', method: 'post', diff --git a/src/lib/seam/connect/routes/events.ts b/src/lib/seam/connect/routes/events.ts index 623eee7f..d7996a59 100644 --- a/src/lib/seam/connect/routes/events.ts +++ b/src/lib/seam/connect/routes/events.ts @@ -154,9 +154,7 @@ export class SeamHttpEvents { await clientSessions.get() } - get( - body?: EventsGetParams, - ): SeamHttpRequest { + get(body?: EventsGetParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/events/get', method: 'post', @@ -165,13 +163,7 @@ export class SeamHttpEvents { }) } - list( - body?: EventsListParams, - ): SeamHttpRequest< - undefined | EventsListParams, - EventsListResponse, - 'events' - > { + list(body?: EventsListParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/events/list', method: 'post', diff --git a/src/lib/seam/connect/routes/locks.ts b/src/lib/seam/connect/routes/locks.ts index aa5ce367..73eb37d2 100644 --- a/src/lib/seam/connect/routes/locks.ts +++ b/src/lib/seam/connect/routes/locks.ts @@ -154,9 +154,7 @@ export class SeamHttpLocks { await clientSessions.get() } - get( - body?: LocksGetParams, - ): SeamHttpRequest { + get(body?: LocksGetParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/locks/get', method: 'post', @@ -165,13 +163,7 @@ export class SeamHttpLocks { }) } - list( - body?: LocksListParams, - ): SeamHttpRequest< - undefined | LocksListParams, - LocksListResponse, - 'devices' - > { + list(body?: LocksListParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/locks/list', method: 'post', @@ -183,11 +175,7 @@ export class SeamHttpLocks { lockDoor( body?: LocksLockDoorBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | LocksLockDoorBody, - LocksLockDoorResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/locks/lock_door', method: 'post', @@ -200,11 +188,7 @@ export class SeamHttpLocks { unlockDoor( body?: LocksUnlockDoorBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | LocksUnlockDoorBody, - LocksUnlockDoorResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/locks/unlock_door', method: 'post', diff --git a/src/lib/seam/connect/routes/networks.ts b/src/lib/seam/connect/routes/networks.ts index 67b15536..d127b731 100644 --- a/src/lib/seam/connect/routes/networks.ts +++ b/src/lib/seam/connect/routes/networks.ts @@ -156,11 +156,7 @@ export class SeamHttpNetworks { get( body?: NetworksGetParams, - ): SeamHttpRequest< - undefined | NetworksGetParams, - NetworksGetResponse, - 'network' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/networks/get', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpNetworks { list( body?: NetworksListParams, - ): SeamHttpRequest< - undefined | NetworksListParams, - NetworksListResponse, - 'networks' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/networks/list', method: 'post', diff --git a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts index 0e41dcd4..7bffab43 100644 --- a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +++ b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts @@ -160,7 +160,6 @@ export class SeamHttpNoiseSensorsNoiseThresholds { create( body?: NoiseSensorsNoiseThresholdsCreateBody, ): SeamHttpRequest< - undefined | NoiseSensorsNoiseThresholdsCreateBody, NoiseSensorsNoiseThresholdsCreateResponse, 'noise_threshold' > { @@ -174,11 +173,7 @@ export class SeamHttpNoiseSensorsNoiseThresholds { delete( body?: NoiseSensorsNoiseThresholdsDeleteBody, - ): SeamHttpRequest< - undefined | NoiseSensorsNoiseThresholdsDeleteBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/noise_sensors/noise_thresholds/delete', method: 'post', @@ -190,7 +185,6 @@ export class SeamHttpNoiseSensorsNoiseThresholds { get( body?: NoiseSensorsNoiseThresholdsGetParams, ): SeamHttpRequest< - undefined | NoiseSensorsNoiseThresholdsGetParams, NoiseSensorsNoiseThresholdsGetResponse, 'noise_threshold' > { @@ -205,7 +199,6 @@ export class SeamHttpNoiseSensorsNoiseThresholds { list( body?: NoiseSensorsNoiseThresholdsListParams, ): SeamHttpRequest< - undefined | NoiseSensorsNoiseThresholdsListParams, NoiseSensorsNoiseThresholdsListResponse, 'noise_thresholds' > { @@ -219,11 +212,7 @@ export class SeamHttpNoiseSensorsNoiseThresholds { update( body?: NoiseSensorsNoiseThresholdsUpdateBody, - ): SeamHttpRequest< - undefined | NoiseSensorsNoiseThresholdsUpdateBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/noise_sensors/noise_thresholds/update', method: 'post', diff --git a/src/lib/seam/connect/routes/phones-simulate.ts b/src/lib/seam/connect/routes/phones-simulate.ts index 7baed20d..45ef4752 100644 --- a/src/lib/seam/connect/routes/phones-simulate.ts +++ b/src/lib/seam/connect/routes/phones-simulate.ts @@ -156,11 +156,7 @@ export class SeamHttpPhonesSimulate { createSandboxPhone( body?: PhonesSimulateCreateSandboxPhoneBody, - ): SeamHttpRequest< - undefined | PhonesSimulateCreateSandboxPhoneBody, - PhonesSimulateCreateSandboxPhoneResponse, - 'phone' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/phones/simulate/create_sandbox_phone', method: 'post', diff --git a/src/lib/seam/connect/routes/phones.ts b/src/lib/seam/connect/routes/phones.ts index 89c017e8..e4b68223 100644 --- a/src/lib/seam/connect/routes/phones.ts +++ b/src/lib/seam/connect/routes/phones.ts @@ -159,9 +159,7 @@ export class SeamHttpPhones { return SeamHttpPhonesSimulate.fromClient(this.client, this.defaults) } - deactivate( - body?: PhonesDeactivateBody, - ): SeamHttpRequest { + deactivate(body?: PhonesDeactivateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/phones/deactivate', method: 'post', @@ -170,13 +168,7 @@ export class SeamHttpPhones { }) } - list( - body?: PhonesListParams, - ): SeamHttpRequest< - undefined | PhonesListParams, - PhonesListResponse, - 'phones' - > { + list(body?: PhonesListParams): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/phones/list', method: 'post', diff --git a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts index 9042f4a1..252b3ca4 100644 --- a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +++ b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts @@ -160,7 +160,6 @@ export class SeamHttpThermostatsClimateSettingSchedules { create( body?: ThermostatsClimateSettingSchedulesCreateBody, ): SeamHttpRequest< - undefined | ThermostatsClimateSettingSchedulesCreateBody, ThermostatsClimateSettingSchedulesCreateResponse, 'climate_setting_schedule' > { @@ -174,11 +173,7 @@ export class SeamHttpThermostatsClimateSettingSchedules { delete( body?: ThermostatsClimateSettingSchedulesDeleteBody, - ): SeamHttpRequest< - undefined | ThermostatsClimateSettingSchedulesDeleteBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/climate_setting_schedules/delete', method: 'post', @@ -190,7 +185,6 @@ export class SeamHttpThermostatsClimateSettingSchedules { get( body?: ThermostatsClimateSettingSchedulesGetParams, ): SeamHttpRequest< - undefined | ThermostatsClimateSettingSchedulesGetParams, ThermostatsClimateSettingSchedulesGetResponse, 'climate_setting_schedule' > { @@ -205,7 +199,6 @@ export class SeamHttpThermostatsClimateSettingSchedules { list( body?: ThermostatsClimateSettingSchedulesListParams, ): SeamHttpRequest< - undefined | ThermostatsClimateSettingSchedulesListParams, ThermostatsClimateSettingSchedulesListResponse, 'climate_setting_schedules' > { @@ -219,11 +212,7 @@ export class SeamHttpThermostatsClimateSettingSchedules { update( body?: ThermostatsClimateSettingSchedulesUpdateBody, - ): SeamHttpRequest< - undefined | ThermostatsClimateSettingSchedulesUpdateBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/climate_setting_schedules/update', method: 'post', diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index c483f647..f766eb0e 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -165,11 +165,7 @@ export class SeamHttpThermostats { cool( body?: ThermostatsCoolBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | ThermostatsCoolBody, - ThermostatsCoolResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/cool', method: 'post', @@ -181,11 +177,7 @@ export class SeamHttpThermostats { get( body?: ThermostatsGetParams, - ): SeamHttpRequest< - undefined | ThermostatsGetParams, - ThermostatsGetResponse, - 'thermostat' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/get', method: 'post', @@ -197,11 +189,7 @@ export class SeamHttpThermostats { heat( body?: ThermostatsHeatBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | ThermostatsHeatBody, - ThermostatsHeatResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/heat', method: 'post', @@ -214,11 +202,7 @@ export class SeamHttpThermostats { heatCool( body?: ThermostatsHeatCoolBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | ThermostatsHeatCoolBody, - ThermostatsHeatCoolResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/heat_cool', method: 'post', @@ -230,11 +214,7 @@ export class SeamHttpThermostats { list( body?: ThermostatsListParams, - ): SeamHttpRequest< - undefined | ThermostatsListParams, - ThermostatsListResponse, - 'thermostats' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/list', method: 'post', @@ -246,11 +226,7 @@ export class SeamHttpThermostats { off( body?: ThermostatsOffBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | ThermostatsOffBody, - ThermostatsOffResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/off', method: 'post', @@ -263,11 +239,7 @@ export class SeamHttpThermostats { setFanMode( body?: ThermostatsSetFanModeBody, options: Pick = {}, - ): SeamHttpRequest< - undefined | ThermostatsSetFanModeBody, - ThermostatsSetFanModeResponse, - 'action_attempt' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/set_fan_mode', method: 'post', @@ -277,9 +249,7 @@ export class SeamHttpThermostats { }) } - update( - body?: ThermostatsUpdateBody, - ): SeamHttpRequest { + update(body?: ThermostatsUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/thermostats/update', method: 'post', diff --git a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts index 18ec126e..30792eb2 100644 --- a/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +++ b/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts @@ -159,11 +159,7 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { delete( body?: UserIdentitiesEnrollmentAutomationsDeleteBody, - ): SeamHttpRequest< - undefined | UserIdentitiesEnrollmentAutomationsDeleteBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/enrollment_automations/delete', method: 'post', @@ -175,7 +171,6 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { get( body?: UserIdentitiesEnrollmentAutomationsGetParams, ): SeamHttpRequest< - undefined | UserIdentitiesEnrollmentAutomationsGetParams, UserIdentitiesEnrollmentAutomationsGetResponse, 'enrollment_automation' > { @@ -190,7 +185,6 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { launch( body?: UserIdentitiesEnrollmentAutomationsLaunchBody, ): SeamHttpRequest< - undefined | UserIdentitiesEnrollmentAutomationsLaunchBody, UserIdentitiesEnrollmentAutomationsLaunchResponse, 'enrollment_automation' > { @@ -205,7 +199,6 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations { list( body?: UserIdentitiesEnrollmentAutomationsListParams, ): SeamHttpRequest< - undefined | UserIdentitiesEnrollmentAutomationsListParams, UserIdentitiesEnrollmentAutomationsListResponse, 'enrollment_automations' > { diff --git a/src/lib/seam/connect/routes/user-identities.ts b/src/lib/seam/connect/routes/user-identities.ts index 8acb09f1..bc0e8f04 100644 --- a/src/lib/seam/connect/routes/user-identities.ts +++ b/src/lib/seam/connect/routes/user-identities.ts @@ -164,11 +164,7 @@ export class SeamHttpUserIdentities { addAcsUser( body?: UserIdentitiesAddAcsUserBody, - ): SeamHttpRequest< - undefined | UserIdentitiesAddAcsUserBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/add_acs_user', method: 'post', @@ -179,11 +175,7 @@ export class SeamHttpUserIdentities { create( body?: UserIdentitiesCreateBody, - ): SeamHttpRequest< - undefined | UserIdentitiesCreateBody, - UserIdentitiesCreateResponse, - 'user_identity' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/create', method: 'post', @@ -192,9 +184,7 @@ export class SeamHttpUserIdentities { }) } - delete( - body?: UserIdentitiesDeleteBody, - ): SeamHttpRequest { + delete(body?: UserIdentitiesDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/delete', method: 'post', @@ -205,11 +195,7 @@ export class SeamHttpUserIdentities { get( body?: UserIdentitiesGetParams, - ): SeamHttpRequest< - undefined | UserIdentitiesGetParams, - UserIdentitiesGetResponse, - 'user_identity' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/get', method: 'post', @@ -220,11 +206,7 @@ export class SeamHttpUserIdentities { grantAccessToDevice( body?: UserIdentitiesGrantAccessToDeviceBody, - ): SeamHttpRequest< - undefined | UserIdentitiesGrantAccessToDeviceBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/grant_access_to_device', method: 'post', @@ -235,11 +217,7 @@ export class SeamHttpUserIdentities { list( body?: UserIdentitiesListParams, - ): SeamHttpRequest< - undefined | UserIdentitiesListParams, - UserIdentitiesListResponse, - 'user_identities' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/list', method: 'post', @@ -251,7 +229,6 @@ export class SeamHttpUserIdentities { listAccessibleDevices( body?: UserIdentitiesListAccessibleDevicesParams, ): SeamHttpRequest< - undefined | UserIdentitiesListAccessibleDevicesParams, UserIdentitiesListAccessibleDevicesResponse, 'accessible_devices' > { @@ -265,11 +242,7 @@ export class SeamHttpUserIdentities { listAcsSystems( body?: UserIdentitiesListAcsSystemsParams, - ): SeamHttpRequest< - undefined | UserIdentitiesListAcsSystemsParams, - UserIdentitiesListAcsSystemsResponse, - 'acs_systems' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/list_acs_systems', method: 'post', @@ -280,11 +253,7 @@ export class SeamHttpUserIdentities { listAcsUsers( body?: UserIdentitiesListAcsUsersParams, - ): SeamHttpRequest< - undefined | UserIdentitiesListAcsUsersParams, - UserIdentitiesListAcsUsersResponse, - 'acs_users' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/list_acs_users', method: 'post', @@ -295,11 +264,7 @@ export class SeamHttpUserIdentities { removeAcsUser( body?: UserIdentitiesRemoveAcsUserBody, - ): SeamHttpRequest< - undefined | UserIdentitiesRemoveAcsUserBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/remove_acs_user', method: 'post', @@ -310,11 +275,7 @@ export class SeamHttpUserIdentities { revokeAccessToDevice( body?: UserIdentitiesRevokeAccessToDeviceBody, - ): SeamHttpRequest< - undefined | UserIdentitiesRevokeAccessToDeviceBody, - void, - undefined - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/revoke_access_to_device', method: 'post', @@ -323,9 +284,7 @@ export class SeamHttpUserIdentities { }) } - update( - body?: UserIdentitiesUpdateBody, - ): SeamHttpRequest { + update(body?: UserIdentitiesUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/user_identities/update', method: 'post', diff --git a/src/lib/seam/connect/routes/webhooks.ts b/src/lib/seam/connect/routes/webhooks.ts index 13f7e512..39b4d85c 100644 --- a/src/lib/seam/connect/routes/webhooks.ts +++ b/src/lib/seam/connect/routes/webhooks.ts @@ -156,11 +156,7 @@ export class SeamHttpWebhooks { create( body?: WebhooksCreateBody, - ): SeamHttpRequest< - undefined | WebhooksCreateBody, - WebhooksCreateResponse, - 'webhook' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/webhooks/create', method: 'post', @@ -169,9 +165,7 @@ export class SeamHttpWebhooks { }) } - delete( - body?: WebhooksDeleteBody, - ): SeamHttpRequest { + delete(body?: WebhooksDeleteBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/webhooks/delete', method: 'post', @@ -182,11 +176,7 @@ export class SeamHttpWebhooks { get( body?: WebhooksGetParams, - ): SeamHttpRequest< - undefined | WebhooksGetParams, - WebhooksGetResponse, - 'webhook' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/webhooks/get', method: 'post', @@ -197,11 +187,7 @@ export class SeamHttpWebhooks { list( body?: WebhooksListParams, - ): SeamHttpRequest< - undefined | WebhooksListParams, - WebhooksListResponse, - 'webhooks' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/webhooks/list', method: 'post', @@ -210,9 +196,7 @@ export class SeamHttpWebhooks { }) } - update( - body?: WebhooksUpdateBody, - ): SeamHttpRequest { + update(body?: WebhooksUpdateBody): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/webhooks/update', method: 'post', diff --git a/src/lib/seam/connect/routes/workspaces.ts b/src/lib/seam/connect/routes/workspaces.ts index 2bce1435..c90cc1a3 100644 --- a/src/lib/seam/connect/routes/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces.ts @@ -156,11 +156,7 @@ export class SeamHttpWorkspaces { create( body?: WorkspacesCreateBody, - ): SeamHttpRequest< - undefined | WorkspacesCreateBody, - WorkspacesCreateResponse, - 'workspace' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/workspaces/create', method: 'post', @@ -171,11 +167,7 @@ export class SeamHttpWorkspaces { get( body?: WorkspacesGetParams, - ): SeamHttpRequest< - undefined | WorkspacesGetParams, - WorkspacesGetResponse, - 'workspace' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/workspaces/get', method: 'post', @@ -186,11 +178,7 @@ export class SeamHttpWorkspaces { list( body?: WorkspacesListParams, - ): SeamHttpRequest< - undefined | WorkspacesListParams, - WorkspacesListResponse, - 'workspaces' - > { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/workspaces/list', method: 'post', @@ -201,7 +189,7 @@ export class SeamHttpWorkspaces { resetSandbox( body?: WorkspacesResetSandboxBody, - ): SeamHttpRequest { + ): SeamHttpRequest { return new SeamHttpRequest(this, { path: '/workspaces/reset_sandbox', method: 'post', diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index 357914db..b21cf00a 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -11,17 +11,16 @@ interface SeamHttpRequestParent { readonly defaults: Required } -interface SeamHttpRequestConfig { +interface SeamHttpRequestConfig { readonly path: string readonly method: Method - readonly body?: TBody + readonly body?: unknown readonly params?: undefined | Record readonly responseKey: TResponseKey readonly options?: Pick } export class SeamHttpRequest< - const TBody, const TResponse, const TResponseKey extends keyof TResponse | undefined, > implements @@ -30,11 +29,11 @@ export class SeamHttpRequest< > { readonly #parent: SeamHttpRequestParent - readonly #config: SeamHttpRequestConfig + readonly #config: SeamHttpRequestConfig constructor( parent: SeamHttpRequestParent, - config: SeamHttpRequestConfig, + config: SeamHttpRequestConfig, ) { this.#parent = parent this.#config = config @@ -68,8 +67,8 @@ export class SeamHttpRequest< return this.#config.method } - public get body(): TBody { - return this.#config.body as TBody + public get body(): unknown { + return this.#config.body } async execute(): Promise< @@ -79,7 +78,7 @@ export class SeamHttpRequest< const response = await client.request({ url: this.#config.path, method: this.#config.method, - data: this.#config.body as TBody, + data: this.#config.body, params: this.#config.params, }) if (this.responseKey === undefined) { diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 073d6c2a..a575bb9c 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -163,7 +163,7 @@ const toPlainUrlObject = (url: URL): Omit => { } type ResponseFromSeamHttpRequest = - T extends SeamHttpRequest + T extends SeamHttpRequest ? TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined