O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Your Turn

Back to the Transformation

So, back to our problem. We have to write the function GithubIssues.fetch, which transforms a user name and project into a data structure containing that project’s issues. The HTTPoison page on GitHub gives us a clue,[21] and we write a new module, Issues.GithubIssues:

project/1/issues/lib/issues/github_issues.ex
 
defmodule​ Issues.GithubIssues ​do
 
@user_agent​ [ {​"User-agent"​, ​"Elixir dave@pragprog.com"​} ]
 
 
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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required