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 16:17 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 16:17 +0000
1from typing import Literal 1a
3from pydantic import Field 1a
5from polar.kit.schemas import EmptyStrToNone, Schema 1a
6from polar.models.benefit import BenefitType 1a
8from ..base.schemas import ( 1a
9 BenefitBase,
10 BenefitCreateBase,
11 BenefitSubscriberBase,
12 BenefitUpdateBase,
13)
16class BenefitLicenseKeyExpirationProperties(Schema): 1a
17 ttl: int = Field(gt=0) 1a
18 timeframe: Literal["year", "month", "day"] 1a
21class BenefitLicenseKeyActivationCreateProperties(Schema): 1a
22 limit: int = Field(gt=0, le=50) 1a
23 enable_customer_admin: bool 1a
26class BenefitLicenseKeyActivationProperties(Schema): 1a
27 limit: int 1a
28 enable_customer_admin: bool 1a
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
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
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
52class BenefitLicenseKeysCreate(BenefitCreateBase): 1a
53 type: Literal[BenefitType.license_keys] 1a
54 properties: BenefitLicenseKeysCreateProperties 1a
57class BenefitLicenseKeysUpdate(BenefitUpdateBase): 1a
58 type: Literal[BenefitType.license_keys] 1a
59 properties: BenefitLicenseKeysCreateProperties | None = None 1a
62class BenefitLicenseKeys(BenefitBase): 1a
63 type: Literal[BenefitType.license_keys] 1a
64 properties: BenefitLicenseKeysProperties 1a
67class BenefitLicenseKeysSubscriber(BenefitSubscriberBase): 1a
68 type: Literal[BenefitType.license_keys] 1a
69 properties: BenefitLicenseKeysSubscriberProperties 1a