Module: Octokit::Client::Users
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/users.rb
Instance Method Summary (collapse)
-
- (Hashie::Mash) access_token(code, app_id, app_secret, options = {})
Retrieve the access_token.
-
- (Array<String>) add_email(email, options = {})
Add email address to user.
-
- (Hashie::Mash) add_key(title, key, options = {})
Add public key to user account.
-
- (Array) all_users(options = {})
List all GitHub users.
-
- (Array<String>) emails(options = {})
List email addresses for a user.
-
- (Boolean) follow(user, options = {})
Follow a user.
-
- (Array<Hashie::Mash>) followers(user = login, options = {})
Get a user's followers.
-
- (Array<Hashie::Mash>) following(user = login, options = {})
Get list of users a user is following.
-
- (Boolean) follows?(*args)
Check if you are following a user.
-
- (Hashie::Mash) key(key_id, options = {})
Get a public key.
-
- (Array<Hashie::Mash>) keys(options = {})
Get list of public keys for user.
-
- (Array<String>) remove_email(email, options = {})
Remove email from user.
-
- (Boolean) remove_key(id, options = {})
Remove a public key from user account.
-
- (Array<Hashie::Mash>) search_users(search, options = {})
Search for user.
-
- (Array<Hashie::Mash>) starred(user = login, options = {})
Get list of repos starred by a user.
-
- (Boolean) starred?(user, repo, options = {})
Check if you are starring a repo.
-
- (Array<Hashie::Mashie>) subscriptions(user = login, options = {})
List repositories being watched by a user.
-
- (Boolean) unfollow(user, options = {})
Unfollow a user.
-
- (Hashie::Mash) update_key(key_id, options = {})
Update a public key.
-
- (Hashie::Mash) update_user(options)
Update the authenticated user.
-
- (Hashie::Mash) user(user = nil)
Get a single user.
-
- (Array<Hashie::Mash>) user_keys(user, options = {})
Get list of public keys for user.
-
- (Boolean) validate_credentials(options = {})
Validate user username and password.
-
- (Array<Hashie::Mash>) watched(user = login, options = {})
Get list of repos watched by a user.
Instance Method Details
- (Hashie::Mash) access_token(code, app_id, app_secret, options = {})
Retrieve the access_token.
57 58 59 60 |
# File 'lib/octokit/client/users.rb', line 57 def access_token(code, app_id, app_secret, = {}) post("login/oauth/access_token", .merge({:endpoint => Octokit.web_endpoint, :code => code, :client_id => app_id, :client_secret => app_secret})) end |
- (Array<String>) add_email(email, options = {})
Add email address to user.
Requires authenticated client.
320 321 322 |
# File 'lib/octokit/client/users.rb', line 320 def add_email(email, ={}) post("user/emails", .merge({:email => email})) end |
- (Hashie::Mash) add_key(title, key, options = {})
Add public key to user account.
Requires authenticated client.
263 264 265 |
# File 'lib/octokit/client/users.rb', line 263 def add_key(title, key, ={}) post("user/keys", .merge({:title => title, :key => key})) end |
- (Array) all_users(options = {})
List all GitHub users
This provides a dump of every user, in the order that they signed up for GitHub.
28 29 30 |
# File 'lib/octokit/client/users.rb', line 28 def all_users(={}) get "users", end |
- (Array<String>) emails(options = {})
List email addresses for a user.
Requires authenticated client.
306 307 308 |
# File 'lib/octokit/client/users.rb', line 306 def emails(={}) get("user/emails", ) end |
- (Boolean) follow(user, options = {})
Follow a user.
Requires authenticatied client.
141 142 143 |
# File 'lib/octokit/client/users.rb', line 141 def follow(user, ={}) boolean_from_response(:put, "user/following/#{user}", ) end |
- (Array<Hashie::Mash>) followers(user = login, options = {})
Get a user's followers.
98 99 100 |
# File 'lib/octokit/client/users.rb', line 98 def followers(user=login, ={}) get("users/#{user}/followers", ) end |
- (Array<Hashie::Mash>) following(user = login, options = {})
Get list of users a user is following.
109 110 111 |
# File 'lib/octokit/client/users.rb', line 109 def following(user=login, ={}) get("users/#{user}/following", ) end |
- (Boolean) follows?(*args)
Check if you are following a user.
Requries an authenticated client.
123 124 125 126 127 128 129 |
# File 'lib/octokit/client/users.rb', line 123 def follows?(*args) target = args.pop user = args.first user ||= login return if user.nil? boolean_from_response(:get, "user/following/#{target}") end |
- (Hashie::Mash) key(key_id, options = {})
Get a public key.
Note, when using dot notation to retrieve the values, ruby will return the hash key for the public keys value instead of the actual value, use symbol or key string to retrieve the value. See example.
Requires authenticated client.
222 223 224 |
# File 'lib/octokit/client/users.rb', line 222 def key(key_id, ={}) get("user/keys/#{key_id}", ) end |
- (Array<Hashie::Mash>) keys(options = {})
Get list of public keys for user.
Requires authenticated client.
235 236 237 |
# File 'lib/octokit/client/users.rb', line 235 def keys(={}) get("user/keys", ) end |
- (Array<String>) remove_email(email, options = {})
Remove email from user.
Requires authenticated client.
334 335 336 |
# File 'lib/octokit/client/users.rb', line 334 def remove_email(email, ={}) boolean_from_response(:delete, "user/emails", .merge({:email => email})) end |
- (Boolean) remove_key(id, options = {})
Remove a public key from user account.
Requires authenticated client.
293 294 295 |
# File 'lib/octokit/client/users.rb', line 293 def remove_key(id, ={}) boolean_from_response(:delete, "user/keys/#{id}", ) end |
- (Array<Hashie::Mash>) search_users(search, options = {})
Search for user.
12 13 14 |
# File 'lib/octokit/client/users.rb', line 12 def search_users(search, ={}) get("legacy/user/search/#{search}", )['users'] end |
- (Array<Hashie::Mash>) starred(user = login, options = {})
Get list of repos starred by a user.
166 167 168 |
# File 'lib/octokit/client/users.rb', line 166 def starred(user=login, ={}) get("users/#{user}/starred", ) end |
- (Boolean) starred?(user, repo, options = {})
Check if you are starring a repo.
Requires authenticated client.
181 182 183 |
# File 'lib/octokit/client/users.rb', line 181 def starred?(user, repo, ={}) boolean_from_response(:get, "user/starred/#{user}/#{repo}", ) end |
- (Array<Hashie::Mashie>) subscriptions(user = login, options = {})
List repositories being watched by a user.
348 349 350 |
# File 'lib/octokit/client/users.rb', line 348 def subscriptions(user=login, ={}) get("users/#{user}/subscriptions", ) end |
- (Boolean) unfollow(user, options = {})
Unfollow a user.
Requires authenticated client.
155 156 157 |
# File 'lib/octokit/client/users.rb', line 155 def unfollow(user, ={}) boolean_from_response(:delete, "user/following/#{user}", ) end |
- (Hashie::Mash) update_key(key_id, options = {})
Update a public key
Requires authenticated client
279 280 281 |
# File 'lib/octokit/client/users.rb', line 279 def update_key(key_id, ={}) patch("/user/keys/#{key_id}", ) end |
- (Hashie::Mash) update_user(options)
Update the authenticated user
87 88 89 |
# File 'lib/octokit/client/users.rb', line 87 def update_user() patch("user", ) end |
- (Hashie::Mash) user(user = nil)
Get a single user
39 40 41 42 43 44 45 |
# File 'lib/octokit/client/users.rb', line 39 def user(user=nil) if user get "users/#{user}" else get 'user' end end |
- (Array<Hashie::Mash>) user_keys(user, options = {})
Get list of public keys for user.
Requires authenticated client.
248 249 250 |
# File 'lib/octokit/client/users.rb', line 248 def user_keys(user, ={}) get("users/#{user}/keys", ) end |
- (Boolean) validate_credentials(options = {})
Validate user username and password
68 69 70 71 72 |
# File 'lib/octokit/client/users.rb', line 68 def validate_credentials( = {}) !self.class.new().user.nil? rescue Octokit::Unauthorized false end |
- (Array<Hashie::Mash>) watched(user = login, options = {})
Get list of repos watched by a user.
Legacy, using github.beta media type. Use `Users#starred` instead.
195 196 197 |
# File 'lib/octokit/client/users.rb', line 195 def watched(user=login, ={}) get("users/#{user}/watched", ) end |