import { apiFetch } from "./client";
import type {
  AuthResponse,
  ConnectionStatus,
  LoginRequest,
  ServiceType,
} from "../types/connection";

export const login = (req: LoginRequest) =>
  apiFetch<AuthResponse>("/login", {
    method: "POST",
    body: JSON.stringify(req),
  });

export const getStatuses = () =>
  apiFetch<ConnectionStatus[]>("/connections/status");

export const logout = (serviceType: ServiceType) =>
  apiFetch<void>(`/connections/${serviceType}`, { method: "DELETE" });
