| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from stripe._expandable_field import ExpandableField |
| 4 |
from stripe._list_object import ListObject |
| 5 |
from stripe._listable_api_resource import ListableAPIResource |
| 6 |
from typing import ClassVar |
| 7 |
from typing_extensions import Literal, Unpack, TYPE_CHECKING |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from stripe.entitlements._feature import Feature |
| 11 |
from stripe.params.entitlements._active_entitlement_list_params import ( |
| 12 |
ActiveEntitlementListParams, |
| 13 |
) |
| 14 |
from stripe.params.entitlements._active_entitlement_retrieve_params import ( |
| 15 |
ActiveEntitlementRetrieveParams, |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
class ActiveEntitlement(ListableAPIResource["ActiveEntitlement"]): |
| 20 |
""" |
| 21 |
An active entitlement describes access to a feature for a customer. |
| 22 |
""" |
| 23 |
|
| 24 |
OBJECT_NAME: ClassVar[Literal["entitlements.active_entitlement"]] = ( |
| 25 |
"entitlements.active_entitlement" |
| 26 |
) |
| 27 |
feature: ExpandableField["Feature"] |
| 28 |
""" |
| 29 |
The [Feature](https://docs.stripe.com/api/entitlements/feature) that the customer is entitled to. |
| 30 |
""" |
| 31 |
id: str |
| 32 |
""" |
| 33 |
Unique identifier for the object. |
| 34 |
""" |
| 35 |
livemode: bool |
| 36 |
""" |
| 37 |
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. |
| 38 |
""" |
| 39 |
lookup_key: str |
| 40 |
""" |
| 41 |
A unique key you provide as your own system identifier. This may be up to 80 characters. |
| 42 |
""" |
| 43 |
object: Literal["entitlements.active_entitlement"] |
| 44 |
""" |
| 45 |
String representing the object's type. Objects of the same type share the same value. |
| 46 |
""" |
| 47 |
|
| 48 |
@classmethod |
| 49 |
def list( |
| 50 |
cls, **params: Unpack["ActiveEntitlementListParams"] |
| 51 |
) -> ListObject["ActiveEntitlement"]: |
| 52 |
""" |
| 53 |
Retrieve a list of active entitlements for a customer |
| 54 |
""" |
| 55 |
result = cls._static_request( |
| 56 |
"get", |
| 57 |
cls.class_url(), |
| 58 |
params=params, |
| 59 |
) |
| 60 |
if not isinstance(result, ListObject): |
| 61 |
raise TypeError( |
| 62 |
"Expected list object from API, got %s" |
| 63 |
% (type(result).__name__) |
| 64 |
) |
| 65 |
|
| 66 |
return result |
| 67 |
|
| 68 |
@classmethod |
| 69 |
async def list_async( |
| 70 |
cls, **params: Unpack["ActiveEntitlementListParams"] |
| 71 |
) -> ListObject["ActiveEntitlement"]: |
| 72 |
""" |
| 73 |
Retrieve a list of active entitlements for a customer |
| 74 |
""" |
| 75 |
result = await cls._static_request_async( |
| 76 |
"get", |
| 77 |
cls.class_url(), |
| 78 |
params=params, |
| 79 |
) |
| 80 |
if not isinstance(result, ListObject): |
| 81 |
raise TypeError( |
| 82 |
"Expected list object from API, got %s" |
| 83 |
% (type(result).__name__) |
| 84 |
) |
| 85 |
|
| 86 |
return result |
| 87 |
|
| 88 |
@classmethod |
| 89 |
def retrieve( |
| 90 |
cls, id: str, **params: Unpack["ActiveEntitlementRetrieveParams"] |
| 91 |
) -> "ActiveEntitlement": |
| 92 |
""" |
| 93 |
Retrieve an active entitlement |
| 94 |
""" |
| 95 |
instance = cls(id, **params) |
| 96 |
instance.refresh() |
| 97 |
return instance |
| 98 |
|
| 99 |
@classmethod |
| 100 |
async def retrieve_async( |
| 101 |
cls, id: str, **params: Unpack["ActiveEntitlementRetrieveParams"] |
| 102 |
) -> "ActiveEntitlement": |
| 103 |
""" |
| 104 |
Retrieve an active entitlement |
| 105 |
""" |
| 106 |
instance = cls(id, **params) |
| 107 |
await instance.refresh_async() |
| 108 |
return instance |