-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add client fn for cloud free connector info API
- Loading branch information
1 parent
38f7f69
commit 5ce541f
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
airbyte-webapp/src/packages/cloud/lib/domain/freeConnectorProgram/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { apiOverride } from "core/request/apiOverride"; | ||
|
||
export type WebBackendGetFreeConnectorProgramInfoForWorkspaceResult = NonNullable< | ||
Awaited<ReturnType<typeof webBackendGetFreeConnectorProgramInfoForWorkspace>> | ||
>; | ||
|
||
export interface WorkspaceIdRequestBody { | ||
workspaceId: WorkspaceId; | ||
} | ||
|
||
/** | ||
* Workspace Id from OSS Airbyte instance | ||
*/ | ||
export type WorkspaceId = string; | ||
|
||
// eslint-disable-next-line | ||
type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never; | ||
|
||
/** | ||
* @summary Return a summary of Free Connector Program info for the indicated Cloud Workspace | ||
*/ | ||
export const webBackendGetFreeConnectorProgramInfoForWorkspace = ( | ||
workspaceIdRequestBody: WorkspaceIdRequestBody, | ||
options?: SecondParameter<typeof apiOverride> | ||
) => { | ||
return apiOverride<WorkspaceFreeConnectorProgramInfoResponse>( | ||
{ | ||
url: `/v1/web_backend/cloud_workspaces/free_connector_program_info`, | ||
method: "post", | ||
headers: { "Content-Type": "application/json" }, | ||
data: workspaceIdRequestBody, | ||
}, | ||
options | ||
); | ||
}; | ||
|
||
export interface WorkspaceFreeConnectorProgramInfoResponse { | ||
hasEligibleConnector: boolean; | ||
hasPaymentAccountSaved: boolean; | ||
} |
19 changes: 19 additions & 0 deletions
19
airbyte-webapp/src/packages/cloud/services/freeConnectorProgram.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useQuery } from "react-query"; | ||
|
||
import { useCurrentWorkspace } from "hooks/services/useWorkspace"; | ||
import { useDefaultRequestMiddlewares } from "services/useDefaultRequestMiddlewares"; | ||
|
||
import { webBackendGetFreeConnectorProgramInfoForWorkspace } from "../lib/domain/freeConnectorProgram/api"; | ||
import { useConfig } from "./config"; | ||
|
||
export const useFreeConnectorProgramInfo = () => { | ||
const { workspaceId } = useCurrentWorkspace(); | ||
const { cloudApiUrl } = useConfig(); | ||
const config = { apiUrl: cloudApiUrl }; | ||
const middlewares = useDefaultRequestMiddlewares(); | ||
const requestOptions = { config, middlewares }; | ||
|
||
return useQuery(["freeConnectorProgramInfo", workspaceId], () => | ||
webBackendGetFreeConnectorProgramInfoForWorkspace({ workspaceId }, requestOptions) | ||
); | ||
}; |