|
1 | 1 | import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
|
| 2 | +import { Axios } from 'axios' |
2 | 3 | import type { SetNonNullable } from 'type-fest'
|
3 | 4 |
|
4 |
| -import { SeamHttpWorkspaces } from 'lib/seam/connect/routes/workspaces.js' |
| 5 | +import { createAxiosClient } from 'lib/seam/connect/axios.js' |
| 6 | +import type { SeamHttpOptions } from 'lib/seam/connect/client-options.js' |
| 7 | +import { parseOptions } from 'lib/seam/connect/parse-options.js' |
5 | 8 |
|
6 |
| -export class SeamHttpLegacyWorkspaces extends SeamHttpWorkspaces { |
7 |
| - override async get( |
| 9 | +export class SeamHttpLegacyWorkspaces { |
| 10 | + client: Axios |
| 11 | + |
| 12 | + constructor(apiKeyOrOptionsOrClient: Axios | string | SeamHttpOptions) { |
| 13 | + if (apiKeyOrOptionsOrClient instanceof Axios) { |
| 14 | + this.client = apiKeyOrOptionsOrClient |
| 15 | + return |
| 16 | + } |
| 17 | + |
| 18 | + const options = parseOptions(apiKeyOrOptionsOrClient) |
| 19 | + this.client = createAxiosClient(options) |
| 20 | + } |
| 21 | + |
| 22 | + async get( |
8 | 23 | params: WorkspacesGetParams = {},
|
9 | 24 | ): Promise<WorkspacesGetResponse['workspace']> {
|
10 |
| - const { data } = await this.client.get<WorkspacesGetResponse>( |
11 |
| - '/workspaces/get', |
12 |
| - { |
13 |
| - params, |
14 |
| - }, |
15 |
| - ) |
| 25 | + const { data } = await this.client.request<WorkspacesGetResponse>({ |
| 26 | + url: '/workspaces/get', |
| 27 | + method: 'get', |
| 28 | + params, |
| 29 | + }) |
16 | 30 | return data.workspace
|
17 | 31 | }
|
18 | 32 | }
|
19 | 33 |
|
20 |
| -export type WorkspacesGetParams = SetNonNullable< |
| 34 | +type WorkspacesGetParams = SetNonNullable< |
21 | 35 | Required<RouteRequestParams<'/workspaces/get'>>
|
22 | 36 | >
|
23 | 37 |
|
24 |
| -export type WorkspacesGetResponse = SetNonNullable< |
| 38 | +type WorkspacesGetResponse = SetNonNullable< |
25 | 39 | Required<RouteResponse<'/workspaces/get'>>
|
26 | 40 | >
|
0 commit comments