From f8acf60a89ce819bb941a6db98a178758a74abe0 Mon Sep 17 00:00:00 2001 From: Ancor Cruz Date: Fri, 19 Jun 2026 15:19:46 +0100 Subject: [PATCH 1/2] feat(subscriptions): add activation_rules, cancellation_reason and activated_at --- .tool-versions | 1 + lago_python_client/models/__init__.py | 2 +- lago_python_client/models/subscription.py | 19 +++++++++++++++++++ tests/fixtures/subscription.json | 13 +++++++++++++ tests/test_subscription_client.py | 21 +++++++++++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..269a4eb --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +python 3.12.5 diff --git a/lago_python_client/models/__init__.py b/lago_python_client/models/__init__.py index fbd141a..7fcf802 100644 --- a/lago_python_client/models/__init__.py +++ b/lago_python_client/models/__init__.py @@ -234,7 +234,7 @@ from .payment_request import PaymentRequest as PaymentRequest from .payment_method import PaymentMethod as PaymentMethod, PaymentMethodResponse as PaymentMethodResponse from .plan import Plan as Plan -from .subscription import Subscription as Subscription +from .subscription import ActivationRuleInput as ActivationRuleInput, Subscription as Subscription from .tax import ( Tax as Tax, ) diff --git a/lago_python_client/models/subscription.py b/lago_python_client/models/subscription.py index 408ec60..807ca74 100644 --- a/lago_python_client/models/subscription.py +++ b/lago_python_client/models/subscription.py @@ -8,6 +8,11 @@ from .plan import PlanOverrides +class ActivationRuleInput(BaseModel): + type: Optional[str] + timeout_hours: Optional[int] + + class Subscription(BaseModel): plan_code: Optional[str] external_customer_id: Optional[str] @@ -20,6 +25,7 @@ class Subscription(BaseModel): payment_method: Optional[PaymentMethod] invoice_custom_section: Optional[InvoiceCustomSectionInput] consolidate_invoice: Optional[bool] + activation_rules: Optional[List[ActivationRuleInput]] class Subscriptions(BaseModel): @@ -28,6 +34,16 @@ class Subscriptions(BaseModel): terminated_at: Optional[str] +class ActivationRuleResponse(BaseResponseModel): + lago_id: Optional[str] + type: Optional[str] + timeout_hours: Optional[int] + status: Optional[str] + expires_at: Optional[str] + created_at: Optional[str] + updated_at: Optional[str] + + class SubscriptionResponse(BaseResponseModel): lago_id: str lago_customer_id: Optional[str] @@ -57,6 +73,9 @@ class SubscriptionResponse(BaseResponseModel): payment_method: Optional[PaymentMethod] applied_invoice_custom_sections: Optional[AppliedInvoiceCustomSections] consolidate_invoice: Optional[bool] + cancellation_reason: Optional[str] + activated_at: Optional[str] + activation_rules: Optional[List[ActivationRuleResponse]] class SubscriptionsResponse(BaseResponseModel): diff --git a/tests/fixtures/subscription.json b/tests/fixtures/subscription.json index 24412ab..ffc6074 100644 --- a/tests/fixtures/subscription.json +++ b/tests/fixtures/subscription.json @@ -37,6 +37,19 @@ "name": "Section Name" } } + ], + "cancellation_reason": "payment_failed", + "activated_at": "2022-04-29T09:00:00Z", + "activation_rules": [ + { + "lago_id": "ar_123", + "type": "payment", + "timeout_hours": 48, + "status": "pending", + "expires_at": "2022-04-29T10:59:51Z", + "created_at": "2022-04-29T08:59:51Z", + "updated_at": "2022-04-29T08:59:51Z" + } ] } } diff --git a/tests/test_subscription_client.py b/tests/test_subscription_client.py index 2512e42..b0af46b 100644 --- a/tests/test_subscription_client.py +++ b/tests/test_subscription_client.py @@ -8,6 +8,7 @@ from lago_python_client.exceptions import LagoApiError from lago_python_client.mixins import DEFAULT_TIMEOUT from lago_python_client.models import ( + ActivationRuleInput, Charge, ChargeFilter, FixedCharge, @@ -108,6 +109,26 @@ def test_valid_create_subscriptions_request_with_payment_method(httpx_mock: HTTP assert response.payment_method.payment_method_id == "pm_123" +def test_valid_create_subscriptions_request_with_activation_rules(httpx_mock: HTTPXMock): + client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d") + + httpx_mock.add_response( + method="POST", + url="https://api.getlago.com/api/v1/subscriptions", + content=mock_response(), + ) + subscription = create_subscription() + subscription.activation_rules = [ActivationRuleInput(type="payment", timeout_hours=48)] + response = client.subscriptions.create(subscription) + + assert response.external_customer_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba" + assert response.cancellation_reason == "payment_failed" + assert response.activated_at == "2022-04-29T09:00:00Z" + assert response.activation_rules[0].type == "payment" + assert response.activation_rules[0].timeout_hours == 48 + assert response.activation_rules[0].status == "pending" + + def test_invalid_create_subscriptions_request(httpx_mock: HTTPXMock): client = Client(api_key="invalid") From 2e841a0dd026a566a48e082d5e2e254c49af773a Mon Sep 17 00:00:00 2001 From: Ancor Cruz Date: Tue, 23 Jun 2026 13:06:43 +0100 Subject: [PATCH 2/2] chore: untrack .tool-versions and gitignore version-manager pins .tool-versions pins a single Python patch, which is a local-dev concern inconsistent with a published library that supports a range (setup.cfg python_requires + CI matrix 3.9-3.13). Matches existing handling of .python-version and mise.toml. --- .gitignore | 2 ++ .tool-versions | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 .tool-versions diff --git a/.gitignore b/.gitignore index 1d80fbf..23a38f5 100644 --- a/.gitignore +++ b/.gitignore @@ -72,5 +72,7 @@ Untitled.ipynb *.iml # End of https://www.toptal.com/developers/gitignore/api/python +# asdf / mise version managers (local dev only; supported versions live in setup.cfg + CI) +.tool-versions mise.toml .claude diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 269a4eb..0000000 --- a/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -python 3.12.5