Class: DigiwinDsp::Configuration
- Inherits:
-
Object
- Object
- DigiwinDsp::Configuration
- Defined in:
- lib/digiwin_dsp/configuration.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
10- DEFAULT_OPEN_TIMEOUT =
5- DEFAULT_ALLOWED_HOSTS =
["digiwindsp.digiwin.com"].freeze
- BASE_URLS =
{ sandbox: "https://digiwindsp.digiwin.com/DSP_UAT/api/DSP", production: "https://digiwindsp.digiwin.com/DSP/api/DSP" }.freeze
Instance Attribute Summary collapse
-
#allowed_hosts ⇒ Object
Returns the value of attribute allowed_hosts.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
- #base_url ⇒ Object
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#platform_id ⇒ Object
Returns the value of attribute platform_id.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/digiwin_dsp/configuration.rb', line 21 def initialize @api_key = ENV["DIGIWIN_DSP_API_KEY"] @api_secret = ENV["DIGIWIN_DSP_API_SECRET"] @platform_id = ENV["DIGIWIN_DSP_PLATFORM_ID"] @environment = ENV.fetch("DIGIWIN_DSP_ENV") { "sandbox" }.to_sym @base_url = ENV["DIGIWIN_DSP_BASE_URL"] @timeout = DEFAULT_TIMEOUT @open_timeout = DEFAULT_OPEN_TIMEOUT @logger = Logger.new(IO::NULL) @allowed_hosts = DEFAULT_ALLOWED_HOSTS.dup end |
Instance Attribute Details
#allowed_hosts ⇒ Object
Returns the value of attribute allowed_hosts.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def allowed_hosts @allowed_hosts end |
#api_key ⇒ Object
Returns the value of attribute api_key.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def api_secret @api_secret end |
#base_url ⇒ Object
33 34 35 36 37 |
# File 'lib/digiwin_dsp/configuration.rb', line 33 def base_url url = @base_url || resolve_default_base_url validate_url!(url) url end |
#environment ⇒ Object
Returns the value of attribute environment.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def environment @environment end |
#logger ⇒ Object
Returns the value of attribute logger.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def logger @logger end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def open_timeout @open_timeout end |
#platform_id ⇒ Object
Returns the value of attribute platform_id.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def platform_id @platform_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
17 18 19 |
# File 'lib/digiwin_dsp/configuration.rb', line 17 def timeout @timeout end |
Instance Method Details
#validate! ⇒ Object
39 40 41 42 43 44 |
# File 'lib/digiwin_dsp/configuration.rb', line 39 def validate! return unless api_key.nil? || api_key.to_s.empty? raise ConfigurationError, "api_key is required (set via DigiwinDsp.configure or DIGIWIN_DSP_API_KEY)" end |