Add a data transformer to transform a json to Author.
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-12 22:11:51 +02:00
parent 2af5f6cf42
commit ecdd4089e5
2 changed files with 47 additions and 0 deletions
@@ -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