diff --git a/generate-routes.ts b/generate-routes.ts index f517b488..5b970e4b 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -4,6 +4,7 @@ import { resolve } from 'node:path' import { openapi } from '@seamapi/types/connect' import { camelCase, paramCase, pascalCase, snakeCase } from 'change-case' import { ESLint } from 'eslint' +import pluralize from 'pluralize' import { format, resolveConfig } from 'prettier' const rootClassPath = resolve('src', 'lib', 'seam', 'connect', 'client.ts') @@ -49,36 +50,17 @@ interface Endpoint { name: string path: string namespace: string - resource: string - method: 'GET' | 'POST' + resource: string | null + method: Method requestFormat: 'params' | 'body' } +type Method = 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH' + interface ClassMeta { constructors: string } -const exampleRoute: Route = { - namespace: 'workspaces', - endpoints: [ - { - name: 'get', - namespace: 'workspaces', - path: '/workspaces/get', - method: 'GET', - resource: 'workspace', - requestFormat: ['GET', 'DELETE'].includes('GET') ? 'params' : 'body', - }, - ], -} - -const isEndpointUnderRoute = ( - endpointPath: string, - routePath: string, -): boolean => - endpointPath.startsWith(routePath) && - endpointPath.split('/').length - 1 === routePath.split('/').length - const createRoutes = (): Route[] => { const paths = Object.keys(openapi.paths) @@ -102,13 +84,75 @@ const createRoutes = (): Route[] => { } const createRoute = (routePath: string): Route => { + const endpointPaths = Object.keys(openapi.paths).filter((path) => + isEndpointUnderRoute(path, routePath), + ) + + const namespace = routePath.split('/').join('_').slice(1) + return { - namespace: routePath.split('/').join('_').slice(1), - endpoints: [], + namespace, + endpoints: endpointPaths.map((endpointPath) => + createEndpoint(namespace, routePath, endpointPath), + ), } } -const routes = createRoutes() +const createEndpoint = ( + namespace: string, + routePath: string, + endpointPath: string, +): Endpoint => { + if (!isOpenApiPath(endpointPath)) { + throw new Error(`Did not find ${endpointPath} in OpenAPI spec`) + } + const spec = openapi.paths[endpointPath] + const method = deriveSemanticMethod(Object.keys(spec)) + const name = endpointPath.split(routePath)[1]?.slice(1) + if (name == null) { + throw new Error(`Could not parse name from ${endpointPath}`) + } + return { + name, + namespace, + path: endpointPath, + method, + resource: deriveResource(routePath, name, method), + requestFormat: ['GET', 'DELETE'].includes(method) ? 'params' : 'body', + } +} + +const deriveResource = ( + routePath: string, + name: string, + method: Method, +): string | null => { + if (['DELETE', 'PATCH', 'PUT'].includes(method)) return null + if (['update', 'delete'].includes(name)) return null + const group = routePath.split('/')[1] + if (group == null) throw new Error(`Could not parse group from ${routePath}`) + if (name === 'list') return group + return pluralize.singular(group) +} + +const deriveSemanticMethod = (methods: string[]): Method => { + if (methods.includes('get')) return 'GET' + if (methods.includes('delete')) return 'DELETE' + if (methods.includes('patch')) return 'PATCH' + if (methods.includes('put')) return 'PUT' + if (methods.includes('post')) return 'POST' + throw new Error(`Could not find valid method in ${methods.join(', ')}`) +} + +const isOpenApiPath = (key: string): key is keyof typeof openapi.paths => + key in openapi.paths + +const isEndpointUnderRoute = ( + endpointPath: string, + routePath: string, +): boolean => + endpointPath.startsWith(routePath) && + endpointPath.split('/').length - 1 === routePath.split('/').length const renderRoute = (route: Route, { constructors }: ClassMeta): string => ` /* @@ -125,7 +169,7 @@ ${renderExports(route)} const renderImports = (): string => ` -import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect' +import type { RouteRequestParams, RouteResponse, RouteRequestBody } from '@seamapi/types/connect' import { Axios } from 'axios' import type { SetNonNullable } from 'type-fest' @@ -173,9 +217,15 @@ const renderClassMethod = ({ name, namespace, requestFormat, - })} = {}, - ): Promise<${renderResponseType({ name, namespace })}['${resource}']> { - const { data } = await this.client.request<${renderResponseType({ + })}, + ): Promise<${ + resource === null + ? 'void' + : `${renderResponseType({ name, namespace })}['${resource}']` + }> { + ${ + resource === null ? '' : 'const { data } = ' + }await this.client.request<${renderResponseType({ name, namespace, })}>({ @@ -184,7 +234,7 @@ const renderClassMethod = ({ requestFormat === 'params' ? 'params,' : '' } ${requestFormat === 'body' ? 'data: body,' : ''} }) - return data.${resource} + ${resource === null ? '' : `return data.${resource}`} } ` @@ -298,4 +348,4 @@ const writeRoute = async (route: Route): Promise => { ) } -await Promise.all(routes.map(writeRoute)) +await Promise.all(createRoutes().map(writeRoute)) diff --git a/package-lock.json b/package-lock.json index a4be6bf0..58ac13cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@seamapi/types": "^1.14.0", "@types/eslint": "^8.44.2", "@types/node": "^18.11.18", + "@types/pluralize": "^0.0.31", "ava": "^5.0.1", "c8": "^8.0.0", "change-case": "^4.1.2", @@ -27,6 +28,7 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-unused-imports": "^3.0.0", "landlubber": "^1.0.0", + "pluralize": "^8.0.0", "prettier": "^3.0.0", "tsc-alias": "^1.8.2", "tsup": "^7.2.0", @@ -858,6 +860,12 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, + "node_modules/@types/pluralize": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@types/pluralize/-/pluralize-0.0.31.tgz", + "integrity": "sha512-MQh69PPwFlYAL2qz/Mw5Zc34VTdt7pTck0Xbb6pbPSzdt5oaLB87iyJJxEMS5Dco/s7lXHunEezAvQurZZdrsQ==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.5.2", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.2.tgz", @@ -5442,6 +5450,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/postcss-load-config": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.1.tgz", diff --git a/package.json b/package.json index 9de30067..cbd9e751 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "@seamapi/types": "^1.14.0", "@types/eslint": "^8.44.2", "@types/node": "^18.11.18", + "@types/pluralize": "^0.0.31", "ava": "^5.0.1", "c8": "^8.0.0", "change-case": "^4.1.2", @@ -102,6 +103,7 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-unused-imports": "^3.0.0", "landlubber": "^1.0.0", + "pluralize": "^8.0.0", "prettier": "^3.0.0", "tsc-alias": "^1.8.2", "tsup": "^7.2.0", diff --git a/src/lib/seam/connect/legacy/workspaces.ts b/src/lib/seam/connect/legacy/workspaces.ts index a5fe3108..effd55de 100644 --- a/src/lib/seam/connect/legacy/workspaces.ts +++ b/src/lib/seam/connect/legacy/workspaces.ts @@ -10,7 +10,7 @@ export class SeamHttpLegacyWorkspaces { } async get( - params: WorkspacesGetParams = {}, + params: WorkspacesGetParams, ): Promise { const { data } = await this.client.request({ url: '/workspaces/get', diff --git a/src/lib/seam/connect/routes/access-codes-unmanaged.ts b/src/lib/seam/connect/routes/access-codes-unmanaged.ts index 61a282f7..1488ac17 100644 --- a/src/lib/seam/connect/routes/access-codes-unmanaged.ts +++ b/src/lib/seam/connect/routes/access-codes-unmanaged.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,95 @@ export class SeamHttpAccessCodesUnmanaged { } return new SeamHttpAccessCodesUnmanaged(opts) } + + async convertToManaged( + body: AccessCodesUnmanagedConvertToManagedBody, + ): Promise { + await this.client.request({ + url: '/access_codes/unmanaged/convert_to_managed', + method: 'patch', + data: body, + }) + } + + async delete(body: AccessCodesUnmanagedDeleteBody): Promise { + await this.client.request({ + url: '/access_codes/unmanaged/delete', + method: 'post', + data: body, + }) + } + + async get( + body: AccessCodesUnmanagedGetBody, + ): Promise { + const { data } = await this.client.request( + { + url: '/access_codes/unmanaged/get', + method: 'post', + data: body, + }, + ) + return data.access_code + } + + async list( + body: AccessCodesUnmanagedListBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/access_codes/unmanaged/list', + method: 'post', + data: body, + }) + return data.access_codes + } + + async update(body: AccessCodesUnmanagedUpdateBody): Promise { + await this.client.request({ + url: '/access_codes/unmanaged/update', + method: 'patch', + data: body, + }) + } } + +type AccessCodesUnmanagedConvertToManagedBody = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedConvertToManagedResponse = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedDeleteBody = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedDeleteResponse = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedGetBody = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedGetResponse = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedListBody = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedListResponse = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedUpdateBody = SetNonNullable< + Required> +> + +type AccessCodesUnmanagedUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/access-codes.ts b/src/lib/seam/connect/routes/access-codes.ts index ce349c06..b9d2f38c 100644 --- a/src/lib/seam/connect/routes/access-codes.ts +++ b/src/lib/seam/connect/routes/access-codes.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,150 @@ export class SeamHttpAccessCodes { } return new SeamHttpAccessCodes(opts) } + + async create( + body: AccessCodesCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/access_codes/create', + method: 'post', + data: body, + }) + return data.access_code + } + + async createMultiple(body: AccessCodesCreateMultipleBody): Promise { + await this.client.request({ + url: '/access_codes/create_multiple', + method: 'put', + data: body, + }) + } + + async delete(body: AccessCodesDeleteBody): Promise { + await this.client.request({ + url: '/access_codes/delete', + method: 'post', + data: body, + }) + } + + async generateCode( + params: AccessCodesGenerateCodeParams, + ): Promise { + const { data } = await this.client.request( + { + url: '/access_codes/generate_code', + method: 'get', + params, + }, + ) + return data.access_code + } + + async get( + body: AccessCodesGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/access_codes/get', + method: 'post', + data: body, + }) + return data.access_code + } + + async list( + body: AccessCodesListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/access_codes/list', + method: 'post', + data: body, + }) + return data.access_codes + } + + async pullBackupAccessCode( + body: AccessCodesPullBackupAccessCodeBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/access_codes/pull_backup_access_code', + method: 'post', + data: body, + }) + return data.access_code + } + + async update(body: AccessCodesUpdateBody): Promise { + await this.client.request({ + url: '/access_codes/update', + method: 'put', + data: body, + }) + } } + +type AccessCodesCreateBody = SetNonNullable< + Required> +> + +type AccessCodesCreateResponse = SetNonNullable< + Required> +> + +type AccessCodesCreateMultipleBody = SetNonNullable< + Required> +> + +type AccessCodesCreateMultipleResponse = SetNonNullable< + Required> +> + +type AccessCodesDeleteBody = SetNonNullable< + Required> +> + +type AccessCodesDeleteResponse = SetNonNullable< + Required> +> + +type AccessCodesGenerateCodeParams = SetNonNullable< + Required> +> + +type AccessCodesGenerateCodeResponse = SetNonNullable< + Required> +> + +type AccessCodesGetBody = SetNonNullable< + Required> +> + +type AccessCodesGetResponse = SetNonNullable< + Required> +> + +type AccessCodesListBody = SetNonNullable< + Required> +> + +type AccessCodesListResponse = SetNonNullable< + Required> +> + +type AccessCodesPullBackupAccessCodeBody = SetNonNullable< + Required> +> + +type AccessCodesPullBackupAccessCodeResponse = SetNonNullable< + Required> +> + +type AccessCodesUpdateBody = SetNonNullable< + Required> +> + +type AccessCodesUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index 3dd14945..4ce1b913 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,149 @@ export class SeamHttpAcsAccessGroups { } return new SeamHttpAcsAccessGroups(opts) } + + async addUser(body: AcsAccessGroupsAddUserBody): Promise { + await this.client.request({ + url: '/acs/access_groups/add_user', + method: 'patch', + data: body, + }) + } + + async create( + body: AcsAccessGroupsCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/access_groups/create', + method: 'post', + data: body, + }) + return data.ac + } + + async delete(body: AcsAccessGroupsDeleteBody): Promise { + await this.client.request({ + url: '/acs/access_groups/delete', + method: 'post', + data: body, + }) + } + + async get( + body: AcsAccessGroupsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/access_groups/get', + method: 'post', + data: body, + }) + return data.ac + } + + async list( + body: AcsAccessGroupsListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/access_groups/list', + method: 'post', + data: body, + }) + return data.acs + } + + async listUsers( + body: AcsAccessGroupsListUsersBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/acs/access_groups/list_users', + method: 'post', + data: body, + }) + return data.ac + } + + async removeUser( + body: AcsAccessGroupsRemoveUserBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/acs/access_groups/remove_user', + method: 'post', + data: body, + }) + return data.ac + } + + async update(body: AcsAccessGroupsUpdateBody): Promise { + await this.client.request({ + url: '/acs/access_groups/update', + method: 'patch', + data: body, + }) + } } + +type AcsAccessGroupsAddUserBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsAddUserResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsCreateBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsCreateResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsDeleteBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsDeleteResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsGetBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsGetResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsListBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsListResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsListUsersBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsListUsersResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsRemoveUserBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsRemoveUserResponse = SetNonNullable< + Required> +> + +type AcsAccessGroupsUpdateBody = SetNonNullable< + Required> +> + +type AcsAccessGroupsUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index 2e7d641e..832e749d 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,77 @@ export class SeamHttpAcsCredentials { } return new SeamHttpAcsCredentials(opts) } + + async create( + body: AcsCredentialsCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/credentials/create', + method: 'post', + data: body, + }) + return data.ac + } + + async delete(body: AcsCredentialsDeleteBody): Promise { + await this.client.request({ + url: '/acs/credentials/delete', + method: 'post', + data: body, + }) + } + + async get( + body: AcsCredentialsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/credentials/get', + method: 'post', + data: body, + }) + return data.ac + } + + async list( + body: AcsCredentialsListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/credentials/list', + method: 'post', + data: body, + }) + return data.acs + } } + +type AcsCredentialsCreateBody = SetNonNullable< + Required> +> + +type AcsCredentialsCreateResponse = SetNonNullable< + Required> +> + +type AcsCredentialsDeleteBody = SetNonNullable< + Required> +> + +type AcsCredentialsDeleteResponse = SetNonNullable< + Required> +> + +type AcsCredentialsGetBody = SetNonNullable< + Required> +> + +type AcsCredentialsGetResponse = SetNonNullable< + Required> +> + +type AcsCredentialsListBody = SetNonNullable< + Required> +> + +type AcsCredentialsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/acs-systems.ts b/src/lib/seam/connect/routes/acs-systems.ts index 56aa8c6e..9f135258 100644 --- a/src/lib/seam/connect/routes/acs-systems.ts +++ b/src/lib/seam/connect/routes/acs-systems.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,40 @@ export class SeamHttpAcsSystems { } return new SeamHttpAcsSystems(opts) } + + async get(body: AcsSystemsGetBody): Promise { + const { data } = await this.client.request({ + url: '/acs/systems/get', + method: 'post', + data: body, + }) + return data.ac + } + + async list( + params: AcsSystemsListParams, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/systems/list', + method: 'get', + params, + }) + return data.acs + } } + +type AcsSystemsGetBody = SetNonNullable< + Required> +> + +type AcsSystemsGetResponse = SetNonNullable< + Required> +> + +type AcsSystemsListParams = SetNonNullable< + Required> +> + +type AcsSystemsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index 167c14e7..f80f64d1 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,125 @@ export class SeamHttpAcsUsers { } return new SeamHttpAcsUsers(opts) } + + async addToAccessGroup(body: AcsUsersAddToAccessGroupBody): Promise { + await this.client.request({ + url: '/acs/users/add_to_access_group', + method: 'patch', + data: body, + }) + } + + async create( + body: AcsUsersCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/acs/users/create', + method: 'post', + data: body, + }) + return data.ac + } + + async delete(body: AcsUsersDeleteBody): Promise { + await this.client.request({ + url: '/acs/users/delete', + method: 'post', + data: body, + }) + } + + async get(body: AcsUsersGetBody): Promise { + const { data } = await this.client.request({ + url: '/acs/users/get', + method: 'post', + data: body, + }) + return data.ac + } + + async list(body: AcsUsersListBody): Promise { + const { data } = await this.client.request({ + url: '/acs/users/list', + method: 'post', + data: body, + }) + return data.acs + } + + async removeFromAccessGroup( + body: AcsUsersRemoveFromAccessGroupBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/acs/users/remove_from_access_group', + method: 'post', + data: body, + }) + return data.ac + } + + async update(body: AcsUsersUpdateBody): Promise { + await this.client.request({ + url: '/acs/users/update', + method: 'patch', + data: body, + }) + } } + +type AcsUsersAddToAccessGroupBody = SetNonNullable< + Required> +> + +type AcsUsersAddToAccessGroupResponse = SetNonNullable< + Required> +> + +type AcsUsersCreateBody = SetNonNullable< + Required> +> + +type AcsUsersCreateResponse = SetNonNullable< + Required> +> + +type AcsUsersDeleteBody = SetNonNullable< + Required> +> + +type AcsUsersDeleteResponse = SetNonNullable< + Required> +> + +type AcsUsersGetBody = SetNonNullable< + Required> +> + +type AcsUsersGetResponse = SetNonNullable< + Required> +> + +type AcsUsersListBody = SetNonNullable< + Required> +> + +type AcsUsersListResponse = SetNonNullable< + Required> +> + +type AcsUsersRemoveFromAccessGroupBody = SetNonNullable< + Required> +> + +type AcsUsersRemoveFromAccessGroupResponse = SetNonNullable< + Required> +> + +type AcsUsersUpdateBody = SetNonNullable< + Required> +> + +type AcsUsersUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts.ts index 762fd179..6defd097 100644 --- a/src/lib/seam/connect/routes/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,42 @@ export class SeamHttpActionAttempts { } return new SeamHttpActionAttempts(opts) } + + async get( + body: ActionAttemptsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/action_attempts/get', + method: 'post', + data: body, + }) + return data.action_attempt + } + + async list( + body: ActionAttemptsListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/action_attempts/list', + method: 'post', + data: body, + }) + return data.action_attempts + } } + +type ActionAttemptsGetBody = SetNonNullable< + Required> +> + +type ActionAttemptsGetResponse = SetNonNullable< + Required> +> + +type ActionAttemptsListBody = SetNonNullable< + Required> +> + +type ActionAttemptsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/client-sessions.ts b/src/lib/seam/connect/routes/client-sessions.ts index 61a0e1e5..bca96034 100644 --- a/src/lib/seam/connect/routes/client-sessions.ts +++ b/src/lib/seam/connect/routes/client-sessions.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,90 @@ export class SeamHttpClientSessions { } return new SeamHttpClientSessions(opts) } + + async create(body: ClientSessionsCreateBody): Promise { + await this.client.request({ + url: '/client_sessions/create', + method: 'put', + data: body, + }) + } + + async delete(body: ClientSessionsDeleteBody): Promise { + await this.client.request({ + url: '/client_sessions/delete', + method: 'post', + data: body, + }) + } + + async get( + body: ClientSessionsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/client_sessions/get', + method: 'post', + data: body, + }) + return data.client_session + } + + async grantAccess(body: ClientSessionsGrantAccessBody): Promise { + await this.client.request({ + url: '/client_sessions/grant_access', + method: 'patch', + data: body, + }) + } + + async list( + body: ClientSessionsListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/client_sessions/list', + method: 'post', + data: body, + }) + return data.client_sessions + } } + +type ClientSessionsCreateBody = SetNonNullable< + Required> +> + +type ClientSessionsCreateResponse = SetNonNullable< + Required> +> + +type ClientSessionsDeleteBody = SetNonNullable< + Required> +> + +type ClientSessionsDeleteResponse = SetNonNullable< + Required> +> + +type ClientSessionsGetBody = SetNonNullable< + Required> +> + +type ClientSessionsGetResponse = SetNonNullable< + Required> +> + +type ClientSessionsGrantAccessBody = SetNonNullable< + Required> +> + +type ClientSessionsGrantAccessResponse = SetNonNullable< + Required> +> + +type ClientSessionsListBody = SetNonNullable< + Required> +> + +type ClientSessionsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/connect-webviews.ts b/src/lib/seam/connect/routes/connect-webviews.ts index 10754e0e..056b38dd 100644 --- a/src/lib/seam/connect/routes/connect-webviews.ts +++ b/src/lib/seam/connect/routes/connect-webviews.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,96 @@ export class SeamHttpConnectWebviews { } return new SeamHttpConnectWebviews(opts) } + + async create( + body: ConnectWebviewsCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/connect_webviews/create', + method: 'post', + data: body, + }) + return data.connect_webview + } + + async delete(body: ConnectWebviewsDeleteBody): Promise { + await this.client.request({ + url: '/connect_webviews/delete', + method: 'post', + data: body, + }) + } + + async get( + body: ConnectWebviewsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/connect_webviews/get', + method: 'post', + data: body, + }) + return data.connect_webview + } + + async list( + params: ConnectWebviewsListParams, + ): Promise { + const { data } = await this.client.request({ + url: '/connect_webviews/list', + method: 'get', + params, + }) + return data.connect_webviews + } + + async view( + params: ConnectWebviewsViewParams, + ): Promise { + const { data } = await this.client.request({ + url: '/connect_webviews/view', + method: 'get', + params, + }) + return data.connect_webview + } } + +type ConnectWebviewsCreateBody = SetNonNullable< + Required> +> + +type ConnectWebviewsCreateResponse = SetNonNullable< + Required> +> + +type ConnectWebviewsDeleteBody = SetNonNullable< + Required> +> + +type ConnectWebviewsDeleteResponse = SetNonNullable< + Required> +> + +type ConnectWebviewsGetBody = SetNonNullable< + Required> +> + +type ConnectWebviewsGetResponse = SetNonNullable< + Required> +> + +type ConnectWebviewsListParams = SetNonNullable< + Required> +> + +type ConnectWebviewsListResponse = SetNonNullable< + Required> +> + +type ConnectWebviewsViewParams = SetNonNullable< + Required> +> + +type ConnectWebviewsViewResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/connected-accounts.ts b/src/lib/seam/connect/routes/connected-accounts.ts index bbac66b0..4998359f 100644 --- a/src/lib/seam/connect/routes/connected-accounts.ts +++ b/src/lib/seam/connect/routes/connected-accounts.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,58 @@ export class SeamHttpConnectedAccounts { } return new SeamHttpConnectedAccounts(opts) } + + async delete(body: ConnectedAccountsDeleteBody): Promise { + await this.client.request({ + url: '/connected_accounts/delete', + method: 'post', + data: body, + }) + } + + async get( + body: ConnectedAccountsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/connected_accounts/get', + method: 'post', + data: body, + }) + return data.connected_account + } + + async list( + params: ConnectedAccountsListParams, + ): Promise { + const { data } = await this.client.request({ + url: '/connected_accounts/list', + method: 'get', + params, + }) + return data.connected_accounts + } } + +type ConnectedAccountsDeleteBody = SetNonNullable< + Required> +> + +type ConnectedAccountsDeleteResponse = SetNonNullable< + Required> +> + +type ConnectedAccountsGetBody = SetNonNullable< + Required> +> + +type ConnectedAccountsGetResponse = SetNonNullable< + Required> +> + +type ConnectedAccountsListParams = SetNonNullable< + Required> +> + +type ConnectedAccountsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/devices-unmanaged.ts b/src/lib/seam/connect/routes/devices-unmanaged.ts index a342c3e9..2606b543 100644 --- a/src/lib/seam/connect/routes/devices-unmanaged.ts +++ b/src/lib/seam/connect/routes/devices-unmanaged.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,58 @@ export class SeamHttpDevicesUnmanaged { } return new SeamHttpDevicesUnmanaged(opts) } + + async get( + body: DevicesUnmanagedGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/devices/unmanaged/get', + method: 'post', + data: body, + }) + return data.device + } + + async list( + body: DevicesUnmanagedListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/devices/unmanaged/list', + method: 'post', + data: body, + }) + return data.devices + } + + async update(body: DevicesUnmanagedUpdateBody): Promise { + await this.client.request({ + url: '/devices/unmanaged/update', + method: 'patch', + data: body, + }) + } } + +type DevicesUnmanagedGetBody = SetNonNullable< + Required> +> + +type DevicesUnmanagedGetResponse = SetNonNullable< + Required> +> + +type DevicesUnmanagedListBody = SetNonNullable< + Required> +> + +type DevicesUnmanagedListResponse = SetNonNullable< + Required> +> + +type DevicesUnmanagedUpdateBody = SetNonNullable< + Required> +> + +type DevicesUnmanagedUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 4aa2d11f..31650ab9 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,88 @@ export class SeamHttpDevices { } return new SeamHttpDevices(opts) } + + async delete(body: DevicesDeleteBody): Promise { + await this.client.request({ + url: '/devices/delete', + method: 'post', + data: body, + }) + } + + async get(body: DevicesGetBody): Promise { + const { data } = await this.client.request({ + url: '/devices/get', + method: 'post', + data: body, + }) + return data.device + } + + async list(body: DevicesListBody): Promise { + const { data } = await this.client.request({ + url: '/devices/list', + method: 'post', + data: body, + }) + return data.devices + } + + async listDeviceProviders( + body: DevicesListDeviceProvidersBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/devices/list_device_providers', + method: 'post', + data: body, + }) + return data.device + } + + async update(body: DevicesUpdateBody): Promise { + await this.client.request({ + url: '/devices/update', + method: 'patch', + data: body, + }) + } } + +type DevicesDeleteBody = SetNonNullable< + Required> +> + +type DevicesDeleteResponse = SetNonNullable< + Required> +> + +type DevicesGetBody = SetNonNullable>> + +type DevicesGetResponse = SetNonNullable< + Required> +> + +type DevicesListBody = SetNonNullable< + Required> +> + +type DevicesListResponse = SetNonNullable< + Required> +> + +type DevicesListDeviceProvidersBody = SetNonNullable< + Required> +> + +type DevicesListDeviceProvidersResponse = SetNonNullable< + Required> +> + +type DevicesUpdateBody = SetNonNullable< + Required> +> + +type DevicesUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/events.ts b/src/lib/seam/connect/routes/events.ts index bac05e86..731fe8fc 100644 --- a/src/lib/seam/connect/routes/events.ts +++ b/src/lib/seam/connect/routes/events.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,32 @@ export class SeamHttpEvents { } return new SeamHttpEvents(opts) } + + async get(body: EventsGetBody): Promise { + const { data } = await this.client.request({ + url: '/events/get', + method: 'post', + data: body, + }) + return data.event + } + + async list(body: EventsListBody): Promise { + const { data } = await this.client.request({ + url: '/events/list', + method: 'post', + data: body, + }) + return data.events + } } + +type EventsGetBody = SetNonNullable>> + +type EventsGetResponse = SetNonNullable>> + +type EventsListBody = SetNonNullable>> + +type EventsListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/locks.ts b/src/lib/seam/connect/routes/locks.ts index 7caf44e9..8edeba61 100644 --- a/src/lib/seam/connect/routes/locks.ts +++ b/src/lib/seam/connect/routes/locks.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,68 @@ export class SeamHttpLocks { } return new SeamHttpLocks(opts) } + + async get(body: LocksGetBody): Promise { + const { data } = await this.client.request({ + url: '/locks/get', + method: 'post', + data: body, + }) + return data.lock + } + + async list(body: LocksListBody): Promise { + const { data } = await this.client.request({ + url: '/locks/list', + method: 'post', + data: body, + }) + return data.locks + } + + async lockDoor( + body: LocksLockDoorBody, + ): Promise { + const { data } = await this.client.request({ + url: '/locks/lock_door', + method: 'post', + data: body, + }) + return data.lock + } + + async unlockDoor( + body: LocksUnlockDoorBody, + ): Promise { + const { data } = await this.client.request({ + url: '/locks/unlock_door', + method: 'post', + data: body, + }) + return data.lock + } } + +type LocksGetBody = SetNonNullable>> + +type LocksGetResponse = SetNonNullable>> + +type LocksListBody = SetNonNullable>> + +type LocksListResponse = SetNonNullable>> + +type LocksLockDoorBody = SetNonNullable< + Required> +> + +type LocksLockDoorResponse = SetNonNullable< + Required> +> + +type LocksUnlockDoorBody = SetNonNullable< + Required> +> + +type LocksUnlockDoorResponse = SetNonNullable< + Required> +> 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 c52f9b32..56e64182 100644 --- a/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +++ b/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,96 @@ export class SeamHttpNoiseSensorsNoiseThresholds { } return new SeamHttpNoiseSensorsNoiseThresholds(opts) } + + async create( + body: NoiseSensorsNoiseThresholdsCreateBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/noise_sensors/noise_thresholds/create', + method: 'post', + data: body, + }) + return data.noise_sensor + } + + async delete(body: NoiseSensorsNoiseThresholdsDeleteBody): Promise { + await this.client.request({ + url: '/noise_sensors/noise_thresholds/delete', + method: 'post', + data: body, + }) + } + + async get( + body: NoiseSensorsNoiseThresholdsGetBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/noise_sensors/noise_thresholds/get', + method: 'post', + data: body, + }) + return data.noise_sensor + } + + async list( + body: NoiseSensorsNoiseThresholdsListBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/noise_sensors/noise_thresholds/list', + method: 'post', + data: body, + }) + return data.noise_sensors + } + + async update(body: NoiseSensorsNoiseThresholdsUpdateBody): Promise { + await this.client.request({ + url: '/noise_sensors/noise_thresholds/update', + method: 'put', + data: body, + }) + } } + +type NoiseSensorsNoiseThresholdsCreateBody = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsCreateResponse = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsDeleteBody = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsDeleteResponse = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsGetBody = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsGetResponse = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsListBody = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsListResponse = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsUpdateBody = SetNonNullable< + Required> +> + +type NoiseSensorsNoiseThresholdsUpdateResponse = SetNonNullable< + Required> +> 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 cac92c67..ad7faa5c 100644 --- a/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +++ b/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,108 @@ export class SeamHttpThermostatsClimateSettingSchedules { } return new SeamHttpThermostatsClimateSettingSchedules(opts) } + + async create( + body: ThermostatsClimateSettingSchedulesCreateBody, + ): Promise { + const { data } = + await this.client.request( + { + url: '/thermostats/climate_setting_schedules/create', + method: 'post', + data: body, + }, + ) + return data.thermostat + } + + async delete( + body: ThermostatsClimateSettingSchedulesDeleteBody, + ): Promise { + await this.client.request( + { + url: '/thermostats/climate_setting_schedules/delete', + method: 'put', + data: body, + }, + ) + } + + async get( + body: ThermostatsClimateSettingSchedulesGetBody, + ): Promise { + const { data } = + await this.client.request({ + url: '/thermostats/climate_setting_schedules/get', + method: 'post', + data: body, + }) + return data.thermostat + } + + async list( + body: ThermostatsClimateSettingSchedulesListBody, + ): Promise { + const { data } = + await this.client.request( + { + url: '/thermostats/climate_setting_schedules/list', + method: 'post', + data: body, + }, + ) + return data.thermostats + } + + async update( + body: ThermostatsClimateSettingSchedulesUpdateBody, + ): Promise { + await this.client.request( + { + url: '/thermostats/climate_setting_schedules/update', + method: 'put', + data: body, + }, + ) + } } + +type ThermostatsClimateSettingSchedulesCreateBody = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesCreateResponse = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesDeleteBody = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesDeleteResponse = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesGetBody = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesGetResponse = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesListBody = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesListResponse = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesUpdateBody = SetNonNullable< + Required> +> + +type ThermostatsClimateSettingSchedulesUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index 8bddc308..9677b656 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -3,7 +3,9 @@ * Do not edit this file or add other files to this directory. */ +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +63,153 @@ export class SeamHttpThermostats { } return new SeamHttpThermostats(opts) } + + async cool( + body: ThermostatsCoolBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/cool', + method: 'post', + data: body, + }) + return data.thermostat + } + + async get( + body: ThermostatsGetBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/get', + method: 'post', + data: body, + }) + return data.thermostat + } + + async heat( + body: ThermostatsHeatBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/heat', + method: 'post', + data: body, + }) + return data.thermostat + } + + async heatCool( + body: ThermostatsHeatCoolBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/heat_cool', + method: 'post', + data: body, + }) + return data.thermostat + } + + async list( + body: ThermostatsListBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/list', + method: 'post', + data: body, + }) + return data.thermostats + } + + async off( + body: ThermostatsOffBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/off', + method: 'post', + data: body, + }) + return data.thermostat + } + + async setFanMode( + body: ThermostatsSetFanModeBody, + ): Promise { + const { data } = await this.client.request({ + url: '/thermostats/set_fan_mode', + method: 'post', + data: body, + }) + return data.thermostat + } + + async update(body: ThermostatsUpdateBody): Promise { + await this.client.request({ + url: '/thermostats/update', + method: 'post', + data: body, + }) + } } + +type ThermostatsCoolBody = SetNonNullable< + Required> +> + +type ThermostatsCoolResponse = SetNonNullable< + Required> +> + +type ThermostatsGetBody = SetNonNullable< + Required> +> + +type ThermostatsGetResponse = SetNonNullable< + Required> +> + +type ThermostatsHeatBody = SetNonNullable< + Required> +> + +type ThermostatsHeatResponse = SetNonNullable< + Required> +> + +type ThermostatsHeatCoolBody = SetNonNullable< + Required> +> + +type ThermostatsHeatCoolResponse = SetNonNullable< + Required> +> + +type ThermostatsListBody = SetNonNullable< + Required> +> + +type ThermostatsListResponse = SetNonNullable< + Required> +> + +type ThermostatsOffBody = SetNonNullable< + Required> +> + +type ThermostatsOffResponse = SetNonNullable< + Required> +> + +type ThermostatsSetFanModeBody = SetNonNullable< + Required> +> + +type ThermostatsSetFanModeResponse = SetNonNullable< + Required> +> + +type ThermostatsUpdateBody = SetNonNullable< + Required> +> + +type ThermostatsUpdateResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/webhooks.ts b/src/lib/seam/connect/routes/webhooks.ts index a25ec030..0213d9b3 100644 --- a/src/lib/seam/connect/routes/webhooks.ts +++ b/src/lib/seam/connect/routes/webhooks.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,75 @@ export class SeamHttpWebhooks { } return new SeamHttpWebhooks(opts) } + + async create( + body: WebhooksCreateBody, + ): Promise { + const { data } = await this.client.request({ + url: '/webhooks/create', + method: 'post', + data: body, + }) + return data.webhook + } + + async delete(body: WebhooksDeleteBody): Promise { + await this.client.request({ + url: '/webhooks/delete', + method: 'post', + data: body, + }) + } + + async get(body: WebhooksGetBody): Promise { + const { data } = await this.client.request({ + url: '/webhooks/get', + method: 'post', + data: body, + }) + return data.webhook + } + + async list( + params: WebhooksListParams, + ): Promise { + const { data } = await this.client.request({ + url: '/webhooks/list', + method: 'get', + params, + }) + return data.webhooks + } } + +type WebhooksCreateBody = SetNonNullable< + Required> +> + +type WebhooksCreateResponse = SetNonNullable< + Required> +> + +type WebhooksDeleteBody = SetNonNullable< + Required> +> + +type WebhooksDeleteResponse = SetNonNullable< + Required> +> + +type WebhooksGetBody = SetNonNullable< + Required> +> + +type WebhooksGetResponse = SetNonNullable< + Required> +> + +type WebhooksListParams = SetNonNullable< + Required> +> + +type WebhooksListResponse = SetNonNullable< + Required> +> diff --git a/src/lib/seam/connect/routes/workspaces.ts b/src/lib/seam/connect/routes/workspaces.ts index 4496926a..cead4c1e 100644 --- a/src/lib/seam/connect/routes/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces.ts @@ -3,7 +3,13 @@ * Do not edit this file or add other files to this directory. */ +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import type { Axios } from 'axios' +import type { SetNonNullable } from 'type-fest' import { createAxiosClient } from 'lib/seam/connect/axios.js' import { @@ -61,4 +67,61 @@ export class SeamHttpWorkspaces { } return new SeamHttpWorkspaces(opts) } + + async get( + params: WorkspacesGetParams, + ): Promise { + const { data } = await this.client.request({ + url: '/workspaces/get', + method: 'get', + params, + }) + return data.workspace + } + + async list( + params: WorkspacesListParams, + ): Promise { + const { data } = await this.client.request({ + url: '/workspaces/list', + method: 'get', + params, + }) + return data.workspaces + } + + async resetSandbox( + body: WorkspacesResetSandboxBody, + ): Promise { + const { data } = await this.client.request({ + url: '/workspaces/reset_sandbox', + method: 'post', + data: body, + }) + return data.workspace + } } + +type WorkspacesGetParams = SetNonNullable< + Required> +> + +type WorkspacesGetResponse = SetNonNullable< + Required> +> + +type WorkspacesListParams = SetNonNullable< + Required> +> + +type WorkspacesListResponse = SetNonNullable< + Required> +> + +type WorkspacesResetSandboxBody = SetNonNullable< + Required> +> + +type WorkspacesResetSandboxResponse = SetNonNullable< + Required> +>