using Hotline.CallCenter;
using Hotline.CallCenter.Configs;
using Hotline.NewRock;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;

namespace Hotline.Api.Controllers;

[ApiController]
[Route("api/report")]
public class ReportController : ControllerBase
{
    private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
    private readonly IDeviceEventHandler _deviceEventHandler;

    public ReportController(IOptionsSnapshot<CallCenterConfiguration> options, IDeviceEventHandler deviceEventHandler)
    {
        _options = options;
        _deviceEventHandler = deviceEventHandler;
    }

    [AllowAnonymous]
    [HttpGet]
    public async Task ReceiveEvents()
    {
        await _deviceEventHandler.HandleAsync(Request.Body, _options.Value.NewRock, HttpContext.RequestAborted);
    }
}