65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using RestSharp;
|
|
|
|
namespace HorseRacingPredictor.Football.API
|
|
{
|
|
internal class Odds : HorseRacingPredictor.Football.Manager.API
|
|
{
|
|
private const string Endpoint = "odds";
|
|
|
|
/// <summary>
|
|
/// Ottiene le quote per una data specifica (tutti i bookmaker, nessun filtro).
|
|
/// </summary>
|
|
public RestResponse GetOddsByDate(DateTime date, int page = 1)
|
|
{
|
|
try
|
|
{
|
|
string dateStr = date.ToString("yyyy-MM-dd");
|
|
return ExecuteRequest($"{Endpoint}?date={dateStr}&page={page}", ApiTypes.Odds);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Errore durante il recupero delle quote per la data {date.ToShortDateString()}: {ex.Message}", ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Overload legacy: mantiene la compatibilità con codice che passa bookmaker.
|
|
/// </summary>
|
|
public RestResponse GetOddsByDate(DateTime date, int bookmaker, int page)
|
|
=> GetOddsByDate(date, page);
|
|
|
|
/// <summary>
|
|
/// Versione asincrona di GetOddsByDate (tutti i bookmaker).
|
|
/// </summary>
|
|
public async Task<RestResponse> GetOddsByDateAsync(DateTime date, int page = 1)
|
|
{
|
|
try
|
|
{
|
|
string dateStr = date.ToString("yyyy-MM-dd");
|
|
return await ExecuteRequestAsync($"{Endpoint}?date={dateStr}&page={page}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Errore durante il recupero asincrono delle quote per la data {date.ToShortDateString()}: {ex.Message}", ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ottiene le quote per una partita specifica (tutti i bookmaker).
|
|
/// </summary>
|
|
public RestResponse GetOddsByFixture(int fixtureId)
|
|
{
|
|
try
|
|
{
|
|
return ExecuteRequest($"{Endpoint}?fixture={fixtureId}", ApiTypes.Odds);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Errore durante il recupero delle quote per la partita {fixtureId}: {ex.Message}", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|