Class: Elements::ElementsConfiguration
- Inherits:
-
Object
- Object
- Elements::ElementsConfiguration
- Defined in:
- lib/elements/elements_configuration.rb
Overview
Configurations:
api_base: The base URL of the Elements API, see elements-pay.readme.io/reference/set-up-elements.
api_key: The client token required to execute requests, see elements-pay.readme.io/reference/fetch-client-token.
max_network_retries, min_network_retry_delay, max_network_retry_delay: The client has the ability to perform automatic retries with exponential backoff, you may configure how the client retries with these variables, setting max_network_retries to 0 disable retries.
ssl_ca_file: The location of a file containing a bundle of CA certificates, the library included one under lib/elements/certs and will use that as default.
ssl_verify_certs: You may disable SSL verification by setting this to false.
logger: When set, the library will log execution information to the prompt location. You may change the verbosity by supplying a log_level config.
Constant Summary collapse
- SANDBOX_URL =
'https://api.elements-sandbox.io'
- PRODUCTION_URL =
'https://api.elements.io'
Instance Attribute Summary collapse
-
#api_base ⇒ Object
Returns the value of attribute api_base.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_network_retries ⇒ Object
Returns the value of attribute max_network_retries.
-
#max_network_retry_delay ⇒ Object
Returns the value of attribute max_network_retry_delay.
-
#min_network_retry_delay ⇒ Object
Returns the value of attribute min_network_retry_delay.
-
#ssl_ca_file ⇒ Object
Returns the value of attribute ssl_ca_file.
-
#ssl_verify_certs ⇒ Object
Returns the value of attribute ssl_verify_certs.
Instance Method Summary collapse
-
#initialize ⇒ ElementsConfiguration
constructor
A new instance of ElementsConfiguration.
- #reverse_duplicate_merge(hash) ⇒ Object
Constructor Details
#initialize ⇒ ElementsConfiguration
Returns a new instance of ElementsConfiguration.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/elements/elements_configuration.rb', line 30 def initialize @api_base = PRODUCTION_URL # disable log by default @logger = Logger.new('/dev/null') @log_level = Logger::DEBUG @max_network_retries = 0 @min_network_retry_delay = 0.5 @max_network_retry_delay = 2.0 @ssl_verify_certs = true @ssl_ca_file = File.('certs/cacert.pem', __dir__) end |
Instance Attribute Details
#api_base ⇒ Object
Returns the value of attribute api_base.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def api_base @api_base end |
#api_key ⇒ Object
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def api_key @api_key end |
#log_level ⇒ Object
Returns the value of attribute log_level.
25 26 27 |
# File 'lib/elements/elements_configuration.rb', line 25 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def logger @logger end |
#max_network_retries ⇒ Object
Returns the value of attribute max_network_retries.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def max_network_retries @max_network_retries end |
#max_network_retry_delay ⇒ Object
Returns the value of attribute max_network_retry_delay.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def max_network_retry_delay @max_network_retry_delay end |
#min_network_retry_delay ⇒ Object
Returns the value of attribute min_network_retry_delay.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def min_network_retry_delay @min_network_retry_delay end |
#ssl_ca_file ⇒ Object
Returns the value of attribute ssl_ca_file.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def ssl_ca_file @ssl_ca_file end |
#ssl_verify_certs ⇒ Object
Returns the value of attribute ssl_verify_certs.
23 24 25 |
# File 'lib/elements/elements_configuration.rb', line 23 def ssl_verify_certs @ssl_verify_certs end |
Instance Method Details
#reverse_duplicate_merge(hash) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/elements/elements_configuration.rb', line 62 def reverse_duplicate_merge(hash) dup.tap do |instance| hash.each do |option, value| instance.public_send("#{option}=", value) end end end |