Update
This commit is contained in:
parent
188bc08494
commit
4af88f3e1d
44 changed files with 1041 additions and 34 deletions
30
lib/nulla_web/controllers/api/media_attachment_json.ex
Normal file
30
lib/nulla_web/controllers/api/media_attachment_json.ex
Normal file
|
@ -0,0 +1,30 @@
|
|||
defmodule NullaWeb.Api.MediaAttachmentJSON do
|
||||
alias Nulla.MediaAttachments.MediaAttachment
|
||||
|
||||
@doc """
|
||||
Renders a list of media_attachments.
|
||||
"""
|
||||
def index(%{media_attachments: media_attachments}) do
|
||||
%{data: for(media_attachment <- media_attachments, do: data(media_attachment))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single media_attachment.
|
||||
"""
|
||||
def show(%{media_attachment: media_attachment}) do
|
||||
%{data: data(media_attachment)}
|
||||
end
|
||||
|
||||
defp data(%MediaAttachment{} = media_attachment) do
|
||||
%{
|
||||
id: media_attachment.id,
|
||||
type: media_attachment.type,
|
||||
mediaType: media_attachment.mediaType,
|
||||
url: media_attachment.url,
|
||||
name: media_attachment.name,
|
||||
width: media_attachment.width,
|
||||
height: media_attachment.height,
|
||||
note_id: media_attachment.note_id
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue