Class: ERPC::CloudClientConfig
- Inherits:
-
Object
- Object
- ERPC::CloudClientConfig
- Defined in:
- lib/erpc_sdk/config.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(access_token:, endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) ⇒ CloudClientConfig
constructor
A new instance of CloudClientConfig.
- #inspect ⇒ Object
Constructor Details
#initialize(access_token:, endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) ⇒ CloudClientConfig
Returns a new instance of CloudClientConfig.
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_token ⇒ Object (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 |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
82 83 84 |
# File 'lib/erpc_sdk/config.rb', line 82 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
82 83 84 |
# File 'lib/erpc_sdk/config.rb', line 82 def headers @headers end |
#timeout ⇒ Object (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
#inspect ⇒ Object
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 |