Class: BitBucket::User

Inherits:
API
  • Object
show all
Defined in:
lib/bitbucket_rest_api/user.rb

Constant Summary collapse

DEFAULT_USER_OPTIONS =
{
    "first_name"      => "",
    "last_name"       => "",
    "avatar"          => ""
    # TODO: can this filed be modified?
    # "resource_uri"    => ""
}.freeze

Constants included from Validations

Validations::VALID_API_KEYS

Constants included from Validations::Token

Validations::Token::TOKEN_REQUIRED, Validations::Token::TOKEN_REQUIRED_REGEXP

Constants included from Request

Request::METHODS, Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ALLOWED_OPTIONS

Constants included from Constants

Constants::ACCEPT, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::QUERY_STR_SEP, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT

Instance Method Summary collapse

Methods inherited from API

#_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, inherited, #method_missing, #process_basic_auth, #set_api_client, #setup, #update_and_validate_user_repo_params

Methods included from Normalizer

#normalize!

Methods included from ParameterFilter

#filter!

Methods included from AutoloadHelper

#autoload_all, #lookup_constant, #register_constant

Methods included from Validations::Required

#assert_required_keys, #assert_required_values_present, #parse_values

Methods included from Validations::Token

#validates_token_for

Methods included from Validations::Format

#assert_valid_values

Methods included from Validations::Presence

#_validate_presence_of, #_validate_user_repo_params

Methods included from Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request

Methods included from Connection

#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack

Methods included from Authorization

#authenticated?, #authentication, #basic_authed?

Constructor Details

#initialize(options = { }) ⇒ User

Creates new User API



16
17
18
# File 'lib/bitbucket_rest_api/user.rb', line 16

def initialize(options = { })
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BitBucket::API

Instance Method Details

#dashboardObject

GET the list of repositories on the dashboard Gets the repositories list from the account’s dashboard.



96
97
98
# File 'lib/bitbucket_rest_api/user.rb', line 96

def dashboard
  get_request("/1.0/user/repositories/dashboard")
end

#followsObject

GET a list of repositories an account follows Gets the details of the repositories that the individual or team account follows. This call returns the full data about the repositories including if the repository is a fork of another repository. An account always “follows” its own repositories.



68
69
70
# File 'lib/bitbucket_rest_api/user.rb', line 68

def follows
  get_request("/1.0/user/follows")
end

#overviewObject

GET a list of repositories the account is following Gets a list of the repositories the account follows. This is the same list that appears on the Following tab on your account dashboard.



88
89
90
# File 'lib/bitbucket_rest_api/user.rb', line 88

def overview
  get_request("/1.0/user/repositories/overview")
end

#privilegesObject

GET a list of user privileges



57
58
59
# File 'lib/bitbucket_rest_api/user.rb', line 57

def privileges
  get_request("/1.0/user/privileges")
end

#profileObject

Gets the basic information associated with an account and a list of all of the repositories owned by the user. See confluence.atlassian.com/display/BITBUCKET/user+Endpoint#userEndpoint-GETauserprofile

Examples

bitbucket = BitBucket.new
bitbucket.user_api.profile


28
29
30
# File 'lib/bitbucket_rest_api/user.rb', line 28

def profile
  get_request("/1.0/user")
end

#repositoriesObject Also known as: repos

GET a list of repositories visible to an account Gets the details of the repositories that the user owns or has at least read access to. Use this if you’re looking for a full list of all of the repositories associated with a user.



77
78
79
# File 'lib/bitbucket_rest_api/user.rb', line 77

def repositories
  get_request("/1.0/user/repositories")
end

#update(params = { }) ⇒ Object

Parameters

  • :first_name Optional string

  • :last_name Optional string

  • :avatar Optional string

  • :resource_uri Optional string

Examples

bitbucket = BitBucket.new
bitbucket.user_api.update :first_name => 'first-name', :last_name => 'last-name'


47
48
49
50
51
52
53
# File 'lib/bitbucket_rest_api/user.rb', line 47

def update( params={ })
  normalize! params
  filter! DEFAULT_USER_OPTIONS, params

  put_request("/1.0/user", DEFAULT_USER_OPTIONS.merge(params))

end