62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
// ============================================================================
|
|
// Purchase Plan API
|
|
// ============================================================================
|
|
|
|
import { api } from "./client";
|
|
import type {
|
|
PurchasePlanChannel,
|
|
PurchasePlanChannelCreateRequest,
|
|
PurchasePlanChannelUpdateRequest,
|
|
PaginatedResponse,
|
|
PaginationParams,
|
|
} from "@/lib/types/api";
|
|
|
|
const buildPath = (workspaceId: string, projectId: string) =>
|
|
`/workspaces/${workspaceId}/projects/${projectId}/purchase-plan/channels`;
|
|
|
|
export const purchasePlanApi = {
|
|
/**
|
|
* Get list of channels in purchase plan
|
|
*/
|
|
list: (
|
|
workspaceId: string,
|
|
projectId: string,
|
|
params?: PaginationParams
|
|
) =>
|
|
api.get<PaginatedResponse<PurchasePlanChannel>>(
|
|
buildPath(workspaceId, projectId),
|
|
{ params }
|
|
),
|
|
|
|
/**
|
|
* Add channel to purchase plan
|
|
*/
|
|
create: (
|
|
workspaceId: string,
|
|
projectId: string,
|
|
data: PurchasePlanChannelCreateRequest
|
|
) =>
|
|
api.post<PurchasePlanChannel>(buildPath(workspaceId, projectId), data),
|
|
|
|
/**
|
|
* Update channel in purchase plan
|
|
*/
|
|
update: (
|
|
workspaceId: string,
|
|
projectId: string,
|
|
channelId: string,
|
|
data: PurchasePlanChannelUpdateRequest
|
|
) =>
|
|
api.patch<PurchasePlanChannel>(
|
|
`${buildPath(workspaceId, projectId)}/${channelId}`,
|
|
data
|
|
),
|
|
|
|
/**
|
|
* Remove channel from purchase plan
|
|
*/
|
|
delete: (workspaceId: string, projectId: string, channelId: string) =>
|
|
api.delete<void>(`${buildPath(workspaceId, projectId)}/${channelId}`),
|
|
};
|
|
|