Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Created September 6, 2014 23:00
Show Gist options
  • Save j-mcnally/403812350dd02623857e to your computer and use it in GitHub Desktop.
Save j-mcnally/403812350dd02623857e to your computer and use it in GitHub Desktop.
GithubOrg serializer
defmodule Koncur.Api.V1.OrganizationController do
use Phoenix.Controller
alias OAuth2Ex.Provider.Github, as: Github
plug Koncur.AuthenticationPlug
plug Koncur.GithubClientPlug
def index(conn, _params) do
github_token = conn.assigns[:github_token]
orgs = Github.organizations(github_token)
orgs = for o <- orgs do
%{
id: o["id"],
name: o["login"]
}
end
IO.inspect orgs
json conn, JSON.encode!(%{organizations: orgs})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment