Coverage for polar/benefit/strategies/custom/schemas.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 15:52 +0000

1from typing import Annotated, Literal 1a

2 

3from pydantic import Field 1a

4from pydantic.json_schema import SkipJsonSchema 1a

5 

6from polar.kit.schemas import Schema 1a

7from polar.models.benefit import BenefitType 1a

8 

9from ..base.schemas import ( 1a

10 BenefitBase, 

11 BenefitCreateBase, 

12 BenefitSubscriberBase, 

13 BenefitUpdateBase, 

14) 

15 

16Note = Annotated[ 1a

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): 1a

27 """ 

28 Properties for a benefit of type `custom`. 

29 """ 

30 

31 note: Note | None 1a

32 

33 

34class BenefitCustomCreateProperties(Schema): 1a

35 """ 

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

37 """ 

38 

39 note: Note | None = None 1a

40 

41 

42class BenefitCustomSubscriberProperties(Schema): 1a

43 """ 

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

45 """ 

46 

47 note: Note | None 1a

48 

49 

50class BenefitCustomCreate(BenefitCreateBase): 1a

51 """ 

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

53 """ 

54 

55 type: Literal[BenefitType.custom] 1a

56 properties: BenefitCustomCreateProperties 1a

57 

58 

59class BenefitCustomUpdate(BenefitUpdateBase): 1a

60 type: Literal[BenefitType.custom] 1a

61 properties: BenefitCustomProperties | None = None 1a

62 

63 

64class BenefitCustom(BenefitBase): 1a

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] 1a

72 properties: BenefitCustomProperties 1a

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

74 

75 

76class BenefitCustomSubscriber(BenefitSubscriberBase): 1a

77 type: Literal[BenefitType.custom] 1a

78 properties: BenefitCustomSubscriberProperties 1a