// ============================================================================ // 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>( `/workspaces/${workspaceId}/creatives`, { params } ), /** * Get list of creatives for a specific project */ listByProject: (workspaceId: string, projectId: string) => api.get>( `/workspaces/${workspaceId}/creatives`, { params: { project_id: projectId } } ), /** * Get single creative */ get: (workspaceId: string, creativeId: string) => api.get(`/workspaces/${workspaceId}/creatives/${creativeId}`), /** * Create new creative * @param projectId - Required query param for the project */ create: ( workspaceId: string, projectId: string, data: CreativeCreateRequest ) => api.post(`/workspaces/${workspaceId}/creatives`, data, { params: { project_id: projectId }, }), /** * Update creative */ update: ( workspaceId: string, creativeId: string, data: CreativeUpdateRequest ) => api.patch( `/workspaces/${workspaceId}/creatives/${creativeId}`, data ), /** * Delete (archive) creative */ delete: (workspaceId: string, creativeId: string) => api.delete(`/workspaces/${workspaceId}/creatives/${creativeId}`), };