Module: Octokit::Client::Users
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/users.rb
Instance Method Summary collapse
-
#add_email(email, options = {}) ⇒ Array<String>
Add email address to user.
-
#add_key(title, key, options = {}) ⇒ Hashie::Mash
Add public key to user account.
-
#all_users(options = {}) ⇒ Array
List all GitHub users.
-
#emails(options = {}) ⇒ Array<String>
List email addresses for a user.
-
#follow(user, options = {}) ⇒ Boolean
Follow a user.
-
#followers(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get a user’s followers.
-
#following(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of users a user is following.
-
#follows?(*args) ⇒ Boolean
Check if you are following a user.
-
#key(key_id, options = {}) ⇒ Hashie::Mash
Get a public key.
-
#keys(options = {}) ⇒ Array<Hashie::Mash>
Get list of public keys for user.
-
#remove_email(email, options = {}) ⇒ Array<String>
Remove email from user.
-
#remove_key(id, options = {}) ⇒ Boolean
Remove a public key from user account.
-
#search_users(search, options = {}) ⇒ Array<Hashie::Mash>
Search for user.
-
#starred(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of repos starred by a user.
-
#starred?(user, repo, options = {}) ⇒ Boolean
Check if you are starring a repo.
-
#subscriptions(user = login, options = {}) ⇒ Array<Hashie::Mashie>
List repositories being watched by a user.
-
#unfollow(user, options = {}) ⇒ Boolean
Unfollow a user.
-
#update_key(key_id, options = {}) ⇒ Hashie::Mash
Update a public key.
-
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user.
-
#user(user = nil) ⇒ Hashie::Mash
Get a single user.
-
#validate_credentials(options = {}) ⇒ Boolean
Validate user username and password.
-
#watched(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of repos watched by a user.
Instance Method Details
#add_email(email, options = {}) ⇒ Array<String>
Add email address to user.
Requires authenticated client.
294 295 296 |
# File 'lib/octokit/client/users.rb', line 294 def add_email(email, ={}) post("user/emails", .merge({:email => email})) end |
#add_key(title, key, options = {}) ⇒ Hashie::Mash
Add public key to user account.
Requires authenticated client.
237 238 239 |
# File 'lib/octokit/client/users.rb', line 237 def add_key(title, key, ={}) post("user/keys", .merge({:title => title, :key => key})) end |
#all_users(options = {}) ⇒ Array
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 |
#emails(options = {}) ⇒ Array<String>
List email addresses for a user.
Requires authenticated client.
280 281 282 |
# File 'lib/octokit/client/users.rb', line 280 def emails(={}) get("user/emails", ) end |
#follow(user, options = {}) ⇒ Boolean
Follow a user.
Requires authenticatied client.
128 129 130 |
# File 'lib/octokit/client/users.rb', line 128 def follow(user, ={}) boolean_from_response(:put, "user/following/#{user}", ) end |
#followers(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get a user’s followers.
85 86 87 |
# File 'lib/octokit/client/users.rb', line 85 def followers(user=login, ={}) get("users/#{user}/followers", ) end |
#following(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of users a user is following.
96 97 98 |
# File 'lib/octokit/client/users.rb', line 96 def following(user=login, ={}) get("users/#{user}/following", ) end |
#follows?(*args) ⇒ Boolean
Check if you are following a user.
Requries an authenticated client.
110 111 112 113 114 115 116 |
# File 'lib/octokit/client/users.rb', line 110 def follows?(*args) target = args.pop user = args.first user ||= login return if user.nil? boolean_from_response(:get, "user/following/#{target}") end |
#key(key_id, options = {}) ⇒ Hashie::Mash
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.
209 210 211 |
# File 'lib/octokit/client/users.rb', line 209 def key(key_id, ={}) get("user/keys/#{key_id}", ) end |
#keys(options = {}) ⇒ Array<Hashie::Mash>
Get list of public keys for user.
Requires authenticated client.
222 223 224 |
# File 'lib/octokit/client/users.rb', line 222 def keys(={}) get("user/keys", ) end |
#remove_email(email, options = {}) ⇒ Array<String>
Remove email from user.
Requires authenticated client.
308 309 310 |
# File 'lib/octokit/client/users.rb', line 308 def remove_email(email, ={}) boolean_from_response(:delete, "user/emails", .merge({:email => email})) end |
#remove_key(id, options = {}) ⇒ Boolean
Remove a public key from user account.
Requires authenticated client.
267 268 269 |
# File 'lib/octokit/client/users.rb', line 267 def remove_key(id, ={}) boolean_from_response(:delete, "user/keys/#{id}", ) end |
#search_users(search, options = {}) ⇒ Array<Hashie::Mash>
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 |
#starred(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of repos starred by a user.
153 154 155 |
# File 'lib/octokit/client/users.rb', line 153 def starred(user=login, ={}) get("users/#{user}/starred", ) end |
#starred?(user, repo, options = {}) ⇒ Boolean
Check if you are starring a repo.
Requires authenticated client.
168 169 170 |
# File 'lib/octokit/client/users.rb', line 168 def starred?(user, repo, ={}) boolean_from_response(:get, "user/starred/#{user}/#{repo}", ) end |
#subscriptions(user = login, options = {}) ⇒ Array<Hashie::Mashie>
List repositories being watched by a user.
322 323 324 |
# File 'lib/octokit/client/users.rb', line 322 def subscriptions(user=login, ={}) get("users/#{user}/subscriptions", ) end |
#unfollow(user, options = {}) ⇒ Boolean
Unfollow a user.
Requires authenticated client.
142 143 144 |
# File 'lib/octokit/client/users.rb', line 142 def unfollow(user, ={}) boolean_from_response(:delete, "user/following/#{user}", ) end |
#update_key(key_id, options = {}) ⇒ Hashie::Mash
Update a public key
Requires authenticated client
253 254 255 |
# File 'lib/octokit/client/users.rb', line 253 def update_key(key_id, ={}) patch("/user/keys/#{key_id}", ) end |
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user
74 75 76 |
# File 'lib/octokit/client/users.rb', line 74 def update_user() patch("user", ) end |
#user(user = nil) ⇒ Hashie::Mash
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 |
#validate_credentials(options = {}) ⇒ Boolean
Validate user username and password
53 54 55 56 57 58 59 |
# File 'lib/octokit/client/users.rb', line 53 def validate_credentials( = {}) begin !self.class.new().user.nil? rescue Octokit::Unauthorized false end end |
#watched(user = login, options = {}) ⇒ Array<Hashie::Mash>
Get list of repos watched by a user.
Legacy, using github.beta media type. Use ‘Users#starred` instead.
182 183 184 |
# File 'lib/octokit/client/users.rb', line 182 def watched(user=login, ={}) get("users/#{user}/watched", ) end |