Skip to content

Commit

Permalink
manual change - update to cast params
Browse files Browse the repository at this point in the history
  • Loading branch information
helenye-stripe committed Dec 17, 2024
1 parent 7cb7a32 commit 5d86bc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/stripe/api_operations/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def execute_resource_request_stream(method, url, base_address = :api,
method, url, base_address,
params, opts, usage,
&read_body_chunk_block)
params = params.to_h if params.is_a?(Stripe::RequestParams)
params ||= {}

error_on_invalid_params(params)
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/api_requestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def request

def execute_request(method, path, base_address,
params: {}, opts: {}, usage: [])
params = params.to_h if params.is_a?(RequestParams)
http_resp, req_opts = execute_request_internal(
method, path, base_address, params, opts, usage
)
Expand Down
11 changes: 11 additions & 0 deletions test/stripe/request_params_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def initialize(games: nil)
expected = { fun: { games: %w[chess go] }, team: "blue" }
assert_equal expected, params.to_h
end

should "make request with params class" do
stub_request(:post, "#{Stripe.api_base}/v1/customers")
.with do |req|
assert req.body == "name=foo"
end
.to_return(body: JSON.generate(object: "customer"))
params = Stripe::Customer::CreateParams.new(name: "foo")
cus = Stripe::Customer.create(params)
assert cus.is_a?(Stripe::Customer)
end
end
end
end

0 comments on commit 5d86bc8

Please sign in to comment.