Added JSON API for biddings. (Only listing all biddings is supported)
This commit is contained in:
28
lib/beet_round_server_web/controllers/bidding_json.ex
Normal file
28
lib/beet_round_server_web/controllers/bidding_json.ex
Normal file
@ -0,0 +1,28 @@
|
||||
defmodule BeetRoundServerWeb.BiddingJSON do
|
||||
alias BeetRoundServer.Biddings.Bidding
|
||||
|
||||
@doc """
|
||||
Renders a list of biddings.
|
||||
"""
|
||||
def index(%{biddings: biddings}) do
|
||||
%{data: for(bidding <- biddings, do: data(bidding))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single bidding.
|
||||
"""
|
||||
def show(%{bidding: bidding}) do
|
||||
%{data: data(bidding)}
|
||||
end
|
||||
|
||||
defp data(%Bidding{} = bidding) do
|
||||
%{
|
||||
user_id: bidding.user_id,
|
||||
id: bidding.id,
|
||||
bidding_round: bidding.bidding_round,
|
||||
amount: bidding.amount,
|
||||
depot_wish_one: bidding.depot_wish_one,
|
||||
depot_wish_two: bidding.depot_wish_two
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user