Files
tgex-frontend/lib/api/creatives.ts
2025-12-29 10:12:13 +03:00

62 lines
1.5 KiB
TypeScript

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