Class: Nexmo::Client
- Inherits:
-
Object
- Object
- Nexmo::Client
- Defined in:
- lib/nexmo/client.rb
Instance Attribute Summary collapse
- #api_key ⇒ Object
- #api_secret ⇒ Object
- #application_id ⇒ Object
- #private_key ⇒ Object
- #signature_secret ⇒ Object
- #token ⇒ Object
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #account ⇒ Object
- #alerts ⇒ Object
- #applications ⇒ Object
- #auth_token=(auth_token) ⇒ Object
- #calls ⇒ Object
- #conversions ⇒ Object
- #files ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #logger ⇒ Object
- #logger=(logger) ⇒ Object
- #messages ⇒ Object
- #number_insight ⇒ Object
- #numbers ⇒ Object
- #pricing ⇒ Object
- #redact ⇒ Object
- #signature ⇒ Object
- #sms ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nexmo/client.rb', line 13 def initialize( = {}) @api_key = [:api_key] || ENV['NEXMO_API_KEY'] @api_secret = [:api_secret] || ENV['NEXMO_API_SECRET'] @signature_secret = [:signature_secret] || ENV['NEXMO_SIGNATURE_SECRET'] @application_id = [:application_id] @private_key = [:private_key] @token = nil @user_agent = UserAgent.string([:app_name], [:app_version]) self.logger = [:logger] || (defined?(Rails.logger) && Rails.logger) end |
Instance Attribute Details
#api_key ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/nexmo/client.rb', line 49 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 ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/nexmo/client.rb', line 59 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 |
#application_id ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/nexmo/client.rb', line 80 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 |
#private_key ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/nexmo/client.rb', line 92 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 ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nexmo/client.rb', line 69 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 |
#token ⇒ Object
39 40 41 |
# File 'lib/nexmo/client.rb', line 39 def token @token || JWT.generate({application_id: application_id}, private_key) end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
11 12 13 |
# File 'lib/nexmo/client.rb', line 11 def user_agent @user_agent end |
Instance Method Details
#account ⇒ Object
108 109 110 |
# File 'lib/nexmo/client.rb', line 108 def account @account ||= Account.new(self) end |
#alerts ⇒ Object
112 113 114 |
# File 'lib/nexmo/client.rb', line 112 def alerts @alerts ||= Alerts.new(self) end |
#applications ⇒ Object
116 117 118 |
# File 'lib/nexmo/client.rb', line 116 def applications @applications ||= Applications.new(self) end |
#auth_token=(auth_token) ⇒ Object
43 44 45 46 47 |
# File 'lib/nexmo/client.rb', line 43 def auth_token=(auth_token) Kernel.warn "#{self.class}##{__method__} is deprecated (use #token= instead)" @token = auth_token end |
#calls ⇒ Object
120 121 122 |
# File 'lib/nexmo/client.rb', line 120 def calls @calls ||= Calls.new(self) end |
#conversions ⇒ Object
124 125 126 |
# File 'lib/nexmo/client.rb', line 124 def conversions @conversions ||= Conversions.new(self) end |
#files ⇒ Object
128 129 130 |
# File 'lib/nexmo/client.rb', line 128 def files @files ||= Files.new(self) end |
#logger ⇒ Object
31 32 33 |
# File 'lib/nexmo/client.rb', line 31 def logger @logger end |
#logger=(logger) ⇒ Object
35 36 37 |
# File 'lib/nexmo/client.rb', line 35 def logger=(logger) @logger = Nexmo::KeyValueLogger.new(logger) end |
#messages ⇒ Object
132 133 134 |
# File 'lib/nexmo/client.rb', line 132 def @messages ||= Messages.new(self) end |
#number_insight ⇒ Object
136 137 138 |
# File 'lib/nexmo/client.rb', line 136 def number_insight @number_insight ||= NumberInsight.new(self) end |
#numbers ⇒ Object
140 141 142 |
# File 'lib/nexmo/client.rb', line 140 def numbers @numbers ||= Numbers.new(self) end |
#pricing ⇒ Object
144 145 146 |
# File 'lib/nexmo/client.rb', line 144 def pricing @pricing ||= PricingTypes.new(self) end |
#redact ⇒ Object
148 149 150 |
# File 'lib/nexmo/client.rb', line 148 def redact @redact ||= Redact.new(self) end |