bb-plane-fork/apps/web/core/services/sticky.service.ts
sriram veeraghanta 02d0ee3e0f
chore: add copyright (#8584)
* feat: adding new copyright info on all files

* chore: adding CI
2026-01-27 13:54:22 +05:30

68 lines
1.9 KiB
TypeScript

/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
// helpers
import { STICKIES_PER_PAGE, API_BASE_URL } from "@plane/constants";
import type { TSticky } from "@plane/types";
// services
import { APIService } from "@/services/api.service";
export class StickyService extends APIService {
constructor() {
super(API_BASE_URL);
}
async createSticky(workspaceSlug: string, payload: Partial<TSticky>) {
return this.post(`/api/workspaces/${workspaceSlug}/stickies/`, payload)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
async getStickies(
workspaceSlug: string,
cursor: string,
query?: string,
per_page?: number
): Promise<{ results: TSticky[]; total_pages: number }> {
return this.get(`/api/workspaces/${workspaceSlug}/stickies/`, {
params: {
cursor,
per_page: per_page || STICKIES_PER_PAGE,
query,
},
})
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
async getSticky(workspaceSlug: string, id: string) {
return this.get(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
async updateSticky(workspaceSlug: string, id: string, data: Partial<TSticky>) {
return await this.patch(`/api/workspaces/${workspaceSlug}/stickies/${id}/`, data)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
async deleteSticky(workspaceSlug: string, id: string) {
return await this.delete(`/api/workspaces/${workspaceSlug}/stickies/${id}`)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
}