|
|
@ -1,21 +1,19 @@
|
|
|
|
defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformer do
|
|
|
|
defmodule DecentralisedBookIndex.Sync.DataTransformers.PublisherTransformer do
|
|
|
|
def from_json(json_body) do
|
|
|
|
def from_json(json_body) do
|
|
|
|
attrs =
|
|
|
|
json_body =
|
|
|
|
if Map.has_key?(json_body, "data") do
|
|
|
|
if Map.has_key?(json_body, "data") do
|
|
|
|
%{
|
|
|
|
json_body["data"]
|
|
|
|
id: get_in(json_body, ["data", "id"]),
|
|
|
|
|
|
|
|
name: get_in(json_body, ["data", "attributes", "name"]),
|
|
|
|
|
|
|
|
inserted_at: get_in(json_body, ["data", "attributes", "inserted_at"]),
|
|
|
|
|
|
|
|
updated_at: get_in(json_body, ["data", "attributes", "updated_at"]),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
json_body
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attrs =
|
|
|
|
%{
|
|
|
|
%{
|
|
|
|
id: get_in(json_body, ["id"]),
|
|
|
|
id: get_in(json_body, ["id"]),
|
|
|
|
name: get_in(json_body, ["attributes", "name"]),
|
|
|
|
name: get_in(json_body, ["attributes", "name"]),
|
|
|
|
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
|
|
|
inserted_at: get_in(json_body, ["attributes", "inserted_at"]),
|
|
|
|
updated_at: get_in(json_body, ["attributes", "updated_at"]),
|
|
|
|
updated_at: get_in(json_body, ["attributes", "updated_at"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, attrs}
|
|
|
|
{:ok, attrs}
|
|
|
|
end
|
|
|
|
end
|
|
|
|