import axios from "../http-client" import type { ChannelId, ChannelType, Server, ServerChannel, ServerId, ServerInvite } from "../types" interface CreateServerRequest { name: string iconId?: string } interface CreateServerChannelRequest { name: string type: ChannelType } export async function list() { const response = await axios.get("/servers") return response.data as Server[] } export async function create(request: CreateServerRequest) { const response = await axios.post("/servers", request) return response.data as Server } export async function get(serverId: ServerId) { const response = await axios.get(`/servers/${serverId}`) return response.data as Server } export async function delet(serverId: ServerId) { const response = await axios.delete(`/servers/${serverId}`) return response.data as Server } export async function listChannels(serverId: ServerId) { const response = await axios.get(`/servers/${serverId}/channels`) return response.data as ServerChannel[] } export async function createChannel(serverId: ServerId, request: CreateServerChannelRequest) { const response = await axios.post(`/servers/${serverId}/channels`, request) return response.data as ServerChannel } export async function getChannel(serverId: ServerId, channelId: ChannelId) { const response = await axios.get(`/servers/${serverId}/channels/${channelId}`) return response.data as ServerChannel } export async function deleteChannel(serverId: ServerId, channelId: ChannelId) { const response = await axios.delete(`/servers/${serverId}/channels/${channelId}`) return response.data as ServerChannel } export async function createInvite(serverId: ServerId) { const response = await axios.post(`/servers/${serverId}/invites`) return response.data as ServerInvite } export async function getInvite(inviteCode: string) { const response = await axios.get(`/invites/${inviteCode}`) return response.data as Server } export default { create, list, listChannels, get, delet, createChannel, getChannel, deleteChannel, createInvite, getInvite }