Class: UnivapayClientSdk::Server

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

Overview

An enum for API servers.

Constant Summary collapse

SERVER =
[
  DEFAULT = 'default'.freeze,
  DIRECTDEBIT = 'directDebit'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = DEFAULT) ⇒ Object

Converts a string or symbol into a valid Server constant.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/univapay_client_sdk/configuration.rb', line 30

def self.from_value(value, default_value = DEFAULT)
  return default_value if value.nil?

  str = value.to_s.strip.downcase
  case str
  when 'default' then DEFAULT
  when 'directdebit' then DIRECTDEBIT

  else
    warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
    default_value
  end
end