Skip to content

Commit

Permalink
feat(ProgressiveBilling): Expose Usage Threshold fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed Aug 29, 2024
1 parent bf34230 commit a1c8633
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions lago_python_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lago_python_client/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions lago_python_client/models/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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):
Expand All @@ -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]
Expand All @@ -53,3 +57,4 @@ class PlanOverrides(BaseModel):
charges: Optional[ChargesOverrides]
minimum_commitment: Optional[MinimumCommitmentOverrides]
tax_codes: Optional[List[str]]
usage_thresholds: Optional[UsageThresholds]
29 changes: 29 additions & 0 deletions lago_python_client/models/usage_threshold.py
Original file line number Diff line number Diff line change
@@ -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]
5 changes: 2 additions & 3 deletions tests/fixtures/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/invoice_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/one_off_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit a1c8633

Please sign in to comment.