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,39 +5,57 @@
import { api } from "./client";
import type {
Creative,
CreativeQueryParams,
CreativeCreateRequest,
CreativeUpdateRequest,
CreativesListResponse,
SuccessResponse,
CreativesQueryParams,
PaginatedResponse,
} from "@/lib/types/api";
export const creativesApi = {
/**
* Get list of creatives
* Get list of creatives for workspace
*/
list: (params?: CreativeQueryParams) =>
api.get<CreativesListResponse>("/creatives", { params }),
list: (workspaceId: string, params?: CreativesQueryParams) =>
api.get<PaginatedResponse<Creative>>(
`/workspaces/${workspaceId}/creatives`,
{ params }
),
/**
* Get creative details
* Get single creative
*/
get: (id: string) => api.get<Creative>(`/creatives/${id}`),
get: (workspaceId: string, creativeId: string) =>
api.get<Creative>(`/workspaces/${workspaceId}/creatives/${creativeId}`),
/**
* Create new creative
* @param projectId - Required query param for the project
*/
create: (data: CreativeCreateRequest) =>
api.post<Creative>("/creatives", data),
create: (
workspaceId: string,
projectId: string,
data: CreativeCreateRequest
) =>
api.post<Creative>(`/workspaces/${workspaceId}/creatives`, data, {
params: { project_id: projectId },
}),
/**
* Update creative
*/
update: (id: string, data: CreativeUpdateRequest) =>
api.patch<Creative>(`/creatives/${id}`, data),
update: (
workspaceId: string,
creativeId: string,
data: CreativeUpdateRequest
) =>
api.patch<Creative>(
`/workspaces/${workspaceId}/creatives/${creativeId}`,
data
),
/**
* Delete creative
* Delete (archive) creative
*/
delete: (id: string) => api.delete<SuccessResponse>(`/creatives/${id}`),
delete: (workspaceId: string, creativeId: string) =>
api.delete<void>(`/workspaces/${workspaceId}/creatives/${creativeId}`),
};