File tree Expand file tree Collapse file tree 2 files changed +30
-38
lines changed Expand file tree Collapse file tree 2 files changed +30
-38
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,8 @@ defmodule JSONAPI.Utils.DataToParams do
94
94
95
95
defp process_included ( % { "included" => included } = incoming ) do
96
96
included
97
- |> Enum . reduce ( incoming , fn % { "data" => % { " type" => type } } = params , acc ->
98
- flattened = process ( params )
97
+ |> Enum . reduce ( incoming , fn % { "type" => type } = params , acc ->
98
+ flattened = process ( % { "data" => params } )
99
99
100
100
case Map . has_key? ( acc , type ) do
101
101
false -> Map . put ( acc , type , [ flattened ] )
Original file line number Diff line number Diff line change @@ -106,13 +106,11 @@ defmodule JSONAPI.DataToParamsTest do
106
106
} ,
107
107
"included" => [
108
108
% {
109
- "data" => % {
110
- "attributes" => % {
111
- "name" => "Tara"
112
- } ,
113
- "id" => "234" ,
114
- "type" => "friend"
115
- }
109
+ "attributes" => % {
110
+ "name" => "Tara"
111
+ } ,
112
+ "id" => "234" ,
113
+ "type" => "friend"
116
114
}
117
115
]
118
116
}
@@ -144,42 +142,36 @@ defmodule JSONAPI.DataToParamsTest do
144
142
} ,
145
143
"included" => [
146
144
% {
147
- "data" => % {
148
- "id" => "234" ,
149
- "type" => "friend" ,
150
- "attributes" => % {
151
- "name" => "Tara"
152
- } ,
153
- "relationships" => % {
154
- "baz" => % {
155
- "data" => % {
156
- "id" => "2" ,
157
- "type" => "baz"
158
- }
159
- } ,
160
- "boo" => % {
161
- "data" => nil
145
+ "id" => "234" ,
146
+ "type" => "friend" ,
147
+ "attributes" => % {
148
+ "name" => "Tara"
149
+ } ,
150
+ "relationships" => % {
151
+ "baz" => % {
152
+ "data" => % {
153
+ "id" => "2" ,
154
+ "type" => "baz"
162
155
}
156
+ } ,
157
+ "boo" => % {
158
+ "data" => nil
163
159
}
164
160
}
165
161
} ,
166
162
% {
167
- "data" => % {
168
- "attributes" => % {
169
- "name" => "Wild Bill"
170
- } ,
171
- "id" => "0012" ,
172
- "type" => "friend"
173
- }
163
+ "attributes" => % {
164
+ "name" => "Wild Bill"
165
+ } ,
166
+ "id" => "0012" ,
167
+ "type" => "friend"
174
168
} ,
175
169
% {
176
- "data" => % {
177
- "attributes" => % {
178
- "title" => "Sr"
179
- } ,
180
- "id" => "456" ,
181
- "type" => "organization"
182
- }
170
+ "attributes" => % {
171
+ "title" => "Sr"
172
+ } ,
173
+ "id" => "456" ,
174
+ "type" => "organization"
183
175
}
184
176
]
185
177
}
You can’t perform that action at this time.
0 commit comments