nexmo 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nexmo.rb +2 -0
  3. data/lib/nexmo/abstract_authentication.rb +2 -0
  4. data/lib/nexmo/account.rb +2 -1
  5. data/lib/nexmo/alerts.rb +2 -1
  6. data/lib/nexmo/applications.rb +1 -0
  7. data/lib/nexmo/applications/list_response.rb +2 -0
  8. data/lib/nexmo/authentication_error.rb +2 -0
  9. data/lib/nexmo/basic.rb +2 -0
  10. data/lib/nexmo/bearer_token.rb +1 -0
  11. data/lib/nexmo/calls.rb +1 -0
  12. data/lib/nexmo/calls/dtmf.rb +1 -0
  13. data/lib/nexmo/calls/list_response.rb +2 -0
  14. data/lib/nexmo/calls/stream.rb +1 -0
  15. data/lib/nexmo/calls/talk.rb +1 -0
  16. data/lib/nexmo/client.rb +2 -0
  17. data/lib/nexmo/client_error.rb +2 -0
  18. data/lib/nexmo/config.rb +7 -0
  19. data/lib/nexmo/conversations.rb +1 -0
  20. data/lib/nexmo/conversations/events.rb +1 -0
  21. data/lib/nexmo/conversations/legs.rb +1 -0
  22. data/lib/nexmo/conversations/members.rb +1 -0
  23. data/lib/nexmo/conversations/users.rb +1 -0
  24. data/lib/nexmo/conversions.rb +1 -0
  25. data/lib/nexmo/entity.rb +2 -0
  26. data/lib/nexmo/error.rb +2 -0
  27. data/lib/nexmo/errors.rb +1 -0
  28. data/lib/nexmo/files.rb +1 -0
  29. data/lib/nexmo/form_data.rb +2 -0
  30. data/lib/nexmo/gsm7.rb +2 -0
  31. data/lib/nexmo/http.rb +1 -0
  32. data/lib/nexmo/json.rb +1 -0
  33. data/lib/nexmo/jwt.rb +1 -0
  34. data/lib/nexmo/key_secret_params.rb +2 -0
  35. data/lib/nexmo/keys.rb +1 -0
  36. data/lib/nexmo/logger.rb +3 -2
  37. data/lib/nexmo/messages.rb +2 -1
  38. data/lib/nexmo/namespace.rb +13 -8
  39. data/lib/nexmo/number_insight.rb +1 -0
  40. data/lib/nexmo/number_insight/response.rb +2 -0
  41. data/lib/nexmo/numbers.rb +2 -1
  42. data/lib/nexmo/numbers/list_response.rb +2 -0
  43. data/lib/nexmo/numbers/response.rb +1 -0
  44. data/lib/nexmo/params.rb +1 -0
  45. data/lib/nexmo/pricing.rb +2 -1
  46. data/lib/nexmo/pricing_types.rb +1 -0
  47. data/lib/nexmo/redact.rb +1 -0
  48. data/lib/nexmo/response.rb +2 -0
  49. data/lib/nexmo/secrets.rb +1 -0
  50. data/lib/nexmo/secrets/list_response.rb +2 -0
  51. data/lib/nexmo/server_error.rb +2 -0
  52. data/lib/nexmo/signature.rb +1 -0
  53. data/lib/nexmo/sms.rb +7 -3
  54. data/lib/nexmo/sms/response.rb +1 -0
  55. data/lib/nexmo/tfa.rb +2 -1
  56. data/lib/nexmo/user_agent.rb +1 -0
  57. data/lib/nexmo/verify.rb +1 -0
  58. data/lib/nexmo/verify/response.rb +2 -0
  59. data/lib/nexmo/version.rb +3 -1
  60. data/nexmo.gemspec +1 -0
  61. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 435a12da7a4fdd6a713aaf4660d5e7ae9e81013e7272df5d0bbbf9b2d5c6c9b8
