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

1from typing import Annotated, Literal 

2 

3from pydantic import Field 

4from pydantic.json_schema import SkipJsonSchema 

5 

6from polar.kit.schemas import Schema 

7from polar.models.benefit import BenefitType 

8 

9from ..base.schemas import ( 

10 BenefitBase, 

11 BenefitCreateBase, 

12 BenefitSubscriberBase, 

13 BenefitUpdateBase, 

14) 

15 

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] 

24 

25 

26class BenefitCustomProperties(Schema): 

27 """ 

28 Properties for a benefit of type `custom`. 

29 """ 

30 

31 note: Note | None 

32 

33 

34class BenefitCustomCreateProperties(Schema): 

35 """ 

36 Properties for creating a benefit of type `custom`. 

37 """ 

38 

39 note: Note | None = None 

40 

41 

42class BenefitCustomSubscriberProperties(Schema): 

43 """ 

44 Properties available to subscribers for a benefit of type `custom`. 

45 """ 

46 

47 note: Note | None 

48 

49 

50class BenefitCustomCreate(BenefitCreateBase): 

51 """ 

52 Schema to create a benefit of type `custom`. 

53 """ 

54 

55 type: Literal[BenefitType.custom] 

56 properties: BenefitCustomCreateProperties 

57 

58 

59class BenefitCustomUpdate(BenefitUpdateBase): 

60 type: Literal[BenefitType.custom] 

61 properties: BenefitCustomProperties | None = None 

62 

63 

64class BenefitCustom(BenefitBase): 

65 """ 

66 A benefit of type `custom`. 

67 

68 Use it to grant any kind of benefit that doesn't fit in the other types. 

69 """ 

70 

71 type: Literal[BenefitType.custom] 

72 properties: BenefitCustomProperties 

73 is_tax_applicable: SkipJsonSchema[bool] = Field(deprecated=True) 

74 

75 

76class BenefitCustomSubscriber(BenefitSubscriberBase): 

77 type: Literal[BenefitType.custom] 

78 properties: BenefitCustomSubscriberProperties