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
- WEBHOOK_BASE_URLS =
Webhook-subscription endpoint (DSPOOFFICIAL100) lives at a separate base path from the SalesOrder endpoints.
{ sandbox: "https://digiwindsp.digiwin.com/DSP_UAT/api/webhook", production: "https://digiwindsp.digiwin.com/DSP/api/webhook" }.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.
- #webhook_base_url ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/digiwin_dsp/configuration.rb', line 28 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"] @webhook_base_url = ENV["DIGIWIN_DSP_WEBHOOK_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.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def allowed_hosts @allowed_hosts end |
#api_key ⇒ Object
Returns the value of attribute api_key.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def api_secret @api_secret end |
#base_url ⇒ Object
41 42 43 44 45 |
# File 'lib/digiwin_dsp/configuration.rb', line 41 def base_url url = @base_url || resolve_default_base_url validate_url!(url) url end |
#environment ⇒ Object
Returns the value of attribute environment.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def environment @environment end |
#logger ⇒ Object
Returns the value of attribute logger.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def logger @logger end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def open_timeout @open_timeout end |
#platform_id ⇒ Object
Returns the value of attribute platform_id.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def platform_id @platform_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
24 25 26 |
# File 'lib/digiwin_dsp/configuration.rb', line 24 def timeout @timeout end |
#webhook_base_url ⇒ Object
47 48 49 50 51 |
# File 'lib/digiwin_dsp/configuration.rb', line 47 def webhook_base_url url = @webhook_base_url || resolve_default_webhook_base_url validate_url!(url) url end |
Instance Method Details
#validate! ⇒ Object
53 54 55 56 57 58 |
# File 'lib/digiwin_dsp/configuration.rb', line 53 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 |