4
- data.tar.gz: ed72a0177f94fdc83b592d86d2e7a198023e6b55511984ffe03a1c409d8947c4
3
+ metadata.gz: 431850b9568a3bacf15de1cf1f31883616451e0fdd49283e9f78deb76cf74ba9
4
+ data.tar.gz: 8d3c2e1314efd2235abb2e3b243367fa715eb9d568048178f8d86e7455ed2abd
5
5
  SHA512:
6
- metadata.gz: 662bf6adc6417ffad8ae5612297a1dce42be997a7a95c030c5b0630fdeff278e0bf09a26be88465827c1e7b69d6f0d4823ca9bbde77a79af132cacd7fe2fb998
7
- data.tar.gz: 0e739f013dc8f4b564a58f90b8aa1bd1ad61920a15825f4ea1b9a38c3b32dbcea3946ee4824eb1e4aae52a3cfbcac654759016c6eef6d32d41a63eaecb238d72
6
+ metadata.gz: c27cf8e95a1793a0c16f5787a9c9fe0063dfdd245e1bb8f162c8195f051f7b3ccbdec407f879e0ff7084c55f7a46ccf8932249255edfa4bb22c30384380cf587
7
+ data.tar.gz: e5d15599fb9f691337d053f76d2c74e498744787e98890256fab12bfa4f681105e9ca932397af14cb034b33cd379065a66d0f80f1ce23a4c2d1bc1fe4df63db3
@@ -1,5 +1,7 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
  require 'zeitwerk'
4
+ require 'sorbet-runtime'
3
5
 
4
6
  module Nexmo
5
7
  loader = Zeitwerk::Loader.new
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  module Nexmo
2
4
  class AbstractAuthentication
3
5
  def initialize(config)
@@ -1,10 +1,11 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class Account < Namespace
5
6
  include Keys
6
7
 
7
- self.host = 'rest.nexmo.com'
8
+ self.host = :rest_host
8
9
 
9
10
  # Retrieve your account balance.
10
11
  #
@@ -1,8 +1,9 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class Alerts < Namespace
5
- self.host = 'rest.nexmo.com'
6
+ self.host = :rest_host
6
7
 
7
8
  # Request the list of phone numbers opted out from your campaign.
8
9
  #
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  class Nexmo::Applications::ListResponse < Nexmo::Response
2
4
  include Enumerable
3
5
 
@@ -1,3 +1,5 @@
1
+ # typed: strong
2
+
1
3
  module Nexmo
2
4
  class AuthenticationError < ClientError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  module Nexmo
2
4
  class Basic < AbstractAuthentication
3
5
  def update(object)
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  class Nexmo::Calls::ListResponse < Nexmo::Response
2
4
  include Enumerable
3
5
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  module Nexmo
2
4
  class Client
3
5
  attr_reader :config
@@ -1,3 +1,5 @@
1
+ # typed: strong
2
+
1
3
  module Nexmo
2
4
  class ClientError < Error
3
5
  end
@@ -1,14 +1,17 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
  require 'logger'
3
4
 
4
5
  module Nexmo
5
6
  class Config
6
7
  def initialize
8
+ self.api_host = 'api.nexmo.com'
7
9
  self.api_key = ENV['NEXMO_API_KEY']
8
10
  self.api_secret = ENV['NEXMO_API_SECRET']
9
11
  self.application_id = nil
10
12
  self.logger = (defined?(Rails.logger) && Rails.logger) || ::Logger.new(nil)
11
13
  self.private_key = nil
14
+ self.rest_host = 'rest.nexmo.com'
12
15
  self.signature_secret = ENV['NEXMO_SIGNATURE_SECRET']
13
16
  self.signature_method = ENV['NEXMO_SIGNATURE_METHOD'] || 'md5hash'
14
17
  self.token = nil
@@ -26,6 +29,8 @@ module Nexmo
26
29
  end
27
30
  end
28
31
 
32
+ attr_accessor :api_host
33
+
29
34
  # Returns the value of attribute api_key.
30
35
  #
31
36
  # @return [String]
@@ -128,6 +133,8 @@ module Nexmo
128
133
 
129
134
  attr_writer :private_key
130
135
 
136
+ attr_accessor :rest_host
137
+
131
138
  # Returns the value of attribute signature_secret.
