nexmo 5.9.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -465
- data/lib/nexmo.rb +31 -48
- data/lib/nexmo/{authentication/abstract.rb → abstract_authentication.rb} +2 -2
- data/lib/nexmo/account.rb +4 -2
- data/lib/nexmo/alerts.rb +3 -3
- data/lib/nexmo/applications.rb +45 -63
- data/lib/nexmo/applications/list_response.rb +9 -0
- data/lib/nexmo/{errors/authentication_error.rb → authentication_error.rb} +0 -0
- data/lib/nexmo/{authentication/basic.rb → basic.rb} +1 -1
- data/lib/nexmo/{authentication/bearer_token.rb → bearer_token.rb} +1 -1
- data/lib/nexmo/calls.rb +18 -18
- data/lib/nexmo/{call_dtmf.rb → calls/dtmf.rb} +2 -2
- data/lib/nexmo/calls/list_response.rb +9 -0
- data/lib/nexmo/{call_stream.rb → calls/stream.rb} +3 -3
- data/lib/nexmo/{call_talk.rb → calls/talk.rb} +3 -3
- data/lib/nexmo/client.rb +20 -169
- data/lib/nexmo/{errors/client_error.rb → client_error.rb} +0 -0
- data/lib/nexmo/config.rb +165 -0
- data/lib/nexmo/conversations.rb +44 -13
- data/lib/nexmo/{conversation_events.rb → conversations/events.rb} +5 -5
- data/lib/nexmo/{conversation_legs.rb → conversations/legs.rb} +3 -3
- data/lib/nexmo/{conversation_members.rb → conversations/members.rb} +6 -6
- data/lib/nexmo/{conversation_users.rb → conversations/users.rb} +6 -6
- data/lib/nexmo/entity.rb +14 -0
- data/lib/nexmo/{errors/error.rb → error.rb} +0 -0
- data/lib/nexmo/files.rb +1 -2
- data/lib/nexmo/gsm7.rb +13 -0
- data/lib/nexmo/{authentication/key_secret_params.rb → key_secret_params.rb} +2 -2
- data/lib/nexmo/{authentication/key_secret_query.rb → key_secret_query.rb} +2 -2
- data/lib/nexmo/keys.rb +4 -22
- data/lib/nexmo/namespace.rb +22 -12
- data/lib/nexmo/number_insight.rb +6 -4
- data/lib/nexmo/number_insight/response.rb +5 -0
- data/lib/nexmo/numbers.rb +20 -12
- data/lib/nexmo/numbers/list_response.rb +9 -0
- data/lib/nexmo/numbers/response.rb +7 -0
- data/lib/nexmo/pricing.rb +2 -2
- data/lib/nexmo/pricing_types.rb +4 -4
- data/lib/nexmo/redact.rb +1 -1
- data/lib/nexmo/response.rb +23 -0
- data/lib/nexmo/secrets.rb +7 -7
- data/lib/nexmo/secrets/list_response.rb +9 -0
- data/lib/nexmo/{errors/server_error.rb → server_error.rb} +0 -0
- data/lib/nexmo/sms.rb +17 -3
- data/lib/nexmo/sms/response.rb +7 -0
- data/lib/nexmo/verify.rb +10 -8
- data/lib/nexmo/verify/response.rb +5 -0
- data/lib/nexmo/version.rb +1 -1
- data/nexmo.gemspec +4 -2
- metadata +45 -20
- data/lib/nexmo/applications_v2.rb +0 -102
data/lib/nexmo/number_insight.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Nexmo
|
4
4
|
class NumberInsight < Namespace
|
5
|
+
self.response_class = Response
|
6
|
+
|
5
7
|
# Provides basic number insight information about a number.
|
6
8
|
#
|
7
9
|
# @example
|
@@ -17,7 +19,7 @@ module Nexmo
|
|
17
19
|
#
|
18
20
|
# @param [Hash] params
|
19
21
|
#
|
20
|
-
# @return [
|
22
|
+
# @return [Response]
|
21
23
|
#
|
22
24
|
# @see https://developer.nexmo.com/api/number-insight#getNumberInsightBasic
|
23
25
|
#
|
@@ -45,7 +47,7 @@ module Nexmo
|
|
45
47
|
#
|
46
48
|
# @param [Hash] params
|
47
49
|
#
|
48
|
-
# @return [
|
50
|
+
# @return [Response]
|
49
51
|
#
|
50
52
|
# @see https://developer.nexmo.com/api/number-insight#getNumberInsightStandard
|
51
53
|
#
|
@@ -77,7 +79,7 @@ module Nexmo
|
|
77
79
|
#
|
78
80
|
# @param [Hash] params
|
79
81
|
#
|
80
|
-
# @return [
|
82
|
+
# @return [Response]
|
81
83
|
#
|
82
84
|
# @see https://developer.nexmo.com/api/number-insight#getNumberInsightAdvanced
|
83
85
|
#
|
@@ -112,7 +114,7 @@ module Nexmo
|
|
112
114
|
#
|
113
115
|
# @param [Hash] params
|
114
116
|
#
|
115
|
-
# @return [
|
117
|
+
# @return [Response]
|
116
118
|
#
|
117
119
|
# @see https://developer.nexmo.com/api/number-insight#getNumberInsightAsync
|
118
120
|
#
|
data/lib/nexmo/numbers.rb
CHANGED
@@ -10,7 +10,7 @@ module Nexmo
|
|
10
10
|
#
|
11
11
|
# @example
|
12
12
|
# response = client.numbers.list
|
13
|
-
# response.
|
13
|
+
# response.each do |item|
|
14
14
|
# puts "#{item.msisdn} #{item.country} #{item.type}"
|
15
15
|
# end
|
16
16
|
#
|
@@ -29,21 +29,29 @@ module Nexmo
|
|
29
29
|
# - `1` - Search for numbers that contain **:pattern**
|
30
30
|
# - `2` - Search for numbers that end with **:pattern**
|
31
31
|
#
|
32
|
+
# @option params [Boolean] :has_application
|
33
|
+
# Set this optional field to `true` to restrict your results to numbers associated with an application (any application).
|
34
|
+
# Set to `false` to find all numbers not associated with any application.
|
35
|
+
# Omit the field to avoid filtering on whether or not the number is assigned to an application.
|
36
|
+
#
|
37
|
+
# @option params [String] :application_id
|
38
|
+
# The application that you want to return the numbers for.
|
39
|
+
#
|
32
40
|
# @param [Hash] params
|
33
41
|
#
|
34
|
-
# @return [
|
42
|
+
# @return [ListResponse]
|
35
43
|
#
|
36
44
|
# @see https://developer.nexmo.com/api/developer/numbers#getOwnedNumbers
|
37
45
|
#
|
38
46
|
def list(params = nil)
|
39
|
-
request('/account/numbers', params: params)
|
47
|
+
request('/account/numbers', params: params, response_class: ListResponse)
|
40
48
|
end
|
41
49
|
|
42
50
|
# Retrieve inbound numbers that are available for the specified country.
|
43
51
|
#
|
44
52
|
# @example
|
45
53
|
# response = client.numbers.search(country: 'GB')
|
46
|
-
# response.
|
54
|
+
# response.each do |item|
|
47
55
|
# puts "#{item.msisdn} #{item.type} #{item.cost}"
|
48
56
|
# end
|
49
57
|
#
|
@@ -75,12 +83,12 @@ module Nexmo
|
|
75
83
|
#
|
76
84
|
# @param [Hash] params
|
77
85
|
#
|
78
|
-
# @return [
|
86
|
+
# @return [ListResponse]
|
79
87
|
#
|
80
88
|
# @see https://developer.nexmo.com/api/developer/numbers#getAvailableNumbers
|
81
89
|
#
|
82
90
|
def search(params)
|
83
|
-
request('/number/search', params: params)
|
91
|
+
request('/number/search', params: params, response_class: ListResponse)
|
84
92
|
end
|
85
93
|
|
86
94
|
# Request to purchase a specific inbound number.
|
@@ -96,12 +104,12 @@ module Nexmo
|
|
96
104
|
#
|
97
105
|
# @param [Hash] params
|
98
106
|
#
|
99
|
-
# @return [
|
107
|
+
# @return [Response]
|
100
108
|
#
|
101
109
|
# @see https://developer.nexmo.com/api/developer/numbers#buyANumber
|
102
110
|
#
|
103
111
|
def buy(params)
|
104
|
-
request('/number/buy', params: params, type: Post)
|
112
|
+
request('/number/buy', params: params, type: Post, response_class: Response)
|
105
113
|
end
|
106
114
|
|
107
115
|
# Cancel your subscription for a specific inbound number.
|
@@ -117,12 +125,12 @@ module Nexmo
|
|
117
125
|
#
|
118
126
|
# @param [Hash] params
|
119
127
|
#
|
120
|
-
# @return [
|
128
|
+
# @return [Response]
|
121
129
|
#
|
122
130
|
# @see https://developer.nexmo.com/api/developer/numbers#cancelANumber
|
123
131
|
#
|
124
132
|
def cancel(params)
|
125
|
-
request('/number/cancel', params: params, type: Post)
|
133
|
+
request('/number/cancel', params: params, type: Post, response_class: Response)
|
126
134
|
end
|
127
135
|
|
128
136
|
# Change the behaviour of a number that you own.
|
@@ -173,12 +181,12 @@ module Nexmo
|
|
173
181
|
#
|
174
182
|
# @param [Hash] params
|
175
183
|
#
|
176
|
-
# @return [
|
184
|
+
# @return [Response]
|
177
185
|
#
|
178
186
|
# @see https://developer.nexmo.com/api/developer/numbers#updateANumber
|
179
187
|
#
|
180
188
|
def update(params)
|
181
|
-
request('/number/update', params: camelcase(params), type: Post)
|
189
|
+
request('/number/update', params: camelcase(params), type: Post, response_class: Response)
|
182
190
|
end
|
183
191
|
end
|
184
192
|
end
|
data/lib/nexmo/pricing.rb
CHANGED
@@ -4,12 +4,12 @@ module Nexmo
|
|
4
4
|
class Pricing < Namespace
|
5
5
|
self.host = 'rest.nexmo.com'
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize(config, type: nil)
|
8
8
|
raise ArgumentError if type.nil?
|
9
9
|
|
10
10
|
@type = type
|
11
11
|
|
12
|
-
super
|
12
|
+
super config
|
13
13
|
end
|
14
14
|
|
15
15
|
attr_reader :type
|
data/lib/nexmo/pricing_types.rb
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
module Nexmo
|
4
4
|
class PricingTypes
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
7
|
end
|
8
8
|
|
9
9
|
def sms
|
10
|
-
@sms ||= Pricing.new(@
|
10
|
+
@sms ||= Pricing.new(@config, type: 'sms')
|
11
11
|
end
|
12
12
|
|
13
13
|
def voice
|
14
|
-
@voice ||= Pricing.new(@
|
14
|
+
@voice ||= Pricing.new(@config, type: 'voice')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/nexmo/redact.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Nexmo
|
2
|
+
class Response
|
3
|
+
def initialize(entity=nil, http_response=nil)
|
4
|
+
@entity = entity
|
5
|
+
|
6
|
+
@http_response = http_response
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :http_response
|
10
|
+
|
11
|
+
def respond_to_missing?(name, include_private = false)
|
12
|
+
return super if @entity.nil?
|
13
|
+
|
14
|
+
@entity.respond_to?(name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(name, *args)
|
18
|
+
return super if @entity.nil?
|
19
|
+
|
20
|
+
@entity.public_send(name, *args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/nexmo/secrets.rb
CHANGED
@@ -21,7 +21,7 @@ module Nexmo
|
|
21
21
|
#
|
22
22
|
# @param [Hash] params
|
23
23
|
#
|
24
|
-
# @return [
|
24
|
+
# @return [Response]
|
25
25
|
#
|
26
26
|
# @see https://developer.nexmo.com/api/account#createAPISecret
|
27
27
|
#
|
@@ -33,16 +33,16 @@ module Nexmo
|
|
33
33
|
#
|
34
34
|
# @example
|
35
35
|
# response = client.secrets.list
|
36
|
-
# response.
|
36
|
+
# response.each do |item|
|
37
37
|
# puts "#{item.created_at} #{item.id}"
|
38
38
|
# end
|
39
39
|
#
|
40
|
-
# @return [
|
40
|
+
# @return [ListResponse]
|
41
41
|
#
|
42
42
|
# @see https://developer.nexmo.com/api/account#retrieveAPISecrets
|
43
43
|
#
|
44
44
|
def list
|
45
|
-
request('/accounts/' + account_id + '/secrets')
|
45
|
+
request('/accounts/' + account_id + '/secrets', response_class: ListResponse)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Retrieve one API Secret.
|
@@ -52,7 +52,7 @@ module Nexmo
|
|
52
52
|
#
|
53
53
|
# @param [String] secret_id
|
54
54
|
#
|
55
|
-
# @return [
|
55
|
+
# @return [Response]
|
56
56
|
#
|
57
57
|
# @see https://developer.nexmo.com/api/account#retrieveAPISecret
|
58
58
|
#
|
@@ -67,7 +67,7 @@ module Nexmo
|
|
67
67
|
#
|
68
68
|
# @param [String] secret_id
|
69
69
|
#
|
70
|
-
# @return [
|
70
|
+
# @return [Response]
|
71
71
|
#
|
72
72
|
# @see https://developer.nexmo.com/api/account#revokeAPISecret
|
73
73
|
#
|
@@ -78,7 +78,7 @@ module Nexmo
|
|
78
78
|
private
|
79
79
|
|
80
80
|
def account_id
|
81
|
-
@
|
81
|
+
@config.api_key
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
File without changes
|
data/lib/nexmo/sms.rb
CHANGED
@@ -11,7 +11,7 @@ module Nexmo
|
|
11
11
|
# @example
|
12
12
|
# response = client.sms.send(from: 'Ruby', to: '447700900000', text: 'Hello world')
|
13
13
|
#
|
14
|
-
# if response.
|
14
|
+
# if response.success?
|
15
15
|
# puts "Sent message id=#{response.messages.first.message_id}"
|
16
16
|
# else
|
17
17
|
# puts "Error: #{response.messages.first.error_text}"
|
@@ -90,12 +90,26 @@ module Nexmo
|
|
90
90
|
#
|
91
91
|
# @param [Hash] params
|
92
92
|
#
|
93
|
-
# @return [
|
93
|
+
# @return [Response]
|
94
94
|
#
|
95
95
|
# @see https://developer.nexmo.com/api/sms#send-an-sms
|
96
96
|
#
|
97
97
|
def send(params)
|
98
|
-
|
98
|
+
if unicode?(params[:text]) && params[:type] != 'unicode'
|
99
|
+
message = 'Sending unicode text SMS without setting the type parameter to "unicode". ' \
|
100
|
+
'See https://developer.nexmo.com/messaging/sms for details, ' \
|
101
|
+
'or email support@nexmo.com if you have any questions.'
|
102
|
+
|
103
|
+
@logger.warn(message)
|
104
|
+
end
|
105
|
+
|
106
|
+
request('/sms/json', params: hyphenate(params), type: Post, response_class: Response)
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def unicode?(text)
|
112
|
+
!GSM7.encoded?(text)
|
99
113
|
end
|
100
114
|
end
|
101
115
|
end
|
data/lib/nexmo/verify.rb
CHANGED
@@ -6,6 +6,8 @@ module Nexmo
|
|
6
6
|
|
7
7
|
private :http_request
|
8
8
|
|
9
|
+
self.response_class = Response
|
10
|
+
|
9
11
|
# Generate and send a PIN to your user.
|
10
12
|
#
|
11
13
|
# @note You can make a maximum of one Verify request per second.
|
@@ -13,7 +15,7 @@ module Nexmo
|
|
13
15
|
# @example
|
14
16
|
# response = client.verify.request(number: '447700900000', brand: 'Acme Inc')
|
15
17
|
#
|
16
|
-
# if response.
|
18
|
+
# if response.success?
|
17
19
|
# puts "Started verification request_id=#{response.request_id}"
|
18
20
|
# else
|
19
21
|
# puts "Error: #{response.error_text}"
|
@@ -58,7 +60,7 @@ module Nexmo
|
|
58
60
|
#
|
59
61
|
# @param [Hash] params
|
60
62
|
#
|
61
|
-
# @return [
|
63
|
+
# @return [Response]
|
62
64
|
#
|
63
65
|
# @see https://developer.nexmo.com/api/verify#verifyRequest
|
64
66
|
#
|
@@ -71,7 +73,7 @@ module Nexmo
|
|
71
73
|
# @example
|
72
74
|
# response = client.verify.check(request_id: request_id, code: '1234')
|
73
75
|
#
|
74
|
-
# if response.
|
76
|
+
# if response.success?
|
75
77
|
# puts "Verification complete, event_id=#{response.event_id}"
|
76
78
|
# else
|
77
79
|
# puts "Error: #{response.error_text}"
|
@@ -90,7 +92,7 @@ module Nexmo
|
|
90
92
|
#
|
91
93
|
# @param [Hash] params
|
92
94
|
#
|
93
|
-
# @return [
|
95
|
+
# @return [Response]
|
94
96
|
#
|
95
97
|
# @see https://developer.nexmo.com/api/verify#verifyCheck
|
96
98
|
#
|
@@ -112,7 +114,7 @@ module Nexmo
|
|
112
114
|
#
|
113
115
|
# @param [Hash] params
|
114
116
|
#
|
115
|
-
# @return [
|
117
|
+
# @return [Response]
|
116
118
|
#
|
117
119
|
# @see https://developer.nexmo.com/api/verify#verifySearch
|
118
120
|
#
|
@@ -134,7 +136,7 @@ module Nexmo
|
|
134
136
|
#
|
135
137
|
# @param [Hash] params
|
136
138
|
#
|
137
|
-
# @return [
|
139
|
+
# @return [Response]
|
138
140
|
#
|
139
141
|
# @see https://developer.nexmo.com/api/verify#verifyControl
|
140
142
|
#
|
@@ -149,7 +151,7 @@ module Nexmo
|
|
149
151
|
#
|
150
152
|
# @param [String] id
|
151
153
|
#
|
152
|
-
# @return [
|
154
|
+
# @return [Response]
|
153
155
|
#
|
154
156
|
# @see https://developer.nexmo.com/api/verify#verifyControl
|
155
157
|
#
|
@@ -164,7 +166,7 @@ module Nexmo
|
|
164
166
|
#
|
165
167
|
# @param [String] id
|
166
168
|
#
|
167
|
-
# @return [
|
169
|
+
# @return [Response]
|
168
170
|
#
|
169
171
|
# @see https://developer.nexmo.com/api/verify#verifyControl
|
170
172
|
#
|
data/lib/nexmo/version.rb
CHANGED
data/nexmo.gemspec
CHANGED
@@ -11,8 +11,9 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = 'Nexmo Client Library for Ruby'
|
12
12
|
s.summary = 'This is the Ruby client library for Nexmo\'s API. To use it you\'ll need a Nexmo account. Sign up for free at https://www.nexmo.com'
|
13
13
|
s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md nexmo.gemspec)
|
14
|
-
s.required_ruby_version = '>= 2.
|
14
|
+
s.required_ruby_version = '>= 2.5.0'
|
15
15
|
s.add_dependency('jwt', '~> 2')
|
16
|
+
s.add_dependency('zeitwerk', '~> 2')
|
16
17
|
s.add_development_dependency('rake', '~> 12.0')
|
17
18
|
s.add_development_dependency('yard', '~> 0.9')
|
18
19
|
s.add_development_dependency('minitest', '~> 5.0')
|
@@ -24,6 +25,7 @@ Gem::Specification.new do |s|
|
|
24
25
|
'homepage' => 'https://github.com/Nexmo/nexmo-ruby',
|
25
26
|
'source_code_uri' => 'https://github.com/Nexmo/nexmo-ruby',
|
26
27
|
'bug_tracker_uri' => 'https://github.com/Nexmo/nexmo-ruby/issues',
|
27
|
-
'changelog_uri' => 'https://github.com/Nexmo/nexmo-ruby/blob/master/CHANGES.md'
|
28
|
+
'changelog_uri' => 'https://github.com/Nexmo/nexmo-ruby/blob/master/CHANGES.md',
|
29
|
+
'documentation_uri' => 'https://www.rubydoc.info/github/nexmo/nexmo-ruby'
|
28
30
|
}
|
29
31
|
end
|