using e_suite.API.Common;
using e_suite.Utilities.Pagination;
using eSuite.API.security;
using eSuite.API.Utilities;
using eSuite.Core.Security;
using Microsoft.AspNetCore.Mvc;

namespace eSuite.API.Controllers;

/// <summary>
/// This part of the API is responsible for maintaining Exception Logs within e-suite
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class ExceptionLogsController : ESuiteControllerBase
{
    private readonly IExceptionLogManager _exceptionLogManager;
    /// <summary>
    /// Default constructor used for dependency injection
    /// </summary>
    public ExceptionLogsController(IExceptionLogManager exceptionLogManager)
    {
        _exceptionLogManager = exceptionLogManager;
    }

    /// <summary>
    /// Returns a list of all the exception logs in the system
    /// </summary>
    /// <remarks>This returns all the exception logs  in the system.</remarks>
    /// <param name="paging"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    [Route("exceptionlogs")]
    [HttpGet]
    [AccessKey(SecurityAccess.ViewErrorLogs)]
    [ProducesResponseType(StatusCodes.Status200OK)]
    public async Task<IActionResult> Get([FromQuery] Paging paging, CancellationToken cancellationToken = default!)
    {
        var result = await _exceptionLogManager.GetExceptionLogs(paging, cancellationToken);
        return Ok(result);
    }
}
