class GitHubV3API::UsersAPI

Provides access to the GitHub Users API (developer.github.com/v3/users/)

example:

api = GitHubV3API.new(ACCESS_TOKEN)

# get list of logged-in user
a_user = api.current
#=> returns an instance of GitHubV3API::User

a_user.login
#=> 'jwilger'

Public Class Methods

new(connection) click to toggle source

Typically not used directly. Use GitHubV3API#users instead.

connection

an instance of GitHubV3API

# File lib/github_v3_api/users_api.rb, line 20
def initialize(connection)
  @connection = connection
end

Public Instance Methods

all() click to toggle source

Returns an array of all GitHubV3API::User instances in the server.

# File lib/github_v3_api/users_api.rb, line 40
def all
  @connection.get("/users").map do |user_data|
    GitHubV3API::User.new_with_all_data(self, user_data)
  end
end
current() click to toggle source

Returns a single GitHubV3API::User instance representing the currently logged in user

# File lib/github_v3_api/users_api.rb, line 26
def current
  user_data = @connection.get("/user")
  GitHubV3API::User.new(self, user_data)
end
get(username) click to toggle source

Returns a GitHubV3API::User instance for the specified username.

username

the string login of the user, e.g. “octocat”

# File lib/github_v3_api/users_api.rb, line 34
def get(username)
  user_data = @connection.get("/users/#{username}")
  GitHubV3API::User.new_with_all_data(self, user_data)
end