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

41 statements  

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

1from typing import Literal 1a

2 

3from pydantic import Field 1a

4 

5from polar.kit.schemas import EmptyStrToNone, Schema 1a

6from polar.models.benefit import BenefitType 1a

7 

8from ..base.schemas import ( 1a

9 BenefitBase, 

10 BenefitCreateBase, 

11 BenefitSubscriberBase, 

12 BenefitUpdateBase, 

13) 

14 

15 

16class BenefitLicenseKeyExpirationProperties(Schema): 1a

17 ttl: int = Field(gt=0) 1a

18 timeframe: Literal["year", "month", "day"] 1a

19 

20 

21class BenefitLicenseKeyActivationCreateProperties(Schema): 1a

22 limit: int = Field(gt=0, le=50) 1a

23 enable_customer_admin: bool 1a

24 

25 

26class BenefitLicenseKeyActivationProperties(Schema): 1a

27 limit: int 1a

28 enable_customer_admin: bool 1a

29 

30 

31class BenefitLicenseKeysCreateProperties(Schema): 1a

32 prefix: EmptyStrToNone | None = None 1a

33 expires: BenefitLicenseKeyExpirationProperties | None = None 1a

34 activations: BenefitLicenseKeyActivationCreateProperties | None = None 1a

35 limit_usage: int | None = Field(gt=0, default=None) 1a

36 

37 

38class BenefitLicenseKeysProperties(Schema): 1a

39 prefix: str | None 1a

40 expires: BenefitLicenseKeyExpirationProperties | None 1a

41 activations: BenefitLicenseKeyActivationProperties | None 1a

42 limit_usage: int | None 1a

43 

44 

45class BenefitLicenseKeysSubscriberProperties(Schema): 1a

46 prefix: str | None 1a

47 expires: BenefitLicenseKeyExpirationProperties | None 1a

48 activations: BenefitLicenseKeyActivationProperties | None 1a

49 limit_usage: int | None 1a

50 

51 

52class BenefitLicenseKeysCreate(BenefitCreateBase): 1a

53 type: Literal[BenefitType.license_keys] 1a

54 properties: BenefitLicenseKeysCreateProperties 1a

55 

56 

57class BenefitLicenseKeysUpdate(BenefitUpdateBase): 1a

58 type: Literal[BenefitType.license_keys] 1a

59 properties: BenefitLicenseKeysCreateProperties | None = None 1a

60 

61 

62class BenefitLicenseKeys(BenefitBase): 1a

63 type: Literal[BenefitType.license_keys] 1a

64 properties: BenefitLicenseKeysProperties 1a

65 

66 

67class BenefitLicenseKeysSubscriber(BenefitSubscriberBase): 1a

68 type: Literal[BenefitType.license_keys] 1a

69 properties: BenefitLicenseKeysSubscriberProperties 1a