Class: Nexmo::Config
Instance Attribute Summary collapse
-
#api_host ⇒ Object
Returns the value of attribute api_host.
- #api_key ⇒ Object
- #api_secret ⇒ Object
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
- #application_id ⇒ Object
-
#http ⇒ Object
Returns the value of attribute http.
-
#logger ⇒ Object
Returns the value of attribute logger.
- #private_key ⇒ Object
-
#rest_host ⇒ Object
Returns the value of attribute rest_host.
-
#signature_method ⇒ Object
Returns the value of attribute signature_method.
- #signature_secret ⇒ Object
- #token ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merge(options) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nexmo/config.rb', line 10 def initialize self.api_host = 'api.nexmo.com' self.api_key = T.let(ENV['NEXMO_API_KEY'], T.nilable(String)) self.api_secret = T.let(ENV['NEXMO_API_SECRET'], T.nilable(String)) self.application_id = ENV['NEXMO_APPLICATION_ID'] self.logger = (defined?(::Rails.logger) && ::Rails.logger) || Nexmo::Logger.new(nil) self.private_key = ENV['NEXMO_PRIVATE_KEY_PATH'] ? File.read(T.must(ENV['NEXMO_PRIVATE_KEY_PATH'])) : ENV['NEXMO_PRIVATE_KEY'] self.rest_host = 'rest.nexmo.com' self.signature_secret = ENV['NEXMO_SIGNATURE_SECRET'] self.signature_method = ENV['NEXMO_SIGNATURE_METHOD'] || 'md5hash' self.token = T.let(nil, T.nilable(String)) end |
Instance Attribute Details
#api_host ⇒ Object
Returns the value of attribute api_host.
37 38 39 |
# File 'lib/nexmo/config.rb', line 37 def api_host @api_host end |
#api_key ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nexmo/config.rb', line 46 def api_key @api_key = T.let(@api_key, T.nilable(String)) 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 ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/nexmo/config.rb', line 67 def api_secret @api_secret = T.let(@api_secret, T.nilable(String)) 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.
105 106 107 |
# File 'lib/nexmo/config.rb', line 105 def app_name @app_name end |
#app_version ⇒ Object
Returns the value of attribute app_version.
108 109 110 |
# File 'lib/nexmo/config.rb', line 108 def app_version @app_version end |
#application_id ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/nexmo/config.rb', line 88 def application_id @application_id = T.let(@application_id, T.nilable(String)) 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 ⇒ Object
Returns the value of attribute http.
115 116 117 |
# File 'lib/nexmo/config.rb', line 115 def http @http end |
#logger ⇒ Object
Returns the value of attribute logger.
128 129 130 |
# File 'lib/nexmo/config.rb', line 128 def logger @logger end |
#private_key ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/nexmo/config.rb', line 144 def private_key @private_key = T.let(@private_key, T.nilable(String)) 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 |
#rest_host ⇒ Object
Returns the value of attribute rest_host.
161 162 163 |
# File 'lib/nexmo/config.rb', line 161 def rest_host @rest_host end |
#signature_method ⇒ Object
Returns the value of attribute signature_method.
186 187 188 |
# File 'lib/nexmo/config.rb', line 186 def signature_method @signature_method end |
#signature_secret ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/nexmo/config.rb', line 170 def signature_secret @signature_secret = T.let(@signature_secret, T.nilable(String)) 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) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nexmo/config.rb', line 28 def merge() return self if .nil? || .empty? .each_with_object(dup) do |(name, value), config| config.write_attribute(name, value) end end |