diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 3ece5fc15..b964824ef 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -05cb5f4269ead45cd337f456026295ed0e467f9c \ No newline at end of file +70d7443c72304ad3165194e362954948b9744def \ No newline at end of file diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 1808fc941..7073706ed 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2207 \ No newline at end of file +v2217 \ No newline at end of file diff --git a/lib/stripe/util.rb b/lib/stripe/util.rb index 9f53225eb..4070447c8 100644 --- a/lib/stripe/util.rb +++ b/lib/stripe/util.rb @@ -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] diff --git a/test/stripe/util_test.rb b/test/stripe/util_test.rb index e88e50701..9ee8010a2 100644 --- a/test/stripe/util_test.rb +++ b/test/stripe/util_test.rb @@ -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 @@ -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