Skip to content

Commit

Permalink
feat: Apply Ruff code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomiguelpinto committed Feb 6, 2025
1 parent d8f9434 commit b6e8b82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions lago_python_client/customers/clients.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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),
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_customer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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"",
)
Expand Down

0 comments on commit b6e8b82

Please sign in to comment.