From a2e2881c7cad5ebe5ad03c013521d01384ab77d9 Mon Sep 17 00:00:00 2001 From: David Brownman Date: Fri, 18 Oct 2024 11:42:37 -0700 Subject: [PATCH 1/4] Bump version to 13.0.1 --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- lib/stripe/version.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c9ab270..b214ebfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog +## 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/VERSION b/VERSION index 02161ca8..5cb7d856 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -13.0.0 +13.0.1 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index 9210f2c8..9ea65f2f 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "13.0.0" + VERSION = "13.0.1" end From 042918c5f8e847eeafc40a14d9e6f0e66529cfb2 Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Wed, 23 Oct 2024 11:45:51 -0400 Subject: [PATCH 2/4] Always return the result of APIResource#refresh in APIResource.retrieve (#1473) * Always return the result of .refresh in .retrieve With the refactor of v13, there are now cases where `self` is not mutated in the call to refresh and instead a new object is returned. This change ensures that the new object is always returned by returning the result of refresh instead. * Update install instructions for stripe-mock --- README.md | 2 +- lib/stripe/api_resource.rb | 1 - test/stripe/api_resource_test.rb | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) 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..4a4c9ef9 100644 --- a/lib/stripe/api_resource.rb +++ b/lib/stripe/api_resource.rb @@ -110,7 +110,6 @@ def self.retrieve(id, opts = {}) 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/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index e6dc9e60..c283aa5a 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -919,6 +919,23 @@ def self.object_name 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 Stripe::StripeObject, custom_stripe_object + assert_equal "hello", custom_stripe_object.result + end + end + @@fixtures = {} # rubocop:disable Style/ClassVars setup do if @@fixtures.empty? From 4c3593e62e18ca5d11acbe396c4fa4a84a902118 Mon Sep 17 00:00:00 2001 From: Jesse Rosalia Date: Wed, 23 Oct 2024 11:03:31 -0700 Subject: [PATCH 3/4] Bump version to 13.0.2 --- CHANGELOG.md | 5 +++++ VERSION | 2 +- lib/stripe/version.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b214ebfc..2a4a432c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## 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 diff --git a/VERSION b/VERSION index 5cb7d856..347caf39 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -13.0.1 +13.0.2 diff --git a/lib/stripe/version.rb b/lib/stripe/version.rb index 9ea65f2f..74452a07 100644 --- a/lib/stripe/version.rb +++ b/lib/stripe/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stripe - VERSION = "13.0.1" + VERSION = "13.0.2" end From c00f901ba218b28dda8461f78df129bc8a50c97f Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:17:35 +0000 Subject: [PATCH 4/4] Update generated code for v1318 --- lib/stripe/object_types.rb | 1 + lib/stripe/resources.rb | 1 + lib/stripe/resources/v2/event_destination.rb | 13 +++ lib/stripe/services.rb | 1 + .../v2/core/event_destination_service.rb | 98 +++++++++++++++++++ lib/stripe/services/v2/core_service.rb | 3 +- 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 lib/stripe/resources/v2/event_destination.rb create mode 100644 lib/stripe/services/v2/core/event_destination_service.rb 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 @@ def self.v2_object_names_to_classes 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_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/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_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/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