Skip to content

Instantly share code, notes, and snippets.

@s3itz
Created March 1, 2016 08:14
Show Gist options
  • Save s3itz/e09dc9defe9304ba93f2 to your computer and use it in GitHub Desktop.
Save s3itz/e09dc9defe9304ba93f2 to your computer and use it in GitHub Desktop.
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