feat: global platform v2 update

This commit is contained in:
ivannoskov
2025-12-29 10:12:13 +03:00
parent 8e6a1fa83f
commit f64cf02100
84 changed files with 11023 additions and 11486 deletions

View File

@@ -5,69 +5,65 @@
import { api } from "./client";
import type {
Placement,
PlacementQueryParams,
PlacementCreateRequest,
PlacementUpdateRequest,
PlacementsListResponse,
ViewsFetchResponse,
ViewsHistoryResponse,
SuccessResponse,
PlacementsQueryParams,
ViewsHistoryItem,
ViewsHistoryQueryParams,
PaginatedResponse,
} from "@/lib/types/api";
export const placementsApi = {
/**
* Get list of placements
* Get list of placements for workspace
*/
list: (params?: PlacementQueryParams) =>
api.get<PlacementsListResponse>("/placements", { params }),
list: (workspaceId: string, params?: PlacementsQueryParams) =>
api.get<PaginatedResponse<Placement>>(
`/workspaces/${workspaceId}/placements`,
{ params }
),
/**
* Get placement details
* Get single placement
*/
get: (id: string) => api.get<Placement>(`/placements/${id}`),
get: (workspaceId: string, placementId: string) =>
api.get<Placement>(`/workspaces/${workspaceId}/placements/${placementId}`),
/**
* Create new placement
*/
create: (data: PlacementCreateRequest) =>
api.post<Placement>("/placements", data),
create: (workspaceId: string, data: PlacementCreateRequest) =>
api.post<Placement>(`/workspaces/${workspaceId}/placements`, data),
/**
* Update placement
*/
update: (id: string, data: PlacementUpdateRequest) =>
api.patch<Placement>(`/placements/${id}`, data),
update: (
workspaceId: string,
placementId: string,
data: PlacementUpdateRequest
) =>
api.patch<Placement>(
`/workspaces/${workspaceId}/placements/${placementId}`,
data
),
/**
* Delete placement
* Delete (archive) placement
*/
delete: (id: string) => api.delete<SuccessResponse>(`/placements/${id}`),
/**
* Fetch views for placement
*/
fetchViews: (id: string) =>
api.post<ViewsFetchResponse>(`/placements/${id}/views/fetch`),
delete: (workspaceId: string, placementId: string) =>
api.delete<void>(`/workspaces/${workspaceId}/placements/${placementId}`),
/**
* Get views history for placement
*/
viewsHistory: (
id: string,
params?: { from_date?: string; to_date?: string }
getViewsHistory: (
workspaceId: string,
placementId: string,
params?: ViewsHistoryQueryParams
) =>
api.get<ViewsHistoryResponse>(`/placements/${id}/views/history`, {
params,
}),
/**
* Set views manually
*/
setViewsManually: (id: string, views_count: number) =>
api.post<Placement>(`/placements/${id}/views/manual`, null, {
params: { views_count },
}),
api.get<PaginatedResponse<ViewsHistoryItem>>(
`/workspaces/${workspaceId}/placements/${placementId}/views/history`,
{ params }
),
};
// Keep purchasesApi as an alias for backwards compatibility
export const purchasesApi = placementsApi;