diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d8370..9d5e48f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.10.0] - 2025-09-04 + +### Added + +- Add `Invoices.PreviewPdfAsync` method to preview invoice PDF before stamping. + ## [4.9.1] - 2025-07-21 ### Fixed diff --git a/Router/InvoiceRouter.cs b/Router/InvoiceRouter.cs index aa05964..1d0073e 100644 --- a/Router/InvoiceRouter.cs +++ b/Router/InvoiceRouter.cs @@ -62,5 +62,10 @@ public static string CopyInvoice(string id) { return $"invoices/{id}/copy"; } + + public static string PreviewPdf(Dictionary query = null) + { + return UriWithQuery("invoices/preview/pdf", query); + } } } diff --git a/Wrappers/InvoiceWrapper.cs b/Wrappers/InvoiceWrapper.cs index 9d25fae..e31ebe8 100644 --- a/Wrappers/InvoiceWrapper.cs +++ b/Wrappers/InvoiceWrapper.cs @@ -183,5 +183,18 @@ public async Task CopyToDraftAsync(string id) var invoice = JsonConvert.DeserializeObject(resultString, this.jsonSettings); return invoice; } + + public async Task PreviewPdfAsync(Dictionary query = null) + { + var response = await client.GetAsync(Router.PreviewPdf(query)); + if (!response.IsSuccessStatusCode) + { + var resultString = await response.Content.ReadAsStringAsync(); + var error = JsonConvert.DeserializeObject(resultString, this.jsonSettings); + throw new FacturapiException(error["message"].ToString()); + } + var stream = await response.Content.ReadAsStreamAsync(); + return stream; + } } } diff --git a/facturapi-net.csproj b/facturapi-net.csproj index 4958096..24ce242 100644 --- a/facturapi-net.csproj +++ b/facturapi-net.csproj @@ -11,7 +11,7 @@ API Keys creando una cuenta gratuita en https://www.facturapi.io factura factura-electronica cfdi facturapi mexico conekta Facturapi - 4.9.1 + 4.10.0 $(Version) Facturapi facturapi.ico