diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 9531d8d24..c63a3302e 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -499f00588b1b41670a44a1e00598db81222ce169 +61e410d24d6de541c86c48b265b7647c164457ee \ No newline at end of file diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 02f8a7cef..5e8e56a7f 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2149 \ No newline at end of file +v2151 \ No newline at end of file diff --git a/stripe/_api_requestor.py b/stripe/_api_requestor.py index e196fd9cc..fecb840b2 100644 --- a/stripe/_api_requestor.py +++ b/stripe/_api_requestor.py @@ -413,6 +413,8 @@ def specific_v2_api_error(self, rbody, rcode, resp, rheaders, error_data): return error.NotCancelableError(**error_args) elif type == "quota_exceeded": return error.QuotaExceededError(**error_args) + elif type == "rate_limit": + return error.RateLimitError(**error_args) elif type == "recipient_not_notifiable": return error.RecipientNotNotifiableError(**error_args) elif type == "temporary_session_expired": diff --git a/stripe/_event_notification_handler.py b/stripe/_event_notification_handler.py index c39700041..d29dda810 100644 --- a/stripe/_event_notification_handler.py +++ b/stripe/_event_notification_handler.py @@ -49,6 +49,9 @@ from stripe.events._v2_core_account_including_defaults_updated_event import ( V2CoreAccountIncludingDefaultsUpdatedEventNotification, ) + from stripe.events._v2_core_account_including_future_requirements_updated_event import ( + V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, + ) from stripe.events._v2_core_account_including_identity_updated_event import ( V2CoreAccountIncludingIdentityUpdatedEventNotification, ) @@ -449,6 +452,19 @@ def on_v2_core_account_including_defaults_updated( ) return func + def on_v2_core_account_including_future_requirements_updated( + self, + func: "Callable[[V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, StripeClient], None]", + ): + """ + Registers a callback for the `V2CoreAccountIncludingFutureRequirementsUpdatedEvent` (`v2.core.account[future_requirements].updated`) event notification. + """ + self._register( + "v2.core.account[future_requirements].updated", + func, + ) + return func + def on_v2_core_account_including_identity_updated( self, func: "Callable[[V2CoreAccountIncludingIdentityUpdatedEventNotification, StripeClient], None]", diff --git a/stripe/events/__init__.py b/stripe/events/__init__.py index 97b92f368..d9bada65b 100644 --- a/stripe/events/__init__.py +++ b/stripe/events/__init__.py @@ -65,6 +65,10 @@ V2CoreAccountIncludingDefaultsUpdatedEvent as V2CoreAccountIncludingDefaultsUpdatedEvent, V2CoreAccountIncludingDefaultsUpdatedEventNotification as V2CoreAccountIncludingDefaultsUpdatedEventNotification, ) + from stripe.events._v2_core_account_including_future_requirements_updated_event import ( + V2CoreAccountIncludingFutureRequirementsUpdatedEvent as V2CoreAccountIncludingFutureRequirementsUpdatedEvent, + V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification as V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, + ) from stripe.events._v2_core_account_including_identity_updated_event import ( V2CoreAccountIncludingIdentityUpdatedEvent as V2CoreAccountIncludingIdentityUpdatedEvent, V2CoreAccountIncludingIdentityUpdatedEventNotification as V2CoreAccountIncludingIdentityUpdatedEventNotification, @@ -353,6 +357,14 @@ "stripe.events._v2_core_account_including_defaults_updated_event", False, ), + "V2CoreAccountIncludingFutureRequirementsUpdatedEvent": ( + "stripe.events._v2_core_account_including_future_requirements_updated_event", + False, + ), + "V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification": ( + "stripe.events._v2_core_account_including_future_requirements_updated_event", + False, + ), "V2CoreAccountIncludingIdentityUpdatedEvent": ( "stripe.events._v2_core_account_including_identity_updated_event", False, diff --git a/stripe/events/_event_classes.py b/stripe/events/_event_classes.py index b250d1e15..8f5dbbbf2 100644 --- a/stripe/events/_event_classes.py +++ b/stripe/events/_event_classes.py @@ -46,6 +46,9 @@ from stripe.events._v2_core_account_including_defaults_updated_event import ( V2CoreAccountIncludingDefaultsUpdatedEventNotification, ) + from stripe.events._v2_core_account_including_future_requirements_updated_event import ( + V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, + ) from stripe.events._v2_core_account_including_identity_updated_event import ( V2CoreAccountIncludingIdentityUpdatedEventNotification, ) @@ -236,6 +239,10 @@ "stripe.events._v2_core_account_including_defaults_updated_event", "V2CoreAccountIncludingDefaultsUpdatedEvent", ), + "v2.core.account[future_requirements].updated": ( + "stripe.events._v2_core_account_including_future_requirements_updated_event", + "V2CoreAccountIncludingFutureRequirementsUpdatedEvent", + ), "v2.core.account[identity].updated": ( "stripe.events._v2_core_account_including_identity_updated_event", "V2CoreAccountIncludingIdentityUpdatedEvent", @@ -483,6 +490,10 @@ def get_v2_event_class(type_: str): "stripe.events._v2_core_account_including_defaults_updated_event", "V2CoreAccountIncludingDefaultsUpdatedEventNotification", ), + "v2.core.account[future_requirements].updated": ( + "stripe.events._v2_core_account_including_future_requirements_updated_event", + "V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification", + ), "v2.core.account[identity].updated": ( "stripe.events._v2_core_account_including_identity_updated_event", "V2CoreAccountIncludingIdentityUpdatedEventNotification", @@ -691,6 +702,7 @@ def get_v2_event_notification_class(type_: str): "V2CoreAccountIncludingConfigurationStorerCapabilityStatusUpdatedEventNotification", "V2CoreAccountIncludingConfigurationStorerUpdatedEventNotification", "V2CoreAccountIncludingDefaultsUpdatedEventNotification", + "V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification", "V2CoreAccountIncludingIdentityUpdatedEventNotification", "V2CoreAccountIncludingRequirementsUpdatedEventNotification", "V2CoreAccountLinkReturnedEventNotification", diff --git a/stripe/events/_v2_core_account_including_future_requirements_updated_event.py b/stripe/events/_v2_core_account_including_future_requirements_updated_event.py new file mode 100644 index 000000000..0e471082b --- /dev/null +++ b/stripe/events/_v2_core_account_including_future_requirements_updated_event.py @@ -0,0 +1,114 @@ +# -*- 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.core._account import Account + + +class V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification( + EventNotification, +): + LOOKUP_TYPE = "v2.core.account[future_requirements].updated" + type: Literal["v2.core.account[future_requirements].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, + ) -> "V2CoreAccountIncludingFutureRequirementsUpdatedEvent": + return cast( + "V2CoreAccountIncludingFutureRequirementsUpdatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "Account": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "Account", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async( + self, + ) -> "V2CoreAccountIncludingFutureRequirementsUpdatedEvent": + return cast( + "V2CoreAccountIncludingFutureRequirementsUpdatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "Account": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "Account", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2CoreAccountIncludingFutureRequirementsUpdatedEvent(Event): + LOOKUP_TYPE = "v2.core.account[future_requirements].updated" + type: Literal["v2.core.account[future_requirements].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) -> "Account": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "Account", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={"stripe_context": self.context}, + ), + ) diff --git a/stripe/params/v2/core/vault/_us_bank_account_update_params.py b/stripe/params/v2/core/vault/_us_bank_account_update_params.py index a75aa9eac..4f3efc16a 100644 --- a/stripe/params/v2/core/vault/_us_bank_account_update_params.py +++ b/stripe/params/v2/core/vault/_us_bank_account_update_params.py @@ -6,7 +6,7 @@ class UsBankAccountUpdateParams(TypedDict): fedwire_routing_number: NotRequired[str] """ - The bank account's fedwire routing number can be provided for update it was were empty previously. + The bank account's Fedwire routing number can be provided for update if it was empty previously. """ routing_number: NotRequired[str] """ diff --git a/stripe/v2/core/vault/_gb_bank_account.py b/stripe/v2/core/vault/_gb_bank_account.py index 5a6c4a81b..52572adde 100644 --- a/stripe/v2/core/vault/_gb_bank_account.py +++ b/stripe/v2/core/vault/_gb_bank_account.py @@ -14,6 +14,16 @@ class GbBankAccount(StripeObject): "v2.core.vault.gb_bank_account" ) + class AlternativeReference(StripeObject): + id: str + """ + The ID of the alternative resource being referenced. + """ + type: Literal["external_account", "payment_method"] + """ + The type of the alternative reference (e.g., external_account for V1 external accounts). + """ + class ConfirmationOfPayee(StripeObject): class Result(StripeObject): class Matched(StripeObject): @@ -71,6 +81,10 @@ class Provided(StripeObject): """ _inner_class_types = {"result": Result} + alternative_reference: Optional[AlternativeReference] + """ + The alternative reference for this payout method, if it's a projected payout method. + """ archived: bool """ Whether this bank account object was archived. Bank account objects can be archived through @@ -114,4 +128,7 @@ class Provided(StripeObject): """ The Sort Code of the bank account. """ - _inner_class_types = {"confirmation_of_payee": ConfirmationOfPayee} + _inner_class_types = { + "alternative_reference": AlternativeReference, + "confirmation_of_payee": ConfirmationOfPayee, + } diff --git a/stripe/v2/core/vault/_us_bank_account.py b/stripe/v2/core/vault/_us_bank_account.py index 711c6f7ac..b5827050a 100644 --- a/stripe/v2/core/vault/_us_bank_account.py +++ b/stripe/v2/core/vault/_us_bank_account.py @@ -14,6 +14,16 @@ class UsBankAccount(StripeObject): "v2.core.vault.us_bank_account" ) + class AlternativeReference(StripeObject): + id: str + """ + The ID of the alternative resource being referenced. + """ + type: Literal["external_account", "payment_method"] + """ + The type of the alternative reference (e.g., external_account for V1 external accounts). + """ + class Verification(StripeObject): class MicrodepositVerificationDetails(StripeObject): expires: str @@ -48,6 +58,10 @@ class MicrodepositVerificationDetails(StripeObject): "microdeposit_verification_details": MicrodepositVerificationDetails, } + alternative_reference: Optional[AlternativeReference] + """ + The alternative reference for this payout method, if it's a projected payout method. + """ archived: bool """ Whether this USBankAccount object was archived. @@ -96,4 +110,7 @@ class MicrodepositVerificationDetails(StripeObject): """ The bank account verification details. """ - _inner_class_types = {"verification": Verification} + _inner_class_types = { + "alternative_reference": AlternativeReference, + "verification": Verification, + } diff --git a/stripe/v2/money_management/_financial_address.py b/stripe/v2/money_management/_financial_address.py index 541f21e1f..1548f5b74 100644 --- a/stripe/v2/money_management/_financial_address.py +++ b/stripe/v2/money_management/_financial_address.py @@ -62,6 +62,44 @@ class SepaBankAccount(StripeObject): """ class UsBankAccount(StripeObject): + class AccountHolderAddress(StripeObject): + city: str + """ + The city of the address. + """ + country: str + """ + The country of the address. + """ + line1: str + """ + The first line of the address. + """ + line2: str + """ + The second line of the address. + """ + postal_code: str + """ + The postal / zip code of the address. + """ + state: str + """ + The state of the address. + """ + town: str + """ + The town of the address. + """ + + account_holder_address: Optional[AccountHolderAddress] + """ + The address of the account holder. + """ + account_holder_name: Optional[str] + """ + The name of the account holder. + """ account_number: Optional[str] """ The account number of the US Bank Account. @@ -83,6 +121,9 @@ class UsBankAccount(StripeObject): """ The swift code of the bank or financial institution. """ + _inner_class_types = { + "account_holder_address": AccountHolderAddress, + } gb_bank_account: Optional[GbBankAccount] """ diff --git a/stripe/v2/money_management/_payout_method.py b/stripe/v2/money_management/_payout_method.py index 1ae47d035..ebbec50c0 100644 --- a/stripe/v2/money_management/_payout_method.py +++ b/stripe/v2/money_management/_payout_method.py @@ -14,6 +14,16 @@ class PayoutMethod(StripeObject): "v2.money_management.payout_method" ) + class AlternativeReference(StripeObject): + id: str + """ + The ID of the alternative resource being referenced. + """ + type: Literal["external_account", "payment_method"] + """ + The type of the alternative reference (e.g., external_account for V1 external accounts). + """ + class BankAccount(StripeObject): archived: bool """ @@ -69,6 +79,11 @@ class Card(StripeObject): """ The year the card expires. """ + fingerprint: str + """ + Uniquely identifies this particular card number. You can use this attribute to check whether two + recipients who've signed up with you are using the same card number, for example. + """ last4: str """ The last 4 digits of the card number. @@ -84,6 +99,10 @@ class UsageStatus(StripeObject): Transfers status - used when making an OutboundTransfer (sending funds to yourself). """ + alternative_reference: Optional[AlternativeReference] + """ + The alternative reference for this payout method, if it's a projected payout method. + """ available_payout_speeds: List[Literal["instant", "standard"]] """ A set of available payout speeds for this payout method. @@ -125,6 +144,7 @@ class UsageStatus(StripeObject): Indicates whether the payout method has met the necessary requirements for outbound money movement. """ _inner_class_types = { + "alternative_reference": AlternativeReference, "bank_account": BankAccount, "card": Card, "usage_status": UsageStatus, diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index aa5f1c3e3..3b90176d7 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -46123,7 +46123,7 @@ def test_blocked_by_stripe_error_service( http_client_mock.stub_request( "post", "/v2/core/vault/us_bank_accounts", - rbody='{"error":{"type":"blocked_by_stripe","code":"blocked_payout_method_bank_account"}}', + rbody='{"error":{"type":"blocked_by_stripe","code":"blocked_payout_method"}}', rcode=400, ) client = StripeClient( @@ -46444,6 +46444,31 @@ def test_quota_exceeded_error_service( is_json=True, ) + def test_rate_limit_error_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "get", + "/v2/core/accounts", + rbody='{"error":{"type":"rate_limit","code":"account_rate_limit_exceeded"}}', + rcode=400, + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + try: + client.v2.core.accounts.list() + except _error.RateLimitError: + pass + http_client_mock.assert_requested( + "get", + path="/v2/core/accounts", + query_string="", + api_base="https://api.stripe.com", + ) + def test_recipient_not_notifiable_error_service( self, http_client_mock: HTTPClientMock ) -> None: