mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-08 00:01:02 -05:00
Merge pull request #612 from stripe/brandur-fix-array-encoding-in-non-post
Fix encoding of arrays that are sent in query strings
This commit is contained in:
commit
e149379b83
@ -121,12 +121,11 @@ module Stripe
|
|||||||
url = api_url(path, api_base)
|
url = api_url(path, api_base)
|
||||||
|
|
||||||
body = nil
|
body = nil
|
||||||
query_string = nil
|
query_params = nil
|
||||||
|
|
||||||
case method.to_s.downcase.to_sym
|
case method.to_s.downcase.to_sym
|
||||||
when :get, :head, :delete
|
when :get, :head, :delete
|
||||||
query_string = Util.encode_parameters(params) if params && params.any?
|
query_params = params
|
||||||
url += "#{URI.parse(url).query ? '&' : '?'}#{query_string}" unless query_string.nil?
|
|
||||||
else
|
else
|
||||||
body = if headers[:content_type] && headers[:content_type] == "multipart/form-data"
|
body = if headers[:content_type] && headers[:content_type] == "multipart/form-data"
|
||||||
params
|
params
|
||||||
@ -148,12 +147,13 @@ module Stripe
|
|||||||
context.idempotency_key = headers["Idempotency-Key"]
|
context.idempotency_key = headers["Idempotency-Key"]
|
||||||
context.method = method
|
context.method = method
|
||||||
context.path = path
|
context.path = path
|
||||||
context.query_string = query_string
|
context.query_params = query_params ? Util.encode_parameters(query_params) : nil
|
||||||
|
|
||||||
http_resp = execute_request_with_rescues(api_base, context) do
|
http_resp = execute_request_with_rescues(api_base, context) do
|
||||||
conn.run_request(method, url, body, headers) do |req|
|
conn.run_request(method, url, body, headers) do |req|
|
||||||
req.options.open_timeout = Stripe.open_timeout
|
req.options.open_timeout = Stripe.open_timeout
|
||||||
req.options.timeout = Stripe.read_timeout
|
req.options.timeout = Stripe.read_timeout
|
||||||
|
req.params = query_params unless query_params.nil?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ module Stripe
|
|||||||
Util.log_debug("Request details",
|
Util.log_debug("Request details",
|
||||||
body: context.body,
|
body: context.body,
|
||||||
idempotency_key: context.idempotency_key,
|
idempotency_key: context.idempotency_key,
|
||||||
query_string: context.query_string)
|
query_params: context.query_params)
|
||||||
end
|
end
|
||||||
private :log_request
|
private :log_request
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ module Stripe
|
|||||||
attr_accessor :idempotency_key
|
attr_accessor :idempotency_key
|
||||||
attr_accessor :method
|
attr_accessor :method
|
||||||
attr_accessor :path
|
attr_accessor :path
|
||||||
attr_accessor :query_string
|
attr_accessor :query_params
|
||||||
attr_accessor :request_id
|
attr_accessor :request_id
|
||||||
|
|
||||||
# The idea with this method is that we might want to update some of
|
# The idea with this method is that we might want to update some of
|
||||||
|
|||||||
@ -87,8 +87,9 @@ module Stripe
|
|||||||
assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming",
|
assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming",
|
||||||
query: {
|
query: {
|
||||||
customer: "cus_123",
|
customer: "cus_123",
|
||||||
:'subscription_items[][plan]' => "gold",
|
subscription_items: [
|
||||||
:'subscription_items[][quantity]' => 2,
|
{ plan: "gold", quantity: "2" },
|
||||||
|
],
|
||||||
}
|
}
|
||||||
assert invoice.is_a?(Stripe::Invoice)
|
assert invoice.is_a?(Stripe::Invoice)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -176,7 +176,7 @@ module Stripe
|
|||||||
Util.expects(:log_debug).with("Request details",
|
Util.expects(:log_debug).with("Request details",
|
||||||
body: "",
|
body: "",
|
||||||
idempotency_key: "abc",
|
idempotency_key: "abc",
|
||||||
query_string: nil)
|
query_params: nil)
|
||||||
|
|
||||||
Util.expects(:log_info).with("Response from Stripe API",
|
Util.expects(:log_info).with("Response from Stripe API",
|
||||||
account: "acct_123",
|
account: "acct_123",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user