Skip to content

Commit

Permalink
Update SeamHttpLegacyWorkspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Sep 22, 2023
1 parent 6e622fe commit 4595f10
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/lib/seam/connect/legacy/workspaces.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
import { Axios } from 'axios'
import type { SetNonNullable } from 'type-fest'

import { SeamHttpWorkspaces } from 'lib/seam/connect/routes/workspaces.js'
import { createAxiosClient } from 'lib/seam/connect/axios.js'
import type { SeamHttpOptions } from 'lib/seam/connect/client-options.js'
import { parseOptions } from 'lib/seam/connect/parse-options.js'

export class SeamHttpLegacyWorkspaces extends SeamHttpWorkspaces {
override async get(
export class SeamHttpLegacyWorkspaces {
client: Axios

constructor(apiKeyOrOptionsOrClient: Axios | string | SeamHttpOptions) {
if (apiKeyOrOptionsOrClient instanceof Axios) {
this.client = apiKeyOrOptionsOrClient
return
}

const options = parseOptions(apiKeyOrOptionsOrClient)
this.client = createAxiosClient(options)
}

async get(
params: WorkspacesGetParams = {},
): Promise<WorkspacesGetResponse['workspace']> {
const { data } = await this.client.get<WorkspacesGetResponse>(
'/workspaces/get',
{
params,
},
)
const { data } = await this.client.request<WorkspacesGetResponse>({
url: '/workspaces/get',
method: 'get',
params,
})
return data.workspace
}
}

export type WorkspacesGetParams = SetNonNullable<
type WorkspacesGetParams = SetNonNullable<
Required<RouteRequestParams<'/workspaces/get'>>
>

export type WorkspacesGetResponse = SetNonNullable<
type WorkspacesGetResponse = SetNonNullable<
Required<RouteResponse<'/workspaces/get'>>
>

0 comments on commit 4595f10

Please sign in to comment.