import { apiClient } from './client';
import type { Kline, OrderBook, Ticker } from '../types/models';

export interface GetKlinesParams {
  symbol: string;
  interval: string;
  limit?: number;
  startTime?: string;
  endTime?: string;
}

export async function getKlines(params: GetKlinesParams): Promise<Kline[]> {
  const response = await apiClient.get<Kline[]>('/api/market/klines', {
    params,
  });
  return response.data;
}

export async function getOrderBook(symbol: string, limit: number = 100): Promise<OrderBook> {
  const response = await apiClient.get<OrderBook>('/api/market/orderbook', {
    params: { symbol, limit },
  });
  return response.data;
}

export async function getTicker(symbol: string): Promise<Ticker> {
  const response = await apiClient.get<Ticker>('/api/market/ticker', {
    params: { symbol },
  });
  return response.data;
}

export async function getAllTickers(): Promise<Ticker[]> {
  const response = await apiClient.get<Ticker[]>('/api/market/tickers');
  return response.data;
}
