using System;
using System.Threading.Tasks;
using RestSharp;

namespace HorseRacingPredictor.Football.API
{
    internal class Prediction : HorseRacingPredictor.Football.Manager.API
    {
        private const string Endpoint = "predictions";
        
        /// <summary>
        /// Ottiene le previsioni per una partita specifica
        /// </summary>
        public RestResponse GetPredictionByFixture(int fixtureId)
        {
            try
            {
                return ExecuteRequest($"{Endpoint}?fixture={fixtureId}", ApiTypes.Predictions);
            }
            catch (Exception ex)
            {
                throw new Exception($"Errore durante il recupero delle previsioni per la partita {fixtureId}: {ex.Message}", ex);
            }
        }
        
        /// <summary>
        /// Versione asincrona di GetPredictionByFixture
        /// </summary>
        public async Task<RestResponse> GetPredictionByFixtureAsync(int fixtureId)
        {
            try
            {
                return await ExecuteRequestAsync($"{Endpoint}?fixture={fixtureId}");
            }
            catch (Exception ex)
            {
                throw new Exception($"Errore durante il recupero asincrono delle previsioni per la partita {fixtureId}: {ex.Message}", ex);
            }
        }
    }
}
