Class: Smspartner::Configuration

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

Constant Summary collapse

ALLOWED_RANGE_VALUES =
%i[premium low_cost].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, range_value:, sandbox: false, sender: nil) ⇒ Configuration

Returns a new instance of Configuration.

Parameters:

  • api_key (String)

    the API key

  • range_value (:premium, :low_cost)
  • sandbox (Boolean) (defaults to: false)

    true to enable sandbox mode, disabled by default

  • sender (String) (defaults to: nil)

    SMS sender’s name



12
13
14
15
16
17
# File 'lib/smspartner/configuration.rb', line 12

def initialize(api_key:, range_value:, sandbox: false, sender: nil)
  self.api_key     = api_key
  self.range_value = range_value
  self.sandbox     = sandbox
  self.sender      = sender
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



29
30
31
# File 'lib/smspartner/configuration.rb', line 29

def api_key
  @api_key
end

Instance Method Details

#to_hHash

Returns attributes as a hash.

Returns:

  • (Hash)

    attributes as a hash



20
21
22
23
24
25
26
27
# File 'lib/smspartner/configuration.rb', line 20

def to_h
  {
    api_key:     api_key,
    range_value: range_value,
    sandbox:     sandbox,
    sender:      sender
  }
end