This commit is contained in:
Iliyan Angelov
2025-11-17 18:26:30 +02:00
parent 48353cde9c
commit 0c59fe1173
2535 changed files with 278997 additions and 2480 deletions

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from importlib import import_module
from typing_extensions import TYPE_CHECKING
if TYPE_CHECKING:
from stripe.entitlements._active_entitlement import (
ActiveEntitlement as ActiveEntitlement,
)
from stripe.entitlements._active_entitlement_service import (
ActiveEntitlementService as ActiveEntitlementService,
)
from stripe.entitlements._active_entitlement_summary import (
ActiveEntitlementSummary as ActiveEntitlementSummary,
)
from stripe.entitlements._feature import Feature as Feature
from stripe.entitlements._feature_service import (
FeatureService as FeatureService,
)
# name -> (import_target, is_submodule)
_import_map = {
"ActiveEntitlement": ("stripe.entitlements._active_entitlement", False),
"ActiveEntitlementService": (
"stripe.entitlements._active_entitlement_service",
False,
),
"ActiveEntitlementSummary": (
"stripe.entitlements._active_entitlement_summary",
False,
),
"Feature": ("stripe.entitlements._feature", False),
"FeatureService": ("stripe.entitlements._feature_service", False),
}
if not TYPE_CHECKING:
def __getattr__(name):
try:
target, is_submodule = _import_map[name]
module = import_module(target)
if is_submodule:
return module
return getattr(
module,
name,
)
except KeyError:
raise AttributeError()

View File

