Skip to content

Commit

Permalink
feat(grouped-by): Add new fields (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet authored Feb 12, 2024
1 parent 8403ba6 commit ddae5df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
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

0 comments on commit ddae5df

Please sign in to comment.