Your Turn
- Exercise: OrganizingAProject-2
Add the dependency to your project and install it.
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" ... |
Get Programming Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.