Skip to content

Commit e4fff95

Browse files
feat(invoice): Add missing void action (#312)
1 parent 3fde923 commit e4fff95

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ Untitled.ipynb
7171
.idea/*
7272
*.iml
7373
# End of https://www.toptal.com/developers/gitignore/api/python
74+
75+
mise.toml

lago_python_client/invoices/clients.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ def finalize(self, resource_id: str) -> InvoiceResponse:
107107
data=get_response_data(response=api_response, key=self.ROOT_NAME),
108108
)
109109

110+
def void(self, resource_id: str) -> InvoiceResponse:
111+
api_response: Response = send_post_request(
112+
url=make_url(
113+
origin=self.base_url,
114+
path_parts=(self.API_RESOURCE, resource_id, "void"),
115+
),
116+
headers=make_headers(api_key=self.api_key),
117+
)
118+
119+
return prepare_object_response(
120+
response_model=self.RESPONSE_MODEL,
121+
data=get_response_data(response=api_response, key=self.ROOT_NAME),
122+
)
123+
110124
def lose_dispute(self, resource_id: str) -> InvoiceResponse:
111125
api_response: Response = send_put_request(
112126
url=make_url(

tests/test_invoice_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,19 @@ def test_valid_finalize_invoice_request(httpx_mock: HTTPXMock):
252252
assert response.lago_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
253253

254254

255+
def test_valid_void_invoice_request(httpx_mock: HTTPXMock):
256+
client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
257+
258+
httpx_mock.add_response(
259+
method="POST",
260+
url="https://api.getlago.com/api/v1/invoices/5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba/void",
261+
content=mock_response(),
262+
)
263+
response = client.invoices.void("5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba")
264+
265+
assert response.lago_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
266+
267+
255268
def test_valid_retry_payment_invoice_request(httpx_mock: HTTPXMock):
256269
client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
257270

0 commit comments

Comments
 (0)