Skip to content

Commit

Permalink
feat: add wheel price endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodiaslobo committed Nov 4, 2023
1 parent dad48ff commit fa38b22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/safira_web/controllers/roulette_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ 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
price = Application.fetch_env!(:safira, :roulette_cost)
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

0 comments on commit fa38b22

Please sign in to comment.