diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e5afc6d..c1cd5196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # Changelog +## 13.1.0 - 2024-10-29 +* [#1472](https://github.com/stripe/stripe-ruby/pull/1472) Update generated code + * Add support for `submit_card` test helper method on resource `Issuing.Card` + * Add support for new resource `V2.EventDestinations` + * Add support for `create`, `retrieve`, `update`, `list`, `delete`, `disable`, `enable` and `ping` methods on resource `V2.EventDestinations` +* [#1476](https://github.com/stripe/stripe-ruby/pull/1476) Fix APIResource#retrieve bug not returning instance of custom resources + * Fix bug in APIResource#refresh and APIResource#retrieve where they returned an instance of `StripeObject` for custom resources. They should now return the instance of the custom resource. + ## 13.1.0-beta.3 - 2024-10-18 * [#1469](https://github.com/stripe/stripe-ruby/pull/1469) Update generated code for beta - ## 13.1.0-beta.2 - 2024-10-08 * [#1468](https://github.com/stripe/stripe-ruby/pull/1468) Update generated code for beta * Add support for `submit_card` test helper method on resource `Issuing.Card` @@ -23,6 +30,17 @@ charge = client.deserialize(resp.data) ``` +## 13.0.2 - 2024-10-23 +* [#1473](https://github.com/stripe/stripe-ruby/pull/1473) Always return the result of APIResource#refresh in APIResource.retrieve + + * Fix bug where we would not return the mutated `self` object when calling `APIResource.retrieve` + +## 13.0.1 - 2024-10-18 +* [#1471](https://github.com/stripe/stripe-ruby/pull/1471) update object tags for meter-related classes + + - fixes a bug where the `object` property of the `MeterEvent`, `MeterEventAdjustment`, and `MeterEventSession` didn't match the server. +* [#1470](https://github.com/stripe/stripe-ruby/pull/1470) Cleaned up examples and added documentation + ## 13.0.0 - 2024-10-01 * [#1458](https://github.com/stripe/stripe-ruby/pull/1458) Support for APIs in the new API version 2024-09-30.acacia diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 622f8076..c626f7dd 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1314 \ No newline at end of file +v1319 \ No newline at end of file diff --git a/README.md b/README.md index a62bc7de..d1b44944 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ background terminal ([stripe-mock's README][stripe-mock] also contains instructions for installing via Homebrew and other methods): ```sh -go get -u github.com/stripe/stripe-mock +go install github.com/stripe/stripe-mock@latest stripe-mock ``` diff --git a/lib/stripe/api_resource.rb b/lib/stripe/api_resource.rb index 7ac3f3cc..d1e5f078 100644 --- a/lib/stripe/api_resource.rb +++ b/lib/stripe/api_resource.rb @@ -98,7 +98,14 @@ module Stripe "It is not possible to refresh v2 objects. Please retrieve the object using the StripeClient instead." end - @requestor.execute_request_initialize_from(:get, resource_url, :api, self, params: @retrieve_params) + @obj = @requestor.execute_request_initialize_from(:get, resource_url, :api, self, params: @retrieve_params) + initialize_from( + @obj.last_response.data, + @obj.instance_variable_get(:@opts), + @obj.last_response, + api_mode: :v1, + requestor: @requestor + ) end def self.retrieve(id, opts = {}) @@ -110,7 +117,6 @@ module Stripe opts = Util.normalize_opts(opts) instance = new(id, opts) instance.refresh - instance end def request_stripe_object(method:, path:, params:, base_address: :api, opts: {}) diff --git a/lib/stripe/api_version.rb b/lib/stripe/api_version.rb index 4d202e4c..f0b789d8 100644 --- a/lib/stripe/api_version.rb +++ b/lib/stripe/api_version.rb @@ -3,6 +3,6 @@ module Stripe module ApiVersion - CURRENT = "2024-09-30.acacia" + CURRENT = "2024-10-28.acacia" end end diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index 643357eb..3f9ed1ca 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -175,6 +175,7 @@ module Stripe V2::Billing::MeterEventAdjustment.object_name => V2::Billing::MeterEventAdjustment, V2::Billing::MeterEventSession.object_name => V2::Billing::MeterEventSession, V2::Event.object_name => V2::Event, + V2::EventDestination.object_name => V2::EventDestination, # v2 object classes: The end of the section generated from our OpenAPI spec } end diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 9f169256..56b79adb 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -153,6 +153,7 @@ require "stripe/resources/v2/billing/meter_event" require "stripe/resources/v2/billing/meter_event_adjustment" require "stripe/resources/v2/billing/meter_event_session" require "stripe/resources/v2/event" +require "stripe/resources/v2/event_destination" require "stripe/resources/webhook_endpoint" require "stripe/events/v1_billing_meter_error_report_triggered_event" require "stripe/events/v1_billing_meter_no_meter_found_event" diff --git a/lib/stripe/resources/payment_intent.rb b/lib/stripe/resources/payment_intent.rb index 98b37c8a..62702658 100644 --- a/lib/stripe/resources/payment_intent.rb +++ b/lib/stripe/resources/payment_intent.rb @@ -316,6 +316,26 @@ module Stripe search(params, opts).auto_paging_each(&blk) end + # Trigger an external action on a PaymentIntent. + def trigger_action(params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/test/payment_intents/%s/trigger_action", { intent: CGI.escape(self["id"]) }), + params: params, + opts: opts + ) + end + + # Trigger an external action on a PaymentIntent. + def self.trigger_action(intent, params = {}, opts = {}) + request_stripe_object( + method: :post, + path: format("/v1/test/payment_intents/%s/trigger_action", { intent: CGI.escape(intent) }), + params: params, + opts: opts + ) + end + # Updates properties on a PaymentIntent object without confirming. # # Depending on which properties you update, you might need to confirm the diff --git a/lib/stripe/resources/v2/event_destination.rb b/lib/stripe/resources/v2/event_destination.rb new file mode 100644 index 00000000..ea088023 --- /dev/null +++ b/lib/stripe/resources/v2/event_destination.rb @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module V2 + class EventDestination < APIResource + OBJECT_NAME = "v2.core.event_destination" + def self.object_name + "v2.core.event_destination" + end + end + end +end diff --git a/lib/stripe/services.rb b/lib/stripe/services.rb index 62fa9896..be6588b1 100644 --- a/lib/stripe/services.rb +++ b/lib/stripe/services.rb @@ -197,6 +197,7 @@ require "stripe/services/v2/billing/meter_event_service" require "stripe/services/v2/billing/meter_event_session_service" require "stripe/services/v2/billing/meter_event_stream_service" require "stripe/services/v2/billing_service" +require "stripe/services/v2/core/event_destination_service" require "stripe/services/v2/core/event_service" require "stripe/services/v2/core_service" require "stripe/services/v2_services" diff --git a/lib/stripe/services/account_login_link_service.rb b/lib/stripe/services/account_login_link_service.rb index a4370ac5..c02e7c24 100644 --- a/lib/stripe/services/account_login_link_service.rb +++ b/lib/stripe/services/account_login_link_service.rb @@ -3,7 +3,7 @@ module Stripe class AccountLoginLinkService < StripeService - # Creates a single-use login link for a connected account to access the Express Dashboard. + # Creates a login link for a connected account to access the Express Dashboard. # # You can only create login links for accounts that use the [Express Dashboard](https://stripe.com/connect/express-dashboard) and are connected to your platform. def create(account, params = {}, opts = {}) diff --git a/lib/stripe/services/payment_intent_service.rb b/lib/stripe/services/payment_intent_service.rb index 5459fe70..b0e02aa3 100644 --- a/lib/stripe/services/payment_intent_service.rb +++ b/lib/stripe/services/payment_intent_service.rb @@ -199,6 +199,17 @@ module Stripe ) end + # Trigger an external action on a PaymentIntent. + def trigger_action(intent, params = {}, opts = {}) + request( + method: :post, + path: format("/v1/test/payment_intents/%s/trigger_action", { intent: CGI.escape(intent) }), + params: params, + opts: opts, + base_address: :api + ) + end + # Updates properties on a PaymentIntent object without confirming. # # Depending on which properties you update, you might need to confirm the diff --git a/lib/stripe/services/v2/core/event_destination_service.rb b/lib/stripe/services/v2/core/event_destination_service.rb new file mode 100644 index 00000000..11dd45c9 --- /dev/null +++ b/lib/stripe/services/v2/core/event_destination_service.rb @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + module V2 + module Core + class EventDestinationService < StripeService + # Create a new event destination. + def create(params = {}, opts = {}) + request( + method: :post, + path: "/v2/core/event_destinations", + params: params, + opts: opts, + base_address: :api + ) + end + + # Delete an event destination. + def delete(id, params = {}, opts = {}) + request( + method: :delete, + path: format("/v2/core/event_destinations/%s", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + + # Disable an event destination. + def disable(id, params = {}, opts = {}) + request( + method: :post, + path: format("/v2/core/event_destinations/%s/disable", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + + # Enable an event destination. + def enable(id, params = {}, opts = {}) + request( + method: :post, + path: format("/v2/core/event_destinations/%s/enable", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + + # Lists all event destinations. + def list(params = {}, opts = {}) + request( + method: :get, + path: "/v2/core/event_destinations", + params: params, + opts: opts, + base_address: :api + ) + end + + # Send a `ping` event to an event destination. + def ping(id, params = {}, opts = {}) + request( + method: :post, + path: format("/v2/core/event_destinations/%s/ping", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + + # Retrieves the details of an event destination. + def retrieve(id, params = {}, opts = {}) + request( + method: :get, + path: format("/v2/core/event_destinations/%s", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + + # Update the details of an event destination. + def update(id, params = {}, opts = {}) + request( + method: :post, + path: format("/v2/core/event_destinations/%s", { id: CGI.escape(id) }), + params: params, + opts: opts, + base_address: :api + ) + end + end + end + end +end diff --git a/lib/stripe/services/v2/core_service.rb b/lib/stripe/services/v2/core_service.rb index 56bf5830..fbf4e934 100644 --- a/lib/stripe/services/v2/core_service.rb +++ b/lib/stripe/services/v2/core_service.rb @@ -4,10 +4,11 @@ module Stripe module V2 class CoreService < StripeService - attr_reader :events + attr_reader :event_destinations, :events def initialize(requestor) super(requestor) + @event_destinations = Stripe::V2::Core::EventDestinationService.new(@requestor) @events = Stripe::V2::Core::EventService.new(@requestor) end end diff --git a/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index 6a46bb4c..a1816a9f 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -932,6 +932,23 @@ module Stripe end end + class CustomStripeObject < APIResource + def self.resource_url + "/v1/custom_stripe_object" + end + end + + context "custom class extending APIResource" do + should "return StripeObject instance when calling retrieve" do + stub_request(:get, "#{Stripe.api_base}/v1/custom_stripe_object/id") + .to_return(body: JSON.generate({ id: "id", object: "custom_stripe_object", result: "hello" })) + + custom_stripe_object = CustomStripeObject.retrieve("id") + assert_instance_of CustomStripeObject, custom_stripe_object + assert_equal "hello", custom_stripe_object.result + end + end + @@fixtures = {} # rubocop:disable Style/ClassVars setup do if @@fixtures.empty?