Class: Bitbucket::ApiConnection

Inherits:
Object
  • Object
show all
Includes:
ExponentialBackoff
Defined in:
lib/bitbucket/api_connection.rb

Constant Summary

Constants included from ExponentialBackoff

ExponentialBackoff::EXPONENTIAL_BASE, ExponentialBackoff::INITIAL_DELAY, ExponentialBackoff::MAX_RETRIES, ExponentialBackoff::RateLimitError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ExponentialBackoff

#retry_with_exponential_backoff

Constructor Details

#initialize(options = {}) ⇒ ApiConnection

Returns a new instance of ApiConnection.



9
10
11
12
13
14
15
16
17
18
# File 'lib/bitbucket/api_connection.rb', line 9

def initialize(options = {})
  @api_version = options.fetch(:api_version, Bitbucket::Connection::DEFAULT_API_VERSION)
  @base_uri = options.fetch(:base_uri, Bitbucket::Connection::DEFAULT_BASE_URI)
  @default_query = options.fetch(:query, Bitbucket::Connection::DEFAULT_QUERY)

  @username = options[:username]
  @app_password = options[:app_password]
  @email = options[:email]
  @api_token = options[:api_token]
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



7
8
9
# File 'lib/bitbucket/api_connection.rb', line 7

def api_token
  @api_token
end

#app_passwordObject (readonly)

Returns the value of attribute app_password.



7
8
9
# File 'lib/bitbucket/api_connection.rb', line 7

def app_password
  @app_password
end

#emailObject (readonly)

Returns the value of attribute email.



7
8
9
# File 'lib/bitbucket/api_connection.rb', line 7

def email
  @email
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/bitbucket/api_connection.rb', line 7

def username
  @username
end

Instance Method Details

#get(path, extra_query = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/bitbucket/api_connection.rb', line 20

def get(path, extra_query = {})
  response = retry_with_exponential_backoff do
    Import::Clients::HTTP.get(build_url(path), basic_auth: basic_auth, headers: headers, query: extra_query)
  end

  response.parsed_response
end