From b6e8b824084daf6f84d44a4181ae5fc974050d26 Mon Sep 17 00:00:00 2001 From: Miguel Pinto Date: Thu, 6 Feb 2025 15:05:29 +0000 Subject: [PATCH] feat: Apply Ruff code formatter --- lago_python_client/customers/clients.py | 13 +++++++------ tests/test_customer_client.py | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lago_python_client/customers/clients.py b/lago_python_client/customers/clients.py index 77956b6..cae9f1a 100644 --- a/lago_python_client/customers/clients.py +++ b/lago_python_client/customers/clients.py @@ -1,5 +1,5 @@ import sys -from typing import Any, Mapping, ClassVar, Type +from typing import Any, Mapping, ClassVar, Type, Optional from ..base_client import BaseClient from ..mixins import ( @@ -36,16 +36,17 @@ class CustomerClient( ROOT_NAME: ClassVar[str] = "customer" def current_usage( - self, resource_id: str, external_subscription_id: str, apply_taxes: bool = True + self, resource_id: str, external_subscription_id: str, apply_taxes: Optional[str] = None ) -> CustomerUsageResponse: + query_params = {"external_subscription_id": external_subscription_id} + if apply_taxes is not None: + query_params["apply_taxes"] = apply_taxes + api_response: Response = send_get_request( url=make_url( origin=self.base_url, path_parts=(self.API_RESOURCE, resource_id, "current_usage"), - query_pairs={ - "external_subscription_id": external_subscription_id, - "apply_taxes": str(apply_taxes).lower(), - }, + query_pairs=query_params, ), headers=make_headers(api_key=self.api_key), ) diff --git a/tests/test_customer_client.py b/tests/test_customer_client.py index 6a1b133..27fa469 100644 --- a/tests/test_customer_client.py +++ b/tests/test_customer_client.py @@ -117,7 +117,7 @@ def test_valid_current_usage(httpx_mock: HTTPXMock): httpx_mock.add_response( method="GET", - url="https://api.getlago.com/api/v1/customers/external_customer_id/current_usage?external_subscription_id=123&apply_taxes=true", + url="https://api.getlago.com/api/v1/customers/external_customer_id/current_usage?external_subscription_id=123", content=mock_response("customer_usage"), ) response = client.customers.current_usage("external_customer_id", "123") @@ -137,7 +137,7 @@ def test_valid_current_usage_without_taxes(httpx_mock: HTTPXMock): url="https://api.getlago.com/api/v1/customers/external_customer_id/current_usage?external_subscription_id=123&apply_taxes=false", content=mock_response("customer_usage"), ) - response = client.customers.current_usage("external_customer_id", "123", False) + response = client.customers.current_usage("external_customer_id", "123", "false") assert response.from_datetime == "2022-07-01T00:00:00Z" assert len(response.charges_usage) == 1 @@ -151,7 +151,7 @@ def test_invalid_current_usage(httpx_mock: HTTPXMock): httpx_mock.add_response( method="GET", - url="https://api.getlago.com/api/v1/customers/invalid_customer/current_usage?external_subscription_id=123&apply_taxes=true", + url="https://api.getlago.com/api/v1/customers/invalid_customer/current_usage?external_subscription_id=123", status_code=404, content=b"", )