Class: GitHubV3API::OrgsAPI
- Inherits:
-
Object
- Object
- GitHubV3API::OrgsAPI
- Defined in:
- lib/github_v3_api/orgs_api.rb
Overview
Provides access to the GitHub Orgs API (developer.github.com/v3/orgs/)
example:
api = GitHubV3API.new(ACCESS_TOKEN)
# get list of all orgs to which the user belongs
orgs = api.orgs.list
#=> returns an array of GitHubV3API::Org instances
an_org = api.orgs.get('github')
#=> returns an instance of GitHubV3API::Org
an_org.name
#=> 'GitHub'
Instance Method Summary collapse
-
#get(org_login) ⇒ Object
Returns a GitHubV3API::Org instance for the specified
org_login
. -
#initialize(connection) ⇒ OrgsAPI
constructor
Typically not used directly.
-
#list ⇒ Object
Returns an array of GitHubV3API::Org instances representing the public and private orgs to which the current user belongs.
-
#list_members(org_login) ⇒ Object
Returns an array of GitHubV3API::User instances representing the members who belong to the specified organization.
-
#list_public_members(org_login) ⇒ Object
Returns an array of GitHubV3API::User instances representing the members who belong to the specified organization who have publicly identified themselves as members of this organization.
-
#list_repos(org_login) ⇒ Object
Returns an array of GitHubV3API::Repo instances representing the repos that belong to the specified org.
Constructor Details
#initialize(connection) ⇒ OrgsAPI
Typically not used directly. Use GitHubV3API#orgs instead.
connection
-
an instance of GitHubV3API
23 24 25 |
# File 'lib/github_v3_api/orgs_api.rb', line 23 def initialize(connection) @connection = connection end |
Instance Method Details
#get(org_login) ⇒ Object
Returns a GitHubV3API::Org instance for the specified org_login
.
org_login
-
the string ID of the organization, e.g. “github”
38 39 40 41 |
# File 'lib/github_v3_api/orgs_api.rb', line 38 def get(org_login) org_data = @connection.get("/orgs/#{org_login}") GitHubV3API::Org.new_with_all_data(self, org_data) end |
#list ⇒ Object
Returns an array of GitHubV3API::Org instances representing the public and private orgs to which the current user belongs.
29 30 31 32 33 |
# File 'lib/github_v3_api/orgs_api.rb', line 29 def list @connection.get('/user/orgs').map do |org_data| GitHubV3API::Org.new(self, org_data) end end |
#list_members(org_login) ⇒ Object
Returns an array of GitHubV3API::User instances representing the members who belong to the specified organization.
org_login
-
the string ID of the organization, e.g. “github”
57 58 59 60 61 |
# File 'lib/github_v3_api/orgs_api.rb', line 57 def list_members(org_login) @connection.get("/orgs/#{org_login}/members").map do |user_data| GitHubV3API::User.new(@connection.users, user_data) end end |
#list_public_members(org_login) ⇒ Object
Returns an array of GitHubV3API::User instances representing the members who belong to the specified organization who have publicly identified themselves as members of this organization.
org_login
-
the string ID of the organization, e.g. “github”
68 69 70 71 72 |
# File 'lib/github_v3_api/orgs_api.rb', line 68 def list_public_members(org_login) @connection.get("/orgs/#{org_login}/public_members").map do |user_data| GitHubV3API::User.new(@connection.users, user_data) end end |
#list_repos(org_login) ⇒ Object
Returns an array of GitHubV3API::Repo instances representing the repos that belong to the specified org.
org_login
-
the string ID of the organization, e.g. “github”
47 48 49 50 51 |
# File 'lib/github_v3_api/orgs_api.rb', line 47 def list_repos(org_login) @connection.get("/orgs/#{org_login}/repos").map do |repo_data| GitHubV3API::Repo.new(@connection.repos, repo_data) end end |