Class: ERPC::CloudClientConfig

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) ⇒ CloudClientConfig

Returns a new instance of CloudClientConfig.

Raises:



84
85
86
87
88
89
90
91
92
# File 'lib/erpc_sdk/config.rb', line 84

def initialize(access_token:, endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT)
  @access_token = access_token.to_s.strip
  raise ConfigError, "access_token must not be empty" if @access_token.empty?
  raise ConfigError, "timeout must be positive" unless timeout.is_a?(Numeric) && timeout.finite? && timeout.positive?

  @endpoint = URLs.normalize_endpoint(endpoint, local_http_only: true)
  @headers = headers.to_h.transform_keys(&:to_s).transform_values(&:to_s).freeze
  @timeout = timeout.to_f
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



82
83
84
# File 'lib/erpc_sdk/config.rb', line 82

def access_token
  @access_token
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



82
83
84
# File 'lib/erpc_sdk/config.rb', line 82

def endpoint
  @endpoint
end

#headersObject (readonly)

Returns the value of attribute headers.



82
83
84
# File 'lib/erpc_sdk/config.rb', line 82

def headers
  @headers
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



82
83
84
# File 'lib/erpc_sdk/config.rb', line 82

def timeout
  @timeout
end

Instance Method Details

#inspectObject



94
95
96
97
# File 'lib/erpc_sdk/config.rb', line 94

def inspect
  "#<#{self.class} access_token=[REDACTED] endpoint=#{endpoint.inspect} " \
    "header_names=#{headers.keys.inspect} timeout=#{timeout.inspect}>"
end