using DoliMiddlewareApi.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace DoliMiddlewareApi.Controllers { [Route("api/[controller]")] [ApiController] [Authorize] public class DocumentController(DocumentService documentService) : ControllerBase { [HttpGet("invoice/{invoiceRef}/pdf")] [ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)] [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] public async Task GetInvoicePdf(string invoiceRef) { var (content, filename) = await documentService.BuildInvoicePdfAsync(invoiceRef); return File(content, "application/pdf", filename); } } }