mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Merge pull request #1653 from stripe/prathmesh/merge-ruby-private-preview
Prathmesh/merge ruby private preview
This commit is contained in:
commit
bbfe517df6
@ -211,7 +211,8 @@ module Stripe
|
||||
|
||||
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
|
||||
|
@ -197,6 +197,7 @@ require "stripe/resources/v2/core/claimable_sandbox"
|
||||
require "stripe/resources/v2/core/person"
|
||||
require "stripe/resources/v2/core/vault/gb_bank_account"
|
||||
require "stripe/resources/v2/core/vault/us_bank_account"
|
||||
require "stripe/resources/v2/deleted_object"
|
||||
require "stripe/resources/v2/event"
|
||||
require "stripe/resources/v2/event_destination"
|
||||
require "stripe/resources/v2/financial_address_credit_simulation"
|
||||
|
13
lib/stripe/resources/v2/deleted_object.rb
Normal file
13
lib/stripe/resources/v2/deleted_object.rb
Normal file
@ -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
|
@ -118,6 +118,7 @@ module Stripe
|
||||
# * +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,
|
||||
@ -125,7 +126,8 @@ module Stripe
|
||||
last_response = nil,
|
||||
api_mode: :v1,
|
||||
requestor: nil,
|
||||
klass: nil
|
||||
klass: nil,
|
||||
v2_deleted_object: false
|
||||
)
|
||||
opts = normalize_opts(opts)
|
||||
|
||||
@ -148,7 +150,9 @@ module Stripe
|
||||
# Use the provided class for inner types
|
||||
klass
|
||||
elsif 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(
|
||||
|
16
rbi/stripe/resources/v2/deleted_object.rbi
Normal file
16
rbi/stripe/resources/v2/deleted_object.rbi
Normal file
@ -0,0 +1,16 @@
|
||||
# File generated from our OpenAPI spec
|
||||
# frozen_string_literal: true
|
||||
|
||||
# typed: 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.
|
||||
sig { returns(T.nilable(String)) }
|
||||
def object; end
|
||||
# The ID of the object that's being deleted.
|
||||
sig { returns(String) }
|
||||
def id; end
|
||||
end
|
||||
end
|
||||
end
|
@ -209,7 +209,7 @@ module Stripe
|
||||
|
||||
# Delete an event destination.
|
||||
sig {
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DeleteParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::EventDestination)
|
||||
params(id: String, params: T.any(::Stripe::V2::Core::EventDestinationService::DeleteParams, T::Hash[T.untyped, T.untyped]), opts: T.untyped).returns(Stripe::V2::DeletedObject)
|
||||
}
|
||||
def delete(id, params = {}, opts = {}); end
|
||||
|
||||
|
@ -1295,6 +1295,23 @@ module Stripe
|
||||
body: "{\"foo\":\"bar\"}"
|
||||
)
|
||||
end
|
||||
|
||||
%w[v1 v2].each do |mode|
|
||||
should "correctly handle #{mode} delete request responses" do
|
||||
stub_request(:delete, "#{Stripe::DEFAULT_API_BASE}/#{mode}/foo")
|
||||
.to_return(body: JSON.generate(object: "customer", id: "abc_123"), status: 200)
|
||||
|
||||
requestor = APIRequestor.new("sk_test_123")
|
||||
|
||||
response = requestor.execute_request(:delete, "/#{mode}/foo", :api)
|
||||
|
||||
if mode == "v1"
|
||||
assert_instance_of Stripe::Customer, response
|
||||
else
|
||||
assert_instance_of Stripe::V2::DeletedObject, response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#execute_request_stream" do
|
||||
|
@ -8844,7 +8844,7 @@ module Stripe
|
||||
end
|
||||
should "Test v2 core event destination get (service)" do
|
||||
stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations").to_return(
|
||||
body: '{"data":[{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}],"next_page_url":null,"previous_page_url":null}',
|
||||
body: '{"data":[{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}],"next_page_url":null,"previous_page_url":null}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
@ -8854,7 +8854,7 @@ module Stripe
|
||||
end
|
||||
should "Test v2 core event destination post (service)" do
|
||||
stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations").to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
@ -8871,10 +8871,7 @@ module Stripe
|
||||
stub_request(
|
||||
:delete,
|
||||
"#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123"
|
||||
).to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
status: 200
|
||||
)
|
||||
).to_return(body: '{"id":"abc_123","object":"some.object.tag","deleted":true}', status: 200)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
|
||||
deleted = client.v2.core.event_destinations.delete("id_123")
|
||||
@ -8882,7 +8879,7 @@ module Stripe
|
||||
end
|
||||
should "Test v2 core event destination get 2 (service)" do
|
||||
stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123").to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
@ -8895,7 +8892,7 @@ module Stripe
|
||||
:post,
|
||||
"#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123"
|
||||
).to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
@ -8908,7 +8905,7 @@ module Stripe
|
||||
:post,
|
||||
"#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/disable"
|
||||
).to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
@ -8921,7 +8918,7 @@ module Stripe
|
||||
:post,
|
||||
"#{Stripe::DEFAULT_API_BASE}/v2/core/event_destinations/id_123/enable"
|
||||
).to_return(
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","events_from":null,"id":"obj_123","metadata":null,"name":"name","object":"v2.core.event_destination","snapshot_api_version":null,"status":"disabled","status_details":null,"type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true,"amazon_eventbridge":null,"webhook_endpoint":null}',
|
||||
body: '{"created":"1970-01-12T21:42:34.472Z","description":"description","enabled_events":["enabled_events"],"event_payload":"thin","id":"obj_123","name":"name","object":"v2.core.event_destination","status":"disabled","type":"amazon_eventbridge","updated":"1970-01-03T17:07:10.277Z","livemode":true}',
|
||||
status: 200
|
||||
)
|
||||
client = Stripe::StripeClient.new("sk_test_123")
|
||||
|
Loading…
x
Reference in New Issue
Block a user