Created
August 12, 2016 04:54
-
-
Save poteto/91bc9a5b455d2be0a958a6991fb3af82 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
# Example taken from https://github.com/edgurgel/httpoison | |
defmodule GitHub do | |
use HTTPoison.Base | |
@expected_fields ~w( | |
login id avatar_url gravatar_id url html_url followers_url | |
following_url gists_url starred_url subscriptions_url | |
organizations_url repos_url events_url received_events_url type | |
site_admin name company blog location email hireable bio | |
public_repos public_gists followers following created_at updated_at | |
) | |
def process_url(url) do | |
"https://api.github.com" <> url | |
end | |
def process_response_body(body) do | |
body | |
|> Poison.decode! | |
|> Map.take(@expected_fields) | |
|> Enum.map(fn({k, v}) -> {String.to_atom(k), v} end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment