Class: FatZebra::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/fat_zebra/config.rb

Overview

FatZebra Config

Represent the FatZebra configuration for the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Initialize and validate the configuration

Parameters:

  • (Hash{Symbol=>Object})


47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fat_zebra/config.rb', line 47

def initialize(options = {})
  self.token       = options[:token]
  self.username    = options[:username]
  self.gateway     = options[:gateway] || 'gateway.fatzebra.com.au'
  self.test_mode   = options[:test_mode] || false
  self.http_secure = options[:http_secure] || true
  self.api_version = options[:api_version] || 'v1.0'
  self.sandbox     = options[:sandbox]
  self.options     = options[:options]
  self.proxy       = options[:proxy]
end

Instance Attribute Details

#api_versionString

Returns api version.

Returns:

  • (String)

    api version



42
43
44
# File 'lib/fat_zebra/config.rb', line 42

def api_version
  @api_version
end

#gatewayString

Returns Gateway url.

Returns:

  • (String)

    Gateway url



30
31
32
# File 'lib/fat_zebra/config.rb', line 30

def gateway
  @gateway
end

#http_secureString

Returns http secure.

Returns:

  • (String)

    http secure



38
39
40
# File 'lib/fat_zebra/config.rb', line 38

def http_secure
  @http_secure
end

#optionsString

Returns Options.

Returns:

  • (String)

    Options



26
27
28
# File 'lib/fat_zebra/config.rb', line 26

def options
  @options
end

#proxyString

Returns Proxy url.

Returns:

  • (String)

    Proxy url



34
35
36
# File 'lib/fat_zebra/config.rb', line 34

def proxy
  @proxy
end

#sandboxString

Returns Sandbox.

Returns:

  • (String)

    Sandbox



22
23
24
# File 'lib/fat_zebra/config.rb', line 22

def sandbox
  @sandbox
end

#test_modeString

Returns Test mode.

Returns:

  • (String)

    Test mode



18
19
20
# File 'lib/fat_zebra/config.rb', line 18

def test_mode
  @test_mode
end

#tokenString

Returns Token.

Returns:

  • (String)

    Token



14
15
16
# File 'lib/fat_zebra/config.rb', line 14

def token
  @token
end

#usernameString

Returns Username.

Returns:

  • (String)

    Username



10
11
12
# File 'lib/fat_zebra/config.rb', line 10

def username
  @username
end

Instance Method Details

#valid!Boolean

validate the configuration Raise when configuration is not valid

Returns:

  • (Boolean)

    true



63
64
65
66
67
68
69
# File 'lib/fat_zebra/config.rb', line 63

def valid!
  %i[username token].each do |field|
    validate_presence(field)
  end

  true
end