42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
// ============================================================================
|
|
// Channels API (Catalog for Placements)
|
|
// ============================================================================
|
|
|
|
import { api } from "./client";
|
|
import type {
|
|
Channel,
|
|
ChannelsQueryParams,
|
|
PaginatedResponse,
|
|
} from "@/lib/types/api";
|
|
|
|
interface CreateChannelInput {
|
|
username?: string;
|
|
invite_link?: string;
|
|
}
|
|
|
|
interface CreateChannelResult {
|
|
index: number;
|
|
status: "created" | "updated" | "failed";
|
|
channel: Channel | null;
|
|
error?: string;
|
|
}
|
|
|
|
interface CreateChannelsResponse {
|
|
results: CreateChannelResult[];
|
|
}
|
|
|
|
export const channelsApi = {
|
|
/**
|
|
* Get catalog of channels for placements
|
|
*/
|
|
list: (params?: ChannelsQueryParams) =>
|
|
api.get<PaginatedResponse<Channel>>("/channels", { params }),
|
|
|
|
/**
|
|
* Create channels by username or invite_link
|
|
* Returns channel IDs for use in placement creation
|
|
*/
|
|
create: (channels: CreateChannelInput[]) =>
|
|
api.post<CreateChannelsResponse>("/channels", { channels }),
|
|
};
|