Class: Airwallex::Configuration
- Inherits:
-
Object
- Object
- Airwallex::Configuration
- Defined in:
- lib/airwallex/configuration.rb
Constant Summary collapse
- SANDBOX_API_URL =
"https://api-demo.airwallex.com"- PRODUCTION_API_URL =
"https://api.airwallex.com"- SANDBOX_FILES_URL =
"https://files-demo.airwallex.com"- PRODUCTION_FILES_URL =
"https://files.airwallex.com"- DEFAULT_API_VERSION =
"2024-09-27"- VALID_ENVIRONMENTS =
%i[sandbox production].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #api_url ⇒ Object
- #configured? ⇒ Boolean
- #files_url ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 |
# File 'lib/airwallex/configuration.rb', line 16 def initialize @environment = :sandbox @api_version = DEFAULT_API_VERSION @log_level = :info end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/airwallex/configuration.rb', line 5 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
5 6 7 |
# File 'lib/airwallex/configuration.rb', line 5 def api_version @api_version end |
#client_id ⇒ Object
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/airwallex/configuration.rb', line 5 def client_id @client_id end |
#environment ⇒ Object
Returns the value of attribute environment.
6 7 8 |
# File 'lib/airwallex/configuration.rb', line 6 def environment @environment end |
#log_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/airwallex/configuration.rb', line 5 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/airwallex/configuration.rb', line 5 def logger @logger end |
Instance Method Details
#api_url ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/airwallex/configuration.rb', line 22 def api_url case environment when :sandbox SANDBOX_API_URL when :production PRODUCTION_API_URL else raise ConfigurationError, "Invalid environment: #{environment}. Must be :sandbox or :production" end end |
#configured? ⇒ Boolean
63 64 65 |
# File 'lib/airwallex/configuration.rb', line 63 def configured? !api_key.nil? && !client_id.nil? && VALID_ENVIRONMENTS.include?(environment) end |
#files_url ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/airwallex/configuration.rb', line 33 def files_url case environment when :sandbox SANDBOX_FILES_URL when :production PRODUCTION_FILES_URL else raise ConfigurationError, "Invalid environment: #{environment}. Must be :sandbox or :production" end end |
#validate! ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/airwallex/configuration.rb', line 52 def validate! errors = [] errors << "api_key is required" if api_key.nil? || api_key.empty? errors << "client_id is required" if client_id.nil? || client_id.empty? errors << "environment must be :sandbox or :production" unless VALID_ENVIRONMENTS.include?(environment) raise ConfigurationError, errors.join(", ") unless errors.empty? true end |