import { get } from './apiClient';
import type {
  ServiceStatsResponse,
  UserStatsResponse,
  ApiStatsResponse,
  TenantStatsResponse,
  UsageTrendResponse,
} from '../types/statistics';

const buildQuery = (startDate: string, endDate: string) =>
  `?startDate=${startDate}&endDate=${endDate}`;

export const getServiceStats = (startDate: string, endDate: string) =>
  get<ServiceStatsResponse>(`/statistics/services${buildQuery(startDate, endDate)}`);

export const getUserStats = (startDate: string, endDate: string) =>
  get<UserStatsResponse>(`/statistics/users${buildQuery(startDate, endDate)}`);

export const getApiStats = (startDate: string, endDate: string) =>
  get<ApiStatsResponse>(`/statistics/apis${buildQuery(startDate, endDate)}`);

export const getTenantStats = (startDate: string, endDate: string) =>
  get<TenantStatsResponse>(`/statistics/tenants${buildQuery(startDate, endDate)}`);

export const getUsageTrend = (period: string) =>
  get<UsageTrendResponse>(`/statistics/usage-trend?period=${period}`);
