plane/apps/app/services/integration/github.service.ts
guru_sainath 2f2caaaf6e
Feat: Github importer to sync issues, users, and labels with workspace projects. (#509)
* Dev: Github integration with issues and layout integration

* dev: Github Integration route and UI configuration
2023-03-23 23:27:11 +05:30

46 lines
1.4 KiB
TypeScript

import APIService from "services/api.service";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const integrationServiceType: string = "github";
class GithubIntegrationService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
}
// fetching all the repositories under the github
async listAllRepositories(workspaceSlug: string, integrationSlug: string): Promise<any> {
return this.get(
`/api/workspaces/${workspaceSlug}/workspace-integrations/${integrationSlug}/github-repositories`
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
// fetching repository stats under the repository eg: users, labels and issues
async fetchRepositoryStats(workspaceSlug: string): Promise<any> {
return this.get(`/api/workspaces/${workspaceSlug}/importers/${integrationServiceType}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
// migrating repository data in workspace project
async migrateRepositoryStatToProject(
workspaceSlug: string,
integrationSlug: string
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/importers/${integrationServiceType}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}
export default new GithubIntegrationService();