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
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fat_zebra/config.rb', line 48 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.
39 40 41 |
# File 'lib/fat_zebra/config.rb', line 39 def api_version @api_version end |
#gateway ⇒ String
Returns Gateway url.
27 28 29 |
# File 'lib/fat_zebra/config.rb', line 27 def gateway @gateway end |
#global_options ⇒ String
Returns global request options.
43 44 45 |
# File 'lib/fat_zebra/config.rb', line 43 def @global_options end |
#http_secure ⇒ String
Returns http secure.
35 36 37 |
# File 'lib/fat_zebra/config.rb', line 35 def http_secure @http_secure end |
#proxy ⇒ String
Returns Proxy url.
31 32 33 |
# File 'lib/fat_zebra/config.rb', line 31 def proxy @proxy end |
#test_mode ⇒ String
Returns Test mode.
23 24 25 |
# File 'lib/fat_zebra/config.rb', line 23 def test_mode @test_mode end |
#token ⇒ String
Returns Token.
19 20 21 |
# File 'lib/fat_zebra/config.rb', line 19 def token @token end |
#username ⇒ String
Returns Username.
15 16 17 |
# File 'lib/fat_zebra/config.rb', line 15 def username @username end |
Instance Method Details
#valid! ⇒ Boolean
validate the configuration Raise when configuration is not valid Remove “http://” or “https://” from urls
67 68 69 70 71 72 73 74 75 |
# File 'lib/fat_zebra/config.rb', line 67 def valid! format! %i[username token gateway api_version].each do |field| validate_presence(field) end true end |