using Hc900Crawler.Infrastructure.Control;
using Microsoft.AspNetCore.Mvc;

namespace Hc900Crawler.Web.Controllers;

[ApiController]
[Route("api/steam")]
public sealed class SteamAdvisorController : ControllerBase
{
    private readonly SteamAdvisor _advisor;

    public SteamAdvisorController(SteamAdvisor advisor)
    {
        _advisor = advisor;
    }

    [HttpGet("health")]
    public IActionResult Health()
    {
        return Ok(new { loaded = _advisor.IsLoaded });
    }

    [HttpGet("predict")]
    public IActionResult Predict(
        [FromQuery] double feed,
        [FromQuery] double product,
        [FromQuery] double tC)
    {
        var result = _advisor.Predict(feed, product, tC);
        return Ok(result);
    }

    [HttpPost("predict")]
    public IActionResult PredictPost([FromBody] SteamPredictBody body)
    {
        var result = _advisor.Predict(body.Feed, body.Product, body.TC);
        return Ok(result);
    }
}

public sealed record SteamPredictBody
{
    public double Feed { get; init; }
    public double Product { get; init; }
    public double TC { get; init; }
}
