Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(grouped-by): Add new fields #223

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lago_python_client/models/customer_usage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Dict, List, Optional

from pydantic import BaseModel

Expand All @@ -23,6 +23,12 @@ class ChargeObject(BaseModel):
charge_model: str
invoice_display_name: Optional[str]

class GroupedUsage(BaseModel):
amount_cents: int
events_count: int
units: float
grouped_by: Dict[str, str]
groups: List[Group]

class ChargeUsage(BaseModel):
units: float
Expand All @@ -32,6 +38,7 @@ class ChargeUsage(BaseModel):
charge: ChargeObject
billable_metric: Metric
groups: List[Group]
grouped_usage: Optional[List[GroupedUsage]]


class CustomerUsageResponse(BaseResponseModel):
Expand Down
3 changes: 2 additions & 1 deletion lago_python_client/models/invoice_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Dict, Optional

from ..base_model import BaseResponseModel

Expand All @@ -12,3 +12,4 @@ class InvoiceItemResponse(BaseResponseModel):
group_invoice_display_name: Optional[str]
lago_item_id: Optional[str]
item_type: Optional[str]
grouped_by: Optional[Dict[str, str]]
20 changes: 20 additions & 0 deletions tests/fixtures/customer_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
"events_count": 1,
"amount_cents": 123
}
],
"grouped_usage": [
{
"amount_cents": 123,
"events_count": 1,
"units": "3.0",
"grouped_by": {
"agent_name": "aragorn"
},
"groups": [
{
"lago_id": "12435687-1de8-4428-9bcd-779314ac1111",
"key": "google",
"value": "europe",
"units": "3.0",
"events_count": 1,
"amount_cents": 123
}
]
}
]
}
]
Expand Down
5 changes: 4 additions & 1 deletion tests/fixtures/fee.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"type": "charge",
"code": "fee_code",
"name": "Fee Code",
"invoice_display_name": "charge_invoice_display_name"
"invoice_display_name": "charge_invoice_display_name",
"grouped_by": {
"agent_name": "aragorn"
}
},
"amount_cents": 120,
"amount_currency": "EUR",
Expand Down
5 changes: 4 additions & 1 deletion tests/fixtures/fees.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"type": "instant_charge",
"code": "fee_code",
"name": "Fee Code",
"invoice_display_name": "charge_invoice_display_name"
"invoice_display_name": "charge_invoice_display_name",
"grouped_by": {
"agent_name": "aragorn"
}
},
"amount_cents": 120,
"amount_currency": "EUR",
Expand Down
5 changes: 4 additions & 1 deletion tests/fixtures/plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"amount": "0.22"
"amount": "0.22",
"grouped_by": [
"agent_name"
]
},
"taxes": [
{
Expand Down
Loading