import { APIClient } from "./ApiClient";

export interface GlobalStats {
  global_balance: number;
  number_movements: number;
  number_files: number;
  total_files_size: number;
}

export type StatBalanceVariation = Record<string, number> & { time: number };

export class StatsApi {
  /**
   * Get global statistics
   */
  static async GetGlobal(): Promise<GlobalStats> {
    return (
      await APIClient.exec({
        uri: `/stats/global`,
        method: "GET",
      })
    ).data;
  }

  /**
   * Get balance variation statistics
   */
  static async BalanceVariationStats(
    start: number,
    end: number,
    interval: number
  ): Promise<StatBalanceVariation[]> {
    return (
      await APIClient.exec({
        uri: `/stats/balance_variation?start=${start}&end=${end}&interval=${interval}`,
        method: "GET",
      })
    ).data;
  }
}
