34 lines
1,019 B
TypeScript
34 lines
1,019 B
TypeScript
import BaseService from "./BaseService";
|
|
|
|
export default class IntegrationsService extends BaseService {
|
|
fetchList = async (name: string) => {
|
|
const r = await this.client.get(`/integrations/${name}`)
|
|
const data = await r.json()
|
|
|
|
return data
|
|
}
|
|
|
|
fetchIntegration = async (name: string, siteId: string) => {
|
|
const url = siteId && name !== 'github' && name !== 'jira' ? `/${siteId}/integrations/${name}` : `/integrations/${name}`
|
|
const r = await this.client.get(url)
|
|
const data = await r.json()
|
|
|
|
return data
|
|
}
|
|
|
|
saveIntegration = async (name: string, siteId: string, data: any) => {
|
|
const url = (siteId ? `/${siteId}` : '') + `/integrations/${name}`
|
|
const r = await this.client.post(url, data)
|
|
const res = await r.json()
|
|
|
|
return res
|
|
}
|
|
|
|
removeIntegration = async (name: string, siteId: string) => {
|
|
const url = (siteId ? `/${siteId}` : '') + `/integrations/${name}`
|
|
const r = await this.client.delete(url)
|
|
const res = await r.json()
|
|
|
|
return res
|
|
}
|
|
}
|