Class: Buckaruby::Configuration
- Inherits:
-
Object
- Object
- Buckaruby::Configuration
- Defined in:
- lib/buckaruby/configuration.rb
Overview
Configuration settings for the Buckaruby Gateway.
Constant Summary collapse
- TEST_URL =
'https://testcheckout.buckaroo.nl/nvp/'- LIVE_URL =
'https://checkout.buckaroo.nl/nvp/'
Instance Method Summary collapse
- #api_url ⇒ Object
-
#hash_method ⇒ Object
Use the hash method from options or default (SHA-1).
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
- #live? ⇒ Boolean
-
#logger ⇒ Object
Use the logger from either the options or the global config.
-
#open_timeout ⇒ Object
Returns the Net::HTTP open timeout value, fallback to global config.
-
#read_timeout ⇒ Object
Returns the Net::HTTP read timeout value, fallback to global config.
- #secret ⇒ Object
- #test? ⇒ Boolean
- #website ⇒ Object
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 |
# File 'lib/buckaruby/configuration.rb', line 9 def initialize() = end |
Instance Method Details
#api_url ⇒ Object
21 22 23 |
# File 'lib/buckaruby/configuration.rb', line 21 def api_url live? ? LIVE_URL : TEST_URL end |
#hash_method ⇒ Object
Use the hash method from options or default (SHA-1).
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/buckaruby/configuration.rb', line 44 def hash_method @hash_method ||= begin hash_method = ([:hash_method] || 'SHA1').downcase.to_sym unless [:sha1, :sha256, :sha512].include?(hash_method) raise ArgumentError, "Invalid hash method provided: #{hash_method} (expected :sha1, :sha256 or :sha512)" end hash_method end end |
#live? ⇒ Boolean
17 18 19 |
# File 'lib/buckaruby/configuration.rb', line 17 def live? !test? end |
#logger ⇒ Object
Use the logger from either the options or the global config.
57 58 59 |
# File 'lib/buckaruby/configuration.rb', line 57 def logger .fetch(:logger) { Buckaruby.config.logger } end |
#open_timeout ⇒ Object
Returns the Net::HTTP open timeout value, fallback to global config.
62 63 64 |
# File 'lib/buckaruby/configuration.rb', line 62 def open_timeout .fetch(:open_timeout) { Buckaruby.config.open_timeout } end |
#read_timeout ⇒ Object
Returns the Net::HTTP read timeout value, fallback to global config.
67 68 69 |
# File 'lib/buckaruby/configuration.rb', line 67 def read_timeout .fetch(:read_timeout) { Buckaruby.config.read_timeout } end |
#secret ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/buckaruby/configuration.rb', line 34 def secret @secret ||= begin secret = [:secret] raise ArgumentError, 'Missing required parameter: secret' if secret.to_s.empty? secret end end |
#test? ⇒ Boolean
13 14 15 |
# File 'lib/buckaruby/configuration.rb', line 13 def test? .fetch(:test, false) end |
#website ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/buckaruby/configuration.rb', line 25 def website @website ||= begin website = [:website] raise ArgumentError, 'Missing required parameter: website' if website.to_s.empty? website end end |