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
-
#http_options ⇒ Object
Returns the value of attribute http_options.
- #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
- #secrets ⇒ 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 30 31 |
# 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. = [:http] self.logger = [:logger] || (defined?(Rails.logger) && Rails.logger) end |
Instance Attribute Details
#api_key ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/nexmo/client.rb', line 57 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
67 68 69 70 71 72 73 74 75 |
# File 'lib/nexmo/client.rb', line 67 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
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/nexmo/client.rb', line 88 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_options ⇒ Object
Returns the value of attribute http_options.
33 34 35 |
# File 'lib/nexmo/client.rb', line 33 def @http_options end |
#private_key ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/nexmo/client.rb', line 100 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
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/nexmo/client.rb', line 77 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
47 48 49 |
# File 'lib/nexmo/client.rb', line 47 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
116 117 118 |
# File 'lib/nexmo/client.rb', line 116 def account @account ||= Account.new(self) end |
#alerts ⇒ Object
120 121 122 |
# File 'lib/nexmo/client.rb', line 120 def alerts @alerts ||= Alerts.new(self) end |
#applications ⇒ Object
124 125 126 |
# File 'lib/nexmo/client.rb', line 124 def applications @applications ||= Applications.new(self) end |
#auth_token=(auth_token) ⇒ Object
51 52 53 54 55 |
# File 'lib/nexmo/client.rb', line 51 def auth_token=(auth_token) Kernel.warn "#{self.class}##{__method__} is deprecated (use #token= instead)" @token = auth_token end |
#calls ⇒ Object
128 129 130 |
# File 'lib/nexmo/client.rb', line 128 def calls @calls ||= Calls.new(self) end |
#conversions ⇒ Object
132 133 134 |
# File 'lib/nexmo/client.rb', line 132 def conversions @conversions ||= Conversions.new(self) end |
#files ⇒ Object
136 137 138 |
# File 'lib/nexmo/client.rb', line 136 def files @files ||= Files.new(self) end |
#logger ⇒ Object
39 40 41 |
# File 'lib/nexmo/client.rb', line 39 def logger @logger end |
#logger=(logger) ⇒ Object
43 44 45 |
# File 'lib/nexmo/client.rb', line 43 def logger=(logger) @logger = Logger.new(logger) end |
#messages ⇒ Object
140 141 142 |
# File 'lib/nexmo/client.rb', line 140 def @messages ||= Messages.new(self) end |
#number_insight ⇒ Object
144 145 146 |
# File 'lib/nexmo/client.rb', line 144 def number_insight @number_insight ||= NumberInsight.new(self) end |
#numbers ⇒ Object
148 149 150 |
# File 'lib/nexmo/client.rb', line 148 def numbers @numbers ||= Numbers.new(self) end |
#pricing ⇒ Object
152 153 154 |
# File 'lib/nexmo/client.rb', line 152 def pricing @pricing ||= PricingTypes.new(self) end |
#redact ⇒ Object
156 157 158 |
# File 'lib/nexmo/client.rb', line 156 def redact @redact ||= Redact.new(self) end |
#secrets ⇒ Object
160 161 162 |
# File 'lib/nexmo/client.rb', line 160 def secrets @secrets ||= Secrets.new(self) end |