Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds 'member' to map/list members #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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
Loading