Created
March 1, 2016 08:14
-
-
Save s3itz/e09dc9defe9304ba93f2 to your computer and use it in GitHub Desktop.
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
defmodule Issues.GitHubIssues do | |
@user_agent [{"User-agent", "Issues [email protected]"}] | |
def fetch(user, project) do | |
issues_url(user, project) | |
|> HTTPoison.get(@user_agent) | |
|> handle_response | |
end | |
def issues_url(user, project) do | |
"https://api.github.com/repos/#{user}/#{project}/issues" | |
end | |
def handle_response({:ok, %{status_code: 200, body: body}}), do: {:ok, body} | |
def handle_response({_, %{status_code: _, body: body}}), do: {:error, body} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment