2026-04-15 14:49:41 +00:00
|
|
|
|
using DoliMiddlewareApi.Services;
|
2026-05-14 18:48:35 +00:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2026-04-15 14:49:41 +00:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DoliMiddlewareApi.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
|
[ApiController]
|
2026-05-14 18:48:35 +00:00
|
|
|
|
[Authorize]
|
2026-04-15 14:49:41 +00:00
|
|
|
|
public class DocumentController(DocumentService documentService) : ControllerBase
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2026-04-16 07:41:46 +00:00
|
|
|
|
[HttpGet("invoice/{invoiceRef}/pdf")]
|
2026-05-14 18:48:35 +00:00
|
|
|
|
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
|
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
|
|
|
|
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
2026-04-16 07:41:46 +00:00
|
|
|
|
public async Task<IActionResult> GetInvoicePdf(string invoiceRef)
|
2026-04-15 14:49:41 +00:00
|
|
|
|
{
|
2026-04-16 07:41:46 +00:00
|
|
|
|
var (content, filename) = await documentService.BuildInvoicePdfAsync(invoiceRef);
|
2026-04-15 14:49:41 +00:00
|
|
|
|
|
2026-04-16 07:41:46 +00:00
|
|
|
|
return File(content, "application/pdf", filename);
|
2026-04-15 14:49:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|