diff --git a/API_VERSION b/API_VERSION index 8e27f52b5..211afa2c0 100644 --- a/API_VERSION +++ b/API_VERSION @@ -1 +1 @@ -56689dcbcaa4c7ce6bf1b51a5add451972e0689c \ No newline at end of file +7684500f9744e3dbcd9b4b87db96f2e919c105aa \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 570bef695..0c8363aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,41 @@ # Changelog +## 13.2.0b1 - 2025-10-29 + +This release changes the pinned API version to `2025-10-29.preview`. + +* [#1655](https://github.com/stripe/stripe-python/pull/1655) Update generated code for beta + * Add support for `crypto_storer` on `v2.core.AccountModifyParamsIdentityAttestationTermsOfService` +* [#1624](https://github.com/stripe/stripe-python/pull/1624) Update generated code for beta + * Add support for `modify` method on resource `v2.money_management.FinancialAccount` + * Add support for `confirm_microdeposits`, `list`, and `send_microdeposits` methods on resource `v2.core.vault.UsBankAccount` + * Add support for `list` method on resource `v2.core.vault.GbBankAccount` + * Add support for new value `verification_data_not_found` on enums `Account.FutureRequirement.Error.code`, `Account.Requirement.Error.code`, `BankAccount.FutureRequirement.Error.code`, `BankAccount.Requirement.Error.code`, `Capability.FutureRequirement.Error.code`, `Capability.Requirement.Error.code`, `Person.FutureRequirement.Error.code`, and `Person.Requirement.Error.code` + * Add support for `payment_portal_url` on `Charge.PaymentMethodDetail.Rechnung`, `PaymentAttemptRecord.PaymentMethodDetail.Rechnung`, and `PaymentRecord.PaymentMethodDetail.Rechnung` + * Add support for `tax_id_element` on `CustomerSession.Component` and `CustomerSessionCreateParamsComponent` + * Add support for `starting_after` on `PaymentAttemptRecordListParams` + * Add support for new value `solana` on enums `PaymentAttemptRecord.PaymentMethodDetail.Crypto.network` and `PaymentRecord.PaymentMethodDetail.Crypto.network` + * Add support for `reference` on `PaymentIntentAmountDetailsLineItem.PaymentMethodOption.Klarna`, `PaymentIntentCaptureParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentConfirmParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentCreateParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentIncrementAuthorizationParamsAmountDetailLineItemPaymentMethodOptionKlarna`, and `PaymentIntentModifyParamsAmountDetailLineItemPaymentMethodOptionKlarna` + * Change `PaymentIntent.PaymentDetail.customer_reference` to be required + * Change `PaymentIntent.PaymentDetail.order_reference` to be required + * Add support for `subscription_reference` on `PaymentIntentAmountDetailsLineItem.PaymentMethodOption.Klarna` + * Add support for `closed` on `V2.Core.Account` and `v2.core.AccountListParams` + * Add support for new value `payment_method` on enums `V2.Core.Account.Configuration.Customer.AutomaticIndirectTax.location_source`, `v2.core.AccountCreateParamsConfigurationCustomerAutomaticIndirectTax.location_source`, and `v2.core.AccountModifyParamsConfigurationCustomerAutomaticIndirectTax.location_source` + * Add support for `usd` on `V2.Core.Account.Configuration.Storer.Capability.HoldsCurrency`, `v2.core.AccountCreateParamsConfigurationStorerCapabilityHoldsCurrency`, and `v2.core.AccountModifyParamsConfigurationStorerCapabilityHoldsCurrency` + * Add support for new values `application_custom` and `application_express` on enums `V2.Core.Account.Default.Responsibility.fees_collector`, `v2.core.AccountCreateParamsDefaultResponsibility.fees_collector`, and `v2.core.AccountModifyParamsDefaultResponsibility.fees_collector` + * Add support for `representative_declaration` on `V2.Core.Account.Identity.Attestation`, `v2.core.AccountCreateParamsIdentityAttestation`, and `v2.core.AccountModifyParamsIdentityAttestation` + * Add support for new value `holds_currencies.usd` on enum `V2.Core.Account.Requirement.Entry.Impact.RestrictsCapability.capability` + * Add support for `verification` on `V2.Core.Vault.UsBankAccount` + * Add support for `v1_id` on `EventsV2MoneyManagementTransactionCreatedEvent` + * Remove support for thin event `V2BillingBillSettingUpdatedEvent` with related object `v2.billing.BillSetting` + * Add support for error code `payment_intent_rate_limit_exceeded` on `QuotePreviewInvoice.LastFinalizationError` + * Add support for error codes `blocked_payout_method_crypto_wallet` and `unsupported_payout_method_crypto_wallet` on `BlockedByStripeError` + * Add support for error code `outbound_flow_from_closed_financial_account_unsupported` on `FeatureNotEnabledError` + * Add support for error code `limit_payout_method_crypto_wallet` on `QuotaExceededError` +* [#1617](https://github.com/stripe/stripe-python/pull/1617) Update generated code for beta + * Add support for `last_seen_at` on `Terminal.Reader` + * Add support for new value `2025-10-29.clover` on enum `WebhookEndpointCreateParams.api_version` + ## 13.2.0a2 - 2025-10-30 * [#1659](https://github.com/stripe/stripe-python/pull/1659) Update generated code for private-preview * Change `delegated_checkout.RequestedSessionModifyParamsLineItemDetail.quantity` to be required @@ -63,42 +99,12 @@ * Add support for `external_amount` on `V2.MoneyManagement.ReceivedCredit` and `V2.MoneyManagement.ReceivedDebit` * Add support for error code `payment_intent_rate_limit_exceeded` on `Invoice.LastFinalizationError`, `PaymentIntent.LastPaymentError`, `QuotePreviewInvoice.LastFinalizationError`, `SetupAttempt.SetupError`, `SetupIntent.LastSetupError`, and `StripeError` -## 13.2.0b1 - 2025-10-29 +## 13.1.2 - 2025-11-04 +* [#1661](https://github.com/stripe/stripe-python/pull/1661) Add support for value `payment_record` to enum `InvoicePayment.payment.type` -This release changes the pinned API version to `2025-10-29.preview`. +## 13.1.1 - 2025-10-31 +* [#1660](https://github.com/stripe/stripe-python/pull/1660) Fix `stripe-context` header not being included in paged list requests -* [#1655](https://github.com/stripe/stripe-python/pull/1655) Update generated code for beta - * Add support for `crypto_storer` on `v2.core.AccountModifyParamsIdentityAttestationTermsOfService` -* [#1624](https://github.com/stripe/stripe-python/pull/1624) Update generated code for beta - * Add support for `modify` method on resource `v2.money_management.FinancialAccount` - * Add support for `confirm_microdeposits`, `list`, and `send_microdeposits` methods on resource `v2.core.vault.UsBankAccount` - * Add support for `list` method on resource `v2.core.vault.GbBankAccount` - * Add support for new value `verification_data_not_found` on enums `Account.FutureRequirement.Error.code`, `Account.Requirement.Error.code`, `BankAccount.FutureRequirement.Error.code`, `BankAccount.Requirement.Error.code`, `Capability.FutureRequirement.Error.code`, `Capability.Requirement.Error.code`, `Person.FutureRequirement.Error.code`, and `Person.Requirement.Error.code` - * Add support for `payment_portal_url` on `Charge.PaymentMethodDetail.Rechnung`, `PaymentAttemptRecord.PaymentMethodDetail.Rechnung`, and `PaymentRecord.PaymentMethodDetail.Rechnung` - * Add support for `tax_id_element` on `CustomerSession.Component` and `CustomerSessionCreateParamsComponent` - * Add support for `starting_after` on `PaymentAttemptRecordListParams` - * Add support for new value `solana` on enums `PaymentAttemptRecord.PaymentMethodDetail.Crypto.network` and `PaymentRecord.PaymentMethodDetail.Crypto.network` - * Add support for `reference` on `PaymentIntentAmountDetailsLineItem.PaymentMethodOption.Klarna`, `PaymentIntentCaptureParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentConfirmParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentCreateParamsAmountDetailLineItemPaymentMethodOptionKlarna`, `PaymentIntentIncrementAuthorizationParamsAmountDetailLineItemPaymentMethodOptionKlarna`, and `PaymentIntentModifyParamsAmountDetailLineItemPaymentMethodOptionKlarna` - * Change `PaymentIntent.PaymentDetail.customer_reference` to be required - * Change `PaymentIntent.PaymentDetail.order_reference` to be required - * Add support for `subscription_reference` on `PaymentIntentAmountDetailsLineItem.PaymentMethodOption.Klarna` - * Add support for `closed` on `V2.Core.Account` and `v2.core.AccountListParams` - * Add support for new value `payment_method` on enums `V2.Core.Account.Configuration.Customer.AutomaticIndirectTax.location_source`, `v2.core.AccountCreateParamsConfigurationCustomerAutomaticIndirectTax.location_source`, and `v2.core.AccountModifyParamsConfigurationCustomerAutomaticIndirectTax.location_source` - * Add support for `usd` on `V2.Core.Account.Configuration.Storer.Capability.HoldsCurrency`, `v2.core.AccountCreateParamsConfigurationStorerCapabilityHoldsCurrency`, and `v2.core.AccountModifyParamsConfigurationStorerCapabilityHoldsCurrency` - * Add support for new values `application_custom` and `application_express` on enums `V2.Core.Account.Default.Responsibility.fees_collector`, `v2.core.AccountCreateParamsDefaultResponsibility.fees_collector`, and `v2.core.AccountModifyParamsDefaultResponsibility.fees_collector` - * Add support for `representative_declaration` on `V2.Core.Account.Identity.Attestation`, `v2.core.AccountCreateParamsIdentityAttestation`, and `v2.core.AccountModifyParamsIdentityAttestation` - * Add support for new value `holds_currencies.usd` on enum `V2.Core.Account.Requirement.Entry.Impact.RestrictsCapability.capability` - * Add support for `verification` on `V2.Core.Vault.UsBankAccount` - * Add support for `v1_id` on `EventsV2MoneyManagementTransactionCreatedEvent` - * Remove support for thin event `V2BillingBillSettingUpdatedEvent` with related object `v2.billing.BillSetting` - * Add support for error code `payment_intent_rate_limit_exceeded` on `QuotePreviewInvoice.LastFinalizationError` - * Add support for error codes `blocked_payout_method_crypto_wallet` and `unsupported_payout_method_crypto_wallet` on `BlockedByStripeError` - * Add support for error code `outbound_flow_from_closed_financial_account_unsupported` on `FeatureNotEnabledError` - * Add support for error code `limit_payout_method_crypto_wallet` on `QuotaExceededError` -* [#1617](https://github.com/stripe/stripe-python/pull/1617) Update generated code for beta - * Add support for `last_seen_at` on `Terminal.Reader` - * Add support for new value `2025-10-29.clover` on enum `WebhookEndpointCreateParams.api_version` - ## 13.1.0 - 2025-10-29 This release changes the pinned API version to `2025-10-29.clover`. diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 4dfe75c0e..e0ee2c2b1 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2106 \ No newline at end of file +v2110 \ No newline at end of file diff --git a/stripe/__init__.py b/stripe/__init__.py index 92aebc838..5a4443985 100644 --- a/stripe/__init__.py +++ b/stripe/__init__.py @@ -604,6 +604,7 @@ def add_beta_version( TransferReversalService as TransferReversalService, ) from stripe._transfer_service import TransferService as TransferService + from stripe._transit_balance import TransitBalance as TransitBalance from stripe._treasury_service import TreasuryService as TreasuryService from stripe._updateable_api_resource import ( UpdateableAPIResource as UpdateableAPIResource, @@ -985,6 +986,7 @@ def add_beta_version( "Transfer": ("stripe._transfer", False), "TransferReversalService": ("stripe._transfer_reversal_service", False), "TransferService": ("stripe._transfer_service", False), + "TransitBalance": ("stripe._transit_balance", False), "TreasuryService": ("stripe._treasury_service", False), "UpdateableAPIResource": ("stripe._updateable_api_resource", False), "convert_to_stripe_object": ("stripe._util", False), diff --git a/stripe/_api_requestor.py b/stripe/_api_requestor.py index ea5347d96..c45992e82 100644 --- a/stripe/_api_requestor.py +++ b/stripe/_api_requestor.py @@ -45,7 +45,11 @@ StripeStreamResponse, StripeStreamResponseAsync, ) -from stripe._request_options import RequestOptions, merge_options +from stripe._request_options import ( + PERSISTENT_OPTIONS_KEYS, + RequestOptions, + merge_options, +) from stripe._requestor_options import ( RequestorOptions, _GlobalRequestorOptions, @@ -124,12 +128,15 @@ def _get_http_client(self) -> HTTPClient: return stripe.default_http_client return client - def _replace_options( + def _new_requestor_with_options( self, options: Optional[RequestOptions] ) -> "_APIRequestor": + """ + Returns a new _APIRequestor instance with the same HTTP client but a (potentially) updated set of options. Useful for ensuring the original isn't modified, but any options the original had are still used. + """ options = options or {} new_options = self._options.to_dict() - for key in ["api_key", "stripe_account", "stripe_version"]: + for key in PERSISTENT_OPTIONS_KEYS: if key in options and options[key] is not None: new_options[key] = options[key] return _APIRequestor( @@ -168,7 +175,9 @@ def _global_instance(cls): def _global_with_options( **params: Unpack[RequestOptions], ) -> "_APIRequestor": - return _APIRequestor._global_instance()._replace_options(params) + return _APIRequestor._global_instance()._new_requestor_with_options( + params + ) @classmethod def _format_app_info(cls, info): @@ -190,7 +199,7 @@ def request( usage: Optional[List[str]] = None, ) -> "StripeObject": api_mode = get_api_mode(url) - requestor = self._replace_options(options) + requestor = self._new_requestor_with_options(options) rbody, rcode, rheaders = requestor.request_raw( method.lower(), url, @@ -224,7 +233,7 @@ async def request_async( usage: Optional[List[str]] = None, ) -> "StripeObject": api_mode = get_api_mode(url) - requestor = self._replace_options(options) + requestor = self._new_requestor_with_options(options) rbody, rcode, rheaders = await requestor.request_raw_async( method.lower(), url, diff --git a/stripe/_charge.py b/stripe/_charge.py index 61c5155a1..e064b0fed 100644 --- a/stripe/_charge.py +++ b/stripe/_charge.py @@ -38,6 +38,7 @@ from stripe._review import Review from stripe._source import Source from stripe._transfer import Transfer + from stripe._transit_balance import TransitBalance from stripe.params._charge_capture_params import ChargeCaptureParams from stripe.params._charge_create_params import ChargeCreateParams from stripe.params._charge_list_params import ChargeListParams @@ -2339,6 +2340,10 @@ class TransferData(StripeObject): ID of an existing, connected Stripe account to transfer funds to if `transfer_data` was specified in the charge request. """ + allocated_funds: Optional["TransitBalance"] + """ + Funds that are in transit and destined for another balance or another connected account. + """ amount: int """ Amount intended to be collected by this payment. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). diff --git a/stripe/_error_object.py b/stripe/_error_object.py index da2f38918..9221218be 100644 --- a/stripe/_error_object.py +++ b/stripe/_error_object.py @@ -39,7 +39,7 @@ def refresh_from( values=values, partial=partial, last_response=last_response, - requestor=self._requestor._replace_options( + requestor=self._requestor._new_requestor_with_options( { "api_key": api_key, "stripe_version": stripe_version, @@ -102,7 +102,7 @@ def refresh_from( values=values, partial=partial, last_response=last_response, - requestor=self._requestor._replace_options( + requestor=self._requestor._new_requestor_with_options( { "api_key": api_key, "stripe_version": stripe_version, diff --git a/stripe/_invoice_payment.py b/stripe/_invoice_payment.py index 203fec916..a66e08069 100644 --- a/stripe/_invoice_payment.py +++ b/stripe/_invoice_payment.py @@ -47,7 +47,7 @@ class Payment(StripeObject): """ ID of the PaymentRecord associated with this payment when `type` is `payment_record`. """ - type: Literal["charge", "payment_intent"] + type: Literal["charge", "payment_intent", "payment_record"] """ Type of payment object associated with this invoice payment. """ diff --git a/stripe/_object_classes.py b/stripe/_object_classes.py index 03e85f272..223de490a 100644 --- a/stripe/_object_classes.py +++ b/stripe/_object_classes.py @@ -349,6 +349,7 @@ "token": ("stripe._token", "Token"), "topup": ("stripe._topup", "Topup"), "transfer": ("stripe._transfer", "Transfer"), + "transit_balance": ("stripe._transit_balance", "TransitBalance"), "treasury.credit_reversal": ( "stripe.treasury._credit_reversal", "CreditReversal", @@ -581,6 +582,11 @@ "stripe.v2.payments._off_session_payment", "OffSessionPayment", ), + "v2.reporting.report": ("stripe.v2.reporting._report", "Report"), + "v2.reporting.report_run": ( + "stripe.v2.reporting._report_run", + "ReportRun", + ), "v2.tax.automatic_rule": ( "stripe.v2.tax._automatic_rule", "AutomaticRule", diff --git a/stripe/_request_options.py b/stripe/_request_options.py index 05d8c45a3..b3c00c433 100644 --- a/stripe/_request_options.py +++ b/stripe/_request_options.py @@ -54,6 +54,18 @@ def merge_options( } +PERSISTENT_OPTIONS_KEYS = { + "api_key", + "stripe_version", + "stripe_account", + "stripe_context", +} +""" +These are the keys in RequestOptions that should persist across requests made +by the same requestor. +""" + + def extract_options_from_dict( d: Optional[Mapping[str, Any]], ) -> Tuple[RequestOptions, Dict[str, Any]]: diff --git a/stripe/_stripe_object.py b/stripe/_stripe_object.py index bcf3c69ab..0f44342f4 100644 --- a/stripe/_stripe_object.py +++ b/stripe/_stripe_object.py @@ -27,7 +27,10 @@ StripeStreamResponseAsync, ) from stripe._encode import _encode_datetime # pyright: ignore -from stripe._request_options import extract_options_from_dict +from stripe._request_options import ( + PERSISTENT_OPTIONS_KEYS, + extract_options_from_dict, +) from stripe._api_mode import ApiMode from stripe._base_address import BaseAddress @@ -152,8 +155,10 @@ def update( # pyright: ignore if not TYPE_CHECKING: def __setattr__(self, k, v): - if k in {"api_key", "stripe_account", "stripe_version"}: - self._requestor = self._requestor._replace_options({k: v}) + if k in PERSISTENT_OPTIONS_KEYS: + self._requestor = self._requestor._new_requestor_with_options( + {k: v} + ) return None if k[0] == "_" or k in self.__dict__: @@ -303,7 +308,7 @@ def refresh_from( values=values, partial=partial, last_response=last_response, - requestor=self._requestor._replace_options( # pyright: ignore[reportPrivateUsage] + requestor=self._requestor._new_requestor_with_options( # pyright: ignore[reportPrivateUsage] { "api_key": api_key, "stripe_version": stripe_version, diff --git a/stripe/_test_helpers_service.py b/stripe/_test_helpers_service.py index 8138b15f3..1fcbaf557 100644 --- a/stripe/_test_helpers_service.py +++ b/stripe/_test_helpers_service.py @@ -5,6 +5,7 @@ from typing_extensions import TYPE_CHECKING if TYPE_CHECKING: + from stripe.test_helpers._capital_service import CapitalService from stripe.test_helpers._confirmation_token_service import ( ConfirmationTokenService, ) @@ -16,6 +17,7 @@ from stripe.test_helpers._treasury_service import TreasuryService _subservices = { + "capital": ["stripe.test_helpers._capital_service", "CapitalService"], "confirmation_tokens": [ "stripe.test_helpers._confirmation_token_service", "ConfirmationTokenService", @@ -33,6 +35,7 @@ class TestHelpersService(StripeService): + capital: "CapitalService" confirmation_tokens: "ConfirmationTokenService" customers: "CustomerService" issuing: "IssuingService" diff --git a/stripe/_transit_balance.py b/stripe/_transit_balance.py new file mode 100644 index 000000000..e6b8ead24 --- /dev/null +++ b/stripe/_transit_balance.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from typing import ClassVar +from typing_extensions import Literal + + +class TransitBalance(StripeObject): + """ + Funds that are in transit and destined for another balance or another connected account. + """ + + OBJECT_NAME: ClassVar[Literal["transit_balance"]] = "transit_balance" + + class Balance(StripeObject): + available: int + pending: int + + balance: Balance + created: int + """ + Time at which the object was created. Measured in seconds since the Unix epoch. + """ + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + livemode: bool + """ + Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + """ + object: Literal["transit_balance"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + _inner_class_types = {"balance": Balance} diff --git a/stripe/_v2_services.py b/stripe/_v2_services.py index 3e663d945..a2cb185ad 100644 --- a/stripe/_v2_services.py +++ b/stripe/_v2_services.py @@ -9,6 +9,7 @@ from stripe.v2._core_service import CoreService from stripe.v2._money_management_service import MoneyManagementService from stripe.v2._payment_service import PaymentService + from stripe.v2._reporting_service import ReportingService from stripe.v2._tax_service import TaxService from stripe.v2._test_helper_service import TestHelperService @@ -20,6 +21,7 @@ "MoneyManagementService", ], "payments": ["stripe.v2._payment_service", "PaymentService"], + "reporting": ["stripe.v2._reporting_service", "ReportingService"], "tax": ["stripe.v2._tax_service", "TaxService"], "test_helpers": ["stripe.v2._test_helper_service", "TestHelperService"], } @@ -30,6 +32,7 @@ class V2Services(StripeService): core: "CoreService" money_management: "MoneyManagementService" payments: "PaymentService" + reporting: "ReportingService" tax: "TaxService" test_helpers: "TestHelperService" diff --git a/stripe/capital/_financing_offer.py b/stripe/capital/_financing_offer.py index d1323ba46..340719461 100644 --- a/stripe/capital/_financing_offer.py +++ b/stripe/capital/_financing_offer.py @@ -3,17 +3,24 @@ from stripe._list_object import ListObject from stripe._listable_api_resource import ListableAPIResource from stripe._stripe_object import StripeObject +from stripe._test_helpers import APIResourceTestHelpers from stripe._util import class_method_variant, sanitize_id from typing import ClassVar, Dict, Optional, cast, overload -from typing_extensions import Literal, Unpack, TYPE_CHECKING +from typing_extensions import Literal, Type, Unpack, TYPE_CHECKING if TYPE_CHECKING: + from stripe.params.capital._financing_offer_create_params import ( + FinancingOfferCreateParams, + ) from stripe.params.capital._financing_offer_list_params import ( FinancingOfferListParams, ) from stripe.params.capital._financing_offer_mark_delivered_params import ( FinancingOfferMarkDeliveredParams, ) + from stripe.params.capital._financing_offer_refill_params import ( + FinancingOfferRefillParams, + ) from stripe.params.capital._financing_offer_retrieve_params import ( FinancingOfferRetrieveParams, ) @@ -350,7 +357,165 @@ async def retrieve_async( await instance.refresh_async() return instance + class TestHelpers(APIResourceTestHelpers["FinancingOffer"]): + _resource_cls: Type["FinancingOffer"] + + @classmethod + def create( + cls, **params: Unpack["FinancingOfferCreateParams"] + ) -> "FinancingOffer": + """ + Creates a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + cls._static_request( + "post", + "/v1/test_helpers/capital/financing_offers", + params=params, + ), + ) + + @classmethod + async def create_async( + cls, **params: Unpack["FinancingOfferCreateParams"] + ) -> "FinancingOffer": + """ + Creates a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + await cls._static_request_async( + "post", + "/v1/test_helpers/capital/financing_offers", + params=params, + ), + ) + + @classmethod + def _cls_refill( + cls, + financing_offer: str, + **params: Unpack["FinancingOfferRefillParams"], + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + cls._static_request( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(financing_offer) + ), + params=params, + ), + ) + + @overload + @staticmethod + def refill( + financing_offer: str, + **params: Unpack["FinancingOfferRefillParams"], + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + ... + + @overload + def refill( + self, **params: Unpack["FinancingOfferRefillParams"] + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + ... + + @class_method_variant("_cls_refill") + def refill( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["FinancingOfferRefillParams"] + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + self.resource._request( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + + @classmethod + async def _cls_refill_async( + cls, + financing_offer: str, + **params: Unpack["FinancingOfferRefillParams"], + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + await cls._static_request_async( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(financing_offer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def refill_async( + financing_offer: str, + **params: Unpack["FinancingOfferRefillParams"], + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + ... + + @overload + async def refill_async( + self, **params: Unpack["FinancingOfferRefillParams"] + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + ... + + @class_method_variant("_cls_refill_async") + async def refill_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["FinancingOfferRefillParams"] + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + await self.resource._request_async( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + + @property + def test_helpers(self): + return self.TestHelpers(self) + _inner_class_types = { "accepted_terms": AcceptedTerms, "offered_terms": OfferedTerms, } + + +FinancingOffer.TestHelpers._resource_cls = FinancingOffer diff --git a/stripe/events/__init__.py b/stripe/events/__init__.py index fd93ebd6b..627d3d697 100644 --- a/stripe/events/__init__.py +++ b/stripe/events/__init__.py @@ -1265,6 +1265,22 @@ V2PaymentsOffSessionPaymentSucceededEvent as V2PaymentsOffSessionPaymentSucceededEvent, V2PaymentsOffSessionPaymentSucceededEventNotification as V2PaymentsOffSessionPaymentSucceededEventNotification, ) + from stripe.events._v2_reporting_report_run_created_event import ( + V2ReportingReportRunCreatedEvent as V2ReportingReportRunCreatedEvent, + V2ReportingReportRunCreatedEventNotification as V2ReportingReportRunCreatedEventNotification, + ) + from stripe.events._v2_reporting_report_run_failed_event import ( + V2ReportingReportRunFailedEvent as V2ReportingReportRunFailedEvent, + V2ReportingReportRunFailedEventNotification as V2ReportingReportRunFailedEventNotification, + ) + from stripe.events._v2_reporting_report_run_succeeded_event import ( + V2ReportingReportRunSucceededEvent as V2ReportingReportRunSucceededEvent, + V2ReportingReportRunSucceededEventNotification as V2ReportingReportRunSucceededEventNotification, + ) + from stripe.events._v2_reporting_report_run_updated_event import ( + V2ReportingReportRunUpdatedEvent as V2ReportingReportRunUpdatedEvent, + V2ReportingReportRunUpdatedEventNotification as V2ReportingReportRunUpdatedEventNotification, + ) # name -> (import_target, is_submodule) _import_map = { @@ -3662,6 +3678,38 @@ "stripe.events._v2_payments_off_session_payment_succeeded_event", False, ), + "V2ReportingReportRunCreatedEvent": ( + "stripe.events._v2_reporting_report_run_created_event", + False, + ), + "V2ReportingReportRunCreatedEventNotification": ( + "stripe.events._v2_reporting_report_run_created_event", + False, + ), + "V2ReportingReportRunFailedEvent": ( + "stripe.events._v2_reporting_report_run_failed_event", + False, + ), + "V2ReportingReportRunFailedEventNotification": ( + "stripe.events._v2_reporting_report_run_failed_event", + False, + ), + "V2ReportingReportRunSucceededEvent": ( + "stripe.events._v2_reporting_report_run_succeeded_event", + False, + ), + "V2ReportingReportRunSucceededEventNotification": ( + "stripe.events._v2_reporting_report_run_succeeded_event", + False, + ), + "V2ReportingReportRunUpdatedEvent": ( + "stripe.events._v2_reporting_report_run_updated_event", + False, + ), + "V2ReportingReportRunUpdatedEventNotification": ( + "stripe.events._v2_reporting_report_run_updated_event", + False, + ), } if not TYPE_CHECKING: diff --git a/stripe/events/_event_classes.py b/stripe/events/_event_classes.py index d2c69f5fa..bc4b1d762 100644 --- a/stripe/events/_event_classes.py +++ b/stripe/events/_event_classes.py @@ -946,6 +946,18 @@ from stripe.events._v2_payments_off_session_payment_succeeded_event import ( V2PaymentsOffSessionPaymentSucceededEventNotification, ) + from stripe.events._v2_reporting_report_run_created_event import ( + V2ReportingReportRunCreatedEventNotification, + ) + from stripe.events._v2_reporting_report_run_failed_event import ( + V2ReportingReportRunFailedEventNotification, + ) + from stripe.events._v2_reporting_report_run_succeeded_event import ( + V2ReportingReportRunSucceededEventNotification, + ) + from stripe.events._v2_reporting_report_run_updated_event import ( + V2ReportingReportRunUpdatedEventNotification, + ) _V2_EVENT_CLASS_LOOKUP = { @@ -2201,6 +2213,22 @@ "stripe.events._v2_payments_off_session_payment_succeeded_event", "V2PaymentsOffSessionPaymentSucceededEvent", ), + "v2.reporting.report_run.created": ( + "stripe.events._v2_reporting_report_run_created_event", + "V2ReportingReportRunCreatedEvent", + ), + "v2.reporting.report_run.failed": ( + "stripe.events._v2_reporting_report_run_failed_event", + "V2ReportingReportRunFailedEvent", + ), + "v2.reporting.report_run.succeeded": ( + "stripe.events._v2_reporting_report_run_succeeded_event", + "V2ReportingReportRunSucceededEvent", + ), + "v2.reporting.report_run.updated": ( + "stripe.events._v2_reporting_report_run_updated_event", + "V2ReportingReportRunUpdatedEvent", + ), } @@ -3468,6 +3496,22 @@ def get_v2_event_class(type_: str): "stripe.events._v2_payments_off_session_payment_succeeded_event", "V2PaymentsOffSessionPaymentSucceededEventNotification", ), + "v2.reporting.report_run.created": ( + "stripe.events._v2_reporting_report_run_created_event", + "V2ReportingReportRunCreatedEventNotification", + ), + "v2.reporting.report_run.failed": ( + "stripe.events._v2_reporting_report_run_failed_event", + "V2ReportingReportRunFailedEventNotification", + ), + "v2.reporting.report_run.succeeded": ( + "stripe.events._v2_reporting_report_run_succeeded_event", + "V2ReportingReportRunSucceededEventNotification", + ), + "v2.reporting.report_run.updated": ( + "stripe.events._v2_reporting_report_run_updated_event", + "V2ReportingReportRunUpdatedEventNotification", + ), } @@ -3796,4 +3840,8 @@ def get_v2_event_notification_class(type_: str): "V2PaymentsOffSessionPaymentFailedEventNotification", "V2PaymentsOffSessionPaymentRequiresCaptureEventNotification", "V2PaymentsOffSessionPaymentSucceededEventNotification", + "V2ReportingReportRunCreatedEventNotification", + "V2ReportingReportRunFailedEventNotification", + "V2ReportingReportRunSucceededEventNotification", + "V2ReportingReportRunUpdatedEventNotification", ] diff --git a/stripe/events/_v2_reporting_report_run_created_event.py b/stripe/events/_v2_reporting_report_run_created_event.py new file mode 100644 index 000000000..3e83fe455 --- /dev/null +++ b/stripe/events/_v2_reporting_report_run_created_event.py @@ -0,0 +1,108 @@ +# -*- 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.reporting._report_run import ReportRun + + +class V2ReportingReportRunCreatedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.reporting.report_run.created" + type: Literal["v2.reporting.report_run.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) -> "V2ReportingReportRunCreatedEvent": + return cast( + "V2ReportingReportRunCreatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "ReportRun": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2ReportingReportRunCreatedEvent": + return cast( + "V2ReportingReportRunCreatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "ReportRun": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2ReportingReportRunCreatedEvent(Event): + LOOKUP_TYPE = "v2.reporting.report_run.created" + type: Literal["v2.reporting.report_run.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) -> "ReportRun": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "ReportRun", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={"stripe_context": self.context}, + ), + ) diff --git a/stripe/events/_v2_reporting_report_run_failed_event.py b/stripe/events/_v2_reporting_report_run_failed_event.py new file mode 100644 index 000000000..dd8a797ae --- /dev/null +++ b/stripe/events/_v2_reporting_report_run_failed_event.py @@ -0,0 +1,108 @@ +# -*- 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.reporting._report_run import ReportRun + + +class V2ReportingReportRunFailedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.reporting.report_run.failed" + type: Literal["v2.reporting.report_run.failed"] + 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) -> "V2ReportingReportRunFailedEvent": + return cast( + "V2ReportingReportRunFailedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "ReportRun": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2ReportingReportRunFailedEvent": + return cast( + "V2ReportingReportRunFailedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "ReportRun": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2ReportingReportRunFailedEvent(Event): + LOOKUP_TYPE = "v2.reporting.report_run.failed" + type: Literal["v2.reporting.report_run.failed"] + + 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) -> "ReportRun": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "ReportRun", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={"stripe_context": self.context}, + ), + ) diff --git a/stripe/events/_v2_reporting_report_run_succeeded_event.py b/stripe/events/_v2_reporting_report_run_succeeded_event.py new file mode 100644 index 000000000..dad77f2b3 --- /dev/null +++ b/stripe/events/_v2_reporting_report_run_succeeded_event.py @@ -0,0 +1,108 @@ +# -*- 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.reporting._report_run import ReportRun + + +class V2ReportingReportRunSucceededEventNotification(EventNotification): + LOOKUP_TYPE = "v2.reporting.report_run.succeeded" + type: Literal["v2.reporting.report_run.succeeded"] + 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) -> "V2ReportingReportRunSucceededEvent": + return cast( + "V2ReportingReportRunSucceededEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "ReportRun": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2ReportingReportRunSucceededEvent": + return cast( + "V2ReportingReportRunSucceededEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "ReportRun": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2ReportingReportRunSucceededEvent(Event): + LOOKUP_TYPE = "v2.reporting.report_run.succeeded" + type: Literal["v2.reporting.report_run.succeeded"] + + 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) -> "ReportRun": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "ReportRun", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={"stripe_context": self.context}, + ), + ) diff --git a/stripe/events/_v2_reporting_report_run_updated_event.py b/stripe/events/_v2_reporting_report_run_updated_event.py new file mode 100644 index 000000000..cc30ca17d --- /dev/null +++ b/stripe/events/_v2_reporting_report_run_updated_event.py @@ -0,0 +1,108 @@ +# -*- 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.reporting._report_run import ReportRun + + +class V2ReportingReportRunUpdatedEventNotification(EventNotification): + LOOKUP_TYPE = "v2.reporting.report_run.updated" + type: Literal["v2.reporting.report_run.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) -> "V2ReportingReportRunUpdatedEvent": + return cast( + "V2ReportingReportRunUpdatedEvent", + super().fetch_event(), + ) + + def fetch_related_object(self) -> "ReportRun": + response = self._client.raw_request( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + @override + async def fetch_event_async(self) -> "V2ReportingReportRunUpdatedEvent": + return cast( + "V2ReportingReportRunUpdatedEvent", + await super().fetch_event_async(), + ) + + async def fetch_related_object_async(self) -> "ReportRun": + response = await self._client.raw_request_async( + "get", + self.related_object.url, + stripe_context=self.context, + usage=["fetch_related_object"], + ) + return cast( + "ReportRun", + self._client.deserialize( + response, + api_mode=get_api_mode(self.related_object.url), + ), + ) + + +class V2ReportingReportRunUpdatedEvent(Event): + LOOKUP_TYPE = "v2.reporting.report_run.updated" + type: Literal["v2.reporting.report_run.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) -> "ReportRun": + """ + Retrieves the related object from the API. Makes an API request on every call. + """ + return cast( + "ReportRun", + self._requestor.request( + "get", + self.related_object.url, + base_address="api", + options={"stripe_context": self.context}, + ), + ) diff --git a/stripe/params/__init__.py b/stripe/params/__init__.py index dd67bb784..fdb5b99ed 100644 --- a/stripe/params/__init__.py +++ b/stripe/params/__init__.py @@ -1881,6 +1881,7 @@ ) from stripe.params._payment_intent_confirm_params import ( PaymentIntentConfirmParams as PaymentIntentConfirmParams, + PaymentIntentConfirmParamsAllocatedFunds as PaymentIntentConfirmParamsAllocatedFunds, PaymentIntentConfirmParamsAmountDetails as PaymentIntentConfirmParamsAmountDetails, PaymentIntentConfirmParamsAmountDetailsLineItem as PaymentIntentConfirmParamsAmountDetailsLineItem, PaymentIntentConfirmParamsAmountDetailsLineItemPaymentMethodOptions as PaymentIntentConfirmParamsAmountDetailsLineItemPaymentMethodOptions, @@ -2084,6 +2085,7 @@ ) from stripe.params._payment_intent_create_params import ( PaymentIntentCreateParams as PaymentIntentCreateParams, + PaymentIntentCreateParamsAllocatedFunds as PaymentIntentCreateParamsAllocatedFunds, PaymentIntentCreateParamsAmountDetails as PaymentIntentCreateParamsAmountDetails, PaymentIntentCreateParamsAmountDetailsLineItem as PaymentIntentCreateParamsAmountDetailsLineItem, PaymentIntentCreateParamsAmountDetailsLineItemPaymentMethodOptions as PaymentIntentCreateParamsAmountDetailsLineItemPaymentMethodOptions, @@ -2323,6 +2325,7 @@ ) from stripe.params._payment_intent_modify_params import ( PaymentIntentModifyParams as PaymentIntentModifyParams, + PaymentIntentModifyParamsAllocatedFunds as PaymentIntentModifyParamsAllocatedFunds, PaymentIntentModifyParamsAmountDetails as PaymentIntentModifyParamsAmountDetails, PaymentIntentModifyParamsAmountDetailsLineItem as PaymentIntentModifyParamsAmountDetailsLineItem, PaymentIntentModifyParamsAmountDetailsLineItemPaymentMethodOptions as PaymentIntentModifyParamsAmountDetailsLineItemPaymentMethodOptions, @@ -2535,6 +2538,7 @@ ) from stripe.params._payment_intent_update_params import ( PaymentIntentUpdateParams as PaymentIntentUpdateParams, + PaymentIntentUpdateParamsAllocatedFunds as PaymentIntentUpdateParamsAllocatedFunds, PaymentIntentUpdateParamsAmountDetails as PaymentIntentUpdateParamsAmountDetails, PaymentIntentUpdateParamsAmountDetailsLineItem as PaymentIntentUpdateParamsAmountDetailsLineItem, PaymentIntentUpdateParamsAmountDetailsLineItemPaymentMethodOptions as PaymentIntentUpdateParamsAmountDetailsLineItemPaymentMethodOptions, @@ -10314,6 +10318,10 @@ "stripe.params._payment_intent_confirm_params", False, ), + "PaymentIntentConfirmParamsAllocatedFunds": ( + "stripe.params._payment_intent_confirm_params", + False, + ), "PaymentIntentConfirmParamsAmountDetails": ( "stripe.params._payment_intent_confirm_params", False, @@ -11118,6 +11126,10 @@ "stripe.params._payment_intent_create_params", False, ), + "PaymentIntentCreateParamsAllocatedFunds": ( + "stripe.params._payment_intent_create_params", + False, + ), "PaymentIntentCreateParamsAmountDetails": ( "stripe.params._payment_intent_create_params", False, @@ -12034,6 +12046,10 @@ "stripe.params._payment_intent_modify_params", False, ), + "PaymentIntentModifyParamsAllocatedFunds": ( + "stripe.params._payment_intent_modify_params", + False, + ), "PaymentIntentModifyParamsAmountDetails": ( "stripe.params._payment_intent_modify_params", False, @@ -12850,6 +12866,10 @@ "stripe.params._payment_intent_update_params", False, ), + "PaymentIntentUpdateParamsAllocatedFunds": ( + "stripe.params._payment_intent_update_params", + False, + ), "PaymentIntentUpdateParamsAmountDetails": ( "stripe.params._payment_intent_update_params", False, diff --git a/stripe/params/_payment_intent_confirm_params.py b/stripe/params/_payment_intent_confirm_params.py index 47fe4aced..a7a935dc6 100644 --- a/stripe/params/_payment_intent_confirm_params.py +++ b/stripe/params/_payment_intent_confirm_params.py @@ -126,6 +126,10 @@ class PaymentIntentConfirmParams(RequestOptions): """ Set to `true` when confirming server-side and using Stripe.js, iOS, or Android client-side SDKs to handle the next actions. """ + allocated_funds: NotRequired["PaymentIntentConfirmParamsAllocatedFunds"] + """ + Allocated Funds configuration for this PaymentIntent. + """ class PaymentIntentConfirmParamsAmountDetails(TypedDict): @@ -4407,3 +4411,10 @@ class PaymentIntentConfirmParamsShippingAddress(TypedDict): """ State, county, province, or region. """ + + +class PaymentIntentConfirmParamsAllocatedFunds(TypedDict): + enabled: NotRequired[bool] + """ + Whether Allocated Funds creation is enabled for this PaymentIntent. + """ diff --git a/stripe/params/_payment_intent_create_params.py b/stripe/params/_payment_intent_create_params.py index 3ec18d3dd..68d9ba97a 100644 --- a/stripe/params/_payment_intent_create_params.py +++ b/stripe/params/_payment_intent_create_params.py @@ -258,6 +258,10 @@ class PaymentIntentCreateParams(RequestOptions): """ Set to `true` when confirming server-side and using Stripe.js, iOS, or Android client-side SDKs to handle the next actions. """ + allocated_funds: NotRequired["PaymentIntentCreateParamsAllocatedFunds"] + """ + Allocated Funds configuration for this PaymentIntent. + """ class PaymentIntentCreateParamsAmountDetails(TypedDict): @@ -4554,3 +4558,10 @@ class PaymentIntentCreateParamsTransferData(TypedDict): to the destination account. The ID of the resulting transfer will be returned on the successful charge's `transfer` field. """ + + +class PaymentIntentCreateParamsAllocatedFunds(TypedDict): + enabled: NotRequired[bool] + """ + Whether Allocated Funds creation is enabled for this PaymentIntent. + """ diff --git a/stripe/params/_payment_intent_modify_params.py b/stripe/params/_payment_intent_modify_params.py index 2dd9597a0..9b450c873 100644 --- a/stripe/params/_payment_intent_modify_params.py +++ b/stripe/params/_payment_intent_modify_params.py @@ -145,6 +145,10 @@ class PaymentIntentModifyParams(RequestOptions): """ A string that identifies the resulting payment as part of a group. You can only provide `transfer_group` if it hasn't been set. Learn more about the [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). """ + allocated_funds: NotRequired["PaymentIntentModifyParamsAllocatedFunds"] + """ + Allocated Funds configuration for this PaymentIntent. + """ class PaymentIntentModifyParamsAmountDetails(TypedDict): @@ -4392,3 +4396,10 @@ class PaymentIntentModifyParamsTransferData(TypedDict): """ The amount that will be transferred automatically when a charge succeeds. """ + + +class PaymentIntentModifyParamsAllocatedFunds(TypedDict): + enabled: NotRequired[bool] + """ + Whether Allocated Funds creation is enabled for this PaymentIntent. + """ diff --git a/stripe/params/_payment_intent_update_params.py b/stripe/params/_payment_intent_update_params.py index 087ad739c..2baedffe6 100644 --- a/stripe/params/_payment_intent_update_params.py +++ b/stripe/params/_payment_intent_update_params.py @@ -144,6 +144,10 @@ class PaymentIntentUpdateParams(TypedDict): """ A string that identifies the resulting payment as part of a group. You can only provide `transfer_group` if it hasn't been set. Learn more about the [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). """ + allocated_funds: NotRequired["PaymentIntentUpdateParamsAllocatedFunds"] + """ + Allocated Funds configuration for this PaymentIntent. + """ class PaymentIntentUpdateParamsAmountDetails(TypedDict): @@ -4391,3 +4395,10 @@ class PaymentIntentUpdateParamsTransferData(TypedDict): """ The amount that will be transferred automatically when a charge succeeds. """ + + +class PaymentIntentUpdateParamsAllocatedFunds(TypedDict): + enabled: NotRequired[bool] + """ + Whether Allocated Funds creation is enabled for this PaymentIntent. + """ diff --git a/stripe/params/capital/__init__.py b/stripe/params/capital/__init__.py index fbc2f7974..9663e6565 100644 --- a/stripe/params/capital/__init__.py +++ b/stripe/params/capital/__init__.py @@ -4,6 +4,9 @@ from typing_extensions import TYPE_CHECKING if TYPE_CHECKING: + from stripe.params.capital._financing_offer_create_params import ( + FinancingOfferCreateParams as FinancingOfferCreateParams, + ) from stripe.params.capital._financing_offer_list_params import ( FinancingOfferListParams as FinancingOfferListParams, FinancingOfferListParamsCreated as FinancingOfferListParamsCreated, @@ -11,6 +14,9 @@ from stripe.params.capital._financing_offer_mark_delivered_params import ( FinancingOfferMarkDeliveredParams as FinancingOfferMarkDeliveredParams, ) + from stripe.params.capital._financing_offer_refill_params import ( + FinancingOfferRefillParams as FinancingOfferRefillParams, + ) from stripe.params.capital._financing_offer_retrieve_params import ( FinancingOfferRetrieveParams as FinancingOfferRetrieveParams, ) @@ -26,6 +32,10 @@ # name -> (import_target, is_submodule) _import_map = { + "FinancingOfferCreateParams": ( + "stripe.params.capital._financing_offer_create_params", + False, + ), "FinancingOfferListParams": ( "stripe.params.capital._financing_offer_list_params", False, @@ -38,6 +48,10 @@ "stripe.params.capital._financing_offer_mark_delivered_params", False, ), + "FinancingOfferRefillParams": ( + "stripe.params.capital._financing_offer_refill_params", + False, + ), "FinancingOfferRetrieveParams": ( "stripe.params.capital._financing_offer_retrieve_params", False, diff --git a/stripe/params/capital/_financing_offer_create_params.py b/stripe/params/capital/_financing_offer_create_params.py new file mode 100644 index 000000000..fcf09f5d0 --- /dev/null +++ b/stripe/params/capital/_financing_offer_create_params.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._request_options import RequestOptions +from typing import List +from typing_extensions import Literal, NotRequired + + +class FinancingOfferCreateParams(RequestOptions): + advance_amount: int + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + fee_amount: int + financing_type: Literal["cash_advance", "fixed_term_loan", "flex_loan"] + status: NotRequired[ + Literal[ + "accepted", + "accepted_other_offer", + "canceled", + "completed", + "delivered", + "expired", + "fully_repaid", + "paid_out", + "rejected", + "replaced", + "undelivered", + ] + ] + withhold_rate: float diff --git a/stripe/params/capital/_financing_offer_refill_params.py b/stripe/params/capital/_financing_offer_refill_params.py new file mode 100644 index 000000000..86557fcfb --- /dev/null +++ b/stripe/params/capital/_financing_offer_refill_params.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._request_options import RequestOptions +from typing import List +from typing_extensions import Literal, NotRequired + + +class FinancingOfferRefillParams(RequestOptions): + advance_amount: int + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + fee_amount: int + financing_type: Literal["cash_advance", "fixed_term_loan", "flex_loan"] + status: NotRequired[ + Literal[ + "accepted", + "accepted_other_offer", + "canceled", + "completed", + "delivered", + "expired", + "fully_repaid", + "paid_out", + "rejected", + "replaced", + "undelivered", + ] + ] + withhold_rate: float diff --git a/stripe/params/test_helpers/__init__.py b/stripe/params/test_helpers/__init__.py index bf44f46ce..e4eb70225 100644 --- a/stripe/params/test_helpers/__init__.py +++ b/stripe/params/test_helpers/__init__.py @@ -5,6 +5,7 @@ if TYPE_CHECKING: from stripe.params.test_helpers import ( + capital as capital, issuing as issuing, terminal as terminal, treasury as treasury, @@ -105,6 +106,7 @@ # name -> (import_target, is_submodule) _import_map = { + "capital": ("stripe.params.test_helpers.capital", True), "issuing": ("stripe.params.test_helpers.issuing", True), "terminal": ("stripe.params.test_helpers.terminal", True), "treasury": ("stripe.params.test_helpers.treasury", True), diff --git a/stripe/params/test_helpers/capital/__init__.py b/stripe/params/test_helpers/capital/__init__.py new file mode 100644 index 000000000..35f6ade0d --- /dev/null +++ b/stripe/params/test_helpers/capital/__init__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.params.test_helpers.capital._financing_offer_create_params import ( + FinancingOfferCreateParams as FinancingOfferCreateParams, + ) + from stripe.params.test_helpers.capital._financing_offer_refill_params import ( + FinancingOfferRefillParams as FinancingOfferRefillParams, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "FinancingOfferCreateParams": ( + "stripe.params.test_helpers.capital._financing_offer_create_params", + False, + ), + "FinancingOfferRefillParams": ( + "stripe.params.test_helpers.capital._financing_offer_refill_params", + False, + ), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/params/test_helpers/capital/_financing_offer_create_params.py b/stripe/params/test_helpers/capital/_financing_offer_create_params.py new file mode 100644 index 000000000..83cb943f6 --- /dev/null +++ b/stripe/params/test_helpers/capital/_financing_offer_create_params.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing import List +from typing_extensions import Literal, NotRequired, TypedDict + + +class FinancingOfferCreateParams(TypedDict): + advance_amount: int + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + fee_amount: int + financing_type: Literal["cash_advance", "fixed_term_loan", "flex_loan"] + status: NotRequired[ + Literal[ + "accepted", + "accepted_other_offer", + "canceled", + "completed", + "delivered", + "expired", + "fully_repaid", + "paid_out", + "rejected", + "replaced", + "undelivered", + ] + ] + withhold_rate: float diff --git a/stripe/params/test_helpers/capital/_financing_offer_refill_params.py b/stripe/params/test_helpers/capital/_financing_offer_refill_params.py new file mode 100644 index 000000000..a4f19fcbc --- /dev/null +++ b/stripe/params/test_helpers/capital/_financing_offer_refill_params.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing import List +from typing_extensions import Literal, NotRequired, TypedDict + + +class FinancingOfferRefillParams(TypedDict): + advance_amount: int + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + fee_amount: int + financing_type: Literal["cash_advance", "fixed_term_loan", "flex_loan"] + status: NotRequired[ + Literal[ + "accepted", + "accepted_other_offer", + "canceled", + "completed", + "delivered", + "expired", + "fully_repaid", + "paid_out", + "rejected", + "replaced", + "undelivered", + ] + ] + withhold_rate: float diff --git a/stripe/params/v2/__init__.py b/stripe/params/v2/__init__.py index 4f469631b..b24a8d82f 100644 --- a/stripe/params/v2/__init__.py +++ b/stripe/params/v2/__init__.py @@ -9,6 +9,7 @@ core as core, money_management as money_management, payments as payments, + reporting as reporting, tax as tax, test_helpers as test_helpers, ) @@ -19,6 +20,7 @@ "core": ("stripe.params.v2.core", True), "money_management": ("stripe.params.v2.money_management", True), "payments": ("stripe.params.v2.payments", True), + "reporting": ("stripe.params.v2.reporting", True), "tax": ("stripe.params.v2.tax", True), "test_helpers": ("stripe.params.v2.test_helpers", True), } diff --git a/stripe/params/v2/reporting/__init__.py b/stripe/params/v2/reporting/__init__.py new file mode 100644 index 000000000..7146ed81f --- /dev/null +++ b/stripe/params/v2/reporting/__init__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.params.v2.reporting._report_retrieve_params import ( + ReportRetrieveParams as ReportRetrieveParams, + ) + from stripe.params.v2.reporting._report_run_create_params import ( + ReportRunCreateParams as ReportRunCreateParams, + ReportRunCreateParamsResultOptions as ReportRunCreateParamsResultOptions, + ) + from stripe.params.v2.reporting._report_run_retrieve_params import ( + ReportRunRetrieveParams as ReportRunRetrieveParams, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "ReportRetrieveParams": ( + "stripe.params.v2.reporting._report_retrieve_params", + False, + ), + "ReportRunCreateParams": ( + "stripe.params.v2.reporting._report_run_create_params", + False, + ), + "ReportRunCreateParamsResultOptions": ( + "stripe.params.v2.reporting._report_run_create_params", + False, + ), + "ReportRunRetrieveParams": ( + "stripe.params.v2.reporting._report_run_retrieve_params", + False, + ), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/params/v2/reporting/_report_retrieve_params.py b/stripe/params/v2/reporting/_report_retrieve_params.py new file mode 100644 index 000000000..db1ad24c0 --- /dev/null +++ b/stripe/params/v2/reporting/_report_retrieve_params.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TypedDict + + +class ReportRetrieveParams(TypedDict): + pass diff --git a/stripe/params/v2/reporting/_report_run_create_params.py b/stripe/params/v2/reporting/_report_run_create_params.py new file mode 100644 index 000000000..ece53d3e5 --- /dev/null +++ b/stripe/params/v2/reporting/_report_run_create_params.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing import Any, Dict +from typing_extensions import NotRequired, TypedDict + + +class ReportRunCreateParams(TypedDict): + report: str + """ + The unique identifier of the `Report` being requested. + """ + report_parameters: Dict[str, "Any"] + """ + A map of parameter names to values, specifying how the report should be customized. + The accepted parameters depend on the specific `Report` being run. + """ + result_options: NotRequired["ReportRunCreateParamsResultOptions"] + """ + Optional settings to customize the results of the `ReportRun`. + """ + + +class ReportRunCreateParamsResultOptions(TypedDict): + compress_file: NotRequired[bool] + """ + If set, the generated report file will be compressed into a ZIP folder. + This is useful for reducing file size and download time for large reports. + """ diff --git a/stripe/params/v2/reporting/_report_run_retrieve_params.py b/stripe/params/v2/reporting/_report_run_retrieve_params.py new file mode 100644 index 000000000..5f2b19209 --- /dev/null +++ b/stripe/params/v2/reporting/_report_run_retrieve_params.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TypedDict + + +class ReportRunRetrieveParams(TypedDict): + pass diff --git a/stripe/test_helpers/__init__.py b/stripe/test_helpers/__init__.py index ec9625f6c..00a17987e 100644 --- a/stripe/test_helpers/__init__.py +++ b/stripe/test_helpers/__init__.py @@ -5,10 +5,14 @@ if TYPE_CHECKING: from stripe.test_helpers import ( + capital as capital, issuing as issuing, terminal as terminal, treasury as treasury, ) + from stripe.test_helpers._capital_service import ( + CapitalService as CapitalService, + ) from stripe.test_helpers._confirmation_token_service import ( ConfirmationTokenService as ConfirmationTokenService, ) @@ -34,9 +38,11 @@ # name -> (import_target, is_submodule) _import_map = { + "capital": ("stripe.test_helpers.capital", True), "issuing": ("stripe.test_helpers.issuing", True), "terminal": ("stripe.test_helpers.terminal", True), "treasury": ("stripe.test_helpers.treasury", True), + "CapitalService": ("stripe.test_helpers._capital_service", False), "ConfirmationTokenService": ( "stripe.test_helpers._confirmation_token_service", False, diff --git a/stripe/test_helpers/_capital_service.py b/stripe/test_helpers/_capital_service.py new file mode 100644 index 000000000..b528574bb --- /dev/null +++ b/stripe/test_helpers/_capital_service.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.test_helpers.capital._financing_offer_service import ( + FinancingOfferService, + ) + +_subservices = { + "financing_offers": [ + "stripe.test_helpers.capital._financing_offer_service", + "FinancingOfferService", + ], +} + + +class CapitalService(StripeService): + financing_offers: "FinancingOfferService" + + def __init__(self, requestor): + super().__init__(requestor) + + def __getattr__(self, name): + try: + import_from, service = _subservices[name] + service_class = getattr( + import_module(import_from), + service, + ) + setattr( + self, + name, + service_class(self._requestor), + ) + return getattr(self, name) + except KeyError: + raise AttributeError() diff --git a/stripe/test_helpers/capital/__init__.py b/stripe/test_helpers/capital/__init__.py new file mode 100644 index 000000000..cfc715912 --- /dev/null +++ b/stripe/test_helpers/capital/__init__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.test_helpers.capital._financing_offer_service import ( + FinancingOfferService as FinancingOfferService, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "FinancingOfferService": ( + "stripe.test_helpers.capital._financing_offer_service", + False, + ), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/test_helpers/capital/_financing_offer_service.py b/stripe/test_helpers/capital/_financing_offer_service.py new file mode 100644 index 000000000..143a25627 --- /dev/null +++ b/stripe/test_helpers/capital/_financing_offer_service.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from stripe._util import sanitize_id +from typing import Optional, cast +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._request_options import RequestOptions + from stripe.capital._financing_offer import FinancingOffer + from stripe.params.test_helpers.capital._financing_offer_create_params import ( + FinancingOfferCreateParams, + ) + from stripe.params.test_helpers.capital._financing_offer_refill_params import ( + FinancingOfferRefillParams, + ) + + +class FinancingOfferService(StripeService): + def create( + self, + params: "FinancingOfferCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "FinancingOffer": + """ + Creates a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + self._request( + "post", + "/v1/test_helpers/capital/financing_offers", + base_address="api", + params=params, + options=options, + ), + ) + + async def create_async( + self, + params: "FinancingOfferCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "FinancingOffer": + """ + Creates a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + await self._request_async( + "post", + "/v1/test_helpers/capital/financing_offers", + base_address="api", + params=params, + options=options, + ), + ) + + def refill( + self, + financing_offer: str, + params: "FinancingOfferRefillParams", + options: Optional["RequestOptions"] = None, + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + self._request( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(financing_offer), + ), + base_address="api", + params=params, + options=options, + ), + ) + + async def refill_async( + self, + financing_offer: str, + params: "FinancingOfferRefillParams", + options: Optional["RequestOptions"] = None, + ) -> "FinancingOffer": + """ + Refills a test financing offer for a connected account. + """ + return cast( + "FinancingOffer", + await self._request_async( + "post", + "/v1/test_helpers/capital/financing_offers/{financing_offer}/refill".format( + financing_offer=sanitize_id(financing_offer), + ), + base_address="api", + params=params, + options=options, + ), + ) diff --git a/stripe/v2/__init__.py b/stripe/v2/__init__.py index e5081976c..e3cfe9c2f 100644 --- a/stripe/v2/__init__.py +++ b/stripe/v2/__init__.py @@ -12,6 +12,7 @@ core as core, money_management as money_management, payments as payments, + reporting as reporting, tax as tax, test_helpers as test_helpers, ) @@ -28,6 +29,9 @@ MoneyManagementService as MoneyManagementService, ) from stripe.v2._payment_service import PaymentService as PaymentService + from stripe.v2._reporting_service import ( + ReportingService as ReportingService, + ) from stripe.v2._tax_service import TaxService as TaxService from stripe.v2._test_helper_service import ( TestHelperService as TestHelperService, @@ -39,6 +43,7 @@ "core": ("stripe.v2.core", True), "money_management": ("stripe.v2.money_management", True), "payments": ("stripe.v2.payments", True), + "reporting": ("stripe.v2.reporting", True), "tax": ("stripe.v2.tax", True), "test_helpers": ("stripe.v2.test_helpers", True), "BillingService": ("stripe.v2._billing_service", False), @@ -54,6 +59,7 @@ ), "MoneyManagementService": ("stripe.v2._money_management_service", False), "PaymentService": ("stripe.v2._payment_service", False), + "ReportingService": ("stripe.v2._reporting_service", False), "TaxService": ("stripe.v2._tax_service", False), "TestHelperService": ("stripe.v2._test_helper_service", False), } diff --git a/stripe/v2/_reporting_service.py b/stripe/v2/_reporting_service.py new file mode 100644 index 000000000..df0db5143 --- /dev/null +++ b/stripe/v2/_reporting_service.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.v2.reporting._report_run_service import ReportRunService + from stripe.v2.reporting._report_service import ReportService + +_subservices = { + "reports": ["stripe.v2.reporting._report_service", "ReportService"], + "report_runs": [ + "stripe.v2.reporting._report_run_service", + "ReportRunService", + ], +} + + +class ReportingService(StripeService): + reports: "ReportService" + report_runs: "ReportRunService" + + def __init__(self, requestor): + super().__init__(requestor) + + def __getattr__(self, name): + try: + import_from, service = _subservices[name] + service_class = getattr( + import_module(import_from), + service, + ) + setattr( + self, + name, + service_class(self._requestor), + ) + return getattr(self, name) + except KeyError: + raise AttributeError() diff --git a/stripe/v2/reporting/__init__.py b/stripe/v2/reporting/__init__.py new file mode 100644 index 000000000..09b9c0488 --- /dev/null +++ b/stripe/v2/reporting/__init__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.v2.reporting._report import Report as Report + from stripe.v2.reporting._report_run import ReportRun as ReportRun + from stripe.v2.reporting._report_run_service import ( + ReportRunService as ReportRunService, + ) + from stripe.v2.reporting._report_service import ( + ReportService as ReportService, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "Report": ("stripe.v2.reporting._report", False), + "ReportRun": ("stripe.v2.reporting._report_run", False), + "ReportRunService": ("stripe.v2.reporting._report_run_service", False), + "ReportService": ("stripe.v2.reporting._report_service", False), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/v2/reporting/_report.py b/stripe/v2/reporting/_report.py new file mode 100644 index 000000000..d8020cad6 --- /dev/null +++ b/stripe/v2/reporting/_report.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from typing import ClassVar, Dict, List, Optional +from typing_extensions import Literal + + +class Report(StripeObject): + """ + The Report resource represents a customizable report template that provides insights into various aspects of your Stripe integration. + """ + + OBJECT_NAME: ClassVar[Literal["v2.reporting.report"]] = ( + "v2.reporting.report" + ) + + class Parameters(StripeObject): + class ArrayDetails(StripeObject): + class EnumDetails(StripeObject): + allowed_values: List[str] + """ + Allowed values of the enum. + """ + + element_type: Literal["enum"] + """ + Data type of the elements in the array. + """ + enum_details: Optional[EnumDetails] + """ + Details about enum elements in the array. + """ + _inner_class_types = {"enum_details": EnumDetails} + + class EnumDetails(StripeObject): + allowed_values: List[str] + """ + Allowed values of the enum. + """ + + class TimestampDetails(StripeObject): + max: str + """ + Maximum permitted timestamp which can be requested. + """ + min: str + """ + Minimum permitted timestamp which can be requested. + """ + + array_details: Optional[ArrayDetails] + """ + For array parameters, provides details about the array elements. + """ + description: str + """ + Explains the purpose and usage of the parameter. + """ + enum_details: Optional[EnumDetails] + """ + For enum parameters, provides the list of allowed values. + """ + required: bool + """ + Indicates whether the parameter must be provided. + """ + timestamp_details: Optional[TimestampDetails] + """ + For timestamp parameters, specifies the allowed date range. + """ + type: Literal["array", "enum", "string", "timestamp"] + """ + The data type of the parameter. + """ + _inner_class_types = { + "array_details": ArrayDetails, + "enum_details": EnumDetails, + "timestamp_details": TimestampDetails, + } + + id: str + """ + The unique identifier of the `Report` object. + """ + livemode: bool + """ + Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + """ + name: str + """ + The human-readable name of the `Report`. + """ + object: Literal["v2.reporting.report"] + """ + String representing the object's type. Objects of the same type share the same value of the object field. + """ + parameters: Dict[str, Parameters] + """ + Specification of the parameters that the `Report` accepts. It details each parameter's + name, description, whether it is required, and any validations performed. + """ + _inner_class_types = {"parameters": Parameters} diff --git a/stripe/v2/reporting/_report_run.py b/stripe/v2/reporting/_report_run.py new file mode 100644 index 000000000..2962e4962 --- /dev/null +++ b/stripe/v2/reporting/_report_run.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from typing import ClassVar, Dict, Optional +from typing_extensions import Literal, TYPE_CHECKING + +if TYPE_CHECKING: + from typing import Any + + +class ReportRun(StripeObject): + """ + The `ReportRun` object represents an instance of a `Report` generated with specific + run parameters. Once the object is created, Stripe begins processing the report. When + the report has finished running, it will give you a reference to the results. + """ + + OBJECT_NAME: ClassVar[Literal["v2.reporting.report_run"]] = ( + "v2.reporting.report_run" + ) + + class Result(StripeObject): + class File(StripeObject): + class DownloadUrl(StripeObject): + expires_at: Optional[str] + """ + The time that the URL expires. + """ + url: str + """ + The URL that can be used for accessing the file. + """ + + content_type: Literal["csv", "zip"] + """ + The content type of the file. + """ + download_url: DownloadUrl + """ + A pre-signed URL that allows secure, time-limited access to download the file. + """ + size: int + """ + The total size of the file in bytes. + """ + _inner_class_types = {"download_url": DownloadUrl} + + file: File + """ + Contains metadata about the file produced by the `ReportRun`, including + its content type, size, and a URL to download its contents. + """ + type: Literal["file"] + """ + The type of the `ReportRun` result. + """ + _inner_class_types = {"file": File} + + class ResultOptions(StripeObject): + compress_file: Optional[bool] + """ + If set, the generated report file will be compressed into a ZIP folder. + This is useful for reducing file size and download time for large reports. + """ + + class StatusDetails(StripeObject): + error_code: Optional[ + Literal["file_size_above_limit", "internal_error"] + ] + """ + Error code categorizing the reason the `ReportRun` failed. + """ + error_message: Optional[str] + """ + Error message with additional details about the failure. + """ + + created: str + """ + Time at which the object was created. + """ + id: str + """ + The unique identifier of the `ReportRun` object. + """ + livemode: bool + """ + Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + """ + object: Literal["v2.reporting.report_run"] + """ + String representing the object's type. Objects of the same type share the same value of the object field. + """ + report: str + """ + The unique identifier of the `Report` object which was run. + """ + report_name: str + """ + The human-readable name of the `Report` which was run. + """ + report_parameters: Dict[str, "Any"] + """ + The parameters used to customize the generation of the report. + """ + result: Optional[Result] + """ + Details how to retrieve the results of a successfully completed `ReportRun`. + """ + result_options: Optional[ResultOptions] + """ + The options specified for customizing the output file of the `ReportRun`. + """ + status: Literal["failed", "running", "succeeded"] + """ + The current status of the `ReportRun`. + """ + status_details: Dict[str, StatusDetails] + """ + Additional details about the current state of the `ReportRun`. The field is currently only populated when a `ReportRun` + is in the `failed` state, providing more information about why the report failed to generate successfully. + """ + _inner_class_types = { + "result": Result, + "result_options": ResultOptions, + "status_details": StatusDetails, + } diff --git a/stripe/v2/reporting/_report_run_service.py b/stripe/v2/reporting/_report_run_service.py new file mode 100644 index 000000000..03e69e159 --- /dev/null +++ b/stripe/v2/reporting/_report_run_service.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from stripe._util import sanitize_id +from typing import Optional, cast +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._request_options import RequestOptions + from stripe.params.v2.reporting._report_run_create_params import ( + ReportRunCreateParams, + ) + from stripe.params.v2.reporting._report_run_retrieve_params import ( + ReportRunRetrieveParams, + ) + from stripe.v2.reporting._report_run import ReportRun + + +class ReportRunService(StripeService): + def create( + self, + params: "ReportRunCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "ReportRun": + """ + Initiates the generation of a `ReportRun` based on the specified report template + and user-provided parameters. It's the starting point for obtaining report data, + and returns a `ReportRun` object which can be used to track the progress and retrieve + the results of the report. + """ + return cast( + "ReportRun", + self._request( + "post", + "/v2/reporting/report_runs", + base_address="api", + params=params, + options=options, + ), + ) + + async def create_async( + self, + params: "ReportRunCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "ReportRun": + """ + Initiates the generation of a `ReportRun` based on the specified report template + and user-provided parameters. It's the starting point for obtaining report data, + and returns a `ReportRun` object which can be used to track the progress and retrieve + the results of the report. + """ + return cast( + "ReportRun", + await self._request_async( + "post", + "/v2/reporting/report_runs", + base_address="api", + params=params, + options=options, + ), + ) + + def retrieve( + self, + id: str, + params: Optional["ReportRunRetrieveParams"] = None, + options: Optional["RequestOptions"] = None, + ) -> "ReportRun": + """ + Fetches the current state and details of a previously created `ReportRun`. If the `ReportRun` + has succeeded, the endpoint will provide details for how to retrieve the results. + """ + return cast( + "ReportRun", + self._request( + "get", + "/v2/reporting/report_runs/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + async def retrieve_async( + self, + id: str, + params: Optional["ReportRunRetrieveParams"] = None, + options: Optional["RequestOptions"] = None, + ) -> "ReportRun": + """ + Fetches the current state and details of a previously created `ReportRun`. If the `ReportRun` + has succeeded, the endpoint will provide details for how to retrieve the results. + """ + return cast( + "ReportRun", + await self._request_async( + "get", + "/v2/reporting/report_runs/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) diff --git a/stripe/v2/reporting/_report_service.py b/stripe/v2/reporting/_report_service.py new file mode 100644 index 000000000..a88b75757 --- /dev/null +++ b/stripe/v2/reporting/_report_service.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from stripe._util import sanitize_id +from typing import Optional, cast +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._request_options import RequestOptions + from stripe.params.v2.reporting._report_retrieve_params import ( + ReportRetrieveParams, + ) + from stripe.v2.reporting._report import Report + + +class ReportService(StripeService): + def retrieve( + self, + id: str, + params: Optional["ReportRetrieveParams"] = None, + options: Optional["RequestOptions"] = None, + ) -> "Report": + """ + Retrieves metadata about a specific `Report` template, including its name, description, + and the parameters it accepts. It's useful for understanding the capabilities and + requirements of a particular `Report` before requesting a `ReportRun`. + """ + return cast( + "Report", + self._request( + "get", + "/v2/reporting/reports/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + async def retrieve_async( + self, + id: str, + params: Optional["ReportRetrieveParams"] = None, + options: Optional["RequestOptions"] = None, + ) -> "Report": + """ + Retrieves metadata about a specific `Report` template, including its name, description, + and the parameters it accepts. It's useful for understanding the capabilities and + requirements of a particular `Report` before requesting a `ReportRun`. + """ + return cast( + "Report", + await self._request_async( + "get", + "/v2/reporting/reports/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) diff --git a/tests/api_resources/test_list_object.py b/tests/api_resources/test_list_object.py index 37ab96fe1..02568c4b7 100644 --- a/tests/api_resources/test_list_object.py +++ b/tests/api_resources/test_list_object.py @@ -5,6 +5,7 @@ import stripe from stripe._util import convert_to_stripe_object from stripe._stripe_object import StripeObject +from tests.http_client_mock import HTTPClientMock class TestListObject(object): @@ -522,6 +523,115 @@ def test_forwards_api_key_to_nested_resources(self, http_client_mock): # assert seen == ["prod_001", "prod_002"] + def test_iter_with_stripe_account(self, http_client_mock: HTTPClientMock): + http_client_mock.stub_request( + "get", + path="/v1/customers", + rbody='{"object": "list", "data": [{"id": "cus_001", "object": "customer"}], "url": "/v1/customers", "has_more": true}', + ) + http_client_mock.stub_request( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + rbody='{"object": "list", "data": [{"id": "cus_002", "object": "customer"}], "url": "/v1/customers", "has_more": false}', + ) + + cu_list = stripe.Customer.list( + api_key="org_key_abc", + stripe_account="ctx_123", + ) + + customers = [item.id for item in cu_list.auto_paging_iter()] + assert customers == ["cus_001", "cus_002"] + + http_client_mock.assert_requested( + "get", + path="/v1/customers", + api_key="org_key_abc", + stripe_account="ctx_123", + ) + http_client_mock.assert_requested( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + api_key="org_key_abc", + stripe_account="ctx_123", + ) + + def test_iter_with_stripe_context(self, http_client_mock: HTTPClientMock): + http_client_mock.stub_request( + "get", + path="/v1/customers", + rbody='{"object": "list", "data": [{"id": "cus_001", "object": "customer"}], "url": "/v1/customers", "has_more": true}', + ) + http_client_mock.stub_request( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + rbody='{"object": "list", "data": [{"id": "cus_002", "object": "customer"}], "url": "/v1/customers", "has_more": false}', + ) + + cu_list = stripe.Customer.list( + api_key="org_key_abc", + stripe_context="ctx_123", + ) + + customers = [item.id for item in cu_list.auto_paging_iter()] + assert customers == ["cus_001", "cus_002"] + + http_client_mock.assert_requested( + "get", + path="/v1/customers", + api_key="org_key_abc", + stripe_context="ctx_123", + ) + http_client_mock.assert_requested( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + api_key="org_key_abc", + stripe_context="ctx_123", + ) + + def test_iter_with_stripe_context_client( + self, http_client_mock: HTTPClientMock + ): + http_client_mock.stub_request( + "get", + path="/v1/customers", + rbody='{"object": "list", "data": [{"id": "cus_001", "object": "customer"}], "url": "/v1/customers", "has_more": true}', + ) + http_client_mock.stub_request( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + rbody='{"object": "list", "data": [{"id": "cus_002", "object": "customer"}], "url": "/v1/customers", "has_more": false}', + ) + + client = stripe.StripeClient( + "org_key_abc", http_client=http_client_mock.get_mock_http_client() + ) + cu_list = client.v1.customers.list( + options={"stripe_context": "ctx_123"} + ) + + customers = [item.id for item in cu_list.auto_paging_iter()] + assert customers == ["cus_001", "cus_002"] + + http_client_mock.assert_requested( + "get", + path="/v1/customers", + api_key="org_key_abc", + stripe_context="ctx_123", + ) + http_client_mock.assert_requested( + "get", + path="/v1/customers", + query_string="starting_after=cus_001", + api_key="org_key_abc", + stripe_context="ctx_123", + ) + class TestAutoPagingAsync: @staticmethod diff --git a/tests/test_api_requestor.py b/tests/test_api_requestor.py index bd9999030..7d2712354 100644 --- a/tests/test_api_requestor.py +++ b/tests/test_api_requestor.py @@ -572,7 +572,9 @@ def test_prefers_headers_api_version(self, requestor, http_client_mock): def test_uses_instance_key(self, requestor, http_client_mock): key = "fookey" - requestor = requestor._replace_options(RequestOptions(api_key=key)) + requestor = requestor._new_requestor_with_options( + RequestOptions(api_key=key) + ) http_client_mock.stub_request( "get", path=self.v1_path, rbody="{}", rcode=200 @@ -585,7 +587,7 @@ def test_uses_instance_key(self, requestor, http_client_mock): def test_uses_instance_account(self, requestor, http_client_mock): account = "acct_foo" - requestor = requestor._replace_options( + requestor = requestor._new_requestor_with_options( RequestOptions(stripe_account=account) ) @@ -610,7 +612,7 @@ def test_removes_None_account( in the generated fetch_related_object doesn't actually send the null header """ account = None - requestor = requestor._replace_options( + requestor = requestor._new_requestor_with_options( RequestOptions(stripe_account=account) ) diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 0fbefd93b..ad48a94e5 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -47427,6 +47427,83 @@ def test_v2_payments_off_session_payment_post_3_service( is_json=True, ) + def test_v2_reporting_report_get_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "get", + "/v2/reporting/reports/id_123", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + client.v2.reporting.reports.retrieve("id_123") + http_client_mock.assert_requested( + "get", + path="/v2/reporting/reports/id_123", + query_string="", + api_base="https://api.stripe.com", + ) + + def test_v2_reporting_report_run_post_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "post", + "/v2/reporting/report_runs", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + client.v2.reporting.report_runs.create( + { + "report": "report", + "report_parameters": { + "int_key": 123, + "string_key": "value", + "boolean_key": True, + "object_key": { + "object_int_key": 123, + "object_string_key": "value", + "object_boolean_key": True, + }, + "array_key": [1, 2, 3], + }, + } + ) + http_client_mock.assert_requested( + "post", + path="/v2/reporting/report_runs", + query_string="", + api_base="https://api.stripe.com", + post_data='{"report":"report","report_parameters":{"int_key":123,"string_key":"value","boolean_key":true,"object_key":{"object_int_key":123,"object_string_key":"value","object_boolean_key":true},"array_key":[1,2,3]}}', + is_json=True, + ) + + def test_v2_reporting_report_run_get_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "get", + "/v2/reporting/report_runs/id_123", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + client.v2.reporting.report_runs.retrieve("id_123") + http_client_mock.assert_requested( + "get", + path="/v2/reporting/report_runs/id_123", + query_string="", + api_base="https://api.stripe.com", + ) + def test_v2_tax_automatic_rule_post_service( self, http_client_mock: HTTPClientMock ) -> None: