diff --git a/.rubocop.yml b/.rubocop.yml index ddcc1e245..b3b299b21 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,10 +27,7 @@ Metrics/BlockLength: - "test/**/*.rb" Metrics/ClassLength: - Exclude: - # Test classes get quite large, so exclude the test directory from having - # to adhere to this rule. - - "test/**/*.rb" + Enabled: false Metrics/MethodLength: # There's ~2 long methods in `StripeClient` and one in `NestedResource`. If diff --git a/CHANGELOG.md b/CHANGELOG.md index fa72e744b..294272fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 10.12.0 - 2024-03-14 +* [#1359](https://github.com/stripe/stripe-ruby/pull/1359) Update generated code + * Add support for new resources `Issuing.PersonalizationDesign` and `Issuing.PhysicalBundle` + * Add support for `create`, `list`, `retrieve`, and `update` methods on resource `PersonalizationDesign` + * Add support for `list` and `retrieve` methods on resource `PhysicalBundle` +* [#1354](https://github.com/stripe/stripe-ruby/pull/1354) Refactor after SDK based generation pattern +* [#1347](https://github.com/stripe/stripe-ruby/pull/1347) Reorder methods with lexographical sort +* [#1355](https://github.com/stripe/stripe-ruby/pull/1355) Disable Metrics/ClassLength +* [#1351](https://github.com/stripe/stripe-ruby/pull/1351) Update CHANGELOG.md + ## 10.12.0-beta.1 - 2024-02-29 * [#1352](https://github.com/stripe/stripe-ruby/pull/1352) Update generated code for beta Release specs are identical. diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 148e3ec37..32951953e 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v857 \ No newline at end of file +v879 \ No newline at end of file diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 1d56534ef..3fb708233 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -1,4 +1,3 @@ -# File generated from our OpenAPI spec # frozen_string_literal: true # rubocop:disable Metrics/MethodLength @@ -11,9 +10,9 @@ def self.object_names_to_classes # data structures ListObject.object_name => ListObject, SearchResultObject.object_name => SearchResultObject, - - # business objects File.object_name_alt => File, + + # The beginning of the section generated from our OpenAPI spec Account.object_name => Account, AccountLink.object_name => AccountLink, AccountNotice.object_name => AccountNotice, @@ -25,6 +24,10 @@ def self.object_names_to_classes Balance.object_name => Balance, BalanceTransaction.object_name => BalanceTransaction, BankAccount.object_name => BankAccount, + Billing::Meter.object_name => Billing::Meter, + Billing::MeterEvent.object_name => Billing::MeterEvent, + Billing::MeterEventAdjustment.object_name => Billing::MeterEventAdjustment, + Billing::MeterEventSummary.object_name => Billing::MeterEventSummary, BillingPortal::Configuration.object_name => BillingPortal::Configuration, BillingPortal::Session.object_name => BillingPortal::Session, Capability.object_name => Capability, @@ -61,8 +64,7 @@ def self.object_names_to_classes FinancialConnections::AccountInferredBalance.object_name => FinancialConnections::AccountInferredBalance, FinancialConnections::AccountOwner.object_name => FinancialConnections::AccountOwner, - FinancialConnections::AccountOwnership.object_name => - FinancialConnections::AccountOwnership, + FinancialConnections::AccountOwnership.object_name => FinancialConnections::AccountOwnership, FinancialConnections::Session.object_name => FinancialConnections::Session, FinancialConnections::Transaction.object_name => FinancialConnections::Transaction, FundingInstructions.object_name => FundingInstructions, @@ -152,6 +154,7 @@ def self.object_names_to_classes UsageRecord.object_name => UsageRecord, UsageRecordSummary.object_name => UsageRecordSummary, WebhookEndpoint.object_name => WebhookEndpoint, + # The end of the section generated from our OpenAPI spec } end end diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index f738e09b1..b34be48fd 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -12,6 +12,10 @@ require "stripe/resources/balance" require "stripe/resources/balance_transaction" require "stripe/resources/bank_account" +require "stripe/resources/billing/meter" +require "stripe/resources/billing/meter_event" +require "stripe/resources/billing/meter_event_adjustment" +require "stripe/resources/billing/meter_event_summary" require "stripe/resources/billing_portal/configuration" require "stripe/resources/billing_portal/session" require "stripe/resources/capability" diff --git a/lib/stripe/resources/account.rb b/lib/stripe/resources/account.rb index e22188ca7..5968b8e3e 100644 --- a/lib/stripe/resources/account.rb +++ b/lib/stripe/resources/account.rb @@ -13,8 +13,8 @@ class Account < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "account" def self.object_name diff --git a/lib/stripe/resources/billing/meter.rb b/lib/stripe/resources/billing/meter.rb new file mode 100644 index 000000000..49bcf2e0f --- /dev/null +++ b/lib/stripe/resources/billing/meter.rb @@ -0,0 +1,83 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter is a resource that allows you to track usage of a particular event. For example, you might create a billing meter to track the number of API calls made by a particular user. You can then use the billing meter to charge the user for the number of API calls they make. + class Meter < APIResource + extend Stripe::APIOperations::Create + extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save + + OBJECT_NAME = "billing.meter" + def self.object_name + "billing.meter" + end + + nested_resource_class_methods :event_summary, + operations: %i[list], + resource_plural: "event_summaries" + + # Creates a billing meter + def self.create(params = {}, opts = {}) + request_stripe_object(method: :post, path: "/v1/billing/meters", params: params, opts: opts) + end + + # Deactivates a billing meter + def deactivate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/deactivate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Deactivates a billing meter + def self.deactivate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/deactivate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Retrieve a list of billing meters. + def self.list(filters = {}, opts = {}) + request_stripe_object(method: :get, path: "/v1/billing/meters", params: filters, opts: opts) + end + + # Reactivates a billing meter + def reactivate(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/reactivate", { id: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Reactivates a billing meter + def self.reactivate(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s/reactivate", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + + # Updates a billing meter + def self.update(id, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/billing/meters/%s", { id: CGI.escape(id) }), + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event.rb b/lib/stripe/resources/billing/meter_event.rb new file mode 100644 index 000000000..53190ce8a --- /dev/null +++ b/lib/stripe/resources/billing/meter_event.rb @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event represents a customer's usage of a product. Meter events are used to bill a customer based on their usage. + # Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing. + class MeterEvent < APIResource + extend Stripe::APIOperations::Create + + OBJECT_NAME = "billing.meter_event" + def self.object_name + "billing.meter_event" + end + + # Creates a billing meter event + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/billing/meter_events", + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event_adjustment.rb b/lib/stripe/resources/billing/meter_event_adjustment.rb new file mode 100644 index 000000000..1da80385d --- /dev/null +++ b/lib/stripe/resources/billing/meter_event_adjustment.rb @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event adjustment represents the status of a meter event adjustment. + class MeterEventAdjustment < APIResource + extend Stripe::APIOperations::Create + + OBJECT_NAME = "billing.meter_event_adjustment" + def self.object_name + "billing.meter_event_adjustment" + end + + # Creates a billing meter event adjustment + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/billing/meter_event_adjustments", + params: params, + opts: opts + ) + end + end + end +end diff --git a/lib/stripe/resources/billing/meter_event_summary.rb b/lib/stripe/resources/billing/meter_event_summary.rb new file mode 100644 index 000000000..0fb71afd5 --- /dev/null +++ b/lib/stripe/resources/billing/meter_event_summary.rb @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module Billing + # A billing meter event summary represents an aggregated view of a customer's billing meter events within a specified timeframe. It indicates how much + # usage was accrued by a customer for that period. + class MeterEventSummary < APIResource + OBJECT_NAME = "billing.meter_event_summary" + def self.object_name + "billing.meter_event_summary" + end + end + end +end diff --git a/lib/stripe/resources/charge.rb b/lib/stripe/resources/charge.rb index 48d0f3505..8177b75f6 100644 --- a/lib/stripe/resources/charge.rb +++ b/lib/stripe/resources/charge.rb @@ -9,9 +9,9 @@ module Stripe class Charge < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource extend Stripe::APIOperations::Search include Stripe::APIOperations::Save - extend Stripe::APIOperations::NestedResource OBJECT_NAME = "charge" def self.object_name diff --git a/lib/stripe/resources/confirmation_token.rb b/lib/stripe/resources/confirmation_token.rb index 5bc38d619..8dcdcfd4b 100644 --- a/lib/stripe/resources/confirmation_token.rb +++ b/lib/stripe/resources/confirmation_token.rb @@ -12,5 +12,26 @@ class ConfirmationToken < APIResource def self.object_name "confirmation_token" end + + def test_helpers + TestHelpers.new(self) + end + + class TestHelpers < APIResourceTestHelpers + RESOURCE_CLASS = ConfirmationToken + def self.resource_class + "ConfirmationToken" + end + + # Creates a test mode Confirmation Token server side for your integration tests. + def self.create(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: "/v1/test_helpers/confirmation_tokens", + params: params, + opts: opts + ) + end + end end end diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index 2c62f3140..4a3390009 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -9,9 +9,9 @@ class Customer < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource extend Stripe::APIOperations::Search include Stripe::APIOperations::Save - extend Stripe::APIOperations::NestedResource OBJECT_NAME = "customer" def self.object_name diff --git a/lib/stripe/resources/invoice.rb b/lib/stripe/resources/invoice.rb index 4c2d4d6c6..58815ab5c 100644 --- a/lib/stripe/resources/invoice.rb +++ b/lib/stripe/resources/invoice.rb @@ -38,9 +38,9 @@ class Invoice < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List + extend Stripe::APIOperations::NestedResource extend Stripe::APIOperations::Search include Stripe::APIOperations::Save - extend Stripe::APIOperations::NestedResource OBJECT_NAME = "invoice" def self.object_name @@ -49,6 +49,26 @@ def self.object_name nested_resource_class_methods :payment, operations: %i[retrieve list] + # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. + def add_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/add_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. + def self.add_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/add_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + # Attaches a PaymentIntent to the invoice, adding it to the list of payments. # When the PaymentIntent's status changes to succeeded, the payment is credited # to the invoice, increasing its amount_paid. When the invoice is fully paid, the @@ -199,6 +219,26 @@ def self.pay(invoice, params = {}, opts = {}) ) end + # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft. + def remove_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/remove_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Removes multiple line items from an invoice. This is only possible when an invoice is still a draft. + def self.remove_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/remove_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoices/search", params: params, opts: opts) end @@ -255,6 +295,26 @@ def self.update(id, params = {}, opts = {}) ) end + # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft. + def update_lines(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/update_lines", { invoice: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Updates multiple line items on an invoice. This is only possible when an invoice is still a draft. + def self.update_lines(invoice, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/invoices/%s/update_lines", { invoice: CGI.escape(invoice) }), + params: params, + opts: opts + ) + end + # Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. def void_invoice(params = {}, opts = {}) request_stripe_object( diff --git a/lib/stripe/resources/issuing/authorization.rb b/lib/stripe/resources/issuing/authorization.rb index 8d4ebfd7e..decc5e3b7 100644 --- a/lib/stripe/resources/issuing/authorization.rb +++ b/lib/stripe/resources/issuing/authorization.rb @@ -101,6 +101,16 @@ def self.capture(authorization, params = {}, opts = {}) ) end + # Capture a test-mode authorization. + def capture(params = {}, opts = {}) + @resource.request_stripe_object( + method: :post, + path: format("/v1/test_helpers/issuing/authorizations/%s/capture", { authorization: CGI.escape(@resource["id"]) }), + params: params, + opts: opts + ) + end + # Create a test-mode authorization. def self.create(params = {}, opts = {}) request_stripe_object( @@ -121,51 +131,41 @@ def self.expire(authorization, params = {}, opts = {}) ) end - # Increment a test-mode Authorization. - def self.increment(authorization, params = {}, opts = {}) - request_stripe_object( + # Expire a test-mode Authorization. + def expire(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(authorization) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/expire", { authorization: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Reverse a test-mode Authorization. - def self.reverse(authorization, params = {}, opts = {}) + # Increment a test-mode Authorization. + def self.increment(authorization, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/reverse", { authorization: CGI.escape(authorization) }), - params: params, - opts: opts - ) - end - - # Capture a test-mode authorization. - def capture(params = {}, opts = {}) - @resource.request_stripe_object( - method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/capture", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(authorization) }), params: params, opts: opts ) end - # Expire a test-mode Authorization. - def expire(params = {}, opts = {}) + # Increment a test-mode Authorization. + def increment(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/expire", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Increment a test-mode Authorization. - def increment(params = {}, opts = {}) - @resource.request_stripe_object( + # Reverse a test-mode Authorization. + def self.reverse(authorization, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/authorizations/%s/increment", { authorization: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/authorizations/%s/reverse", { authorization: CGI.escape(authorization) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/issuing/card.rb b/lib/stripe/resources/issuing/card.rb index 28f3247b7..36cdf0ecc 100644 --- a/lib/stripe/resources/issuing/card.rb +++ b/lib/stripe/resources/issuing/card.rb @@ -54,61 +54,61 @@ def self.deliver_card(card, params = {}, opts = {}) ) end - # Updates the shipping status of the specified Issuing Card object to failure. - def self.fail_card(card, params = {}, opts = {}) - request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to delivered. + def deliver_card(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/deliver", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to returned. - def self.return_card(card, params = {}, opts = {}) + # Updates the shipping status of the specified Issuing Card object to failure. + def self.fail_card(card, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(card) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to shipped. - def self.ship_card(card, params = {}, opts = {}) - request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to failure. + def fail_card(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/ship", { card: CGI.escape(card) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to delivered. - def deliver_card(params = {}, opts = {}) - @resource.request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to returned. + def self.return_card(card, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/deliver", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(card) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to failure. - def fail_card(params = {}, opts = {}) + # Updates the shipping status of the specified Issuing Card object to returned. + def return_card(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/fail", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the shipping status of the specified Issuing Card object to returned. - def return_card(params = {}, opts = {}) - @resource.request_stripe_object( + # Updates the shipping status of the specified Issuing Card object to shipped. + def self.ship_card(card, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/cards/%s/shipping/return", { card: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/cards/%s/shipping/ship", { card: CGI.escape(card) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/issuing/personalization_design.rb b/lib/stripe/resources/issuing/personalization_design.rb index 68b5cb87b..37d00f50a 100644 --- a/lib/stripe/resources/issuing/personalization_design.rb +++ b/lib/stripe/resources/issuing/personalization_design.rb @@ -64,41 +64,41 @@ def self.activate(personalization_design, params = {}, opts = {}) ) end - # Updates the status of the specified testmode personalization design object to inactive. - def self.deactivate(personalization_design, params = {}, opts = {}) - request_stripe_object( + # Updates the status of the specified testmode personalization design object to active. + def activate(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(personalization_design) }), + path: format("/v1/test_helpers/issuing/personalization_designs/%s/activate", { personalization_design: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the status of the specified testmode personalization design object to rejected. - def self.reject(personalization_design, params = {}, opts = {}) + # Updates the status of the specified testmode personalization design object to inactive. + def self.deactivate(personalization_design, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/personalization_designs/%s/reject", { personalization_design: CGI.escape(personalization_design) }), + path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(personalization_design) }), params: params, opts: opts ) end - # Updates the status of the specified testmode personalization design object to active. - def activate(params = {}, opts = {}) + # Updates the status of the specified testmode personalization design object to inactive. + def deactivate(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/personalization_designs/%s/activate", { personalization_design: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Updates the status of the specified testmode personalization design object to inactive. - def deactivate(params = {}, opts = {}) - @resource.request_stripe_object( + # Updates the status of the specified testmode personalization design object to rejected. + def self.reject(personalization_design, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/issuing/personalization_designs/%s/deactivate", { personalization_design: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/issuing/personalization_designs/%s/reject", { personalization_design: CGI.escape(personalization_design) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/quote.rb b/lib/stripe/resources/quote.rb index f774e7417..52254fa67 100644 --- a/lib/stripe/resources/quote.rb +++ b/lib/stripe/resources/quote.rb @@ -7,8 +7,8 @@ module Stripe class Quote < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "quote" def self.object_name diff --git a/lib/stripe/resources/source.rb b/lib/stripe/resources/source.rb index aff52e27e..ba5e442ba 100644 --- a/lib/stripe/resources/source.rb +++ b/lib/stripe/resources/source.rb @@ -14,8 +14,8 @@ module Stripe # Related guides: [Sources API](https://stripe.com/docs/sources) and [Sources & Customers](https://stripe.com/docs/sources/customers). class Source < APIResource extend Stripe::APIOperations::Create - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "source" def self.object_name diff --git a/lib/stripe/resources/subscription_item.rb b/lib/stripe/resources/subscription_item.rb index 61948da98..d37a70b2a 100644 --- a/lib/stripe/resources/subscription_item.rb +++ b/lib/stripe/resources/subscription_item.rb @@ -8,8 +8,8 @@ class SubscriptionItem < APIResource extend Stripe::APIOperations::Create include Stripe::APIOperations::Delete extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "subscription_item" def self.object_name diff --git a/lib/stripe/resources/tax/settings.rb b/lib/stripe/resources/tax/settings.rb index 66eab9e80..1250ea35f 100644 --- a/lib/stripe/resources/tax/settings.rb +++ b/lib/stripe/resources/tax/settings.rb @@ -8,7 +8,6 @@ module Tax # Related guide: [Using the Settings API](https://stripe.com/docs/tax/settings-api) class Settings < SingletonAPIResource include Stripe::APIOperations::SingletonSave - OBJECT_NAME = "tax.settings" def self.object_name "tax.settings" diff --git a/lib/stripe/resources/transfer.rb b/lib/stripe/resources/transfer.rb index 4543fad3a..476be51fd 100644 --- a/lib/stripe/resources/transfer.rb +++ b/lib/stripe/resources/transfer.rb @@ -15,8 +15,8 @@ module Stripe class Transfer < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List - include Stripe::APIOperations::Save extend Stripe::APIOperations::NestedResource + include Stripe::APIOperations::Save OBJECT_NAME = "transfer" def self.object_name diff --git a/lib/stripe/resources/treasury/inbound_transfer.rb b/lib/stripe/resources/treasury/inbound_transfer.rb index c48b0da14..ec55fdc11 100644 --- a/lib/stripe/resources/treasury/inbound_transfer.rb +++ b/lib/stripe/resources/treasury/inbound_transfer.rb @@ -73,41 +73,41 @@ def self.fail(id, params = {}, opts = {}) ) end - # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. - def self.return_inbound_transfer(id, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/fail", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. - def self.succeed(id, params = {}, opts = {}) + # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + def self.return_inbound_transfer(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/succeed", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. - def fail(params = {}, opts = {}) + # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + def return_inbound_transfer(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/fail", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. - def return_inbound_transfer(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + def self.succeed(id, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/inbound_transfers/%s/return", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/inbound_transfers/%s/succeed", { id: CGI.escape(id) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/treasury/outbound_payment.rb b/lib/stripe/resources/treasury/outbound_payment.rb index a376de29b..232db3b6b 100644 --- a/lib/stripe/resources/treasury/outbound_payment.rb +++ b/lib/stripe/resources/treasury/outbound_payment.rb @@ -75,41 +75,41 @@ def self.fail(id, params = {}, opts = {}) ) end - # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. - def self.post(id, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/fail", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. - def self.return_outbound_payment(id, params = {}, opts = {}) + # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + def self.post(id, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/return", { id: CGI.escape(id) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(id) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. - def fail(params = {}, opts = {}) + # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + def post(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/fail", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. - def post(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + def self.return_outbound_payment(id, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_payments/%s/post", { id: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_payments/%s/return", { id: CGI.escape(id) }), params: params, opts: opts ) diff --git a/lib/stripe/resources/treasury/outbound_transfer.rb b/lib/stripe/resources/treasury/outbound_transfer.rb index 261cdbea6..59451cb6c 100644 --- a/lib/stripe/resources/treasury/outbound_transfer.rb +++ b/lib/stripe/resources/treasury/outbound_transfer.rb @@ -75,41 +75,41 @@ def self.fail(outbound_transfer, params = {}, opts = {}) ) end - # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. - def self.post(outbound_transfer, params = {}, opts = {}) - request_stripe_object( + # Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + def fail(params = {}, opts = {}) + @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(outbound_transfer) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. - def self.return_outbound_transfer(outbound_transfer, params = {}, opts = {}) + # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + def self.post(outbound_transfer, params = {}, opts = {}) request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/return", { outbound_transfer: CGI.escape(outbound_transfer) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(outbound_transfer) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. - def fail(params = {}, opts = {}) + # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + def post(params = {}, opts = {}) @resource.request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end - # Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. - def post(params = {}, opts = {}) - @resource.request_stripe_object( + # Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + def self.return_outbound_transfer(outbound_transfer, params = {}, opts = {}) + request_stripe_object( method: :post, - path: format("/v1/test_helpers/treasury/outbound_transfers/%s/post", { outbound_transfer: CGI.escape(@resource["id"]) }), + path: format("/v1/test_helpers/treasury/outbound_transfers/%s/return", { outbound_transfer: CGI.escape(outbound_transfer) }), params: params, opts: opts ) diff --git a/test/stripe/generated_examples_test.rb b/test/stripe/generated_examples_test.rb index e8973eecc..892685c53 100644 --- a/test/stripe/generated_examples_test.rb +++ b/test/stripe/generated_examples_test.rb @@ -426,6 +426,10 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Customer.update_cash_balance("cus_123", { settings: { reconciliation_mode: "manual" } }) assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance" end + should "Test customers cash balance transactions get" do + Stripe::Customer.list_cash_balance_transactions("cus_123", { limit: 3 }) + assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance_transactions?limit=3" + end should "Test customers delete" do Stripe::Customer.delete("cus_xxxxxxxxxxxxx") assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx?" @@ -895,6 +899,30 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Dispute.submit("idp_xxxxxxxxxxxxx") assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/idp_xxxxxxxxxxxxx/submit?" end + should "Test issuing personalization designs get" do + Stripe::Issuing::PersonalizationDesign.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs?" + end + should "Test issuing personalization designs get 2" do + Stripe::Issuing::PersonalizationDesign.retrieve("pd_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing personalization designs post" do + Stripe::Issuing::PersonalizationDesign.create({ physical_bundle: "pb_xyz" }) + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs" + end + should "Test issuing personalization designs post 2" do + Stripe::Issuing::PersonalizationDesign.update("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/issuing/personalization_designs/pd_xyz?" + end + should "Test issuing physical bundles get" do + Stripe::Issuing::PhysicalBundle.list + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles?" + end + should "Test issuing physical bundles get 2" do + Stripe::Issuing::PhysicalBundle.retrieve("pb_xyz") + assert_requested :get, "#{Stripe.api_base}/v1/issuing/physical_bundles/pb_xyz?" + end should "Test issuing transactions get" do Stripe::Issuing::Transaction.list({ limit: 3 }) assert_requested :get, "#{Stripe.api_base}/v1/issuing/transactions?limit=3" @@ -1609,6 +1637,25 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Tax::Form.pdf("form_xxxxxxxxxxxxx", &block_handler) assert_requested :get, "#{Stripe.api_base}/v1/tax/forms/form_xxxxxxxxxxxxx/pdf?" end + should "Test tax ids delete" do + Stripe::TaxId.delete("taxid_123") + assert_requested :delete, "#{Stripe.api_base}/v1/tax_ids/taxid_123?" + end + should "Test tax ids get" do + Stripe::TaxId.list + assert_requested :get, "#{Stripe.api_base}/v1/tax_ids?" + end + should "Test tax ids get 2" do + Stripe::TaxId.retrieve("taxid_123") + assert_requested :get, "#{Stripe.api_base}/v1/tax_ids/taxid_123?" + end + should "Test tax ids post" do + Stripe::TaxId.create({ + type: "eu_vat", + value: "123", + }) + assert_requested :post, "#{Stripe.api_base}/v1/tax_ids" + end should "Test tax rates get" do Stripe::TaxRate.list({ limit: 3 }) assert_requested :get, "#{Stripe.api_base}/v1/tax_rates?limit=3" @@ -1911,6 +1958,21 @@ class CodegennedExampleTest < Test::Unit::TestCase Stripe::Issuing::Card::TestHelpers.ship_card("card_123") assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/cards/card_123/shipping/ship?" end + should "Test test helpers issuing personalization designs activate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.activate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/activate?" + end + should "Test test helpers issuing personalization designs deactivate post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.deactivate("pd_xyz") + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/deactivate?" + end + should "Test test helpers issuing personalization designs reject post" do + Stripe::Issuing::PersonalizationDesign::TestHelpers.reject( + "pd_xyz", + { rejection_reasons: { card_logo: ["geographic_location"] } } + ) + assert_requested :post, "#{Stripe.api_base}/v1/test_helpers/issuing/personalization_designs/pd_xyz/reject" + end should "Test test helpers issuing transactions create force capture post" do Stripe::Issuing::Transaction::TestHelpers.create_force_capture({ amount: 100,