Module: Smplkit::Account

Defined in:
lib/smplkit/account/client.rb,
lib/smplkit/account/models.rb

Defined Under Namespace

Classes: AccountClient, AccountSettings, SettingsClient

Class Method Summary collapse

Class Method Details

.resolve_account_target(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Resolve the (app_base_url, api_key, extra_headers) for the settings client.

base_url/api_key are used directly when both are supplied (the path the top-level client takes after it has already resolved them); otherwise the config resolver fills in whatever is missing.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/smplkit/account/client.rb', line 15

def self.(api_key:, base_url:, profile:, base_domain:, scheme:, debug:, extra_headers:)
  cfg = ConfigResolution.resolve_client_config(
    profile: profile, api_key: api_key, base_domain: base_domain, scheme: scheme, debug: debug
  )
  resolved_key = api_key.nil? ? cfg.api_key : api_key
  app_url = base_url.nil? ? ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain) : base_url
  headers = {}
  headers.merge!(cfg.extra_headers || {})
  headers.merge!(extra_headers || {})
  [app_url.sub(%r{/+\z}, ""), resolved_key, headers]
end