Skip to content

Commit 4595f10

Browse files
committed
Update SeamHttpLegacyWorkspaces
1 parent 6e622fe commit 4595f10

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
2+
import { Axios } from 'axios'
23
import type { SetNonNullable } from 'type-fest'
34

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'
58

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(
823
params: WorkspacesGetParams = {},
924
): 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+
})
1630
return data.workspace
1731
}
1832
}
1933

20-
export type WorkspacesGetParams = SetNonNullable<
34+
type WorkspacesGetParams = SetNonNullable<
2135
Required<RouteRequestParams<'/workspaces/get'>>
2236
>
2337

24-
export type WorkspacesGetResponse = SetNonNullable<
38+
type WorkspacesGetResponse = SetNonNullable<
2539
Required<RouteResponse<'/workspaces/get'>>
2640
>

0 commit comments

Comments
 (0)