39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { http } from './client'
|
|
import type { ChannelConnection, ChannelSyncLog, ChannelType } from '@/types'
|
|
|
|
/** GET /api/channels */
|
|
export function getChannels() {
|
|
return http.get<ChannelConnection[]>('/api/channels')
|
|
}
|
|
|
|
/** POST /api/channels/connect */
|
|
export function connectChannel(payload: {
|
|
type: ChannelType
|
|
account: string
|
|
syncRange?: string
|
|
defaultOwnerId?: string
|
|
autoReply?: boolean
|
|
}) {
|
|
return http.post<ChannelConnection>('/api/channels/connect', payload)
|
|
}
|
|
|
|
/** POST /api/channels/test */
|
|
export function testChannel(id: string) {
|
|
return http.post<{ success: boolean; latencyMs: number; message: string }>('/api/channels/test', { id })
|
|
}
|
|
|
|
/** PATCH /api/channels/:id */
|
|
export function updateChannel(id: string, payload: Partial<ChannelConnection>) {
|
|
return http.patch<ChannelConnection>(`/api/channels/${id}`, payload)
|
|
}
|
|
|
|
/** DELETE /api/channels/:id */
|
|
export function deleteChannel(id: string) {
|
|
return http.del<{ success: boolean }>(`/api/channels/${id}`)
|
|
}
|
|
|
|
/** GET /api/channels/:id/logs */
|
|
export function getChannelLogs(id: string) {
|
|
return http.get<ChannelSyncLog[]>(`/api/channels/${id}/logs`)
|
|
}
|