diff --git a/lago_python_client/models/__init__.py b/lago_python_client/models/__init__.py index 21753244..e64c56f0 100644 --- a/lago_python_client/models/__init__.py +++ b/lago_python_client/models/__init__.py @@ -17,6 +17,7 @@ from .subscription import Subscription from .customer_usage import Metric, ChargeObject, ChargeUsage, CustomerUsageResponse from .tax import Tax, Taxes, TaxResponse, TaxesResponse -from .wallet import Wallet +from .wallet import Wallet, RecurringTransactionRule, RecurringTransactionRuleList, \ + RecurringTransactionRuleResponse, RecurringTransactionRuleResponseList from .wallet_transaction import WalletTransaction from .webhook_endpoint import WebhookEndpoint diff --git a/lago_python_client/models/wallet.py b/lago_python_client/models/wallet.py index 10f7f46f..00042773 100644 --- a/lago_python_client/models/wallet.py +++ b/lago_python_client/models/wallet.py @@ -1,10 +1,37 @@ -from typing import Optional +from typing import List, Optional from pydantic import BaseModel from ..base_model import BaseResponseModel +class RecurringTransactionRule(BaseModel): + lago_id: Optional[str] + rule_type: Optional[str] + interval: Optional[str] + threshold_credits: Optional[str] + paid_credits: Optional[str] + granted_credits: Optional[str] + + +class RecurringTransactionRuleResponse(BaseModel): + lago_id: Optional[str] + rule_type: Optional[str] + interval: Optional[str] + threshold_credits: Optional[str] + paid_credits: Optional[str] + granted_credits: Optional[str] + created_at: Optional[str] + + +class RecurringTransactionRuleList(BaseModel): + __root__: List[RecurringTransactionRule] + + +class RecurringTransactionRuleResponseList(BaseModel): + __root__: List[RecurringTransactionRuleResponse] + + class Wallet(BaseModel): external_customer_id: Optional[str] rate_amount: Optional[str] @@ -13,6 +40,7 @@ class Wallet(BaseModel): granted_credits: Optional[str] expiration_at: Optional[str] currency: Optional[str] + recurring_transaction_rules: Optional[RecurringTransactionRuleList] class WalletResponse(BaseResponseModel): @@ -31,4 +59,5 @@ class WalletResponse(BaseResponseModel): last_balance_sync_at: Optional[str] last_consumed_credit_at: Optional[str] terminated_at: Optional[str] + recurring_transaction_rules: Optional[RecurringTransactionRuleResponseList] balance: str # NOTE(legacy) diff --git a/tests/fixtures/wallet.json b/tests/fixtures/wallet.json index 08e975e0..c65c3b68 100644 --- a/tests/fixtures/wallet.json +++ b/tests/fixtures/wallet.json @@ -14,6 +14,15 @@ "created_at": "2022-04-29T08:59:51Z", "expiration_at": null, "last_balance_sync_at": "2022-04-29T08:59:51Z", - "last_consumed_credit_at": "2022-04-29T08:59:51Z" + "last_consumed_credit_at": "2022-04-29T08:59:51Z", + "recurring_transaction_rules": [ + { + "lago_id": "12345", + "rule_type": "interval", + "interval": "monthly", + "paid_credits": "105.0", + "granted_credits": "105.0" + } + ] } } diff --git a/tests/test_wallet_client.py b/tests/test_wallet_client.py index 09b518e7..d5399589 100644 --- a/tests/test_wallet_client.py +++ b/tests/test_wallet_client.py @@ -5,16 +5,24 @@ from lago_python_client.client import Client from lago_python_client.exceptions import LagoApiError -from lago_python_client.models import Wallet +from lago_python_client.models import Wallet, RecurringTransactionRule, RecurringTransactionRuleList def wallet_object(): + rule = RecurringTransactionRule( + rule_type='interval', + interval='monthly', + paid_credits='105.0', + granted_credits='105.0', + ) + rules_list = RecurringTransactionRuleList(__root__=[rule]) return Wallet( name='name', external_customer_id='12345', rate_amount='1', paid_credits='10', - granted_credits='10' + granted_credits='10', + recurring_transaction_rules=rules_list ) @@ -41,6 +49,9 @@ def test_valid_create_wallet_request(httpx_mock: HTTPXMock): response = client.wallets.create(wallet_object()) assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b' + assert response.recurring_transaction_rules.__root__[0].lago_id == '12345' + assert response.recurring_transaction_rules.__root__[0].rule_type == 'interval' + assert response.recurring_transaction_rules.__root__[0].interval == 'monthly' def test_invalid_create_wallet_request(httpx_mock: HTTPXMock):