class Nexmo::Config
Attributes
api_host[RW]
api_key[W]
api_secret[W]
app_name[RW]
app_version[RW]
application_id[W]
http[R]
logger[R]
private_key[W]
rest_host[RW]
signature_method[RW]
signature_secret[W]
token[W]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
api_key()
click to toggle source
# 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 support@nexmo.com if you have any questions.') end @api_key end
api_secret()
click to toggle source
# 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 support@nexmo.com if you have any questions.') end @api_secret end
application_id()
click to toggle source
# 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 support@nexmo.com if you have any questions.') end @application_id end
http=(hash)
click to toggle source
# File lib/nexmo/config.rb, line 118 def http=(hash) @http = T.let(nil, T.nilable(Nexmo::HTTP::Options)) @http = Nexmo::HTTP::Options.new(hash) end
logger=(logger)
click to toggle source
# File lib/nexmo/config.rb, line 133 def logger=(logger) @logger = T.let(Logger.new(logger), T.nilable(Nexmo::Logger)) end
merge(options)
click to toggle source
# File lib/nexmo/config.rb, line 28 def merge(options) return self if options.nil? || options.empty? options.each_with_object(dup) do |(name, value), config| config.write_attribute(name, value) end end
private_key()
click to toggle source
# 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 support@nexmo.com if you have any questions.') end @private_key end
signature_secret()
click to toggle source
# 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 support@nexmo.com if you have any questions.') end @signature_secret end
token()
click to toggle source
# File lib/nexmo/config.rb, line 193 def token @token = T.let(nil, T.nilable(String)) @token || JWT.generate({application_id: application_id}, T.must(private_key)) end
Protected Instance Methods
write_attribute(name, value)
click to toggle source
# File lib/nexmo/config.rb, line 204 def write_attribute(name, value) public_send(:"#{name}=", value) end