Coverage for polar/benefit/strategies/custom/schemas.py: 100%
17 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from typing import Annotated, Literal
3from pydantic import Field
4from pydantic.json_schema import SkipJsonSchema
6from polar.kit.schemas import Schema
7from polar.models.benefit import BenefitType
9from ..base.schemas import (
10 BenefitBase,
11 BenefitCreateBase,
12 BenefitSubscriberBase,
13 BenefitUpdateBase,
14)
16Note = Annotated[
17 str | None,
18 Field(
19 description=(
20 "Private note to be shared with customers who have this benefit granted."
21 ),
22 ),
23]
26class BenefitCustomProperties(Schema):
27 """
28 Properties for a benefit of type `custom`.
29 """
31 note: Note | None
34class BenefitCustomCreateProperties(Schema):
35 """
36 Properties for creating a benefit of type `custom`.
37 """
39 note: Note | None = None
42class BenefitCustomSubscriberProperties(Schema):
43 """
44 Properties available to subscribers for a benefit of type `custom`.
45 """
47 note: Note | None
50class BenefitCustomCreate(BenefitCreateBase):
51 """
52 Schema to create a benefit of type `custom`.
53 """
55 type: Literal[BenefitType.custom]
56 properties: BenefitCustomCreateProperties
59class BenefitCustomUpdate(BenefitUpdateBase):
60 type: Literal[BenefitType.custom]
61 properties: BenefitCustomProperties | None = None
64class BenefitCustom(BenefitBase):
65 """
66 A benefit of type `custom`.
68 Use it to grant any kind of benefit that doesn't fit in the other types.
69 """
71 type: Literal[BenefitType.custom]
72 properties: BenefitCustomProperties
73 is_tax_applicable: SkipJsonSchema[bool] = Field(deprecated=True)
76class BenefitCustomSubscriber(BenefitSubscriberBase):
77 type: Literal[BenefitType.custom]
78 properties: BenefitCustomSubscriberProperties