Class: ERPC::ClientConfig
- Inherits:
-
Object
- Object
- ERPC::ClientConfig
- Defined in:
- lib/erpc_sdk/config.rb
Instance Attribute Summary collapse
-
#account_endpoint ⇒ Object
readonly
Returns the value of attribute account_endpoint.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#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.
-
#user_endpoint ⇒ Object
readonly
Returns the value of attribute user_endpoint.
Instance Method Summary collapse
-
#initialize(api_key:, endpoint: DEFAULT_ENDPOINT, account_endpoint: DEFAULT_ACCOUNT_ENDPOINT, user_endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) ⇒ ClientConfig
constructor
A new instance of ClientConfig.
- #inspect ⇒ Object
Constructor Details
#initialize(api_key:, endpoint: DEFAULT_ENDPOINT, account_endpoint: DEFAULT_ACCOUNT_ENDPOINT, user_endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) ⇒ ClientConfig
Returns a new instance of ClientConfig.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/erpc_sdk/config.rb', line 61 def initialize(api_key:, endpoint: DEFAULT_ENDPOINT, account_endpoint: DEFAULT_ACCOUNT_ENDPOINT, user_endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT) @api_key = api_key.to_s.strip raise ConfigError, "api_key must not be empty" if @api_key.empty? raise ConfigError, "timeout must be positive" unless timeout.is_a?(Numeric) && timeout.finite? && timeout.positive? @endpoint = URLs.normalize_endpoint(endpoint) @account_endpoint = URLs.normalize_endpoint(account_endpoint) @user_endpoint = URLs.normalize_endpoint(user_endpoint) @headers = headers.to_h.transform_keys(&:to_s).transform_values(&:to_s).freeze @timeout = timeout.to_f end |
Instance Attribute Details
#account_endpoint ⇒ Object (readonly)
Returns the value of attribute account_endpoint.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def account_endpoint @account_endpoint end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def api_key @api_key end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def headers @headers end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def timeout @timeout end |
#user_endpoint ⇒ Object (readonly)
Returns the value of attribute user_endpoint.
59 60 61 |
# File 'lib/erpc_sdk/config.rb', line 59 def user_endpoint @user_endpoint end |
Instance Method Details
#inspect ⇒ Object
74 75 76 77 78 |
# File 'lib/erpc_sdk/config.rb', line 74 def inspect "#<#{self.class} api_key=[REDACTED] endpoint=#{endpoint.inspect} " \ "account_endpoint=#{account_endpoint.inspect} user_endpoint=#{user_endpoint.inspect} " \ "header_names=#{headers.keys.inspect} timeout=#{timeout.inspect}>" end |