Class: Nexmo::Config
- Inherits:
-
Object
- Object
- Nexmo::Config
- Defined in:
- lib/nexmo/config.rb
Instance Attribute Summary collapse
-
#api_key ⇒ String
Returns the value of attribute api_key.
-
#api_secret ⇒ String
Returns the value of attribute api_secret.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#application_id ⇒ String
Returns the value of attribute application_id.
-
#http ⇒ Nexmo::HTTP::Options
Returns the value of attribute http.
-
#logger ⇒ Nexmo::Logger
Returns the value of attribute logger.
-
#private_key ⇒ String
Returns the value of attribute private_key.
-
#signature_secret ⇒ String
Returns the value of attribute signature_secret.
-
#token ⇒ String
Returns the value of attribute token, or a temporary short lived token.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#merge(options) ⇒ Nexmo::Config
Merges the config with the given options hash.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 13 14 |
# File 'lib/nexmo/config.rb', line 6 def initialize self.api_key = ENV['NEXMO_API_KEY'] self.api_secret = ENV['NEXMO_API_SECRET'] self.application_id = nil self.logger = (defined?(Rails.logger) && Rails.logger) || ::Logger.new(nil) self.private_key = nil self.signature_secret = ENV['NEXMO_SIGNATURE_SECRET'] self.token = nil end |
Instance Attribute Details
#api_key ⇒ String
Returns the value of attribute api_key.
34 35 36 37 38 39 40 41 42 |
# File 'lib/nexmo/config.rb', line 34 def api_key unless @api_key raise AuthenticationError.new('No API key provided. ' \ 'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \ 'or email [email protected] if you have any questions.') end @api_key end |
#api_secret ⇒ String
Returns the value of attribute api_secret.
52 53 54 55 56 57 58 59 60 |
# File 'lib/nexmo/config.rb', line 52 def api_secret unless @api_secret raise AuthenticationError.new('No API secret provided. ' \ 'See https://developer.nexmo.com/concepts/guides/authentication for details, ' \ 'or email [email protected] if you have any questions.') end @api_secret end |
#app_name ⇒ Object
Returns the value of attribute app_name
84 85 86 |
# File 'lib/nexmo/config.rb', line 84 def app_name @app_name end |
#app_version ⇒ Object
Returns the value of attribute app_version
86 87 88 |
# File 'lib/nexmo/config.rb', line 86 def app_version @app_version end |
#application_id ⇒ String
Returns the value of attribute application_id.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/nexmo/config.rb', line 70 def application_id unless @application_id raise AuthenticationError.new('No application_id provided. ' \ 'Either provide an application_id, or set an auth token. ' \ 'You can add new applications from the Nexmo dashboard. ' \ 'See https://developer.nexmo.com/concepts/guides/applications for details, ' \ 'or email [email protected] if you have any questions.') end @application_id end |
#http ⇒ Nexmo::HTTP::Options
Returns the value of attribute http.
92 93 94 |
# File 'lib/nexmo/config.rb', line 92 def http @http end |
#logger ⇒ Nexmo::Logger
Returns the value of attribute logger.
102 103 104 |
# File 'lib/nexmo/config.rb', line 102 def logger @logger end |
#private_key ⇒ String
Returns the value of attribute private_key.
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/nexmo/config.rb', line 116 def private_key unless @private_key raise AuthenticationError.new('No private_key provided. ' \ 'Either provide a private_key, or set an auth token. ' \ 'You can add new applications from the Nexmo dashboard. ' \ 'See https://developer.nexmo.com/concepts/guides/applications for details, ' \ 'or email [email protected] if you have any questions.') end @private_key end |
#signature_secret ⇒ String
Returns the value of attribute signature_secret.
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/nexmo/config.rb', line 136 def signature_secret unless @signature_secret raise AuthenticationError.new('No signature_secret provided. ' \ 'You can find your signature secret in the Nexmo dashboard. ' \ 'See https://developer.nexmo.com/concepts/guides/signing-messages for details, ' \ 'or email [email protected] if you have any questions.') end @signature_secret end |
Instance Method Details
#merge(options) ⇒ Nexmo::Config
Merges the config with the given options hash.
20 21 22 23 24 25 26 |
# File 'lib/nexmo/config.rb', line 20 def merge() return self if .nil? || .empty? .each_with_object(dup) do |(name, value), config| config.write_attribute(name, value) end end |