Module: Octokit::Client::Users
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/octokit/client/users.rb |
Overview
Methods for the Users
API
Instance Method Summary
-
#add_email(email, _options = {}) ⇒ Array<String>
Add email address to user.
-
#add_key(title, key, options = {}) ⇒ Sawyer::Resource
Add public key to user account.
-
#all_users(options = {}) ⇒ Array<Sawyer::Resource>
List all GitHub users.
-
#delete_user_migration_archive(id, options = {})
Deletes a previous migration archive.
-
#emails(options = {}) ⇒ Array<String>
List email addresses for a user.
-
#exchange_code_for_token(code, app_id = client_id, app_secret = client_secret, options = {}) ⇒ Sawyer::Resource
Retrieve the access_token.
-
#follow(user, options = {}) ⇒ Boolean
Follow a user.
-
#followers(user = login, options = {}) ⇒ Array<Sawyer::Resource>
Get a user's followers.
-
#following(user = login, options = {}) ⇒ Array<Sawyer::Resource>
Get list of users a user is following.
-
#follows?(target) ⇒ Boolean
Check if you are following a user.
-
#key(key_id, options = {}) ⇒ Sawyer::Resource
Get a public key.
-
#keys(options = {}) ⇒ Array<Sawyer::Resource>
Get list of public keys for user.
-
#remove_email(email) ⇒ Array<String>
Remove email from user.
-
#remove_key(id, options = {}) ⇒ Boolean
Remove a public key from user account.
-
#starred(user = login, options = {}) ⇒ Array<Sawyer::Resource>
Get list of repos starred by a user.
-
#starred?(repo, options = {}) ⇒ Boolean
Check if you are starring a repo.
-
#start_user_migration(repositories, options = {}) ⇒ Sawyer::Resource
Initiates the generation of a migration archive.
-
#subscriptions(user = login, options = {}) ⇒ Array<Sawyer::Resource>
(also: #watched)
List repositories being watched by a user.
-
#unfollow(user, options = {}) ⇒ Boolean
Unfollow a user.
-
#unlock_user_repository(id, repo, options = {})
Unlock a user repository which has been locked by a migration.
-
#update_key(key_id, options = {}) ⇒ Sawyer::Resource
deprecated
Deprecated.
This method is no longer supported in the API
-
#update_user(options) ⇒ Sawyer::Resource
Update the authenticated user.
-
#user(user = nil, options = {}) ⇒ Sawyer::Resource
Get a single user.
-
#user_keys(user, options = {}) ⇒ Array<Sawyer::Resource>
Get list of public keys for user.
-
#user_migration_archive_url(id, options = {})
Fetches the URL to a migration archive.
-
#user_migration_repositories(id, options = {})
List repositories for a user migration.
-
#user_migration_status(id, options = {})
Fetches the status of a migration.
-
#user_migrations(options = {}) ⇒ Array<Sawyer::Resource>
Lists the most recent migrations.
-
#validate_credentials(options = {}) ⇒ Boolean
Validate user username and password.
-
#watched(user = login, options = {})
Alias for #subscriptions.
Instance Method Details
#add_email(email, _options = {}) ⇒ Array
<String
>
Add email address to user.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 312
def add_email(email, = {}) email = Array(email) post 'user/emails', email end
#add_key(title, key, options = {}) ⇒ Sawyer::Resource
Add public key to user account.
Requires authenticated client.
#all_users(options = {}) ⇒ Array
<Sawyer::Resource
>
List all GitHub users
This provides a list of every user, in the order that they signed up for GitHub.
# File 'lib/octokit/client/users.rb', line 21
def all_users( = {}) paginate 'users', end
#delete_user_migration_archive(id, options = {})
Deletes a previous migration archive.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 402
def delete_user_migration_archive(id, = {}) = ensure_api_media_type(:migrations, ) delete "user/migrations/#{id}/archive", end
#emails(options = {}) ⇒ Array
<String
>
List email addresses for a user.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 299
def emails( = {}) paginate 'user/emails', end
#exchange_code_for_token(code, app_id = client_id, app_secret = client_secret, options = {}) ⇒ Sawyer::Resource
Retrieve the access_token.
# File 'lib/octokit/client/users.rb', line 46
def exchange_code_for_token(code, app_id = client_id, app_secret = client_secret, = {}) = .merge({ code: code, client_id: app_id, client_secret: app_secret, headers: { content_type: 'application/json', accept: 'application/json' } }) post "#{web_endpoint}login/oauth/access_token", end
#follow(user, options = {}) ⇒ Boolean
Follow a user.
Requires authenticatied client.
#followers(user = login, options = {}) ⇒ Array
<Sawyer::Resource
>
Get a user's followers.
#following(user = login, options = {}) ⇒ Array
<Sawyer::Resource
>
Get list of users a user is following.
#follows?(target) ⇒ Boolean
#follows?(user, target) ⇒ Boolean
Boolean
#follows?(user, target) ⇒ Boolean
Check if you are following a user. Alternatively, check if a given user is following a target user.
Requries an authenticated client.
#key(key_id, options = {}) ⇒ Sawyer::Resource
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.
# File 'lib/octokit/client/users.rb', line 217
def key(key_id, = {}) get "user/keys/#{key_id}", end
#keys(options = {}) ⇒ Array
<Sawyer::Resource
>
Get list of public keys for user.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 229
def keys( = {}) paginate 'user/keys', end
#remove_email(email) ⇒ Array
<String
>
Remove email from user.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 326
def remove_email(email) email = Array(email) boolean_from_response :delete, 'user/emails', email end
#remove_key(id, options = {}) ⇒ Boolean
Remove a public key from user account.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 287
def remove_key(id, = {}) boolean_from_response :delete, "user/keys/#{id}", end
#starred(user = login, options = {}) ⇒ Array
<Sawyer::Resource
>
Get list of repos starred by a user.
#starred?(repo, options = {}) ⇒ Boolean
Check if you are starring a repo.
Requires authenticated client.
# File 'lib/octokit/client/users.rb', line 190
def starred?(repo, = {}) boolean_from_response :get, "user/starred/#{Repository.new(repo)}", end
#start_user_migration(repositories, options = {}) ⇒ Sawyer::Resource
Initiates the generation of a migration archive.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 354
def start_user_migration(repositories, = {}) = ensure_api_media_type(:migrations, ) [:repositories] = repositories post 'user/migrations', end
#subscriptions(user = login, options = {}) ⇒ Array
<Sawyer::Resource
>
Also known as: #watched
List repositories being watched by a user.
#unfollow(user, options = {}) ⇒ Boolean
Unfollow a user.
Requires authenticated client.
#unlock_user_repository(id, repo, options = {})
Unlock a user repository which has been locked by a migration.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 425
def unlock_user_repository(id, repo, = {}) = ensure_api_media_type(:migrations, ) delete "user/migrations/#{id}/repos/#{repo}/lock", end
#update_key(key_id, options = {}) ⇒ Sawyer::Resource
This method is no longer supported in the API
Update a public key
Requires authenticated client
# File 'lib/octokit/client/users.rb', line 274
def update_key(key_id, = {}) patch "user/keys/#{key_id}", end
#update_user(options) ⇒ Sawyer::Resource
Update the authenticated user
# File 'lib/octokit/client/users.rb', line 86
def update_user( ) patch 'user', end
#user(user = nil, options = {}) ⇒ Sawyer::Resource
Get a single user
#user_keys(user, options = {}) ⇒ Array
<Sawyer::Resource
>
Get list of public keys for user.
#user_migration_archive_url(id, options = {})
Fetches the URL to a migration archive.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 388
def user_migration_archive_url(id, = {}) = ensure_api_media_type(:migrations, ) url = "user/migrations/#{id}/archive" response = client_without_redirects( ).get(url) response.headers['location'] end
#user_migration_repositories(id, options = {})
List repositories for a user migration.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 413
def user_migration_repositories(id, = {}) = ensure_api_media_type(:migrations, ) get "user/migrations/#{id}/repositories", end
#user_migration_status(id, options = {})
Fetches the status of a migration.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 377
def user_migration_status(id, = {}) = ensure_api_media_type(:migrations, ) get "user/migrations/#{id}", end
#user_migrations(options = {}) ⇒ Array
<Sawyer::Resource
>
Lists the most recent migrations.
Requires authenticated user.
# File 'lib/octokit/client/users.rb', line 366
def user_migrations( = {}) = ensure_api_media_type(:migrations, ) paginate 'user/migrations', end
#validate_credentials(options = {}) ⇒ Boolean
Validate user username and password
# File 'lib/octokit/client/users.rb', line 66
def validate_credentials( = {}) !self.class.new( ).user.nil? rescue Octokit::Unauthorized false end
#watched(user = login, options = {})
Alias for #subscriptions.
# File 'lib/octokit/client/users.rb', line 341
alias watched subscriptions