132
139
  #
133
140
  # @return [String]
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  module Nexmo
2
4
  class Entity
3
5
  include Keys
@@ -1,3 +1,5 @@
1
+ # typed: strong
2
+
1
3
  module Nexmo
2
4
  class Error < StandardError
3
5
  end
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'json'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  module Nexmo
2
4
  module FormData
3
5
  def self.update(http_request, params)
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  module Nexmo
2
4
  module GSM7
3
5
  CHARACTERS = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ ¡£¤¥§¿ÄÅÆÉÑÖØÜßàäåæçèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€"
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'net/http'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'json'
3
4
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
  require 'securerandom'
3
4
  require 'openssl'
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  module Nexmo
2
4
  class KeySecretParams < AbstractAuthentication
3
5
  def update(object)
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'logger'
3
4
  require 'forwardable'
@@ -15,7 +16,7 @@ module Nexmo
15
16
  end
16
17
 
17
18
  def log_request_info(request)
18
- info do
19
+ @logger.info do
19
20
  format('Nexmo API request', {
20
21
  method: request.method,
21
22
  path: request.uri.path
@@ -24,7 +25,7 @@ module Nexmo
24
25
  end
25
26
 
26
27
  def log_response_info(response, host)
27
- info do
28
+ @logger.info do
28
29
  format('Nexmo API response', {
29
30
  host: host,
30
31
  status: response.code,
@@ -1,8 +1,9 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class Messages < Namespace
5
- self.host = 'rest.nexmo.com'
6
+ self.host = :rest_host
6
7
 
7
8
  def get(id)
8
9
  request('/search/message', params: {id: id})
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'net/http'
3
4
  require 'json'
@@ -7,9 +8,7 @@ module Nexmo
7
8
  def initialize(config)
8
9
  @config = config
9
10
 
10
- @logger = config.logger
11
-
12
- @host = self.class.host
11
+ @host = self.class.host == :api_host ? @config.api_host : @config.rest_host
13
12
 
14
13
  @http = Net::HTTP.new(@host, Net::HTTP.https_default_port, p_addr = nil)
15
14
  @http.use_ssl = true
@@ -18,10 +17,12 @@ module Nexmo
18
17
  end
19
18
 
20
19
  def self.host
21
- @host ||= 'api.nexmo.com'
20
+ @host ||= :api_host
22
21
  end
23
22
 
24
23
  def self.host=(host)
24
+ raise ArgumentError unless host == :rest_host
25
+
25
26
  @host = host
26
27
  end
27
28
 
@@ -53,7 +54,7 @@ module Nexmo
53
54
  @response_class = response_class
54
55
  end
55
56
 
56
- private
57
+ protected
57
58
 
58
59
  Get = Net::HTTP::Get
59
60
  Put = Net::HTTP::Put
@@ -86,15 +87,15 @@ module Nexmo
86
87
 
87
88
  self.class.request_body.update(message, params) if type::REQUEST_HAS_BODY
88
89
 
89
- @logger.log_request_info(message)
90
+ logger.log_request_info(message)
90
91
 
91
92
  response = @http.request(message, &block)
92
93
 
93
- @logger.log_response_info(response, @host)
94
+ logger.log_response_info(response, @host)
94
95
 
95
96
  return if block
96
97
 
97
- @logger.debug(response.body) if response.body
98
+ logger.debug(response.body) if response.body
98
99
 
99
100
  parse(response, response_class || self.class.response_class)
100
101
  end
@@ -115,6 +116,10 @@ module Nexmo
115
116
  raise Errors.parse(response)
116
117
  end
117
118
  end
119
+
120
+ def logger
121
+ @config.logger
122
+ end
118
123
  end
119
124
 
120
125
  private_constant :Namespace
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  class Nexmo::NumberInsight::Response < Nexmo::Response
2
4
  def success?
3
5
  status.zero?
@@ -1,10 +1,11 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class Numbers < Namespace
5
6
  include Keys
6
7
 
7
- self.host = 'rest.nexmo.com'
8
+ self.host = :rest_host
8
9
 
9
10
  # Retrieve all the inbound numbers associated with your Nexmo account.
10
11
  #
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  class Nexmo::Numbers::ListResponse < Nexmo::Response
2
4
  include Enumerable
3
5
 
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  class Nexmo::Numbers::Response < Nexmo::Response
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
  require 'cgi'
3
4
 
@@ -1,8 +1,9 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class Pricing < Namespace
5
- self.host = 'rest.nexmo.com'
6
+ self.host = :rest_host
6
7
 
7
8
  def initialize(config, type: nil)
8
9
  raise ArgumentError if type.nil?
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  module Nexmo
2
4
  class Response
3
5
  def initialize(entity=nil, http_response=nil)
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: ignore
2
+
1
3
  class Nexmo::Secrets::ListResponse < Nexmo::Response
2
4
  include Enumerable
3
5
 
@@ -1,3 +1,5 @@
1
+ # typed: strong
2
+
1
3
  module Nexmo
2
4
  class ServerError < Error
3
5
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
  require 'openssl'
3
4
  require 'digest/md5'
@@ -1,10 +1,12 @@
1
+ # typed: strict
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class SMS < Namespace
6
+ extend T::Sig
5
7
  include Keys
6
8
 
7
- self.host = 'rest.nexmo.com'
9
+ self.host = :rest_host
8
10
 
9
11
  # Send an outbound SMS from your Nexmo account.
10
12
  #
@@ -94,13 +96,14 @@ module Nexmo
94
96
  #
95
97
  # @see https://developer.nexmo.com/api/sms#send-an-sms
96
98
  #
99
+ sig { params(params: T::Hash[Symbol, T.untyped]).returns(Nexmo::SMS::Response) }
97
100
  def send(params)
98
- if unicode?(params[:text]) && params[:type] != 'unicode'
101
+ if unicode?(params.fetch(:text)) && params[:type] != 'unicode'
99
102
  message = 'Sending unicode text SMS without setting the type parameter to "unicode". ' \
100
103
  'See https://developer.nexmo.com/messaging/sms for details, ' \
101
104
  'or email support@nexmo.com if you have any questions.'
102
105
 
103
- @logger.warn(message)
106
+ logger.warn(message)
104
107
  end
105
108
 
106
109
  request('/sms/json', params: hyphenate(params), type: Post, response_class: Response)
@@ -108,6 +111,7 @@ module Nexmo
108
111
 
109
112
  private
110
113
 
114
+ sig { params(text: String).returns(T::Boolean) }
111
115
  def unicode?(text)
112
116
  !GSM7.encoded?(text)
113
117
  end
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  class Nexmo::SMS::Response < Nexmo::Response
@@ -1,10 +1,11 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
4
5
  class TFA < Namespace
5
6
  include Keys
6
7
 
7
- self.host = 'rest.nexmo.com'
8
+ self.host = :rest_host
8
9
 
9
10
  def send(params)
10
11
  request('/sc/us/2fa/json', params: hyphenate(params), type: Post)
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,4 @@
1
+ # typed: false
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Nexmo
@@ -1,3 +1,5 @@
1
+ # typed: false
2
+
1
3
  class Nexmo::Verify::Response < Nexmo::Response
2
4
  def success?
3
5
  respond_to?(:status) && !respond_to?(:error_text)
@@ -1,3 +1,5 @@
1
+ # typed: strong
2
+
1
3
  module Nexmo
2
- VERSION = '6.2.0'
4
+ VERSION = '6.3.0'
3
5
  end
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.required_ruby_version = '>= 2.5.0'
15
15
  s.add_dependency('jwt', '~> 2')
16
16
  s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
17
+ s.add_dependency('sorbet-runtime', '~> 0.5')
17
18
  s.require_path = 'lib'
18
19
  s.metadata = {
19
20
  'homepage' => 'https://github.com/Nexmo/nexmo-ruby',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexmo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: sorbet-runtime
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.5'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.5'
47
61
  description: Nexmo Client Library for Ruby
48
62
  email:
49
63
  - devrel@nexmo.com