Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add wheel price endpoint #349

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/safira_web/controllers/roulette_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ defmodule SafiraWeb.RouletteController do

action_fallback SafiraWeb.FallbackController

@price Application.compile_env!(:safira, :roulette_cost)

def spin(conn, _params) do
attendee = Accounts.get_user(conn) |> Map.fetch!(:attendee)

Expand All @@ -30,4 +32,8 @@ defmodule SafiraWeb.RouletteController do
latest_prizes = Roulette.latest_five_wins()
render(conn, "latest_prizes.json", latest_prizes: latest_prizes)
end

def price(conn, _params) do
render(conn, "price.json", price: @price)
end
end
1 change: 1 addition & 0 deletions lib/safira_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defmodule SafiraWeb.Router do
get "/leaderboard", LeaderboardController, :index
get "/leaderboard/:date", LeaderboardController, :daily
get "/roulette/latestwins", RouletteController, :latest_wins
get "/roulette/price", RouletteController, :price
get "/store/redeem/:id", DeliverRedeemableController, :show
get "/roulette/redeem/:id", DeliverPrizeController, :show

Expand Down
4 changes: 4 additions & 0 deletions lib/safira_web/views/roulette_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ defmodule SafiraWeb.RouletteView do
resp
end

def render("price.json", %{price: price}) do
%{price: price}
end

def render("latest_prizes.json", %{latest_prizes: latest_prizes}) do
%{data: render_many(latest_prizes, SafiraWeb.RouletteView, "latest_prize_show.json")}
end
Expand Down
Loading