Skip to content
Open
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
2 changes: 1 addition & 1 deletion CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
05cb5f4269ead45cd337f456026295ed0e467f9c
70d7443c72304ad3165194e362954948b9744def
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2207
v2217
2 changes: 1 addition & 1 deletion lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def self.flatten_params_array(value, api_mode, calculated_key)
if elem.is_a?(Hash)
result += flatten_params(elem, api_mode, "#{calculated_key}[#{i}]")
elsif elem.is_a?(Array)
result += flatten_params_array(elem, api_mode, calculated_key)
result += flatten_params_array(elem, api_mode, "#{calculated_key}[#{i}]")
else
# Always use indexed format for arrays
result << ["#{calculated_key}[#{i}]", elem]
Expand Down
18 changes: 17 additions & 1 deletion test/stripe/util_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ class UtilTest < Test::Unit::TestCase
a: [[foo: "bar", baz: "qux"]],
}
assert_equal(
"a[0][foo]=bar&a[0][baz]=qux",
"a[0][0][foo]=bar&a[0][0][baz]=qux",
Stripe::Util.encode_parameters(params, :v1)
)
end

should "correctly encode 2D arrays of scalars" do
params = { a: [[1, 2], [3, 4]] }
assert_equal(
"a[0][0]=1&a[0][1]=2&a[1][0]=3&a[1][1]=4",
Stripe::Util.encode_parameters(params, :v1)
)
end
Expand Down Expand Up @@ -96,6 +104,14 @@ class UtilTest < Test::Unit::TestCase
]
assert_equal([["d[a]", "a"], ["d[b]", "b"], ["e[0]", 0], ["e[1]", 1]], Stripe::Util.flatten_params(params, :v2))
end

should "flatten 2D arrays with correct indices" do
params = { a: [[1, 2], [3, 4]] }
assert_equal(
[["a[0][0]", 1], ["a[0][1]", 2], ["a[1][0]", 3], ["a[1][1]", 4]],
Stripe::Util.flatten_params(params, :v1)
)
end
end

should "#symbolize_names should convert names to symbols" do
Expand Down
Loading