Skip to content

Commit

Permalink
feat: Expose billing periods with invoice object (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet authored Jan 17, 2025
1 parent 3a29bd3 commit 68516be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lago_python_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
BillableMetricEvaluateExpression as BillableMetricEvaluateExpression,
BillableMetricEvaluateExpressionResponse as BillableMetricEvaluateExpressionResponse,
)
from .billing_period import (
BillingPeriodResponse as BillingPeriodResponse,
BillingPeriodsResponse as BillingPeriodsResponse,
)
from .charge import (
Charge as Charge,
Charges as Charges,
Expand Down
18 changes: 18 additions & 0 deletions lago_python_client/models/billing_period.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import List

from lago_python_client.base_model import BaseResponseModel


class BillingPeriodResponse(BaseResponseModel):
lago_subscription_id: str
external_subscription_id: str
lago_plan_id: str
subscription_from_datetime: str
subscription_to_datetime: str
charges_from_datetime: str
charges_to_datetime: str
invoicing_reason: str


class BillingPeriodsResponse(BaseResponseModel):
__root__: List[BillingPeriodResponse]
2 changes: 2 additions & 0 deletions lago_python_client/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from lago_python_client.base_model import BaseModel

from .billing_period import BillingPeriodsResponse
from .credit import CreditsResponse
from .customer import CustomerResponse
from .fee import FeesResponse
Expand Down Expand Up @@ -118,6 +119,7 @@ class InvoiceResponse(BaseResponseModel):

file_url: Optional[str]
customer: Optional[CustomerResponse]
billing_periods: Optional[BillingPeriodsResponse]
subscriptions: Optional[SubscriptionsResponse]
fees: Optional[FeesResponse]
credits: Optional[CreditsResponse]
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
}
]
},
"billing_periods": [
{
"lago_subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "LAG-EXT-1234",
"lago_plan_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"subscription_from_datetime": "2025-02-00T00:00:00Z",
"subscription_to_datetime": "2025-02-28T23:59:59Z",
"charges_from_datetime": "2025-01-00T00:00:00Z",
"charges_to_datetime": "2025-01-31T23:59:59Z",
"invoicing_reason": "subscription_periodic"
}
],
"subscriptions": [
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
Expand Down

0 comments on commit 68516be

Please sign in to comment.