-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00e1f06
commit f578de4
Showing
2 changed files
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
defmodule Servy.PledgeController do | ||
alias Servy.Conv | ||
alias Servy.PledgeServer | ||
|
||
def create(%Conv{} = conv, %{"name" => name, "amount" => amount}) do | ||
def create(conv, %{"name" => name, "amount" => amount}) do | ||
# sends pledge to the external service and caches it | ||
PledgeServer.create_pledge(name, String.to_integer(amount)) | ||
Servy.PledgeServer.create_pledge(name, String.to_integer(amount)) | ||
|
||
%{conv | status: 200, resp_body: "#{name} pledged #{amount}!"} | ||
%{conv | status: 201, resp_body: "#{name} pledged #{amount}!"} | ||
end | ||
|
||
def index(%Conv{} = conv) do | ||
def index(conv) do | ||
# get recent pledges from cache | ||
pledges = PledgeServer.recent_pledges() | ||
pledges = Servy.PledgeServer.recent_pledges() | ||
|
||
%{Conv | status: 200, resp_body: inspect(pledges)} | ||
%{conv | status: 200, resp_body: inspect(pledges)} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters