dolibarr-bff/DoliMiddlewareApi/Controllers/DocumentController.cs

27 lines
914 B
C#
Raw Normal View History

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<IActionResult> GetInvoicePdf(string invoiceRef)
{
var (content, filename) = await documentService.BuildInvoicePdfAsync(invoiceRef);
return File(content, "application/pdf", filename);
}
}
}