Coverage for polar/customer_meter/schemas.py: 100%
16 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 16:17 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 16:17 +0000
1from typing import Annotated 1a
3from fastapi import Path 1a
4from pydantic import UUID4, Field 1a
6from polar.customer.schemas.customer import Customer 1a
7from polar.kit.schemas import ( 1a
8 CUSTOMER_ID_EXAMPLE,
9 METER_ID_EXAMPLE,
10 IDSchema,
11 TimestampedSchema,
12)
13from polar.meter.schemas import Meter 1a
15CustomerMeterID = Annotated[UUID4, Path(description="The customer meter ID.")] 1a
18class CustomerMeterBase(TimestampedSchema, IDSchema): 1a
19 customer_id: UUID4 = Field( 1a
20 description="The ID of the customer.", examples=[CUSTOMER_ID_EXAMPLE]
21 )
22 meter_id: UUID4 = Field( 1a
23 description="The ID of the meter.", examples=[METER_ID_EXAMPLE]
24 )
25 consumed_units: float = Field( 1a
26 description="The number of consumed units.", examples=[25.0]
27 )
28 credited_units: int = Field( 1a
29 description="The number of credited units.", examples=[100]
30 )
31 balance: float = Field( 1a
32 description=(
33 "The balance of the meter, "
34 "i.e. the difference between credited and consumed units."
35 ),
36 examples=[75.0],
37 )
40class CustomerMeter(CustomerMeterBase): 1a
41 """An active customer meter, with current consumed and credited units."""
43 customer: Customer = Field(description="The customer associated with this meter.") 1a
44 meter: Meter = Field(description="The meter associated with this customer.") 1a