Add a data transformer to transform a json to Author.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
defmodule DecentralisedBookIndex.Sync.DataTransformers.AuthorTransformer do
|
||||
|
||||
alias DecentralisedBookIndex.Metadata.Author
|
||||
|
||||
def from_json(json_body) do
|
||||
author = %Author{
|
||||
id: get_in(json_body, ["data", "id"]),
|
||||
name: get_in(json_body, ["data", "attributes", "name"]),
|
||||
description: get_in(json_body, ["data", "attributes", "description"]),
|
||||
}
|
||||
|
||||
{:ok, author}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user