2023-03-23 17:57:11 +00:00
|
|
|
import APIService from "services/api.service";
|
|
|
|
// types
|
2023-04-05 19:21:15 +00:00
|
|
|
import { IAppIntegrations, IImporterService, IWorkspaceIntegrations } from "types";
|
2023-03-23 17:57:11 +00:00
|
|
|
|
|
|
|
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
class IntegrationService extends APIService {
|
2023-03-23 17:57:11 +00:00
|
|
|
constructor() {
|
|
|
|
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
|
|
|
|
}
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
async getAppIntegrationsList(): Promise<IAppIntegrations[]> {
|
2023-03-23 17:57:11 +00:00
|
|
|
return this.get(`/api/integrations/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
async getWorkspaceIntegrationsList(workspaceSlug: string): Promise<IWorkspaceIntegrations[]> {
|
2023-03-23 17:57:11 +00:00
|
|
|
return this.get(`/api/workspaces/${workspaceSlug}/workspace-integrations/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
async deleteWorkspaceIntegration(workspaceSlug: string, integrationId: string): Promise<any> {
|
|
|
|
return this.delete(
|
|
|
|
`/api/workspaces/${workspaceSlug}/workspace-integrations/${integrationId}/provider/`
|
|
|
|
)
|
|
|
|
.then((res) => res?.data)
|
2023-03-23 17:57:11 +00:00
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
async getImporterServicesList(workspaceSlug: string): Promise<IImporterService[]> {
|
2023-03-23 17:57:11 +00:00
|
|
|
return this.get(`/api/workspaces/${workspaceSlug}/importers/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
2023-04-06 10:36:31 +00:00
|
|
|
|
|
|
|
async deleteImporterService(workspaceSlug: string, importerId: string): Promise<any> {
|
|
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/importers/${importerId}/`)
|
|
|
|
.then((res) => res?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
2023-03-23 17:57:11 +00:00
|
|
|
}
|
|
|
|
|
2023-04-05 19:21:15 +00:00
|
|
|
export default new IntegrationService();
|