Skip to content

Commit

Permalink
adds 'member' to map/list members
Browse files Browse the repository at this point in the history
  • Loading branch information
namjae committed Nov 1, 2024
1 parent 6eeae20 commit cc171b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/aws/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ defmodule AWS.Util do
iex> input = %{"Action" => "OperationName", "Bar" => ["val1", "val2"], "Foo" => 42}
iex> AWS.Util.encode_query(input)
"Action=OperationName&Bar.1=val1&Bar.2=val2&Foo=42"
"Action=OperationName&Bar.member.1=val1&Bar.member.2=val2&Foo=42"
iex> input = %{"Action" => "OperationName", "Bar" => %{"Baz" => ["val1", "val2"]}, "Foo" => 42}
iex> AWS.Util.encode_query(input)
"Action=OperationName&Bar.Baz.1=val1&Bar.Baz.2=val2&Foo=42"
"Action=OperationName&Bar.Baz.member.1=val1&Bar.Baz.member.2=val2&Foo=42"
"""
def encode_query(input) do
Expand All @@ -54,7 +54,7 @@ defmodule AWS.Util do
value
|> Enum.with_index(1)
|> Enum.map(fn {inner_value, idx} ->
encode_query_value({[key, ?., to_string(idx)], inner_value})
encode_query_value({[key, ?., "member", ?., to_string(idx)], inner_value})
end)
end

Expand Down
4 changes: 2 additions & 2 deletions test/aws/util_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule AWS.UtilTest do
}

assert Util.encode_query(input) ==
"Action=OperationName&Operations.1=foo&Operations.2=bar"
"Action=OperationName&Operations.member.1=foo&Operations.member.2=bar"
end

test "with a map with string values" do
Expand All @@ -59,7 +59,7 @@ defmodule AWS.UtilTest do
}

assert Util.encode_query(input) ==
"Action=OperationName&Operation.1.name=foo&Operation.1.state=bar&Operation.2.name=baz&Operation.2.state=full&Operation.3.other.1=a&Operation.3.other.2=b&Operation.3.other.3=c"
"Action=OperationName&Operation.member.1.name=foo&Operation.member.1.state=bar&Operation.member.2.name=baz&Operation.member.2.state=full&Operation.member.3.other.member.1=a&Operation.member.3.other.member.2=b&Operation.member.3.other.member.3=c"
end
end
end

0 comments on commit cc171b7

Please sign in to comment.