nexmo 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nexmo.rb +2 -0
- data/lib/nexmo/abstract_authentication.rb +2 -0
- data/lib/nexmo/account.rb +2 -1
- data/lib/nexmo/alerts.rb +2 -1
- data/lib/nexmo/applications.rb +1 -0
- data/lib/nexmo/applications/list_response.rb +2 -0
- data/lib/nexmo/authentication_error.rb +2 -0
- data/lib/nexmo/basic.rb +2 -0
- data/lib/nexmo/bearer_token.rb +1 -0
- data/lib/nexmo/calls.rb +1 -0
- data/lib/nexmo/calls/dtmf.rb +1 -0
- data/lib/nexmo/calls/list_response.rb +2 -0
- data/lib/nexmo/calls/stream.rb +1 -0
- data/lib/nexmo/calls/talk.rb +1 -0
- data/lib/nexmo/client.rb +2 -0
- data/lib/nexmo/client_error.rb +2 -0
- data/lib/nexmo/config.rb +7 -0
- data/lib/nexmo/conversations.rb +1 -0
- data/lib/nexmo/conversations/events.rb +1 -0
- data/lib/nexmo/conversations/legs.rb +1 -0
- data/lib/nexmo/conversations/members.rb +1 -0
- data/lib/nexmo/conversations/users.rb +1 -0
- data/lib/nexmo/conversions.rb +1 -0
- data/lib/nexmo/entity.rb +2 -0
- data/lib/nexmo/error.rb +2 -0
- data/lib/nexmo/errors.rb +1 -0
- data/lib/nexmo/files.rb +1 -0
- data/lib/nexmo/form_data.rb +2 -0
- data/lib/nexmo/gsm7.rb +2 -0
- data/lib/nexmo/http.rb +1 -0
- data/lib/nexmo/json.rb +1 -0
- data/lib/nexmo/jwt.rb +1 -0
- data/lib/nexmo/key_secret_params.rb +2 -0
- data/lib/nexmo/keys.rb +1 -0
- data/lib/nexmo/logger.rb +3 -2
- data/lib/nexmo/messages.rb +2 -1
- data/lib/nexmo/namespace.rb +13 -8
- data/lib/nexmo/number_insight.rb +1 -0
- data/lib/nexmo/number_insight/response.rb +2 -0
- data/lib/nexmo/numbers.rb +2 -1
- data/lib/nexmo/numbers/list_response.rb +2 -0
- data/lib/nexmo/numbers/response.rb +1 -0
- data/lib/nexmo/params.rb +1 -0
- data/lib/nexmo/pricing.rb +2 -1
- data/lib/nexmo/pricing_types.rb +1 -0
- data/lib/nexmo/redact.rb +1 -0
- data/lib/nexmo/response.rb +2 -0
- data/lib/nexmo/secrets.rb +1 -0
- data/lib/nexmo/secrets/list_response.rb +2 -0
- data/lib/nexmo/server_error.rb +2 -0
- data/lib/nexmo/signature.rb +1 -0
- data/lib/nexmo/sms.rb +7 -3
- data/lib/nexmo/sms/response.rb +1 -0
- data/lib/nexmo/tfa.rb +2 -1
- data/lib/nexmo/user_agent.rb +1 -0
- data/lib/nexmo/verify.rb +1 -0
- data/lib/nexmo/verify/response.rb +2 -0
- data/lib/nexmo/version.rb +3 -1
- data/nexmo.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 431850b9568a3bacf15de1cf1f31883616451e0fdd49283e9f78deb76cf74ba9
|
4
|
+
data.tar.gz: 8d3c2e1314efd2235abb2e3b243367fa715eb9d568048178f8d86e7455ed2abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c27cf8e95a1793a0c16f5787a9c9fe0063dfdd245e1bb8f162c8195f051f7b3ccbdec407f879e0ff7084c55f7a46ccf8932249255edfa4bb22c30384380cf587
|
7
|
+
data.tar.gz: e5d15599fb9f691337d053f76d2c74e498744787e98890256fab12bfa4f681105e9ca932397af14cb034b33cd379065a66d0f80f1ce23a4c2d1bc1fe4df63db3
|
data/lib/nexmo.rb
CHANGED
data/lib/nexmo/account.rb
CHANGED
data/lib/nexmo/alerts.rb
CHANGED
data/lib/nexmo/applications.rb
CHANGED
data/lib/nexmo/basic.rb
CHANGED
data/lib/nexmo/bearer_token.rb
CHANGED
data/lib/nexmo/calls.rb
CHANGED
data/lib/nexmo/calls/dtmf.rb
CHANGED
data/lib/nexmo/calls/stream.rb
CHANGED
data/lib/nexmo/calls/talk.rb
CHANGED
data/lib/nexmo/client.rb
CHANGED
data/lib/nexmo/client_error.rb
CHANGED
data/lib/nexmo/config.rb
CHANGED
@@ -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]
|
data/lib/nexmo/conversations.rb
CHANGED
data/lib/nexmo/conversions.rb
CHANGED
data/lib/nexmo/entity.rb
CHANGED
data/lib/nexmo/error.rb
CHANGED
data/lib/nexmo/errors.rb
CHANGED
data/lib/nexmo/files.rb
CHANGED
data/lib/nexmo/form_data.rb
CHANGED
data/lib/nexmo/gsm7.rb
CHANGED
data/lib/nexmo/http.rb
CHANGED
data/lib/nexmo/json.rb
CHANGED
data/lib/nexmo/jwt.rb
CHANGED
data/lib/nexmo/keys.rb
CHANGED
data/lib/nexmo/logger.rb
CHANGED
@@ -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,
|
data/lib/nexmo/messages.rb
CHANGED
data/lib/nexmo/namespace.rb
CHANGED
@@ -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
|
-
@
|
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 ||=
|
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
|
-
|
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
|
-
|
90
|
+
logger.log_request_info(message)
|
90
91
|
|
91
92
|
response = @http.request(message, &block)
|
92
93
|
|
93
|
-
|
94
|
+
logger.log_response_info(response, @host)
|
94
95
|
|
95
96
|
return if block
|
96
97
|
|
97
|
-
|
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
|
data/lib/nexmo/number_insight.rb
CHANGED
data/lib/nexmo/numbers.rb
CHANGED
data/lib/nexmo/params.rb
CHANGED
data/lib/nexmo/pricing.rb
CHANGED
data/lib/nexmo/pricing_types.rb
CHANGED
data/lib/nexmo/redact.rb
CHANGED
data/lib/nexmo/response.rb
CHANGED
data/lib/nexmo/secrets.rb
CHANGED
data/lib/nexmo/server_error.rb
CHANGED
data/lib/nexmo/signature.rb
CHANGED
data/lib/nexmo/sms.rb
CHANGED
@@ -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 =
|
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
|
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
|
-
|
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
|
data/lib/nexmo/sms/response.rb
CHANGED
data/lib/nexmo/tfa.rb
CHANGED
data/lib/nexmo/user_agent.rb
CHANGED
data/lib/nexmo/verify.rb
CHANGED
data/lib/nexmo/version.rb
CHANGED
data/nexmo.gemspec
CHANGED
@@ -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.
|
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-
|
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
|