import apiClient from './client';
import type { IndicatorResult, EMACrossResult } from '../lib/types';

interface IndicatorEnvelopeData {
  symbol: string;
  indicator: IndicatorResult;
}

interface EMACrossEnvelopeData {
  symbol: string;
  ema_cross: EMACrossResult;
}

export function getIndicator(symbol: string, indicatorType: string) {
  return apiClient
    .get<IndicatorEnvelopeData>(`indicators/${symbol}/${indicatorType}`)
    .then((r) => (r.data as unknown as IndicatorEnvelopeData).indicator);
}

export function getEMACross(symbol: string) {
  return apiClient
    .get<EMACrossEnvelopeData>(`indicators/${symbol}/ema-cross`)
    .then((r) => (r.data as unknown as EMACrossEnvelopeData).ema_cross);
}
