From 0bff4c085e7193cfc4711397704e81458a398583 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2026 15:50:55 +0000 Subject: [PATCH 1/2] Update generated code for v2342 and 75508b1901371b06c1d21fdcd9d5850498e4cb75 --- CODEGEN_VERSION | 2 +- stripe/_event_notification_handler.py | 80 +++++++++++++ stripe/events/__init__.py | 60 ++++++++++ stripe/events/_event_classes.py | 60 ++++++++++ .../_v2_billing_contract_activated_event.py | 113 ++++++++++++++++++ .../_v2_billing_contract_canceled_event.py | 113 ++++++++++++++++++ .../_v2_billing_contract_created_event.py | 113 ++++++++++++++++++ .../_v2_billing_contract_ended_event.py | 113 ++++++++++++++++++ .../_v2_billing_contract_updated_event.py | 113 ++++++++++++++++++ .../analytics/_metric_query_create_params.py | 4 +- stripe/v2/billing/_contract.py | 33 ++--- 11 files changed, 780 insertions(+), 24 deletions(-) create mode 100644 stripe/events/_v2_billing_contract_activated_event.py create mode 100644 stripe/events/_v2_billing_contract_canceled_event.py create mode 100644 stripe/events/_v2_billing_contract_created_event.py create mode 100644 stripe/events/_v2_billing_contract_ended_event.py create mode 100644 stripe/events/_v2_billing_contract_updated_event.py diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 001f568a9..b2c7a9d1a 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -23a0d1c154d81b4b4185658446b2ee07f06f969a \ No newline at end of file +75508b1901371b06c1d21fdcd9d5850498e4cb75 \ No newline at end of file diff --git a/stripe/_event_notification_handler.py b/stripe/_event_notification_handler.py index 4cae2cc0f..81a2542ae 100644 --- a/stripe/_event_notification_handler.py +++ b/stripe/_event_notification_handler.py @@ -627,6 +627,21 @@ from stripe.events._v2_billing_cadence_created_event import ( V2BillingCadenceCreatedEventNotification, ) + from stripe.events._v2_billing_contract_activated_event import ( + V2BillingContractActivatedEventNotification, + ) + from stripe.events._v2_billing_contract_canceled_event import ( + V2BillingContractCanceledEventNotification, + ) + from stripe.events._v2_billing_contract_created_event import ( + V2BillingContractCreatedEventNotification, + ) + from stripe.events._v2_billing_contract_ended_event import ( + V2BillingContractEndedEventNotification, + ) + from stripe.events._v2_billing_contract_updated_event import ( + V2BillingContractUpdatedEventNotification, + ) from stripe.events._v2_billing_licensed_item_created_event import ( V2BillingLicensedItemCreatedEventNotification, ) @@ -4009,6 +4024,71 @@ def on_v2_billing_cadence_created( ) return func + def on_v2_billing_contract_activated( + self, + func: "Callable[[V2BillingContractActivatedEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2BillingContractActivatedEvent` (`v2.billing.contract.activated`) event notification. + """ + self._register( + "v2.billing.contract.activated", + func, + ) + return func + + def on_v2_billing_contract_canceled( + self, + func: "Callable[[V2BillingContractCanceledEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2BillingContractCanceledEvent` (`v2.billing.contract.canceled`) event notification. + """ + self._register( + "v2.billing.contract.canceled", + func, + ) + return func + + def on_v2_billing_contract_created( + self, + func: "Callable[[V2BillingContractCreatedEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2BillingContractCreatedEvent` (`v2.billing.contract.created`) event notification. + """ + self._register( + "v2.billing.contract.created", + func, + ) + return func + + def on_v2_billing_contract_ended( + self, + func: "Callable[[V2BillingContractEndedEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2BillingContractEndedEvent` (`v2.billing.contract.ended`) event notification. + """ + self._register( + "v2.billing.contract.ended", + func, + ) + return func + + def on_v2_billing_contract_updated( + self, + func: "Callable[[V2BillingContractUpdatedEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2BillingContractUpdatedEvent` (`v2.billing.contract.updated`) event notification. + """ + self._register( + "v2.billing.contract.updated", + func, + ) + return func + def on_v2_billing_licensed_item_created( self, func: "Callable[[V2BillingLicensedItemCreatedEventNotification, StripeClient], None]", diff --git a/stripe/events/__init__.py b/stripe/events/__init__.py index 9b80e14b5..ea4b0dcc8 100644 --- a/stripe/events/__init__.py +++ b/stripe/events/__init__.py @@ -835,6 +835,26 @@ V2BillingCadenceCreatedEvent as V2BillingCadenceCreatedEvent, V2BillingCadenceCreatedEventNotification as V2BillingCadenceCreatedEventNotification, ) + from stripe.events._v2_billing_contract_activated_event import ( + V2BillingContractActivatedEvent as V2BillingContractActivatedEvent, + V2BillingContractActivatedEventNotification as V2BillingContractActivatedEventNotification, + ) + from stripe.events._v2_billing_contract_canceled_event import ( + V2BillingContractCanceledEvent as V2BillingContractCanceledEvent, + V2BillingContractCanceledEventNotification as V2BillingContractCanceledEventNotification, + ) + from stripe.events._v2_billing_contract_created_event import ( + V2BillingContractCreatedEvent as V2BillingContractCreatedEvent, + V2BillingContractCreatedEventNotification as V2BillingContractCreatedEventNotification, + ) + from stripe.events._v2_billing_contract_ended_event import ( + V2BillingContractEndedEvent as V2BillingContractEndedEvent, + V2BillingContractEndedEventNotification as V2BillingContractEndedEventNotification, + ) + from stripe.events._v2_billing_contract_updated_event import ( + V2BillingContractUpdatedEvent as V2BillingContractUpdatedEvent, + V2BillingContractUpdatedEventNotification as V2BillingContractUpdatedEventNotification, + ) from stripe.events._v2_billing_license_fee_created_event import ( V2BillingLicenseFeeCreatedEvent as V2BillingLicenseFeeCreatedEvent, V2BillingLicenseFeeCreatedEventNotification as V2BillingLicenseFeeCreatedEventNotification, @@ -3196,6 +3216,46 @@ "stripe.events._v2_billing_cadence_created_event", False, ), + "V2BillingContractActivatedEvent": ( + "stripe.events._v2_billing_contract_activated_event", + False, + ), + "V2BillingContractActivatedEventNotification": ( + "stripe.events._v2_billing_contract_activated_event", + False, + ), + "V2BillingContractCanceledEvent": ( + "stripe.events._v2_billing_contract_canceled_event", + False, + ), + "V2BillingContractCanceledEventNotification": ( + "stripe.events._v2_billing_contract_canceled_event", + False, + ), + "V2BillingContractCreatedEvent": ( + "stripe.events._v2_billing_contract_created_event", + False, + ), + "V2BillingContractCreatedEventNotification": ( + "stripe.events._v2_billing_contract_created_event", + False, + ), + "V2BillingContractEndedEvent": ( + "stripe.events._v2_billing_contract_ended_event", + False, + ), + "V2BillingContractEndedEventNotification": ( + "stripe.events._v2_billing_contract_ended_event", + False, + ), + "V2BillingContractUpdatedEvent": ( + "stripe.events._v2_billing_contract_updated_event", + False, + ), + "V2BillingContractUpdatedEventNotification": ( + "stripe.events._v2_billing_contract_updated_event", + False, + ), "V2BillingLicenseFeeCreatedEvent": ( "stripe.events._v2_billing_license_fee_created_event", False, diff --git a/stripe/events/_event_classes.py b/stripe/events/_event_classes.py index 0789defb0..b3df984c2 100644 --- a/stripe/events/_event_classes.py +++ b/stripe/events/_event_classes.py @@ -622,6 +622,21 @@ from stripe.events._v2_billing_cadence_created_event import ( V2BillingCadenceCreatedEventNotification, ) + from stripe.events._v2_billing_contract_activated_event import ( + V2BillingContractActivatedEventNotification, + ) + from stripe.events._v2_billing_contract_canceled_event import ( + V2BillingContractCanceledEventNotification, + ) + from stripe.events._v2_billing_contract_created_event import ( + V2BillingContractCreatedEventNotification, + ) + from stripe.events._v2_billing_contract_ended_event import ( + V2BillingContractEndedEventNotification, + ) + from stripe.events._v2_billing_contract_updated_event import ( + V2BillingContractUpdatedEventNotification, + ) from stripe.events._v2_billing_licensed_item_created_event import ( V2BillingLicensedItemCreatedEventNotification, ) @@ -2066,6 +2081,26 @@ "stripe.events._v2_billing_cadence_created_event", "V2BillingCadenceCreatedEvent", ), + "v2.billing.contract.activated": ( + "stripe.events._v2_billing_contract_activated_event", + "V2BillingContractActivatedEvent", + ), + "v2.billing.contract.canceled": ( + "stripe.events._v2_billing_contract_canceled_event", + "V2BillingContractCanceledEvent", + ), + "v2.billing.contract.created": ( + "stripe.events._v2_billing_contract_created_event", + "V2BillingContractCreatedEvent", + ), + "v2.billing.contract.ended": ( + "stripe.events._v2_billing_contract_ended_event", + "V2BillingContractEndedEvent", + ), + "v2.billing.contract.updated": ( + "stripe.events._v2_billing_contract_updated_event", + "V2BillingContractUpdatedEvent", + ), "v2.billing.licensed_item.created": ( "stripe.events._v2_billing_licensed_item_created_event", "V2BillingLicensedItemCreatedEvent", @@ -3729,6 +3764,26 @@ def get_v2_event_class(type_: str): "stripe.events._v2_billing_cadence_created_event", "V2BillingCadenceCreatedEventNotification", ), + "v2.billing.contract.activated": ( + "stripe.events._v2_billing_contract_activated_event", + "V2BillingContractActivatedEventNotification", + ), + "v2.billing.contract.canceled": ( + "stripe.events._v2_billing_contract_canceled_event", + "V2BillingContractCanceledEventNotification", + ), + "v2.billing.contract.created": ( + "stripe.events._v2_billing_contract_created_event", + "V2BillingContractCreatedEventNotification", + ), + "v2.billing.contract.ended": ( + "stripe.events._v2_billing_contract_ended_event", + "V2BillingContractEndedEventNotification", + ), + "v2.billing.contract.updated": ( + "stripe.events._v2_billing_contract_updated_event", + "V2BillingContractUpdatedEventNotification", + ), "v2.billing.licensed_item.created": ( "stripe.events._v2_billing_licensed_item_created_event", "V2BillingLicensedItemCreatedEventNotification", @@ -4777,6 +4832,11 @@ def get_v2_event_notification_class(type_: str): "V2BillingCadenceBilledEventNotification", "V2BillingCadenceCanceledEventNotification", "V2BillingCadenceCreatedEventNotification", + "V2BillingContractActivatedEventNotification", + "V2BillingContractCanceledEventNotification", + "V2BillingContractCreatedEventNotification", + "V2BillingContractEndedEventNotification", + "V2BillingContractUpdatedEventNotification", "V2BillingLicensedItemCreatedEventNotification", "V2BillingLicensedItemUpdatedEventNotification", "V2BillingLicenseFeeCreatedEventNotification", diff --git a/stripe/events/_v2_billing_contract_activated_event.py b/stripe/events/_v2_billing_contract_activated_event.py new file mode 100644 index 000000000..e8e5bcec3 --- /dev/null +++ b/stripe/events/_v2_billing_contract_activated_event.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from stripe._util import get_api_mode +from stripe.v2.core._event import Event, EventNotification, RelatedObject +from typing import Any, Dict, cast +from typing_extensions import Literal, TYPE_CHECKING, override + +if TYPE_CHECKING: + from stripe._stripe_client import StripeClient + from stripe.v2.billing._contract import Contract + + +class V2BillingContractActivatedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.billing.contract.activated" + type: Literal["v2.billing.contract.activated"] + related_object: RelatedObject + + def __init__( + self, parsed_body: Dict[str, Any], client: "StripeClient" + ) -> None: + super().__init__( + parsed_body, + client, + ) + self.related_object = RelatedObject(parsed_body["related_object"]) + + @override + def fetch_event(self) -> "V2BillingContractActivatedEvent": + return cast( + "V2BillingContractActivatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Contract": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2BillingContractActivatedEvent": + return cast( + "V2BillingContractActivatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Contract": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2BillingContractActivatedEvent(Event): + LOOKUP_TYPE = "v2.billing.contract.activated" + type: Literal["v2.billing.contract.activated"] + + class RelatedObject(StripeObject): + id: str + """ + Unique identifier for the object relevant to the event. + """ + type: str + """ + Type of the object relevant to the event. + """ + url: str + """ + URL to retrieve the resource. + """ + + related_object: RelatedObject + """ + Object containing the reference to API resource relevant to the event + """ + + def fetch_related_object(self) -> "Contract": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Contract", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={ + "stripe_context": self.context, + "headers": {"Stripe-Request-Trigger": f"event={self.id}"}, + }, + ), + ) diff --git a/stripe/events/_v2_billing_contract_canceled_event.py b/stripe/events/_v2_billing_contract_canceled_event.py new file mode 100644 index 000000000..e7883d31d --- /dev/null +++ b/stripe/events/_v2_billing_contract_canceled_event.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from stripe._util import get_api_mode +from stripe.v2.core._event import Event, EventNotification, RelatedObject +from typing import Any, Dict, cast +from typing_extensions import Literal, TYPE_CHECKING, override + +if TYPE_CHECKING: + from stripe._stripe_client import StripeClient + from stripe.v2.billing._contract import Contract + + +class V2BillingContractCanceledEventNotification(EventNotification): + LOOKUP_TYPE = "v2.billing.contract.canceled" + type: Literal["v2.billing.contract.canceled"] + related_object: RelatedObject + + def __init__( + self, parsed_body: Dict[str, Any], client: "StripeClient" + ) -> None: + super().__init__( + parsed_body, + client, + ) + self.related_object = RelatedObject(parsed_body["related_object"]) + + @override + def fetch_event(self) -> "V2BillingContractCanceledEvent": + return cast( + "V2BillingContractCanceledEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Contract": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2BillingContractCanceledEvent": + return cast( + "V2BillingContractCanceledEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Contract": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2BillingContractCanceledEvent(Event): + LOOKUP_TYPE = "v2.billing.contract.canceled" + type: Literal["v2.billing.contract.canceled"] + + class RelatedObject(StripeObject): + id: str + """ + Unique identifier for the object relevant to the event. + """ + type: str + """ + Type of the object relevant to the event. + """ + url: str + """ + URL to retrieve the resource. + """ + + related_object: RelatedObject + """ + Object containing the reference to API resource relevant to the event + """ + + def fetch_related_object(self) -> "Contract": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Contract", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={ + "stripe_context": self.context, + "headers": {"Stripe-Request-Trigger": f"event={self.id}"}, + }, + ), + ) diff --git a/stripe/events/_v2_billing_contract_created_event.py b/stripe/events/_v2_billing_contract_created_event.py new file mode 100644 index 000000000..00724c0b4 --- /dev/null +++ b/stripe/events/_v2_billing_contract_created_event.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from stripe._util import get_api_mode +from stripe.v2.core._event import Event, EventNotification, RelatedObject +from typing import Any, Dict, cast +from typing_extensions import Literal, TYPE_CHECKING, override + +if TYPE_CHECKING: + from stripe._stripe_client import StripeClient + from stripe.v2.billing._contract import Contract + + +class V2BillingContractCreatedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.billing.contract.created" + type: Literal["v2.billing.contract.created"] + related_object: RelatedObject + + def __init__( + self, parsed_body: Dict[str, Any], client: "StripeClient" + ) -> None: + super().__init__( + parsed_body, + client, + ) + self.related_object = RelatedObject(parsed_body["related_object"]) + + @override + def fetch_event(self) -> "V2BillingContractCreatedEvent": + return cast( + "V2BillingContractCreatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Contract": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2BillingContractCreatedEvent": + return cast( + "V2BillingContractCreatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Contract": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2BillingContractCreatedEvent(Event): + LOOKUP_TYPE = "v2.billing.contract.created" + type: Literal["v2.billing.contract.created"] + + class RelatedObject(StripeObject): + id: str + """ + Unique identifier for the object relevant to the event. + """ + type: str + """ + Type of the object relevant to the event. + """ + url: str + """ + URL to retrieve the resource. + """ + + related_object: RelatedObject + """ + Object containing the reference to API resource relevant to the event + """ + + def fetch_related_object(self) -> "Contract": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Contract", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={ + "stripe_context": self.context, + "headers": {"Stripe-Request-Trigger": f"event={self.id}"}, + }, + ), + ) diff --git a/stripe/events/_v2_billing_contract_ended_event.py b/stripe/events/_v2_billing_contract_ended_event.py new file mode 100644 index 000000000..f83b609ca --- /dev/null +++ b/stripe/events/_v2_billing_contract_ended_event.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from stripe._util import get_api_mode +from stripe.v2.core._event import Event, EventNotification, RelatedObject +from typing import Any, Dict, cast +from typing_extensions import Literal, TYPE_CHECKING, override + +if TYPE_CHECKING: + from stripe._stripe_client import StripeClient + from stripe.v2.billing._contract import Contract + + +class V2BillingContractEndedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.billing.contract.ended" + type: Literal["v2.billing.contract.ended"] + related_object: RelatedObject + + def __init__( + self, parsed_body: Dict[str, Any], client: "StripeClient" + ) -> None: + super().__init__( + parsed_body, + client, + ) + self.related_object = RelatedObject(parsed_body["related_object"]) + + @override + def fetch_event(self) -> "V2BillingContractEndedEvent": + return cast( + "V2BillingContractEndedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Contract": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2BillingContractEndedEvent": + return cast( + "V2BillingContractEndedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Contract": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2BillingContractEndedEvent(Event): + LOOKUP_TYPE = "v2.billing.contract.ended" + type: Literal["v2.billing.contract.ended"] + + class RelatedObject(StripeObject): + id: str + """ + Unique identifier for the object relevant to the event. + """ + type: str + """ + Type of the object relevant to the event. + """ + url: str + """ + URL to retrieve the resource. + """ + + related_object: RelatedObject + """ + Object containing the reference to API resource relevant to the event + """ + + def fetch_related_object(self) -> "Contract": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Contract", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={ + "stripe_context": self.context, + "headers": {"Stripe-Request-Trigger": f"event={self.id}"}, + }, + ), + ) diff --git a/stripe/events/_v2_billing_contract_updated_event.py b/stripe/events/_v2_billing_contract_updated_event.py new file mode 100644 index 000000000..3e9d5975a --- /dev/null +++ b/stripe/events/_v2_billing_contract_updated_event.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from stripe._util import get_api_mode +from stripe.v2.core._event import Event, EventNotification, RelatedObject +from typing import Any, Dict, cast +from typing_extensions import Literal, TYPE_CHECKING, override + +if TYPE_CHECKING: + from stripe._stripe_client import StripeClient + from stripe.v2.billing._contract import Contract + + +class V2BillingContractUpdatedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.billing.contract.updated" + type: Literal["v2.billing.contract.updated"] + related_object: RelatedObject + + def __init__( + self, parsed_body: Dict[str, Any], client: "StripeClient" + ) -> None: + super().__init__( + parsed_body, + client, + ) + self.related_object = RelatedObject(parsed_body["related_object"]) + + @override + def fetch_event(self) -> "V2BillingContractUpdatedEvent": + return cast( + "V2BillingContractUpdatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Contract": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2BillingContractUpdatedEvent": + return cast( + "V2BillingContractUpdatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Contract": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + headers={"Stripe-Request-Trigger": f"event={self.id}"}, + usage=["fetch_related_object"], + ) + return cast( + "Contract", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2BillingContractUpdatedEvent(Event): + LOOKUP_TYPE = "v2.billing.contract.updated" + type: Literal["v2.billing.contract.updated"] + + class RelatedObject(StripeObject): + id: str + """ + Unique identifier for the object relevant to the event. + """ + type: str + """ + Type of the object relevant to the event. + """ + url: str + """ + URL to retrieve the resource. + """ + + related_object: RelatedObject + """ + Object containing the reference to API resource relevant to the event + """ + + def fetch_related_object(self) -> "Contract": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Contract", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={ + "stripe_context": self.context, + "headers": {"Stripe-Request-Trigger": f"event={self.id}"}, + }, + ), + ) diff --git a/stripe/params/v2/data/analytics/_metric_query_create_params.py b/stripe/params/v2/data/analytics/_metric_query_create_params.py index 0d6f3f912..9152c2473 100644 --- a/stripe/params/v2/data/analytics/_metric_query_create_params.py +++ b/stripe/params/v2/data/analytics/_metric_query_create_params.py @@ -51,9 +51,9 @@ class MetricQueryCreateParams(TypedDict): class MetricQueryCreateParamsMetric(TypedDict): id: NotRequired[str] """ - The ID for this metric, e.g. metric_61Sud3n5oAGVCWiSr5. + The ID for this metric (for example, `metric_61Sud3n5oAGVCWiSr5`). For the full list of supported metrics, see [Supported metrics](https://docs.stripe.com/data/analytics/supported-metrics). """ name: NotRequired[str] """ - The common name for this metric, e.g. revenue.mrr. + The common name for this metric (for example, `revenue.mrr`). For the full list of supported metric names, see [Supported metrics](https://docs.stripe.com/data/analytics/supported-metrics). """ diff --git a/stripe/v2/billing/_contract.py b/stripe/v2/billing/_contract.py index 75b528e69..c40b81de6 100644 --- a/stripe/v2/billing/_contract.py +++ b/stripe/v2/billing/_contract.py @@ -387,28 +387,19 @@ class StartsAt(StripeObject): """ _inner_class_types = {"data": Data} - class StatusDetails(StripeObject): - class Active(StripeObject): - activated_at: str - """ - The timestamp when the contract was activated. - """ - - class Canceled(StripeObject): - canceled_at: str - """ - The timestamp when the contract was canceled. - """ - - active: Optional[Active] + class StatusTransitions(StripeObject): + activated_at: Optional[str] + """ + The timestamp when the contract was activated. + """ + canceled_at: Optional[str] """ - Details of the active contract status. + The timestamp when the contract was canceled. """ - canceled: Optional[Canceled] + ended_at: Optional[str] """ - Details of the canceled contract status. + The timestamp when the contract ended. """ - _inner_class_types = {"active": Active, "canceled": Canceled} billing_cycle_anchor: Optional[BillingCycleAnchor] """ @@ -466,9 +457,9 @@ class Canceled(StripeObject): """ The current status of the contract. """ - status_details: StatusDetails + status_transitions: Optional[StatusTransitions] """ - Information about the contract status transitions. + Historical timestamps of when the contract transitioned into each status. """ _inner_class_types = { "billing_cycle_anchor": BillingCycleAnchor, @@ -476,5 +467,5 @@ class Canceled(StripeObject): "one_time_fees": OneTimeFees, "pricing_lines": PricingLines, "pricing_overrides": PricingOverrides, - "status_details": StatusDetails, + "status_transitions": StatusTransitions, } From 937693d2e04cf3c31bb4b2263bb77b9a2587b9b1 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2026 22:08:21 +0000 Subject: [PATCH 2/2] Update generated code for v2342 and 51726cfe77f5ee46f2ffac5f0984f971df101fcd --- CODEGEN_VERSION | 2 +- stripe/params/v2/billing/__init__.py | 16 +-- .../v2/billing/_contract_cancel_params.py | 2 +- .../v2/billing/_contract_create_params.py | 44 ++++--- .../v2/billing/_contract_list_params.py | 2 +- .../v2/billing/_contract_update_params.py | 124 +++++++++--------- stripe/v2/billing/_contract.py | 60 +++++---- .../_contract_pricing_line_quantity_change.py | 4 +- stripe/v2/billing/_contract_service.py | 28 ++-- tests/test_generated_examples.py | 10 +- 10 files changed, 149 insertions(+), 143 deletions(-) diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index b2c7a9d1a..c740570a4 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -75508b1901371b06c1d21fdcd9d5850498e4cb75 \ No newline at end of file +51726cfe77f5ee46f2ffac5f0984f971df101fcd \ No newline at end of file diff --git a/stripe/params/v2/billing/__init__.py b/stripe/params/v2/billing/__init__.py index 90bdcdb49..3ee47cc75 100644 --- a/stripe/params/v2/billing/__init__.py +++ b/stripe/params/v2/billing/__init__.py @@ -145,8 +145,8 @@ ContractCreateParamsPricingLineStartsAt as ContractCreateParamsPricingLineStartsAt, ContractCreateParamsPricingOverride as ContractCreateParamsPricingOverride, ContractCreateParamsPricingOverrideEndsAt as ContractCreateParamsPricingOverrideEndsAt, - ContractCreateParamsPricingOverrideMultiplier as ContractCreateParamsPricingOverrideMultiplier, - ContractCreateParamsPricingOverrideMultiplierCriterion as ContractCreateParamsPricingOverrideMultiplierCriterion, + ContractCreateParamsPricingOverrideMultiplyPricing as ContractCreateParamsPricingOverrideMultiplyPricing, + ContractCreateParamsPricingOverrideMultiplyPricingCriterion as ContractCreateParamsPricingOverrideMultiplyPricingCriterion, ContractCreateParamsPricingOverrideStartsAt as ContractCreateParamsPricingOverrideStartsAt, ) from stripe.params.v2.billing._contract_delete_params import ( @@ -194,8 +194,8 @@ ContractUpdateParamsPricingOverrideAction as ContractUpdateParamsPricingOverrideAction, ContractUpdateParamsPricingOverrideActionAdd as ContractUpdateParamsPricingOverrideActionAdd, ContractUpdateParamsPricingOverrideActionAddEndsAt as ContractUpdateParamsPricingOverrideActionAddEndsAt, - ContractUpdateParamsPricingOverrideActionAddMultiplier as ContractUpdateParamsPricingOverrideActionAddMultiplier, - ContractUpdateParamsPricingOverrideActionAddMultiplierCriterion as ContractUpdateParamsPricingOverrideActionAddMultiplierCriterion, + ContractUpdateParamsPricingOverrideActionAddMultiplyPricing as ContractUpdateParamsPricingOverrideActionAddMultiplyPricing, + ContractUpdateParamsPricingOverrideActionAddMultiplyPricingCriterion as ContractUpdateParamsPricingOverrideActionAddMultiplyPricingCriterion, ContractUpdateParamsPricingOverrideActionAddOverwritePrice as ContractUpdateParamsPricingOverrideActionAddOverwritePrice, ContractUpdateParamsPricingOverrideActionAddOverwritePriceTier as ContractUpdateParamsPricingOverrideActionAddOverwritePriceTier, ContractUpdateParamsPricingOverrideActionAddStartsAt as ContractUpdateParamsPricingOverrideActionAddStartsAt, @@ -882,11 +882,11 @@ "stripe.params.v2.billing._contract_create_params", False, ), - "ContractCreateParamsPricingOverrideMultiplier": ( + "ContractCreateParamsPricingOverrideMultiplyPricing": ( "stripe.params.v2.billing._contract_create_params", False, ), - "ContractCreateParamsPricingOverrideMultiplierCriterion": ( + "ContractCreateParamsPricingOverrideMultiplyPricingCriterion": ( "stripe.params.v2.billing._contract_create_params", False, ), @@ -1046,11 +1046,11 @@ "stripe.params.v2.billing._contract_update_params", False, ), - "ContractUpdateParamsPricingOverrideActionAddMultiplier": ( + "ContractUpdateParamsPricingOverrideActionAddMultiplyPricing": ( "stripe.params.v2.billing._contract_update_params", False, ), - "ContractUpdateParamsPricingOverrideActionAddMultiplierCriterion": ( + "ContractUpdateParamsPricingOverrideActionAddMultiplyPricingCriterion": ( "stripe.params.v2.billing._contract_update_params", False, ), diff --git a/stripe/params/v2/billing/_contract_cancel_params.py b/stripe/params/v2/billing/_contract_cancel_params.py index a4acff420..ec5b7c91e 100644 --- a/stripe/params/v2/billing/_contract_cancel_params.py +++ b/stripe/params/v2/billing/_contract_cancel_params.py @@ -34,7 +34,7 @@ class ContractCancelParams(TypedDict): class ContractCancelParamsCancelPricingLine(TypedDict): id: NotRequired[str] """ - The ID of the pricing line. + The id of the pricing line. """ lookup_key: NotRequired[str] """ diff --git a/stripe/params/v2/billing/_contract_create_params.py b/stripe/params/v2/billing/_contract_create_params.py index 15b17220f..f9a805032 100644 --- a/stripe/params/v2/billing/_contract_create_params.py +++ b/stripe/params/v2/billing/_contract_create_params.py @@ -155,7 +155,7 @@ class ContractCreateParamsBillingSettingsBillSettingsDetailsInvoice(TypedDict): "ContractCreateParamsBillingSettingsBillSettingsDetailsInvoiceTimeUntilDue" ] """ - The number of time units before the invoice is past due. + How long the customer has to pay the invoice before it's past due. """ @@ -186,7 +186,7 @@ class ContractCreateParamsBillingSettingsBillingProfileDetails(TypedDict): class ContractCreateParamsBillingSettingsCollectionSettingsDetails(TypedDict): collection_method: Literal["charge_automatically", "send_invoice"] """ - The collection method. + How payment is collected for the contract. """ payment_method_configuration: NotRequired[str] """ @@ -209,7 +209,7 @@ class ContractCreateParamsOneTimeFee(TypedDict): """ product: str """ - The ID of the v1 Product for this fee. + The id of the product for this fee. """ @@ -252,7 +252,7 @@ class ContractCreateParamsPricingLineEndsAt(TypedDict): """ The timestamp when the item ends. Required if `type` is `timestamp`. """ - type: Literal["contract_end", "timestamp"] + type: Literal["timestamp"] """ The type of the ends_at. """ @@ -274,7 +274,7 @@ class ContractCreateParamsPricingLinePricing(TypedDict): class ContractCreateParamsPricingLinePricingPriceDetails(TypedDict): price: str """ - The ID of the V1 price. + The id of the price. """ pricing_overrides: NotRequired[ List[ @@ -291,7 +291,7 @@ class ContractCreateParamsPricingLinePricingPriceDetails(TypedDict): ] """ Quantity changes for the pricing line. For now, at most one entry is allowed. - A quantity change clears all future quantity changes on this pricing line. + A quantity change clears all future quantity changes on this pricing line. Defaults to 1. """ @@ -330,7 +330,7 @@ class ContractCreateParamsPricingLinePricingPriceDetailsPricingOverride( """ type: Literal["overwrite_price"] """ - The type of override. Currently only `overwrite_price` is supported. + The type of override. """ @@ -341,7 +341,7 @@ class ContractCreateParamsPricingLinePricingPriceDetailsPricingOverrideEndsAt( """ The timestamp when the item ends. Required if `type` is `timestamp`. """ - type: Literal["contract_end", "timestamp"] + type: Literal["timestamp"] """ The type of the ends_at. """ @@ -396,7 +396,7 @@ class ContractCreateParamsPricingLinePricingPriceDetailsPricingOverrideStartsAt( """ The timestamp when the item starts. Required if `type` is `timestamp`. """ - type: Literal["contract_start", "timestamp"] + type: Literal["timestamp"] """ The type of the starts_at. """ @@ -433,7 +433,7 @@ class ContractCreateParamsPricingLineStartsAt(TypedDict): """ The timestamp when the item starts. Required if `type` is `timestamp`. """ - type: Literal["contract_start", "timestamp"] + type: Literal["timestamp"] """ The type of the starts_at. """ @@ -448,11 +448,13 @@ class ContractCreateParamsPricingOverride(TypedDict): """ A user-provided lookup key to reference this pricing override. """ - multiplier: NotRequired["ContractCreateParamsPricingOverrideMultiplier"] + multiply_pricing: NotRequired[ + "ContractCreateParamsPricingOverrideMultiplyPricing" + ] """ - Parameters for a multiplier override. Required if `type` is `multiplier`. + Parameters for a multiply_pricing override. Required if `type` is `multiply_pricing`. """ - priority: int + priority: NotRequired[int] """ The priority of this override relative to others. The highest priority is 0 and the lowest is 100. """ @@ -460,7 +462,7 @@ class ContractCreateParamsPricingOverride(TypedDict): """ When the pricing override starts. """ - type: Literal["multiplier"] + type: Literal["multiply_pricing"] """ The type of pricing override. """ @@ -471,26 +473,26 @@ class ContractCreateParamsPricingOverrideEndsAt(TypedDict): """ The timestamp when the item ends. Required if `type` is `timestamp`. """ - type: Literal["contract_end", "timestamp"] + type: Literal["timestamp"] """ The type of the ends_at. """ -class ContractCreateParamsPricingOverrideMultiplier(TypedDict): +class ContractCreateParamsPricingOverrideMultiplyPricing(TypedDict): criteria: NotRequired[ - List["ContractCreateParamsPricingOverrideMultiplierCriterion"] + List["ContractCreateParamsPricingOverrideMultiplyPricingCriterion"] ] """ - Criteria determining which rates the multiplier applies to. + Criteria determining which rates the multiply_pricing override applies to. """ factor: str """ - The multiplier factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. + The multiply_pricing factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. """ -class ContractCreateParamsPricingOverrideMultiplierCriterion(TypedDict): +class ContractCreateParamsPricingOverrideMultiplyPricingCriterion(TypedDict): pricing_line_ids: NotRequired[List[str]] """ Filter by pricing line IDs. @@ -510,7 +512,7 @@ class ContractCreateParamsPricingOverrideStartsAt(TypedDict): """ The timestamp when the item starts. Required if `type` is `timestamp`. """ - type: Literal["contract_start", "timestamp"] + type: Literal["timestamp"] """ The type of the starts_at. """ diff --git a/stripe/params/v2/billing/_contract_list_params.py b/stripe/params/v2/billing/_contract_list_params.py index b6170681a..2ae1d4eb6 100644 --- a/stripe/params/v2/billing/_contract_list_params.py +++ b/stripe/params/v2/billing/_contract_list_params.py @@ -7,7 +7,7 @@ class ContractListParams(TypedDict): customer: NotRequired[str] """ - Filter by customer ID. + Filter by customer id. """ include: NotRequired[ List[ diff --git a/stripe/params/v2/billing/_contract_update_params.py b/stripe/params/v2/billing/_contract_update_params.py index a30cdf835..2fed90615 100644 --- a/stripe/params/v2/billing/_contract_update_params.py +++ b/stripe/params/v2/billing/_contract_update_params.py @@ -37,11 +37,11 @@ class ContractUpdateParams(TypedDict): class ContractUpdateParamsPricingLineAction(TypedDict): add: NotRequired["ContractUpdateParamsPricingLineActionAdd"] """ - Parameters for adding a pricing line. + Add a pricing line. """ remove: NotRequired["ContractUpdateParamsPricingLineActionRemove"] """ - Parameters for removing a pricing line. + Remove a pricing line. """ type: Literal["add", "remove", "update"] """ @@ -49,7 +49,7 @@ class ContractUpdateParamsPricingLineAction(TypedDict): """ update: NotRequired["ContractUpdateParamsPricingLineActionUpdate"] """ - Parameters for updating a pricing line. + Update a pricing line. """ @@ -79,9 +79,9 @@ class ContractUpdateParamsPricingLineActionAdd(TypedDict): class ContractUpdateParamsPricingLineActionAddEndsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ @@ -103,7 +103,7 @@ class ContractUpdateParamsPricingLineActionAddPricing(TypedDict): class ContractUpdateParamsPricingLineActionAddPricingPriceDetails(TypedDict): price: str """ - The ID of the V1 price. + The id of the price. """ pricing_overrides: NotRequired[ List[ @@ -120,7 +120,7 @@ class ContractUpdateParamsPricingLineActionAddPricingPriceDetails(TypedDict): ] """ Quantity changes for the pricing line. For now, at most one entry is allowed. - A quantity change clears all future quantity changes on this pricing line. + A quantity change clears all future quantity changes on this pricing line. Defaults to 1. """ @@ -159,7 +159,7 @@ class ContractUpdateParamsPricingLineActionAddPricingPriceDetailsPricingOverride """ type: Literal["overwrite_price"] """ - The type of override. Currently only `overwrite_price` is supported. + The type of override. """ @@ -170,7 +170,7 @@ class ContractUpdateParamsPricingLineActionAddPricingPriceDetailsPricingOverride """ The timestamp when the item ends. Required if `type` is `timestamp`. """ - type: Literal["contract_end", "timestamp"] + type: Literal["timestamp"] """ The type of the ends_at. """ @@ -225,7 +225,7 @@ class ContractUpdateParamsPricingLineActionAddPricingPriceDetailsPricingOverride """ The timestamp when the item starts. Required if `type` is `timestamp`. """ - type: Literal["contract_start", "timestamp"] + type: Literal["timestamp"] """ The type of the starts_at. """ @@ -260,9 +260,9 @@ class ContractUpdateParamsPricingLineActionAddPricingPriceDetailsQuantityChangeE class ContractUpdateParamsPricingLineActionAddStartsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ @@ -271,37 +271,37 @@ class ContractUpdateParamsPricingLineActionAddStartsAt(TypedDict): class ContractUpdateParamsPricingLineActionRemove(TypedDict): id: str """ - The ID of the pricing line to remove. + The id of the pricing line to remove. """ class ContractUpdateParamsPricingLineActionUpdate(TypedDict): ends_at: NotRequired["ContractUpdateParamsPricingLineActionUpdateEndsAt"] """ - The updated end time for the pricing line. + Updated end time. """ id: str """ - The ID of the pricing line. + The id of the pricing line. """ pricing: NotRequired["ContractUpdateParamsPricingLineActionUpdatePricing"] """ - Pricing updates for the pricing line (quantity changes and pricing override actions). + Updated pricing configuration. """ starts_at: NotRequired[ "ContractUpdateParamsPricingLineActionUpdateStartsAt" ] """ - The updated start time for the pricing line. + Updated start time. """ class ContractUpdateParamsPricingLineActionUpdateEndsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ @@ -344,13 +344,13 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionAdd" ] """ - Parameters for adding a pricing line override. + Add a pricing line override. """ remove: NotRequired[ "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionRemove" ] """ - Parameters for removing a pricing line override. + Remove a pricing line override. """ type: Literal["add", "remove", "update"] """ @@ -360,7 +360,7 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionUpdate" ] """ - Parameters for updating a pricing line override. + Update a pricing line override. """ @@ -377,7 +377,7 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr """ metadata: NotRequired["Dict[str, str]|UntypedStripeObject[str]"] """ - Set of key-value pairs that you can attach to an object. + Metadata for the pricing override. """ overwrite_price: NotRequired[ "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionAddOverwritePrice" @@ -404,9 +404,9 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr ): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ @@ -459,9 +459,9 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr ): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ @@ -472,11 +472,11 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr ): id: NotRequired[str] """ - The ID of the pricing line override to remove. + The id of the pricing override to remove. """ lookup_key: NotRequired[str] """ - A lookup key for the override to remove. + Lookup key of the override to remove. """ @@ -487,25 +487,25 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionUpdateEndsAt" ] """ - The updated end time for the override. + Updated end time. """ id: NotRequired[str] """ - The ID of the pricing line override to update. + The id of the pricing override to update. """ lookup_key: NotRequired[str] """ - A lookup key for the override to update. + Updated lookup key. """ metadata: NotRequired["Dict[str, str]|UntypedStripeObject[str]"] """ - Set of key-value pairs that you can attach to an object. + Metadata for the pricing override. """ starts_at: NotRequired[ "ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverrideActionUpdateStartsAt" ] """ - The updated start time for the override. + Updated start time. """ @@ -514,9 +514,9 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr ): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ @@ -527,9 +527,9 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsPricingOverr ): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ @@ -564,9 +564,9 @@ class ContractUpdateParamsPricingLineActionUpdatePricingPriceDetailsQuantityChan class ContractUpdateParamsPricingLineActionUpdateStartsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ @@ -575,11 +575,11 @@ class ContractUpdateParamsPricingLineActionUpdateStartsAt(TypedDict): class ContractUpdateParamsPricingOverrideAction(TypedDict): add: NotRequired["ContractUpdateParamsPricingOverrideActionAdd"] """ - Parameters for adding a pricing override. + Add a pricing override. """ remove: NotRequired["ContractUpdateParamsPricingOverrideActionRemove"] """ - Parameters for removing a pricing override. + Remove a pricing override. """ type: Literal["add", "remove", "update"] """ @@ -587,7 +587,7 @@ class ContractUpdateParamsPricingOverrideAction(TypedDict): """ update: NotRequired["ContractUpdateParamsPricingOverrideActionUpdate"] """ - Parameters for updating a pricing override. + Update a pricing override. """ @@ -600,11 +600,11 @@ class ContractUpdateParamsPricingOverrideActionAdd(TypedDict): """ A lookup key for the pricing override. """ - multiplier: NotRequired[ - "ContractUpdateParamsPricingOverrideActionAddMultiplier" + multiply_pricing: NotRequired[ + "ContractUpdateParamsPricingOverrideActionAddMultiplyPricing" ] """ - A multiplier override to add. + A multiply_pricing override to add. """ overwrite_price: NotRequired[ "ContractUpdateParamsPricingOverrideActionAddOverwritePrice" @@ -612,7 +612,7 @@ class ContractUpdateParamsPricingOverrideActionAdd(TypedDict): """ An overwrite price override to add. """ - priority: int + priority: NotRequired[int] """ The priority for the pricing override. The highest priority is 0 and the lowest is 100. """ @@ -620,7 +620,7 @@ class ContractUpdateParamsPricingOverrideActionAdd(TypedDict): """ The start time for the pricing override. """ - type: Literal["multiplier"] + type: Literal["multiply_pricing"] """ The type of pricing override to add. """ @@ -629,28 +629,28 @@ class ContractUpdateParamsPricingOverrideActionAdd(TypedDict): class ContractUpdateParamsPricingOverrideActionAddEndsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ -class ContractUpdateParamsPricingOverrideActionAddMultiplier(TypedDict): +class ContractUpdateParamsPricingOverrideActionAddMultiplyPricing(TypedDict): criteria: List[ - "ContractUpdateParamsPricingOverrideActionAddMultiplierCriterion" + "ContractUpdateParamsPricingOverrideActionAddMultiplyPricingCriterion" ] """ - Criteria determining which rates the multiplier applies to. + Criteria determining which rates the multiply_pricing override applies to. """ factor: str """ - The multiplier factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. + The multiply_pricing factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. """ -class ContractUpdateParamsPricingOverrideActionAddMultiplierCriterion( +class ContractUpdateParamsPricingOverrideActionAddMultiplyPricingCriterion( TypedDict, ): pricing_line_ids: NotRequired[List[str]] @@ -708,9 +708,9 @@ class ContractUpdateParamsPricingOverrideActionAddOverwritePriceTier( class ContractUpdateParamsPricingOverrideActionAddStartsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ @@ -719,7 +719,7 @@ class ContractUpdateParamsPricingOverrideActionAddStartsAt(TypedDict): class ContractUpdateParamsPricingOverrideActionRemove(TypedDict): id: str """ - The ID of the pricing override to remove. + The id of the pricing override to remove. """ @@ -745,9 +745,9 @@ class ContractUpdateParamsPricingOverrideActionUpdate(TypedDict): class ContractUpdateParamsPricingOverrideActionUpdateEndsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item ends. + The timestamp when the pricing ends. """ - type: Literal["billing_period_end", "timestamp"] + type: Literal["timestamp"] """ The type of end time to apply. """ @@ -756,9 +756,9 @@ class ContractUpdateParamsPricingOverrideActionUpdateEndsAt(TypedDict): class ContractUpdateParamsPricingOverrideActionUpdateStartsAt(TypedDict): timestamp: NotRequired[str] """ - The timestamp when the item starts. + The timestamp when the pricing starts. """ - type: Literal["billing_period_start", "timestamp"] + type: Literal["timestamp"] """ The type of start time to apply. """ diff --git a/stripe/v2/billing/_contract.py b/stripe/v2/billing/_contract.py index c40b81de6..3f7bd6b9d 100644 --- a/stripe/v2/billing/_contract.py +++ b/stripe/v2/billing/_contract.py @@ -9,7 +9,7 @@ class Contract(StripeObject): """ - Main Contract resource representing a comprehensive billing agreement + Contract resource representing a comprehensive sales agreement """ OBJECT_NAME: ClassVar[Literal["v2.billing.contract"]] = ( @@ -123,7 +123,7 @@ class BillAt(StripeObject): """ id: str """ - The ID of the one-time fee. + The id of the one-time fee. """ lookup_key: Optional[str] """ @@ -131,7 +131,7 @@ class BillAt(StripeObject): """ product: str """ - The ID of the v1 Product for this fee. + The id of the product for this fee. """ _inner_class_types = {"bill_at": BillAt} @@ -205,7 +205,11 @@ class StartsAt(StripeObject): ends_at: EndsAt """ - Resolved timestamp when this override ends. + Timestamp when this override ends. + """ + id: str + """ + The ID of the pricing override. """ lookup_key: Optional[str] """ @@ -215,13 +219,13 @@ class StartsAt(StripeObject): """ Details for an overwrite_price override. """ - pricing_override: str + priority: int """ - The ID of the pricing line override. + The priority of this override relative to others. Lower number = higher priority. """ starts_at: StartsAt """ - Resolved timestamp when this override starts. + Timestamp when this override starts. """ type: Literal["overwrite_price"] """ @@ -274,11 +278,11 @@ class StartsAt(StripeObject): ends_at: EndsAt """ - Resolved timestamp when the pricing line ends. + Timestamp when the pricing line ends. """ id: str """ - The ID of the pricing line. + The id of the pricing line. """ lookup_key: Optional[str] """ @@ -286,7 +290,7 @@ class StartsAt(StripeObject): """ metadata: Optional[UntypedStripeObject[str]] """ - Set of key-value pairs that you can attach to an object. + Set of key-value pairs. """ pricing: Pricing """ @@ -294,7 +298,7 @@ class StartsAt(StripeObject): """ starts_at: StartsAt """ - Resolved timestamp when the pricing line starts. + Timestamp when the pricing line starts. """ _inner_class_types = { "ends_at": EndsAt, @@ -316,7 +320,7 @@ class EndsAt(StripeObject): The timestamp when the item ends. """ - class Multiplier(StripeObject): + class MultiplyPricing(StripeObject): class Criterion(StripeObject): pricing_line_ids: Optional[List[str]] """ @@ -333,11 +337,11 @@ class Criterion(StripeObject): criteria: List[Criterion] """ - Criteria determining which rates the multiplier applies to. + Criteria determining which rates the multiply_pricing override applies to. """ factor: str """ - The multiplier factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. + The multiply_pricing factor, represented as a decimal string. e.g. "0.8" for a 20% reduction. """ _inner_class_types = {"criteria": Criterion} @@ -359,9 +363,9 @@ class StartsAt(StripeObject): """ The user-provided lookup key for the pricing override. """ - multiplier: Optional[Multiplier] + multiply_pricing: Optional[MultiplyPricing] """ - Details for a multiplier override. + Details for a multiply_pricing override. """ priority: int """ @@ -371,13 +375,13 @@ class StartsAt(StripeObject): """ Resolved timestamp when the pricing override starts. """ - type: Literal["multiplier"] + type: Literal["multiply_pricing"] """ The type of pricing override. """ _inner_class_types = { "ends_at": EndsAt, - "multiplier": Multiplier, + "multiply_pricing": MultiplyPricing, "starts_at": StartsAt, } @@ -403,11 +407,11 @@ class StatusTransitions(StripeObject): billing_cycle_anchor: Optional[BillingCycleAnchor] """ - The billing cycle anchor for the contract. + The billing cycle anchor. """ billing_settings: Optional[BillingSettings] """ - The billing settings for the contract. + The billing settings. """ contract_number: str """ @@ -415,19 +419,19 @@ class StatusTransitions(StripeObject): """ created: str """ - Timestamp of when the object was created. + Timestamp of when the contract was created. """ currency: str """ - The currency of the contract. + The currency. """ customer: str """ - The ID of the customer associated with the contract. + The customer id. """ id: str """ - The ID of the contract object. + The contract id. """ livemode: bool """ @@ -435,7 +439,7 @@ class StatusTransitions(StripeObject): """ metadata: Optional[UntypedStripeObject[str]] """ - Set of key-value pairs that you can attach to an object. + Set of key-value pairs. """ object: Literal["v2.billing.contract"] """ @@ -443,15 +447,15 @@ class StatusTransitions(StripeObject): """ one_time_fees: Optional[OneTimeFees] """ - The one-time fees of the contract. Only populated when `one_time_fees` is passed in the `include` parameter. + The one-time fees. Only populated when `one_time_fees` is passed in the `include` parameter. """ pricing_lines: Optional[PricingLines] """ - The pricing lines of the contract. Only populated when `pricing_lines` is passed in the `include` parameter. + The pricing lines. Only populated when `pricing_lines` is passed in the `include` parameter. """ pricing_overrides: Optional[PricingOverrides] """ - The pricing overrides of the contract. Only populated when `pricing_overrides` is passed in the `include` parameter. + The pricing overrides. Only populated when `pricing_overrides` is passed in the `include` parameter. """ status: Literal["active", "canceled", "draft", "ended"] """ diff --git a/stripe/v2/billing/_contract_pricing_line_quantity_change.py b/stripe/v2/billing/_contract_pricing_line_quantity_change.py index 269e78209..f473bc5ca 100644 --- a/stripe/v2/billing/_contract_pricing_line_quantity_change.py +++ b/stripe/v2/billing/_contract_pricing_line_quantity_change.py @@ -35,7 +35,7 @@ class Pricing(StripeObject): """ id: str """ - The ID of the quantity change object. + The id of the quantity change object. """ livemode: bool """ @@ -51,7 +51,7 @@ class Pricing(StripeObject): """ pricing_line: str """ - The ID of the pricing line associated with this quantity change. + The id of the pricing line associated with this quantity change. """ quantity: Decimal """ diff --git a/stripe/v2/billing/_contract_service.py b/stripe/v2/billing/_contract_service.py index 9a846ac9e..e484922a0 100644 --- a/stripe/v2/billing/_contract_service.py +++ b/stripe/v2/billing/_contract_service.py @@ -72,7 +72,7 @@ def list( options: Optional["RequestOptions"] = None, ) -> "ListObject[Contract]": """ - List Contract objects with pagination. + List contracts. """ return cast( "ListObject[Contract]", @@ -91,7 +91,7 @@ async def list_async( options: Optional["RequestOptions"] = None, ) -> "ListObject[Contract]": """ - List Contract objects with pagination. + List contracts. """ return cast( "ListObject[Contract]", @@ -110,7 +110,7 @@ def create( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Create a Contract object. + Create a draft contract. """ return cast( "Contract", @@ -129,7 +129,7 @@ async def create_async( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Create a Contract object. + Create a draft contract. """ return cast( "Contract", @@ -149,7 +149,7 @@ def delete( options: Optional["RequestOptions"] = None, ) -> "DeletedObject": """ - Delete a draft Contract object by ID. + Delete a draft contract. """ return cast( "DeletedObject", @@ -169,7 +169,7 @@ async def delete_async( options: Optional["RequestOptions"] = None, ) -> "DeletedObject": """ - Delete a draft Contract object by ID. + Delete a draft contract. """ return cast( "DeletedObject", @@ -189,7 +189,7 @@ def retrieve( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Retrieve a Contract object by ID. + Retrieve a contract. """ return cast( "Contract", @@ -209,7 +209,7 @@ async def retrieve_async( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Retrieve a Contract object by ID. + Retrieve a contract. """ return cast( "Contract", @@ -229,7 +229,7 @@ def update( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Update a Contract object by ID. + Update a draft or active contract. """ return cast( "Contract", @@ -249,7 +249,7 @@ async def update_async( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Update a Contract object by ID. + Update a draft or active contract. """ return cast( "Contract", @@ -269,7 +269,7 @@ def activate( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Activate a Draft Contract object by ID. + Activate a draft contract. """ return cast( "Contract", @@ -291,7 +291,7 @@ async def activate_async( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Activate a Draft Contract object by ID. + Activate a draft contract. """ return cast( "Contract", @@ -313,7 +313,7 @@ def cancel( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Cancel a Contract object by ID. + Cancel an active contract. """ return cast( "Contract", @@ -333,7 +333,7 @@ async def cancel_async( options: Optional["RequestOptions"] = None, ) -> "Contract": """ - Cancel a Contract object by ID. + Cancel an active contract. """ return cast( "Contract", diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 99f5b9e4f..d0e675375 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -43952,7 +43952,7 @@ def test_v2_billing_contract_post_service( { "ends_at": { "timestamp": "1970-01-01T15:18:46.294Z", - "type": "contract_end", + "type": "timestamp", }, "lookup_key": "lookup_key", "metadata": {"key": "metadata"}, @@ -43963,7 +43963,7 @@ def test_v2_billing_contract_post_service( { "ends_at": { "timestamp": "1970-01-01T15:18:46.294Z", - "type": "contract_end", + "type": "timestamp", }, "lookup_key": "lookup_key", "metadata": {"key": "metadata"}, @@ -43984,7 +43984,7 @@ def test_v2_billing_contract_post_service( "priority": 1165461084, "starts_at": { "timestamp": "1970-01-01T15:18:46.294Z", - "type": "contract_start", + "type": "timestamp", }, "type": "overwrite_price", }, @@ -44003,7 +44003,7 @@ def test_v2_billing_contract_post_service( }, "starts_at": { "timestamp": "1970-01-01T15:18:46.294Z", - "type": "contract_start", + "type": "timestamp", }, }, ], @@ -44014,7 +44014,7 @@ def test_v2_billing_contract_post_service( path="/v2/billing/contracts", query_string="", api_base="https://api.stripe.com", - post_data='{"contract_number":"contract_number","currency":"usd","pricing_lines":[{"ends_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"contract_end"},"lookup_key":"lookup_key","metadata":{"key":"metadata"},"pricing":{"price_details":{"price":"price","pricing_overrides":[{"ends_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"contract_end"},"lookup_key":"lookup_key","metadata":{"key":"metadata"},"overwrite_price":{"tiering_mode":"graduated","tiers":[{"flat_amount":"flat_amount","unit_amount":"unit_amount","up_to_decimal":"1387931359.3333333","up_to_inf":"inf"}],"unit_amount":"unit_amount"},"priority":1165461084,"starts_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"contract_start"},"type":"overwrite_price"}],"quantity_changes":[{"effective_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"},"set":"75841.33333333333"}]},"type":"price"},"starts_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"contract_start"}}]}', + post_data='{"contract_number":"contract_number","currency":"usd","pricing_lines":[{"ends_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"},"lookup_key":"lookup_key","metadata":{"key":"metadata"},"pricing":{"price_details":{"price":"price","pricing_overrides":[{"ends_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"},"lookup_key":"lookup_key","metadata":{"key":"metadata"},"overwrite_price":{"tiering_mode":"graduated","tiers":[{"flat_amount":"flat_amount","unit_amount":"unit_amount","up_to_decimal":"1387931359.3333333","up_to_inf":"inf"}],"unit_amount":"unit_amount"},"priority":1165461084,"starts_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"},"type":"overwrite_price"}],"quantity_changes":[{"effective_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"},"set":"75841.33333333333"}]},"type":"price"},"starts_at":{"timestamp":"1970-01-01T15:18:46.294Z","type":"timestamp"}}]}', is_json=True, )