Class: FatZebra::Config
- Inherits:
-
Object
- Object
- FatZebra::Config
- Defined in:
- lib/fat_zebra/config.rb
Overview
FatZebra Config
Represent the FatZebra configuration for the API
Constant Summary collapse
- GATEWAY_URLS =
{ production: 'gateway.fatzebra.com.au', sandbox: 'gateway.sandbox.fatzebra.com.au' }.freeze
Instance Attribute Summary collapse
-
#api_version ⇒ String
Api version.
-
#gateway ⇒ String
Gateway url.
-
#global_options ⇒ String
Global request options.
-
#http_secure ⇒ String
Http secure.
-
#proxy ⇒ String
Proxy url.
-
#test_mode ⇒ String
Test mode.
-
#token ⇒ String
Token.
-
#username ⇒ String
Username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Initialize and validate the configuration.
-
#valid! ⇒ Boolean
validate the configuration Raise when configuration is not valid Remove “http://” or “https://” from urls.
Constructor Details
#initialize(options = {}) ⇒ Config
Initialize and validate the configuration
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fat_zebra/config.rb', line 50 def initialize( = {}) self.token = [:token] self.username = [:username] self.gateway = [:gateway] || :production self.test_mode = [:test_mode] || false self.http_secure = [:http_secure] || true self.api_version = [:api_version] || 'v1.0' self.proxy = [:proxy] self. = [:global_options] || {} valid! unless .empty? end |
Instance Attribute Details
#api_version ⇒ String
Returns api version.
41 42 43 |
# File 'lib/fat_zebra/config.rb', line 41 def api_version @api_version end |
#gateway ⇒ String
Returns Gateway url.
29 30 31 |
# File 'lib/fat_zebra/config.rb', line 29 def gateway @gateway end |
#global_options ⇒ String
Returns global request options.
45 46 47 |
# File 'lib/fat_zebra/config.rb', line 45 def @global_options end |
#http_secure ⇒ String
Returns http secure.
37 38 39 |
# File 'lib/fat_zebra/config.rb', line 37 def http_secure @http_secure end |
#proxy ⇒ String
Returns Proxy url.
33 34 35 |
# File 'lib/fat_zebra/config.rb', line 33 def proxy @proxy end |
#test_mode ⇒ String
Returns Test mode.
25 26 27 |
# File 'lib/fat_zebra/config.rb', line 25 def test_mode @test_mode end |
#token ⇒ String
Returns Token.
21 22 23 |
# File 'lib/fat_zebra/config.rb', line 21 def token @token end |
#username ⇒ String
Returns Username.
17 18 19 |
# File 'lib/fat_zebra/config.rb', line 17 def username @username end |
Instance Method Details
#valid! ⇒ Boolean
validate the configuration Raise when configuration is not valid Remove “http://” or “https://” from urls
69 70 71 72 73 74 75 76 77 |
# File 'lib/fat_zebra/config.rb', line 69 def valid! format! %i[username token gateway api_version].each do |field| validate_presence(field) end true end |