Class: Airwallex::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/airwallex/configuration.rb

Constant Summary collapse

ENVIRONMENTS =
{
  demo: "https://api-demo.airwallex.com/api/v1",
  production: "https://api.airwallex.com/api/v1"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
17
18
# File 'lib/airwallex/configuration.rb', line 13

def initialize
  @environment = :demo
  @timeout = 30
  @open_timeout = 10
  @logger = nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def api_key
  @api_key
end

#client_idObject

Returns the value of attribute client_id.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def client_id
  @client_id
end

#environmentObject

Returns the value of attribute environment.



11
12
13
# File 'lib/airwallex/configuration.rb', line 11

def environment
  @environment
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def logger
  @logger
end

#login_asObject

Returns the value of attribute login_as.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def 
  @login_as
end

#open_timeoutObject

Returns the value of attribute open_timeout.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def open_timeout
  @open_timeout
end

#timeoutObject

Returns the value of attribute timeout.



10
11
12
# File 'lib/airwallex/configuration.rb', line 10

def timeout
  @timeout
end

Class Method Details

.validate_environment!(environment) ⇒ Object

Raises:



31
32
33
34
35
36
# File 'lib/airwallex/configuration.rb', line 31

def self.validate_environment!(environment)
  return environment if ENVIRONMENTS.key?(environment)

  valid = ENVIRONMENTS.keys.map(&:inspect).join(", ")
  raise ConfigurationError, "Invalid environment: #{environment.inspect}. Valid environments are: #{valid}"
end

Instance Method Details

#base_urlObject Also known as: api_base_url



25
26
27
# File 'lib/airwallex/configuration.rb', line 25

def base_url
  ENVIRONMENTS.fetch(environment)
end