forked from github/plane
102 lines
2.9 KiB
TypeScript
102 lines
2.9 KiB
TypeScript
import { API_BASE_URL } from "helpers/common.helper";
|
|
// services
|
|
import APIService from "services/api.service";
|
|
import trackEventServices from "services/track_event.service";
|
|
// types
|
|
import { ICurrentUserResponse } from "types";
|
|
import { IProjectPublishSettings } from "store/project_publish";
|
|
|
|
export class ProjectPublishServices extends APIService {
|
|
constructor() {
|
|
super(API_BASE_URL);
|
|
}
|
|
|
|
async getProjectSettingsAsync(
|
|
workspace_slug: string,
|
|
project_slug: string,
|
|
user: ICurrentUserResponse | undefined
|
|
): Promise<any> {
|
|
return this.get(`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/`)
|
|
.then((response) => {
|
|
// trackEventServices.trackProjectPublishSettingsEvent(
|
|
// response.data,
|
|
// "GET_PROJECT_PUBLISH_SETTINGS",
|
|
// user
|
|
// );
|
|
return response?.data;
|
|
})
|
|
.catch((error) => {
|
|
throw error?.response;
|
|
});
|
|
}
|
|
|
|
async createProjectSettingsAsync(
|
|
workspace_slug: string,
|
|
project_slug: string,
|
|
data: IProjectPublishSettings,
|
|
user: ICurrentUserResponse | undefined
|
|
): Promise<any> {
|
|
return this.post(`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/`, data)
|
|
.then((response) => {
|
|
// trackEventServices.trackProjectPublishSettingsEvent(
|
|
// response.data,
|
|
// "CREATE_PROJECT_PUBLISH_SETTINGS",
|
|
// user
|
|
// );
|
|
|
|
return response?.data;
|
|
})
|
|
.catch((error) => {
|
|
throw error?.response;
|
|
});
|
|
}
|
|
|
|
async updateProjectSettingsAsync(
|
|
workspace_slug: string,
|
|
project_slug: string,
|
|
project_publish_id: string,
|
|
data: IProjectPublishSettings,
|
|
user: ICurrentUserResponse | undefined
|
|
): Promise<any> {
|
|
return this.patch(
|
|
`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/${project_publish_id}/`,
|
|
data
|
|
)
|
|
.then((response) => {
|
|
// trackEventServices.trackProjectPublishSettingsEvent(
|
|
// response.data,
|
|
// "UPDATE_PROJECT_PUBLISH_SETTINGS",
|
|
// user
|
|
// );
|
|
return response?.data;
|
|
})
|
|
.catch((error) => {
|
|
throw error?.response;
|
|
});
|
|
}
|
|
|
|
async deleteProjectSettingsAsync(
|
|
workspace_slug: string,
|
|
project_slug: string,
|
|
project_publish_id: string,
|
|
user: ICurrentUserResponse | undefined
|
|
): Promise<any> {
|
|
return this.delete(
|
|
`/api/workspaces/${workspace_slug}/projects/${project_slug}/project-deploy-boards/${project_publish_id}/`
|
|
)
|
|
.then((response) => {
|
|
// trackEventServices.trackProjectPublishSettingsEvent(
|
|
// response.data,
|
|
// "DELETE_PROJECT_PUBLISH_SETTINGS",
|
|
// user
|
|
// );
|
|
return response?.data;
|
|
})
|
|
.catch((error) => {
|
|
throw error?.response;
|
|
});
|
|
}
|
|
}
|
|
|
|
export default new ProjectPublishServices();
|