Skip to content

Instantly share code, notes, and snippets.

@poteto
Created August 12, 2016 04:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poteto/91bc9a5b455d2be0a958a6991fb3af82 to your computer and use it in GitHub Desktop.
Save poteto/91bc9a5b455d2be0a958a6991fb3af82 to your computer and use it in GitHub Desktop.
# 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