From a1c8633963d5c58a5b8cc950f2a46943a57923bb Mon Sep 17 00:00:00 2001 From: Vincent Pochet Date: Thu, 29 Aug 2024 14:28:48 +0200 Subject: [PATCH] feat(ProgressiveBilling): Expose Usage Threshold fields --- lago_python_client/models/__init__.py | 1 + lago_python_client/models/invoice.py | 1 + lago_python_client/models/plan.py | 5 ++++ lago_python_client/models/usage_threshold.py | 29 ++++++++++++++++++++ tests/fixtures/invoice.json | 5 ++-- tests/fixtures/invoice_index.json | 2 ++ tests/fixtures/one_off_invoice.json | 1 + 7 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 lago_python_client/models/usage_threshold.py diff --git a/lago_python_client/models/__init__.py b/lago_python_client/models/__init__.py index 31e29a6f..5aae8344 100644 --- a/lago_python_client/models/__init__.py +++ b/lago_python_client/models/__init__.py @@ -19,6 +19,7 @@ from .subscription import Subscription from .customer_usage import Metric, ChargeObject, ChargeUsage, CustomerUsageResponse from .tax import Tax, Taxes, TaxResponse, TaxesResponse +from .usage_threshold import UsageThreshold, UsageThresholds, UsageThresholdResponse, UsageThresholdsResponse from .wallet import Wallet, RecurringTransactionRule, RecurringTransactionRuleList, \ RecurringTransactionRuleResponse, RecurringTransactionRuleResponseList from .wallet_transaction import WalletTransaction diff --git a/lago_python_client/models/invoice.py b/lago_python_client/models/invoice.py index b78ef8e4..f5750526 100644 --- a/lago_python_client/models/invoice.py +++ b/lago_python_client/models/invoice.py @@ -88,6 +88,7 @@ class InvoiceResponse(BaseResponseModel): sub_total_including_taxes_amount_cents: int total_amount_cents: int prepaid_credit_amount_cents: int + progressive_billing_credit_amount_cents: int file_url: Optional[str] customer: Optional[CustomerResponse] subscriptions: Optional[SubscriptionsResponse] diff --git a/lago_python_client/models/plan.py b/lago_python_client/models/plan.py index 3a825930..830d1aed 100644 --- a/lago_python_client/models/plan.py +++ b/lago_python_client/models/plan.py @@ -5,6 +5,7 @@ from .charge import Charges, ChargesResponse, ChargesOverrides from .minimum_commitment import MinimumCommitment, MinimumCommitmentResponse, MinimumCommitmentOverrides from .tax import Taxes, TaxesResponse +from .usage_threshold import UsageThresholds, UsageThresholdsResponse from ..base_model import BaseResponseModel @@ -22,6 +23,7 @@ class Plan(BaseModel): charges: Optional[Charges] minimum_commitment: Optional[MinimumCommitment] tax_codes: Optional[List[str]] + usage_thresholds: Optional[UsageThresholds] class PlanResponse(BaseResponseModel): @@ -42,6 +44,8 @@ class PlanResponse(BaseResponseModel): active_subscriptions_count: int draft_invoices_count: int taxes: Optional[TaxesResponse] + usage_thresholds: Optional[UsageThresholdsResponse] + class PlanOverrides(BaseModel): name: Optional[str] @@ -53,3 +57,4 @@ class PlanOverrides(BaseModel): charges: Optional[ChargesOverrides] minimum_commitment: Optional[MinimumCommitmentOverrides] tax_codes: Optional[List[str]] + usage_thresholds: Optional[UsageThresholds] diff --git a/lago_python_client/models/usage_threshold.py b/lago_python_client/models/usage_threshold.py new file mode 100644 index 00000000..793ba938 --- /dev/null +++ b/lago_python_client/models/usage_threshold.py @@ -0,0 +1,29 @@ +from typing import List, Optional + +from lago_python_client.base_model import BaseModel + +from ..base_model import BaseResponseModel + + +class UsageThreshold(BaseModel): + id: Optional[str] + threshold_display_name: Optional[str] + amount_cents: int + recurring: bool + + +class UsageThresholds(BaseModel): + __root__: List[UsageThreshold] + + +class UsageThresholdResponse(BaseResponseModel): + lago_id: str + threshold_display_name: Optional[str] + amount_cents: int + recurring: bool + created_at: str + updated_at: str + + +class UsageThresholdsResponse(BaseResponseModel): + __root__: List[UsageThresholdResponse] diff --git a/tests/fixtures/invoice.json b/tests/fixtures/invoice.json index 49b555dd..46d677d2 100644 --- a/tests/fixtures/invoice.json +++ b/tests/fixtures/invoice.json @@ -19,6 +19,7 @@ "sub_total_excluding_taxes_amount_cents": 100, "sub_total_including_taxes_amount_cents": 120, "prepaid_credit_amount_cents": 0, + "progressive_billing_credit_amount_cents": 0, "total_amount_cents": 120, "metadata": [ { @@ -112,9 +113,7 @@ "name": "User Seats", "invoice_display_name": "charge_invoice_display_name", "filters": { - "region": [ - "us-east-1" - ] + "region": ["us-east-1"] } }, "amount_cents": 100, diff --git a/tests/fixtures/invoice_index.json b/tests/fixtures/invoice_index.json index 65a39bc9..989cf21b 100644 --- a/tests/fixtures/invoice_index.json +++ b/tests/fixtures/invoice_index.json @@ -20,6 +20,7 @@ "sub_total_excluding_taxes_amount_cents": 100, "sub_total_including_taxes_amount_cents": 120, "prepaid_credit_amount_cents": 0, + "progressive_billing_credit_amount_cents": 0, "total_amount_cents": 120, "applied_taxes": [ { @@ -56,6 +57,7 @@ "sub_total_excluding_taxes_amount_cents": 100, "sub_total_including_taxes_amount_cents": 120, "prepaid_credit_amount_cents": 0, + "progressive_billing_credit_amount_cents": 0, "total_amount_cents": 120, "applied_taxes": [ { diff --git a/tests/fixtures/one_off_invoice.json b/tests/fixtures/one_off_invoice.json index 0f73c890..b24015ff 100644 --- a/tests/fixtures/one_off_invoice.json +++ b/tests/fixtures/one_off_invoice.json @@ -19,6 +19,7 @@ "sub_total_excluding_taxes_amount_cents": 100, "sub_total_including_taxes_amount_cents": 120, "prepaid_credit_amount_cents": 0, + "progressive_billing_credit_amount_cents": 0, "total_amount_cents": 120, "metadata": [ {