Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/stripe/api_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def execute_request(method, path, base_address,

api_mode = Util.get_api_mode(path)
Util.convert_to_stripe_object_with_params(resp.data, params, RequestOptions.persistable(req_opts), resp,
api_mode: api_mode, requestor: self)
api_mode: api_mode, requestor: self,
v2_deleted_object: method == :delete && api_mode == :v2)
end

# Execute request without instantiating a new object if the relevant object's name matches the class
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,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/deleted_object"
require "stripe/resources/v2/event"
require "stripe/resources/v2/event_destination"
require "stripe/resources/webhook_endpoint"
Expand Down
13 changes: 13 additions & 0 deletions lib/stripe/resources/v2/deleted_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
module V2
class DeletedObject < APIResource
# String representing the type of the object that has been deleted. Objects of the same type share the same value of the object field.
attr_reader :object
# The ID of the object that's being deleted.
attr_reader :id
end
end
end
8 changes: 6 additions & 2 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ def self.convert_to_stripe_object(data, opts = {}, api_mode: :v1, requestor: nil
# * +last_response+ - The raw response associated with the object.
# * +api_mode+ - The API mode to use when converting the object, either :v1 or :v2.
# * +requestor+ - The requestor to use when constructing the object.
# * +v2_deleted_object+ - If true, ignore the object tag for casting purposes
def self.convert_to_stripe_object_with_params(
data,
params,
opts = {},
last_response = nil,
api_mode: :v1,
requestor: nil
requestor: nil,
v2_deleted_object: false
)
opts = normalize_opts(opts)

Expand All @@ -144,7 +146,9 @@ def self.convert_to_stripe_object_with_params(
object_type = data[:type] || data["type"]
object_name = data[:object] || data["object"]
object_class = if api_mode == :v2
if object_name == "v2.core.event" && thin_event_classes.key?(object_type)
if v2_deleted_object
V2::DeletedObject
elsif object_name == "v2.core.event" && thin_event_classes.key?(object_type)
thin_event_classes.fetch(object_type)
else
v2_object_classes.fetch(
Expand Down
Loading