Class: Finlight::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/finlight/config.rb

Overview

Connection settings shared by the REST and WebSocket clients.

Constant Summary collapse

DEFAULT_BASE_URL =
"https://api.finlight.me"
DEFAULT_WSS_URL =
"wss://wss.finlight.me"
DEFAULT_TIMEOUT =
5
DEFAULT_RETRY_COUNT =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: DEFAULT_BASE_URL, wss_url: DEFAULT_WSS_URL, timeout: DEFAULT_TIMEOUT, retry_count: DEFAULT_RETRY_COUNT) ⇒ Config

Returns a new instance of Config.

Parameters:

  • api_key (String)

    your finlight API key

  • base_url (String) (defaults to: DEFAULT_BASE_URL)

    REST endpoint

  • wss_url (String) (defaults to: DEFAULT_WSS_URL)

    WebSocket endpoint

  • timeout (Numeric) (defaults to: DEFAULT_TIMEOUT)

    per-request and connect timeout in seconds

  • retry_count (Integer) (defaults to: DEFAULT_RETRY_COUNT)

    total attempts for retryable failures (429/5xx)

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
# File 'lib/finlight/config.rb', line 18

def initialize(api_key:, base_url: DEFAULT_BASE_URL, wss_url: DEFAULT_WSS_URL,
               timeout: DEFAULT_TIMEOUT, retry_count: DEFAULT_RETRY_COUNT)
  raise ArgumentError, "api_key is required" if api_key.nil? || api_key.to_s.empty?

  @api_key = api_key
  @base_url = base_url.chomp("/")
  @wss_url = wss_url.chomp("/")
  @timeout = timeout
  @retry_count = retry_count
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



11
12
13
# File 'lib/finlight/config.rb', line 11

def api_key
  @api_key
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



11
12
13
# File 'lib/finlight/config.rb', line 11

def base_url
  @base_url
end

#retry_countObject (readonly)

Returns the value of attribute retry_count.



11
12
13
# File 'lib/finlight/config.rb', line 11

def retry_count
  @retry_count
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



11
12
13
# File 'lib/finlight/config.rb', line 11

def timeout
  @timeout
end

#wss_urlObject (readonly)

Returns the value of attribute wss_url.



11
12
13
# File 'lib/finlight/config.rb', line 11

def wss_url
  @wss_url
end