From 4072564de53d9ac2a7e931c8f33f43a907020bca Mon Sep 17 00:00:00 2001 From: endenis Date: Tue, 28 Jul 2026 16:25:31 +0200 Subject: [PATCH] feat(invoices): support deleting a draft invoice --- lago_python_client/invoices/clients.py | 2 ++ tests/test_invoice_client.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lago_python_client/invoices/clients.py b/lago_python_client/invoices/clients.py index 58c4a777..30732fbf 100644 --- a/lago_python_client/invoices/clients.py +++ b/lago_python_client/invoices/clients.py @@ -3,6 +3,7 @@ from ..base_client import BaseClient from ..mixins import ( CreateCommandMixin, + DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin, @@ -24,6 +25,7 @@ class InvoiceClient( FindAllCommandMixin[InvoiceResponse], UpdateCommandMixin[InvoiceResponse], CreateCommandMixin[InvoiceResponse], + DestroyCommandMixin[InvoiceResponse], BaseClient, ): API_RESOURCE: ClassVar[str] = "invoices" diff --git a/tests/test_invoice_client.py b/tests/test_invoice_client.py index c2a838ac..a3399c70 100644 --- a/tests/test_invoice_client.py +++ b/tests/test_invoice_client.py @@ -307,6 +307,32 @@ def test_valid_void_invoice_request(httpx_mock: HTTPXMock): assert response.lago_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba" +def test_valid_destroy_invoice_request(httpx_mock: HTTPXMock): + client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d") + + httpx_mock.add_response( + method="DELETE", + url="https://api.getlago.com/api/v1/invoices/5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba", + content=mock_response(), + ) + response = client.invoices.destroy("5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba") + + assert response.lago_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba" + + +def test_invalid_destroy_invoice_request(httpx_mock: HTTPXMock): + client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d") + + httpx_mock.add_response( + method="DELETE", + url="https://api.getlago.com/api/v1/invoices/5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba", + status_code=422, + content=b"", + ) + with pytest.raises(LagoApiError): + client.invoices.destroy("5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba") + + def test_valid_retry_payment_invoice_request(httpx_mock: HTTPXMock): client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")