Commit c7c4d657 authored by Stan Hu's avatar Stan Hu

Clean up Bitbucket connection based on review comments

parent 4d7303a9
module Bitbucket module Bitbucket
class Client class Client
def initialize(options = {}) def initialize(options = {})
@connection = options.fetch(:connection, Connection.new(options)) @connection = Connection.new(options)
end end
def issues(repo) def issues(repo)
......
...@@ -7,12 +7,12 @@ module Bitbucket ...@@ -7,12 +7,12 @@ module Bitbucket
def initialize(options = {}) def initialize(options = {})
@api_version = options.fetch(:api_version, DEFAULT_API_VERSION) @api_version = options.fetch(:api_version, DEFAULT_API_VERSION)
@base_uri = options.fetch(:base_uri, DEFAULT_BASE_URI) @base_uri = options.fetch(:base_uri, DEFAULT_BASE_URI)
@query = options.fetch(:query, DEFAULT_QUERY) @default_query = options.fetch(:query, DEFAULT_QUERY)
@token = options.fetch(:token) @token = options[:token]
@expires_at = options.fetch(:expires_at) @expires_at = options[:expires_at]
@expires_in = options.fetch(:expires_in) @expires_in = options[:expires_in]
@refresh_token = options.fetch(:refresh_token) @refresh_token = options[:refresh_token]
end end
def client def client
...@@ -24,13 +24,13 @@ module Bitbucket ...@@ -24,13 +24,13 @@ module Bitbucket
end end
def query(params = {}) def query(params = {})
@query.merge!(params) @default_query.merge!(params)
end end
def get(path, query = {}) def get(path, extra_query = {})
refresh! if expired? refresh! if expired?
response = connection.get(build_url(path), params: @query.merge(query)) response = connection.get(build_url(path), params: @default_query.merge(extra_query))
response.parsed response.parsed
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment