feat: global platform v2 update
This commit is contained in:
@@ -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}`),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user