Skip to content

Commit 405d25c

Browse files
authored
Add support for pricing units (#328)
1 parent cea0810 commit 405d25c

File tree

7 files changed

+74
-1
lines changed

7 files changed

+74
-1
lines changed

lago_python_client/models/charge.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class ChargeFilter(BaseModel):
1212
values: Optional[Dict[str, List[str]]]
1313

1414

15+
class AppliedPricingUnit(BaseModel):
16+
code: Optional[str]
17+
conversion_rate: Optional[float]
18+
19+
1520
class ChargeFilters(BaseModel):
1621
__root__: List[ChargeFilter]
1722

@@ -29,6 +34,7 @@ class Charge(BaseModel):
2934
properties: Optional[Dict[str, Any]]
3035
filters: Optional[ChargeFilters]
3136
tax_codes: Optional[List[str]]
37+
applied_pricing_unit: Optional[AppliedPricingUnit]
3238

3339

3440
class Charges(BaseModel):

lago_python_client/models/customer_usage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ class Metric(BaseModel):
1212
aggregation_type: str
1313

1414

15+
class PricingUnitDetails(BaseModel):
16+
amount_cents: int
17+
short_name: str
18+
conversion_rate: float
19+
20+
1521
class ChargeFilterUsage(BaseModel):
1622
invoice_display_name: Optional[str]
1723
values: Dict[str, List[str]]
1824
units: str
1925
amount_cents: int
2026
events_count: int
27+
pricing_unit_details: Optional[PricingUnitDetails]
2128

2229

2330
class ChargeObject(BaseModel):
@@ -32,6 +39,7 @@ class GroupedUsage(BaseModel):
3239
units: float
3340
grouped_by: Dict[str, str]
3441
filters: List[ChargeFilterUsage]
42+
pricing_unit_details: Optional[PricingUnitDetails]
3543

3644

3745
class ChargeUsage(BaseModel):
@@ -43,6 +51,7 @@ class ChargeUsage(BaseModel):
4351
billable_metric: Metric
4452
filters: List[ChargeFilterUsage]
4553
grouped_usage: Optional[List[GroupedUsage]]
54+
pricing_unit_details: Optional[PricingUnitDetails]
4655

4756

4857
class CustomerUsageResponse(BaseResponseModel):

lago_python_client/models/fee.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ class FeeAppliedTaxes(BaseResponseModel):
2626
__root__: List[FeeAppliedTax]
2727

2828

29+
class PricingUnitDetails(BaseResponseModel):
30+
lago_pricing_unit_id: Optional[str]
31+
pricing_unit_code: Optional[str]
32+
short_name: Optional[str]
33+
amount_cents: Optional[int]
34+
precise_amount_cents: Optional[str]
35+
unit_amount_cents: Optional[int]
36+
precise_unit_amount: Optional[str]
37+
conversion_rate: Optional[float]
38+
39+
2940
class FeeResponse(BaseResponseModel):
3041
lago_id: Optional[str]
3142
lago_charge_id: Optional[str]
@@ -59,6 +70,7 @@ class FeeResponse(BaseResponseModel):
5970
from_date: Optional[str]
6071
to_date: Optional[str]
6172
amount_details: Optional[Dict[str, Any]]
73+
pricing_unit_details: Optional[PricingUnitDetails]
6274
billing_entity_code: Optional[str]
6375

6476
item: Optional[InvoiceItemResponse]

tests/fixtures/customer_past_usage.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
"code": "usage_metric",
2626
"aggregation_type": "sum"
2727
},
28+
"pricing_unit_details": {
29+
"amount_cents": 123,
30+
"short_name": "CR",
31+
"conversion_rate": 1.0
32+
},
2833
"filters": [
2934
{
3035
"units": "3.0",
@@ -34,6 +39,11 @@
3439
"country": [
3540
"france"
3641
]
42+
},
43+
"pricing_unit_details": {
44+
"amount_cents": 123,
45+
"short_name": "CR",
46+
"conversion_rate": 1.0
3747
}
3848
}
3949
]

tests/fixtures/customer_usage.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
"code": "usage_metric",
2626
"aggregation_type": "sum"
2727
},
28+
"pricing_unit_details": {
29+
"amount_cents": 123,
30+
"short_name": "CR",
31+
"conversion_rate": 1.0
32+
},
2833
"filters": [
2934
{
3035
"units": "3.0",
@@ -34,6 +39,11 @@
3439
"country": [
3540
"france"
3641
]
42+
},
43+
"pricing_unit_details": {
44+
"amount_cents": 123,
45+
"short_name": "CR",
46+
"conversion_rate": 1.0
3747
}
3848
}
3949
],
@@ -45,6 +55,11 @@
4555
"grouped_by": {
4656
"agent_name": "aragorn"
4757
},
58+
"pricing_unit_details": {
59+
"amount_cents": 456,
60+
"short_name": "CR",
61+
"conversion_rate": 1.2
62+
},
4863
"filters": [
4964
{
5065
"units": "3.0",
@@ -54,7 +69,8 @@
5469
"country": [
5570
"france"
5671
]
57-
}
72+
},
73+
"pricing_unit_details": null
5874
}
5975
]
6076
}

tests/fixtures/fee.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
"total_amount_currency": "EUR",
2727
"units": "10.0",
2828
"events_count": 10,
29+
"pricing_unit_details": {
30+
"lago_pricing_unit_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
31+
"pricing_unit_code": "unit_code",
32+
"short_name": "UC",
33+
"amount_cents": 120,
34+
"precise_amount_cents": "120.00",
35+
"unit_amount_cents": 12,
36+
"precise_unit_amount": "12.00",
37+
"conversion_rate": 1.0
38+
},
2939
"applied_taxes": [
3040
{
3141
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",

tests/fixtures/fees.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
"total_amount_currency": "EUR",
2727
"units": "1.0",
2828
"events_count": 1,
29+
"pricing_unit_details": {
30+
"lago_pricing_unit_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
31+
"pricing_unit_code": "unit_code",
32+
"short_name": "UN",
33+
"amount_cents": 120,
34+
"precise_amount_cents": "120.00",
35+
"unit_amount_cents": 120,
36+
"precise_unit_amount": "120.00",
37+
"conversion_rate": 1.0
38+
},
2939
"applied_taxes": [
3040
{
3141
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",

0 commit comments

Comments
 (0)