defmodule NullaWeb.NoteJSON do alias Nulla.Notes.Note @doc """ Renders a list of notes. """ def index(%{notes: notes}) do %{data: for(note <- notes, do: data(note))} end @doc """ Renders a single note. """ def show(%{note: note}) do %{data: data(note)} end defp data(%Note{} = note) do %{ id: note.id, inReplyTo: note.inReplyTo, published: note.published, url: note.url, visibility: note.visibility, to: note.to, cc: note.cc, sensitive: note.sensitive, content: note.content, language: note.language } end end