From 68a8d665d720a953f4ece72e3f9e28b1027e63a6 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:18:57 -0800 Subject: [PATCH] Remove broken child methods (#1237) --- stripe/_credit_note_line_item.py | 47 +------------ stripe/_customer.py | 16 ++--- stripe/_customer_cash_balance_transaction.py | 70 +------------------- stripe/_ephemeral_key.py | 6 +- stripe/_usage_record.py | 4 +- tests/test_generated_examples.py | 2 +- 6 files changed, 21 insertions(+), 124 deletions(-) diff --git a/stripe/_credit_note_line_item.py b/stripe/_credit_note_line_item.py index 160e8c6dc..f358bc77a 100644 --- a/stripe/_credit_note_line_item.py +++ b/stripe/_credit_note_line_item.py @@ -1,19 +1,16 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec from stripe._expandable_field import ExpandableField -from stripe._list_object import ListObject -from stripe._listable_api_resource import ListableAPIResource -from stripe._request_options import RequestOptions from stripe._stripe_object import StripeObject from typing import ClassVar, List, Optional -from typing_extensions import Literal, NotRequired, Unpack, TYPE_CHECKING +from typing_extensions import Literal, TYPE_CHECKING if TYPE_CHECKING: from stripe._discount import Discount from stripe._tax_rate import TaxRate -class CreditNoteLineItem(ListableAPIResource["CreditNoteLineItem"]): +class CreditNoteLineItem(StripeObject): """ The credit note line item object """ @@ -72,24 +69,6 @@ class TaxAmount(StripeObject): The amount on which tax is calculated, in cents (or local equivalent). """ - class ListParams(RequestOptions): - ending_before: NotRequired["str"] - """ - A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - """ - expand: NotRequired["List[str]"] - """ - Specifies which fields in the response should be expanded. - """ - limit: NotRequired["int"] - """ - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - """ - starting_after: NotRequired["str"] - """ - A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - """ - amount: int """ The integer amount in cents (or local equivalent) representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts. @@ -154,28 +133,6 @@ class ListParams(RequestOptions): """ The amount in cents (or local equivalent) representing the unit amount being credited for this line item, excluding all tax and discounts. """ - - @classmethod - def list( - cls, **params: Unpack["CreditNoteLineItem.ListParams"] - ) -> ListObject["CreditNoteLineItem"]: - """ - When retrieving a credit note, you'll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - """ - result = cls._static_request( - "get", - cls.class_url(), - params=params, - ) - if not isinstance(result, ListObject): - - raise TypeError( - "Expected list object from API, got %s" - % (type(result).__name__) - ) - - return result - _inner_class_types = { "discount_amounts": DiscountAmount, "tax_amounts": TaxAmount, diff --git a/stripe/_customer.py b/stripe/_customer.py index aa49494f8..cc004ff67 100644 --- a/stripe/_customer.py +++ b/stripe/_customer.py @@ -2061,18 +2061,18 @@ def list_tax_ids( ) @classmethod - def modify_cash_balance( + def retrieve_cash_balance( cls, customer: str, - **params: Unpack["Customer.ModifyCashBalanceParams"] + **params: Unpack["Customer.RetrieveCashBalanceParams"] ) -> "CashBalance": """ - Changes the settings on a customer's cash balance. + Retrieves a customer's cash balance. """ return cast( "CashBalance", cls._static_request( - "post", + "get", "/v1/customers/{customer}/cash_balance".format( customer=sanitize_id(customer) ), @@ -2081,18 +2081,18 @@ def modify_cash_balance( ) @classmethod - def retrieve_cash_balance( + def modify_cash_balance( cls, customer: str, - **params: Unpack["Customer.RetrieveCashBalanceParams"] + **params: Unpack["Customer.ModifyCashBalanceParams"] ) -> "CashBalance": """ - Retrieves a customer's cash balance. + Changes the settings on a customer's cash balance. """ return cast( "CashBalance", cls._static_request( - "get", + "post", "/v1/customers/{customer}/cash_balance".format( customer=sanitize_id(customer) ), diff --git a/stripe/_customer_cash_balance_transaction.py b/stripe/_customer_cash_balance_transaction.py index 32cce2e4e..0983295d1 100644 --- a/stripe/_customer_cash_balance_transaction.py +++ b/stripe/_customer_cash_balance_transaction.py @@ -1,12 +1,9 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec from stripe._expandable_field import ExpandableField -from stripe._list_object import ListObject -from stripe._listable_api_resource import ListableAPIResource -from stripe._request_options import RequestOptions from stripe._stripe_object import StripeObject -from typing import ClassVar, List, Optional -from typing_extensions import Literal, NotRequired, Unpack, TYPE_CHECKING +from typing import ClassVar, Optional +from typing_extensions import Literal, TYPE_CHECKING if TYPE_CHECKING: from stripe._balance_transaction import BalanceTransaction @@ -15,9 +12,7 @@ from stripe._refund import Refund -class CustomerCashBalanceTransaction( - ListableAPIResource["CustomerCashBalanceTransaction"], -): +class CustomerCashBalanceTransaction(StripeObject): """ Customers with certain payments enabled have a cash balance, representing funds that were paid by the customer to a merchant, but have not yet been allocated to a payment. Cash Balance Transactions @@ -145,30 +140,6 @@ class UnappliedFromPayment(StripeObject): The [Payment Intent](https://stripe.com/docs/api/payment_intents/object) that funds were unapplied from. """ - class ListParams(RequestOptions): - ending_before: NotRequired["str"] - """ - A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - """ - expand: NotRequired["List[str]"] - """ - Specifies which fields in the response should be expanded. - """ - limit: NotRequired["int"] - """ - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - """ - starting_after: NotRequired["str"] - """ - A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - """ - - class RetrieveParams(RequestOptions): - expand: NotRequired["List[str]"] - """ - Specifies which fields in the response should be expanded. - """ - adjusted_for_overdraft: Optional[AdjustedForOverdraft] applied_to_payment: Optional[AppliedToPayment] created: int @@ -221,41 +192,6 @@ class RetrieveParams(RequestOptions): The type of the cash balance transaction. New types may be added in future. See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types. """ unapplied_from_payment: Optional[UnappliedFromPayment] - - @classmethod - def list( - cls, **params: Unpack["CustomerCashBalanceTransaction.ListParams"] - ) -> ListObject["CustomerCashBalanceTransaction"]: - """ - Returns a list of transactions that modified the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). - """ - result = cls._static_request( - "get", - cls.class_url(), - params=params, - ) - if not isinstance(result, ListObject): - - raise TypeError( - "Expected list object from API, got %s" - % (type(result).__name__) - ) - - return result - - @classmethod - def retrieve( - cls, - id: str, - **params: Unpack["CustomerCashBalanceTransaction.RetrieveParams"] - ) -> "CustomerCashBalanceTransaction": - """ - Retrieves a specific cash balance transaction, which updated the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). - """ - instance = cls(id, **params) - instance.refresh() - return instance - _inner_class_types = { "adjusted_for_overdraft": AdjustedForOverdraft, "applied_to_payment": AppliedToPayment, diff --git a/stripe/_ephemeral_key.py b/stripe/_ephemeral_key.py index 8717ce371..581912159 100644 --- a/stripe/_ephemeral_key.py +++ b/stripe/_ephemeral_key.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec +from stripe._createable_api_resource import CreateableAPIResource from stripe._deletable_api_resource import DeletableAPIResource from stripe._request_options import RequestOptions from stripe._util import class_method_variant, sanitize_id @@ -7,7 +8,10 @@ from typing_extensions import Literal, NotRequired, Unpack -class EphemeralKey(DeletableAPIResource["EphemeralKey"]): +class EphemeralKey( + CreateableAPIResource["EphemeralKey"], + DeletableAPIResource["EphemeralKey"], +): OBJECT_NAME: ClassVar[Literal["ephemeral_key"]] = "ephemeral_key" class DeleteParams(RequestOptions): diff --git a/stripe/_usage_record.py b/stripe/_usage_record.py index d1835ac5d..e9d59a621 100644 --- a/stripe/_usage_record.py +++ b/stripe/_usage_record.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec -from stripe._api_resource import APIResource +from stripe._createable_api_resource import CreateableAPIResource from typing import ClassVar from typing_extensions import Literal -class UsageRecord(APIResource["UsageRecord"]): +class UsageRecord(CreateableAPIResource["UsageRecord"]): """ Usage records allow you to report customer usage and metrics to Stripe for metered billing of subscription prices. diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 19c0bfd23..623170709 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -726,7 +726,7 @@ def test_accounts_persons_delete_service( def test_accounts_persons_get( self, http_client_mock: HTTPClientMock ) -> None: - stripe.Account.list_persons( + stripe.Account.persons( "acct_xxxxxxxxxxxxx", limit=3, )