Coverage for polar/storefront/schemas.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 12:42 +0000

1from pydantic import Field 

2 

3from polar.benefit.schemas import BenefitPublic 

4from polar.file.schemas import ProductMediaFileRead 

5from polar.kit.schemas import Schema 

6from polar.organization.schemas import Organization 

7from polar.product.schemas import ProductBase, ProductPrice 

8 

9 

10class ProductStorefront(ProductBase): 

11 """Schema of a public product.""" 

12 

13 prices: list[ProductPrice] = Field( 

14 description="List of available prices for this product." 

15 ) 

16 benefits: list[BenefitPublic] = Field( 

17 title="BenefitPublic", description="The benefits granted by the product." 

18 ) 

19 medias: list[ProductMediaFileRead] = Field( 

20 description="The medias associated to the product." 

21 ) 

22 

23 

24class StorefrontCustomer(Schema): 

25 name: str 

26 

27 

28class StorefrontCustomers(Schema): 

29 total: int 

30 customers: list[StorefrontCustomer] 

31 

32 

33class Storefront(Schema): 

34 """Schema of a public storefront.""" 

35 

36 organization: Organization 

37 products: list[ProductStorefront] 

38 donation_product: ProductStorefront | None 

39 customers: StorefrontCustomers 

40 

41 

42class OrganizationSlugLookup(Schema): 

43 """Schema for organization slug lookup response.""" 

44 

45 organization_slug: str = Field( 

46 description="The slug of the organization that owns the product or subscription." 

47 )