Module: GitHub::Client::Users
- Included in:
- GitHub::Client
- Defined in:
- lib/github_api_v3/client/users.rb
Overview
Contains methods for the Users API.
Instance Method Summary collapse
-
#create_key(title, key) ⇒ Hash
Create a public key.
-
#delete_key(id) ⇒ Boolean
Remove a public key from a user’s account.
-
#emails ⇒ Array
Get all emails for an authenticated user.
-
#follow(username) ⇒ Boolean
Follow a user.
-
#followers(username = nil) ⇒ Array
List a user’s followers.
-
#following(username) ⇒ Array
List users who a specific user is following.
-
#following?(username) ⇒ Boolean
Check if an authenticated user is following another user.
-
#follows?(username, target_username) ⇒ Boolean
Checks to see if a user is following another user.
-
#key(id) ⇒ Hash
Get a public key.
-
#keys(username = nil) ⇒ Array
Get a list of public keys for a user.
-
#notifications(options = {}) ⇒ Array
List notifications.
-
#organizations(username = nil) ⇒ Array
List public organizations for a user.
-
#rate_limit ⇒ Hash
Get the current client’s rate limit info.
-
#repo_notifications(owner, repo, options = {}) ⇒ Array
List notifications for a repository.
-
#starring(username = nil) ⇒ Array
List repositories a user is starring.
-
#starring?(owner, repo) ⇒ Boolean
Check if you are starring a repository.
-
#unfollow(username) ⇒ Boolean
Unfollow a user.
-
#update_key(id, title, key) ⇒ Hash
Update a public key.
-
#user(username = nil) ⇒ Hash
Returns a single user.
-
#users ⇒ Array
Returns a list of all GitHub users.
-
#watching(username = nil) ⇒ Array
List repositories a user is watching.
Instance Method Details
#create_key(title, key) ⇒ Hash
Create a public key.
Requires authentication.
168 169 170 |
# File 'lib/github_api_v3/client/users.rb', line 168 def create_key(title, key) post '/user/keys', body: {title: title, key: key} end |
#delete_key(id) ⇒ Boolean
Remove a public key from a user’s account.
Requires authentication.
195 196 197 |
# File 'lib/github_api_v3/client/users.rb', line 195 def delete_key(id) boolean_request :delete, "/user/keys/#{id}" end |
#emails ⇒ Array
Get all emails for an authenticated user.
43 44 45 |
# File 'lib/github_api_v3/client/users.rb', line 43 def emails get '/user/emails' end |
#follow(username) ⇒ Boolean
Follow a user.
Requires authentication.
56 57 58 |
# File 'lib/github_api_v3/client/users.rb', line 56 def follow(username) boolean_request :put, "/user/following/#{username}" end |
#followers(username = nil) ⇒ Array
List a user’s followers.
If username is left blank, returns the currently authenticated user’s list of followers.
85 86 87 88 89 90 91 |
# File 'lib/github_api_v3/client/users.rb', line 85 def followers(username=nil) if username get "/users/#{username}/followers" else get '/user/followers' end end |
#following(username) ⇒ Array
List users who a specific user is following.
100 101 102 |
# File 'lib/github_api_v3/client/users.rb', line 100 def following(username) get "/users/#{username}/following" end |
#following?(username) ⇒ Boolean
Check if an authenticated user is following another user.
Requires the user to be authenticated.
112 113 114 |
# File 'lib/github_api_v3/client/users.rb', line 112 def following?(username) boolean_request :get, "/user/following/#{username}" end |
#follows?(username, target_username) ⇒ Boolean
Checks to see if a user is following another user.
68 69 70 |
# File 'lib/github_api_v3/client/users.rb', line 68 def follows?(username, target_username) boolean_request :get, "/users/#{username}/following/#{target_username}" end |
#key(id) ⇒ Hash
Get a public key.
Requires authentication.
154 155 156 |
# File 'lib/github_api_v3/client/users.rb', line 154 def key(id) get "/user/keys/#{id}" end |
#keys(username = nil) ⇒ Array
Get a list of public keys for a user.
If username left blank, get currently authenticated user’s keys.
138 139 140 141 142 143 144 |
# File 'lib/github_api_v3/client/users.rb', line 138 def keys(username=nil) if username get "/users/#{username}/keys" else get '/user/keys' end end |
#notifications(options = {}) ⇒ Array
List notifications.
Requires authentication.
211 212 213 |
# File 'lib/github_api_v3/client/users.rb', line 211 def notifications(={}) get "/notifications", params: end |
#organizations(username = nil) ⇒ Array
List public organizations for a user.
292 293 294 295 296 297 298 |
# File 'lib/github_api_v3/client/users.rb', line 292 def organizations(username=nil) if username get "/users/#{username}/orgs" else get "/user/orgs" end end |
#rate_limit ⇒ Hash
Get the current client’s rate limit info.
308 309 310 |
# File 'lib/github_api_v3/client/users.rb', line 308 def rate_limit get "/rate_limit" end |
#repo_notifications(owner, repo, options = {}) ⇒ Array
List notifications for a repository.
Requires authentication.
229 230 231 |
# File 'lib/github_api_v3/client/users.rb', line 229 def repo_notifications(owner, repo, ={}) get "/repos/#{owner}/#{repo}/notifications" end |
#starring(username = nil) ⇒ Array
List repositories a user is starring.
Can be used unauthenticated or authenticated.
244 245 246 247 248 249 250 |
# File 'lib/github_api_v3/client/users.rb', line 244 def starring(username=nil) if username get "/users/#{username}/starred" else get "/user/starred" end end |
#starring?(owner, repo) ⇒ Boolean
Check if you are starring a repository.
Requires authentication.
262 263 264 |
# File 'lib/github_api_v3/client/users.rb', line 262 def starring?(owner, repo) boolean_request :get, "/user/starred/#{owner}/#{repo}" end |
#unfollow(username) ⇒ Boolean
Unfollow a user.
Requires authentication.
124 125 126 |
# File 'lib/github_api_v3/client/users.rb', line 124 def unfollow(username) boolean_request :delete, "/user/following/#{username}" end |
#update_key(id, title, key) ⇒ Hash
Update a public key
Requires authentication.
183 184 185 |
# File 'lib/github_api_v3/client/users.rb', line 183 def update_key(id, title, key) patch "/user/keys/#{id}", body: {title: title, key: key} end |
#user(username = nil) ⇒ Hash
Returns a single user.
If called without the username parameter, it will return the currently authenticated user.
20 21 22 23 24 25 26 |
# File 'lib/github_api_v3/client/users.rb', line 20 def user(username=nil) if username get "/users/#{username}" else get '/user' end end |
#users ⇒ Array
Returns a list of all GitHub users.
32 33 34 |
# File 'lib/github_api_v3/client/users.rb', line 32 def users get '/users' end |
#watching(username = nil) ⇒ Array
List repositories a user is watching.
275 276 277 278 279 280 281 |
# File 'lib/github_api_v3/client/users.rb', line 275 def watching(username=nil) if username get "/users/#{username}/subscriptions" else get "/user/subscriptions" end end |