Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23a0d1c154d81b4b4185658446b2ee07f06f969a
51726cfe77f5ee46f2ffac5f0984f971df101fcd
80 changes: 80 additions & 0 deletions stripe/_event_notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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]",
Expand Down
60 changes: 60 additions & 0 deletions stripe/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
60 changes: 60 additions & 0 deletions stripe/events/_event_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -4777,6 +4832,11 @@ def get_v2_event_notification_class(type_: str):
"V2BillingCadenceBilledEventNotification",
"V2BillingCadenceCanceledEventNotification",
"V2BillingCadenceCreatedEventNotification",
"V2BillingContractActivatedEventNotification",
"V2BillingContractCanceledEventNotification",
"V2BillingContractCreatedEventNotification",
"V2BillingContractEndedEventNotification",
"V2BillingContractUpdatedEventNotification",
"V2BillingLicensedItemCreatedEventNotification",
"V2BillingLicensedItemUpdatedEventNotification",
"V2BillingLicenseFeeCreatedEventNotification",
Expand Down
113 changes: 113 additions & 0 deletions stripe/events/_v2_billing_contract_activated_event.py
Original file line number Diff line number Diff line change
@@ -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}"},
},
),
)
Loading
Loading