Class: Delhivery::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
8
# File 'lib/delhivery/configuration.rb', line 5

def initialize(opts = {})
  @api_key = opts[:api_key]
  @production = opts[:production] || false
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/delhivery/configuration.rb', line 3

def api_key
  @api_key
end

#productionObject

Returns the value of attribute production.



3
4
5
# File 'lib/delhivery/configuration.rb', line 3

def production
  @production
end

Instance Method Details

#validateObject



10
11
12
13
14
15
16
# File 'lib/delhivery/configuration.rb', line 10

def validate
  errors = []
  errors << "Invalid API Key" if @api_key.nil? || @api_key.empty? 
  unless errors.empty?
    raise ArgumentError, "#{errors.join(', ')}"
  end
end