@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._expandable_field import ExpandableField
from stripe._list_object import ListObject
from stripe._listable_api_resource import ListableAPIResource
from typing import ClassVar
from typing_extensions import Literal, Unpack, TYPE_CHECKING
if TYPE_CHECKING:
from stripe.entitlements._feature import Feature
from stripe.params.entitlements._active_entitlement_list_params import (
ActiveEntitlementListParams,
)
from stripe.params.entitlements._active_entitlement_retrieve_params import (
ActiveEntitlementRetrieveParams,
)
class ActiveEntitlement(ListableAPIResource["ActiveEntitlement"]):
"""
An active entitlement describes access to a feature for a customer.
"""
OBJECT_NAME: ClassVar[Literal["entitlements.active_entitlement"]] = (
"entitlements.active_entitlement"
)
feature: ExpandableField["Feature"]
"""
The [Feature](https://stripe.com/docs/api/entitlements/feature) that the customer is entitled to.
"""
id: str
"""
Unique identifier for the object.
"""
livemode: bool
"""
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
"""
lookup_key: str
"""
A unique key you provide as your own system identifier. This may be up to 80 characters.
"""
object: Literal["entitlements.active_entitlement"]
"""
String representing the object's type. Objects of the same type share the same value.
"""
@classmethod
def list(
cls, **params: Unpack["ActiveEntitlementListParams"]
) -> ListObject["ActiveEntitlement"]:
"""
Retrieve a list of active entitlements for a customer
"""
result = cls._static_request(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
async def list_async(
cls, **params: Unpack["ActiveEntitlementListParams"]
) -> ListObject["ActiveEntitlement"]:
"""
Retrieve a list of active entitlements for a customer
"""
result = await cls._static_request_async(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
def retrieve(
cls, id: str, **params: Unpack["ActiveEntitlementRetrieveParams"]
) -> "ActiveEntitlement":
"""
Retrieve an active entitlement
"""
instance = cls(id, **params)
instance.refresh()
return instance
@classmethod
async def retrieve_async(
cls, id: str, **params: Unpack["ActiveEntitlementRetrieveParams"]
) -> "ActiveEntitlement":
"""
Retrieve an active entitlement
"""
instance = cls(id, **params)
await instance.refresh_async()
return instance

View File

@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from typing_extensions import TYPE_CHECKING
if TYPE_CHECKING:
from stripe._list_object import ListObject
from stripe._request_options import RequestOptions
from stripe.entitlements._active_entitlement import ActiveEntitlement
from stripe.params.entitlements._active_entitlement_list_params import (
ActiveEntitlementListParams,
)
from stripe.params.entitlements._active_entitlement_retrieve_params import (
ActiveEntitlementRetrieveParams,
)
class ActiveEntitlementService(StripeService):
def list(
self,
params: "ActiveEntitlementListParams",
options: Optional["RequestOptions"] = None,
) -> "ListObject[ActiveEntitlement]":
"""
Retrieve a list of active entitlements for a customer
"""
return cast(
"ListObject[ActiveEntitlement]",
self._request(
"get",
"/v1/entitlements/active_entitlements",
base_address="api",
params=params,
options=options,
),
)
async def list_async(
self,
params: "ActiveEntitlementListParams",
options: Optional["RequestOptions"] = None,
) -> "ListObject[ActiveEntitlement]":
"""
Retrieve a list of active entitlements for a customer
"""
return cast(
"ListObject[ActiveEntitlement]",
await self._request_async(
"get",
"/v1/entitlements/active_entitlements",
base_address="api",
params=params,
options=options,
),
)
def retrieve(
self,
id: str,
params: Optional["ActiveEntitlementRetrieveParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "ActiveEntitlement":
"""
Retrieve an active entitlement
"""
return cast(
"ActiveEntitlement",
self._request(
"get",
"/v1/entitlements/active_entitlements/{id}".format(
id=sanitize_id(id),
),
base_address="api",
params=params,
options=options,
),
)
async def retrieve_async(
self,
id: str,
params: Optional["ActiveEntitlementRetrieveParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "ActiveEntitlement":
"""
Retrieve an active entitlement
"""
return cast(
"ActiveEntitlement",
await self._request_async(
"get",
"/v1/entitlements/active_entitlements/{id}".format(
id=sanitize_id(id),
),
base_address="api",
params=params,
options=options,
),
)

View File

@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._list_object import ListObject
from stripe._stripe_object import StripeObject
from typing import ClassVar
from typing_extensions import Literal, TYPE_CHECKING
if TYPE_CHECKING:
from stripe.entitlements._active_entitlement import ActiveEntitlement
class ActiveEntitlementSummary(StripeObject):
"""
A summary of a customer's active entitlements.
"""
OBJECT_NAME: ClassVar[
Literal["entitlements.active_entitlement_summary"]
] = "entitlements.active_entitlement_summary"
customer: str
"""
The customer that is entitled to this feature.
"""
entitlements: ListObject["ActiveEntitlement"]
"""
The list of entitlements this customer has.
"""
livemode: bool
"""
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
"""
object: Literal["entitlements.active_entitlement_summary"]
"""
String representing the object's type. Objects of the same type share the same value.
"""

View File

@@ -0,0 +1,192 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._createable_api_resource import CreateableAPIResource
from stripe._list_object import ListObject
from stripe._listable_api_resource import ListableAPIResource
from stripe._updateable_api_resource import UpdateableAPIResource
from stripe._util import sanitize_id
from typing import ClassVar, Dict, cast
from typing_extensions import Literal, Unpack, TYPE_CHECKING
if TYPE_CHECKING:
from stripe.params.entitlements._feature_create_params import (
FeatureCreateParams,
)
from stripe.params.entitlements._feature_list_params import (
FeatureListParams,
)
from stripe.params.entitlements._feature_modify_params import (
FeatureModifyParams,
)
from stripe.params.entitlements._feature_retrieve_params import (
FeatureRetrieveParams,
)
class Feature(
CreateableAPIResource["Feature"],
ListableAPIResource["Feature"],
UpdateableAPIResource["Feature"],
):
"""
A feature represents a monetizable ability or functionality in your system.
Features can be assigned to products, and when those products are purchased, Stripe will create an entitlement to the feature for the purchasing customer.
"""
OBJECT_NAME: ClassVar[Literal["entitlements.feature"]] = (
"entitlements.feature"
)
active: bool
"""
Inactive features cannot be attached to new products and will not be returned from the features list endpoint.
"""
id: str
"""
Unique identifier for the object.
"""
livemode: bool
"""
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
"""
lookup_key: str
"""
A unique key you provide as your own system identifier. This may be up to 80 characters.
"""
metadata: Dict[str, str]
"""
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
"""
name: str
"""
The feature's name, for your own purpose, not meant to be displayable to the customer.
"""
object: Literal["entitlements.feature"]
"""
String representing the object's type. Objects of the same type share the same value.
"""
@classmethod
def create(cls, **params: Unpack["FeatureCreateParams"]) -> "Feature":
"""
Creates a feature
"""
return cast(
"Feature",
cls._static_request(
"post",
cls.class_url(),
params=params,
),
)
@classmethod
async def create_async(
cls, **params: Unpack["FeatureCreateParams"]
) -> "Feature":
"""
Creates a feature
"""
return cast(
"Feature",
await cls._static_request_async(
"post",
cls.class_url(),
params=params,
),
)
@classmethod
def list(
cls, **params: Unpack["FeatureListParams"]
) -> ListObject["Feature"]:
"""
Retrieve a list of features
"""
result = cls._static_request(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
async def list_async(
cls, **params: Unpack["FeatureListParams"]
) -> ListObject["Feature"]:
"""
Retrieve a list of features
"""
result = await cls._static_request_async(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
def modify(
cls, id: str, **params: Unpack["FeatureModifyParams"]
) -> "Feature":
"""
Update a feature's metadata or permanently deactivate it.
"""
url = "%s/%s" % (cls.class_url(), sanitize_id(id))
return cast(
"Feature",
cls._static_request(
"post",
url,
params=params,
),
)
@classmethod
async def modify_async(
cls, id: str, **params: Unpack["FeatureModifyParams"]
) -> "Feature":
"""
Update a feature's metadata or permanently deactivate it.
"""
url = "%s/%s" % (cls.class_url(), sanitize_id(id))
return cast(
"Feature",
await cls._static_request_async(
"post",
url,
params=params,
),
)
@classmethod
def retrieve(
cls, id: str, **params: Unpack["FeatureRetrieveParams"]
) -> "Feature":
"""
Retrieves a feature
"""
instance = cls(id, **params)
instance.refresh()
return instance
@classmethod
async def retrieve_async(
cls, id: str, **params: Unpack["FeatureRetrieveParams"]
) -> "Feature":
"""
Retrieves a feature
"""
instance = cls(id, **params)
await instance.refresh_async()
return instance

View File

@@ -0,0 +1,181 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from typing_extensions import TYPE_CHECKING
if TYPE_CHECKING:
from stripe._list_object import ListObject
from stripe._request_options import RequestOptions
from stripe.entitlements._feature import Feature
from stripe.params.entitlements._feature_create_params import (
FeatureCreateParams,
)
from stripe.params.entitlements._feature_list_params import (
FeatureListParams,
)
from stripe.params.entitlements._feature_retrieve_params import (
FeatureRetrieveParams,
)
from stripe.params.entitlements._feature_update_params import (
FeatureUpdateParams,
)
class FeatureService(StripeService):
def list(
self,
params: Optional["FeatureListParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "ListObject[Feature]":
"""
Retrieve a list of features
"""
return cast(
"ListObject[Feature]",
self._request(
"get",
"/v1/entitlements/features",
base_address="api",
params=params,
options=options,
),
)
async def list_async(
self,
params: Optional["FeatureListParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "ListObject[Feature]":
"""
Retrieve a list of features
"""
return cast(
"ListObject[Feature]",
await self._request_async(
"get",
"/v1/entitlements/features",
base_address="api",
params=params,
options=options,
),
)
def create(
self,
params: "FeatureCreateParams",
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Creates a feature
"""
return cast(
"Feature",
self._request(
"post",
"/v1/entitlements/features",
base_address="api",
params=params,
options=options,
),
)
async def create_async(
self,
params: "FeatureCreateParams",
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Creates a feature
"""
return cast(
"Feature",
await self._request_async(
"post",
"/v1/entitlements/features",
base_address="api",
params=params,
options=options,
),
)
def retrieve(
self,
id: str,
params: Optional["FeatureRetrieveParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Retrieves a feature
"""
return cast(
"Feature",
self._request(
"get",
"/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
base_address="api",
params=params,
options=options,
),
)
async def retrieve_async(
self,
id: str,
params: Optional["FeatureRetrieveParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Retrieves a feature
"""
return cast(
"Feature",
await self._request_async(
"get",
"/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
base_address="api",
params=params,
options=options,
),
)
def update(
self,
id: str,
params: Optional["FeatureUpdateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Update a feature's metadata or permanently deactivate it.
"""
return cast(
"Feature",
self._request(
"post",
"/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
base_address="api",
params=params,
options=options,
),
)
async def update_async(
self,
id: str,
params: Optional["FeatureUpdateParams"] = None,
options: Optional["RequestOptions"] = None,
) -> "Feature":
"""
Update a feature's metadata or permanently deactivate it.
"""
return cast(
"Feature",
await self._request_async(
"post",
"/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
base_address="api",
params=params,
options=options,
),
)