Skip to content

Commit

Permalink
Add support for repositories/contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony Denyer committed Oct 10, 2017
1 parent e0df824 commit 9b87cb1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Tentacool + Cat = Tentacat
* Statuses
* Deployments
* Collaborators
* Contributors

Documentation can be found [here](https://hexdocs.pm/tentacat)

Expand Down
19 changes: 19 additions & 0 deletions lib/tentacat/repositories/contributors.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule Tentacat.Repositories.Contributors do
import Tentacat
alias Tentacat.Client

@doc """
List contributors for a specific repository
## Example
Tentacat.Repositories.contributors.list "elixir-lang", "elixir"
Tentacat.Repositories.contributors.list "elixir-lang", "elixir", client
More info at: https://developer.github.com/v3/repos/#list-contributors
"""
@spec list(binary, binary, Client.t) :: Tentacat.response
def list(owner, repo, client \\ %Client{}) do
get "repos/#{owner}/#{repo}/contributors", client
end

end
12 changes: 12 additions & 0 deletions test/fixture/vcr_cassettes/repositories/contributors#list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"request": {
"url": "https://api.github.com/repos/antonydenyer/tentatest/contributors"
},
"response": {
"body": "[{\"login\":\"octocat\",\"id\":1,\"avatar_url\":\"https://github.com/images/error/octocat_happy.gif\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/octocat\",\"html_url\":\"https://github.com/octocat\",\"followers_url\":\"https://api.github.com/users/octocat/followers\",\"following_url\":\"https://api.github.com/users/octocat/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/octocat/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/octocat/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/octocat/subscriptions\",\"organizations_url\":\"https://api.github.com/users/octocat/orgs\",\"repos_url\":\"https://api.github.com/users/octocat/repos\",\"events_url\":\"https://api.github.com/users/octocat/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/octocat/received_events\",\"type\":\"User\",\"site_admin\":false,\"contributions\":32}]",
"status_code": 200,
"type": "ok"
}
}
]
19 changes: 19 additions & 0 deletions test/repositories/contributors_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule Tentacat.Repositories.ContributorsTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
import Tentacat.Repositories.Contributors

doctest Tentacat.Repositories.Contributors

@client Tentacat.Client.new(%{access_token: "yourtokencomeshere"})

setup_all do
HTTPoison.start
end

test "list/3" do
use_cassette "repositories/contributors#list" do
assert list("antonydenyer", "tentatest", @client) |> Enum.count() == 1
end
end
end

0 comments on commit 9b87cb1

Please sign in to comment.