Class: Connectors::GitLab::CustomClient

Inherits:
Base::CustomClient show all
Defined in:
lib/connectors/gitlab/custom_client.rb

Defined Under Namespace

Classes: ClientError

Constant Summary

Constants inherited from Base::CustomClient

Base::CustomClient::MAX_RETRIES

Instance Attribute Summary collapse

Attributes inherited from Base::CustomClient

#base_url, #ensure_fresh_auth, #middleware

Instance Method Summary collapse

Methods inherited from Base::CustomClient

#default_middleware, #http_client, #http_client!, #middleware!, #retry_config

Constructor Details

#initialize(base_url:, api_token:, ensure_fresh_auth: nil) ⇒ CustomClient

Returns a new instance of CustomClient.



30
31
32
33
# File 'lib/connectors/gitlab/custom_client.rb', line 30

def initialize(base_url:, api_token:, ensure_fresh_auth: nil)
  @api_token = api_token
  super(:base_url => base_url || DEFAULT_BASE_URL, :ensure_fresh_auth => ensure_fresh_auth)
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



19
20
21
# File 'lib/connectors/gitlab/custom_client.rb', line 19

def api_token
  @api_token
end

Instance Method Details

#additional_middlewareObject



35
36
37
38
39
40
41
# File 'lib/connectors/gitlab/custom_client.rb', line 35

def additional_middleware
  [
    ::FaradayMiddleware::FollowRedirects,
    [Utility::Middleware::RestrictHostnames, { :allowed_hosts => [base_url, DEFAULT_BASE_URL] }],
    [Utility::Middleware::BearerAuth, { :bearer_auth_token => api_token }]
  ]
end