plane/web/services/integration/jira.service.ts
sriram veeraghanta 6659cfc8b0
fix: track events issue and env variables fixes (#2184)
* fix: track event fixes

* fix: adding env variables to trubo
2023-09-14 16:05:31 +05:30

41 lines
1.2 KiB
TypeScript

import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
import { API_BASE_URL } from "helpers/common.helper";
// types
import { IJiraMetadata, IJiraResponse, IJiraImporterForm, ICurrentUserResponse } from "types";
class JiraImportedService extends APIService {
constructor() {
super(API_BASE_URL);
}
async getJiraProjectInfo(workspaceSlug: string, params: IJiraMetadata): Promise<IJiraResponse> {
return this.get(`/api/workspaces/${workspaceSlug}/importers/jira`, {
params,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async createJiraImporter(
workspaceSlug: string,
data: IJiraImporterForm,
user: ICurrentUserResponse | undefined
): Promise<IJiraResponse> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/importers/jira/`, data)
.then((response) => {
trackEventServices.trackImporterEvent(response?.data, "JIRA_IMPORTER_CREATE", user);
return response?.data;
})
.catch((error) => {
throw error?.response?.data;
});
}
}
const jiraImporterService = new JiraImportedService();
export default jiraImporterService;