Class: Chip::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/chip/configuration.rb

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Instance Method Summary collapse

Methods inherited from Common::Client::Configuration::Base

#base_path, #breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception

Instance Method Details

#connectionFaraday::Connection

Creates a Faraday connection with middleware for mapping errors, and adding breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chip/configuration.rb', line 37

def connection
  @conn ||= Faraday.new(url:) do |faraday|
    faraday.use :breakers
    faraday.request :json

    faraday.response :chip_error
    faraday.response :betamocks if settings.mock

    faraday.adapter Faraday.default_adapter
  end
end

#service_nameString

Returns service name.

Returns:

  • (String)

    service name



19
20
21
# File 'lib/chip/configuration.rb', line 19

def service_name
  'Chip'
end

#settingsConfig::Options

Returns Chip settings object.

Returns:

  • (Config::Options)

    Chip settings object



10
11
12
# File 'lib/chip/configuration.rb', line 10

def settings
  Settings.chip
end

#valid_tenant?(tenant_name:, tenant_id:) ⇒ Boolean

Validate that the tenant_id matches the tenant_name

Returns:

  • (Boolean)


28
29
30
# File 'lib/chip/configuration.rb', line 28

def valid_tenant?(tenant_name:, tenant_id:)
  settings[tenant_name]&.tenant_id == tenant_id
end