Coverage for polar/benefit/strategies/custom/service.py: 81%
16 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 Any, cast
3from polar.auth.models import AuthSubject
4from polar.models import Benefit, Customer, Organization, User
6from ..base.service import BenefitServiceProtocol
7from .properties import BenefitCustomProperties, BenefitGrantCustomProperties
10class BenefitCustomService(
11 BenefitServiceProtocol[BenefitCustomProperties, BenefitGrantCustomProperties]
12):
13 async def grant(
14 self,
15 benefit: Benefit,
16 customer: Customer,
17 grant_properties: BenefitGrantCustomProperties,
18 *,
19 update: bool = False,
20 attempt: int = 1,
21 ) -> BenefitGrantCustomProperties:
22 return {}
24 async def cycle(
25 self,
26 benefit: Benefit,
27 customer: Customer,
28 grant_properties: BenefitGrantCustomProperties,
29 *,
30 attempt: int = 1,
31 ) -> BenefitGrantCustomProperties:
32 return {}
34 async def revoke(
35 self,
36 benefit: Benefit,
37 customer: Customer,
38 grant_properties: BenefitGrantCustomProperties,
39 *,
40 attempt: int = 1,
41 ) -> BenefitGrantCustomProperties:
42 return {}
44 async def requires_update(
45 self, benefit: Benefit, previous_properties: BenefitCustomProperties
46 ) -> bool:
47 return False
49 async def validate_properties(
50 self, auth_subject: AuthSubject[User | Organization], properties: dict[str, Any]
51 ) -> BenefitCustomProperties:
52 return cast(BenefitCustomProperties, properties)