70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
// ============================================================================
|
|
// Placements API
|
|
// ============================================================================
|
|
|
|
import { api } from "./client";
|
|
import type {
|
|
Placement,
|
|
PlacementCreateRequest,
|
|
PlacementUpdateRequest,
|
|
PlacementsQueryParams,
|
|
ViewsHistoryItem,
|
|
ViewsHistoryQueryParams,
|
|
PaginatedResponse,
|
|
} from "@/lib/types/api";
|
|
|
|
export const placementsApi = {
|
|
/**
|
|
* Get list of placements for workspace
|
|
*/
|
|
list: (workspaceId: string, params?: PlacementsQueryParams) =>
|
|
api.get<PaginatedResponse<Placement>>(
|
|
`/workspaces/${workspaceId}/placements`,
|
|
{ params }
|
|
),
|
|
|
|
/**
|
|
* Get single placement
|
|
*/
|
|
get: (workspaceId: string, placementId: string) =>
|
|
api.get<Placement>(`/workspaces/${workspaceId}/placements/${placementId}`),
|
|
|
|
/**
|
|
* Create new placement
|
|
*/
|
|
create: (workspaceId: string, data: PlacementCreateRequest) =>
|
|
api.post<Placement>(`/workspaces/${workspaceId}/placements`, data),
|
|
|
|
/**
|
|
* Update placement
|
|
*/
|
|
update: (
|
|
workspaceId: string,
|
|
placementId: string,
|
|
data: PlacementUpdateRequest
|
|
) =>
|
|
api.patch<Placement>(
|
|
`/workspaces/${workspaceId}/placements/${placementId}`,
|
|
data
|
|
),
|
|
|
|
/**
|
|
* Delete (archive) placement
|
|
*/
|
|
delete: (workspaceId: string, placementId: string) =>
|
|
api.delete<void>(`/workspaces/${workspaceId}/placements/${placementId}`),
|
|
|
|
/**
|
|
* Get views history for placement
|
|
*/
|
|
getViewsHistory: (
|
|
workspaceId: string,
|
|
placementId: string,
|
|
params?: ViewsHistoryQueryParams
|
|
) =>
|
|
api.get<PaginatedResponse<ViewsHistoryItem>>(
|
|
`/workspaces/${workspaceId}/placements/${placementId}/views/history`,
|
|
{ params }
|
|
),
|
|
};
|