Class: LetMeSendEmail::Config
- Inherits:
-
Object
- Object
- LetMeSendEmail::Config
- Defined in:
- lib/letmesendemail/config.rb
Overview
Validated client configuration.
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://letmesend.email/api/v1'- DEFAULT_TIMEOUT_MS =
30_000- DEFAULT_RETRIES =
0- MAX_RETRIES =
20
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#retries ⇒ Object
Returns the value of attribute retries.
-
#timeout_ms ⇒ Object
Returns the value of attribute timeout_ms.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Config
constructor
A new instance of Config.
-
#validate! ⇒ self
Validates and normalizes configuration before use.
Constructor Details
#initialize(api_key) ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 |
# File 'lib/letmesendemail/config.rb', line 17 def initialize(api_key) @api_key = api_key @base_url = DEFAULT_BASE_URL @timeout_ms = DEFAULT_TIMEOUT_MS @retries = DEFAULT_RETRIES end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/letmesendemail/config.rb', line 14 def api_key @api_key end |
#base_url ⇒ Object
Returns the value of attribute base_url.
13 14 15 |
# File 'lib/letmesendemail/config.rb', line 13 def base_url @base_url end |
#retries ⇒ Object
Returns the value of attribute retries.
14 15 16 |
# File 'lib/letmesendemail/config.rb', line 14 def retries @retries end |
#timeout_ms ⇒ Object
Returns the value of attribute timeout_ms.
14 15 16 |
# File 'lib/letmesendemail/config.rb', line 14 def timeout_ms @timeout_ms end |
Instance Method Details
#validate! ⇒ self
Validates and normalizes configuration before use.
33 34 35 36 37 38 39 40 41 |
# File 'lib/letmesendemail/config.rb', line 33 def validate! validate_api_key! validate_base_url! validate_timeout! validate_retries! @api_key = api_key.dup.freeze @base_url = base_url.dup.freeze self end |