Skip to content

Commit

Permalink
run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyhat committed Oct 10, 2020
1 parent a8378ab commit 10376cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/xml_json/aws_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ defmodule XmlJson.AwsApi do
# {:ok, "<alice>bob</alice>"}

# """
def serialize(object, opts \\[])
def serialize(object, opts \\ [])

def serialize(object, opts),
do: Serializer.serialize(object, merge_default_options(opts))

def serialize_as_params(object, opts \\ [])

def serialize_as_params(object, opts),
do: ParamsSerializer.serialize(object, merge_default_options(opts))

Expand Down
6 changes: 5 additions & 1 deletion lib/xml_json/aws_api/params_serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ defmodule XmlJson.AwsApi.ParamsSerializer do

Enum.with_index(v, 1)
|> Enum.map(fn {v, vi} ->
to_params(prefix <> k <> "." <> list_element_name <> "." <> to_string(vi) <> ".", v, child_opts)
to_params(
prefix <> k <> "." <> list_element_name <> "." <> to_string(vi) <> ".",
v,
child_opts
)
end)
end

Expand Down
7 changes: 4 additions & 3 deletions lib/xml_json/aws_api/serializer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ defmodule XmlJson.AwsApi.Serializer do
defp to_simple_form(list, name, opts) when is_list(list) do
{list_element_name, child_opts} = cycle_list_name(opts)

children = Enum.reduce(list, [], fn item, acc ->
[to_simple_form(item, list_element_name, child_opts) | acc]
end)
children =
Enum.reduce(list, [], fn item, acc ->
[to_simple_form(item, list_element_name, child_opts) | acc]
end)

{name, [], Enum.reverse(children)}
end
Expand Down
7 changes: 4 additions & 3 deletions test/xml_json/aws_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ defmodule XmlJson.AwsApiTest do
<alice><first><bob><second><charlie><first>chet</first></charlie></second></bob></first><first><bob><second><charlie><first>chaz</first></charlie></second></bob></first></alice>
"""

assert {:ok, String.trim(xml)} == XmlJson.AwsApi.serialize(object, list_element_names: ["first", "second"])
assert {:ok, String.trim(xml)} ==
XmlJson.AwsApi.serialize(object, list_element_names: ["first", "second"])
end
end

Expand Down Expand Up @@ -369,7 +370,8 @@ defmodule XmlJson.AwsApiTest do
"List.first.1.DeepList.second.1.DeeperList.first.1.Address" => "value"
}

assert {:ok, params} == XmlJson.AwsApi.serialize_as_params(map, list_element_names: ["first", "second"])
assert {:ok, params} ==
XmlJson.AwsApi.serialize_as_params(map, list_element_names: ["first", "second"])
end

test "handles a real world example" do
Expand Down Expand Up @@ -468,5 +470,4 @@ defmodule XmlJson.AwsApiTest do
assert {:ok, params} == XmlJson.AwsApi.serialize_as_params(map)
end
end

end

0 comments on commit 10376cc

Please sign in to comment.