mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 13:29:56 +02:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { IWebhook } from "@plane/types";
|
|
// helpers
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
// services
|
|
import { APIService } from "@/services/api.service";
|
|
|
|
export class InternalWebhookService extends APIService {
|
|
constructor() {
|
|
super(API_BASE_URL);
|
|
}
|
|
|
|
/**
|
|
* @description get or create the internal webhook url
|
|
* @param { string } workspaceSlug
|
|
* @param { Partial<IWebhook> } payload
|
|
* @returns { Promise<{ is_connected: boolean } | undefined> }
|
|
*/
|
|
async getOrCreateInternalWebhook(
|
|
workspaceSlug: string,
|
|
payload: Partial<IWebhook>
|
|
): Promise<{ is_connected: boolean; id: string } | undefined> {
|
|
return this.post(`/api/workspaces/${workspaceSlug}/internal-webhooks/`, payload)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @description delete the internal webhook url
|
|
* @param { string } workspaceSlug
|
|
* @param { string } id
|
|
* @returns { Promise<void> }
|
|
*/
|
|
async deleteInternalWebhook(workspaceSlug: string, id: string): Promise<void> {
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/internal-webhooks/${id}`)
|
|
.then((res) => res?.data)
|
|
.catch((err) => {
|
|
throw err?.response?.data;
|
|
});
|
|
}
|
|
}
|
|
|
|
export const internalWebhookService = new InternalWebhookService();
|
|
|
|
export default internalWebhookService;
|