nexmo 5.9.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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.rb
CHANGED
@@ -1,48 +1,31 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
require 'nexmo/conversation_events'
|
33
|
-
require 'nexmo/conversation_legs'
|
34
|
-
require 'nexmo/conversation_members'
|
35
|
-
require 'nexmo/conversation_users'
|
36
|
-
require 'nexmo/conversations'
|
37
|
-
require 'nexmo/conversions'
|
38
|
-
require 'nexmo/files'
|
39
|
-
require 'nexmo/messages'
|
40
|
-
require 'nexmo/number_insight'
|
41
|
-
require 'nexmo/numbers'
|
42
|
-
require 'nexmo/pricing_types'
|
43
|
-
require 'nexmo/pricing'
|
44
|
-
require 'nexmo/redact'
|
45
|
-
require 'nexmo/secrets'
|
46
|
-
require 'nexmo/sms'
|
47
|
-
require 'nexmo/tfa'
|
48
|
-
require 'nexmo/verify'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'zeitwerk'
|
3
|
+
|
4
|
+
module Nexmo
|
5
|
+
class ZeitwerkInflector < Zeitwerk::Inflector
|
6
|
+
def camelize(basename, _abspath)
|
7
|
+
case basename
|
8
|
+
when 'http', 'json', 'jwt', 'sms', 'tfa', 'gsm7', 'dtmf', 'version'
|
9
|
+
basename.upcase
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private_constant :ZeitwerkInflector
|
17
|
+
|
18
|
+
loader = Zeitwerk::Loader.new
|
19
|
+
loader.tag = File.basename(__FILE__, '.rb')
|
20
|
+
loader.inflector = ZeitwerkInflector.new
|
21
|
+
loader.push_dir(__dir__)
|
22
|
+
loader.setup
|
23
|
+
|
24
|
+
def self.config
|
25
|
+
@config ||= Config.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.configure(&block)
|
29
|
+
block.call(config)
|
30
|
+
end
|
31
|
+
end
|
data/lib/nexmo/account.rb
CHANGED
@@ -8,7 +8,7 @@ module Nexmo
|
|
8
8
|
|
9
9
|
# Retrieve your account balance.
|
10
10
|
#
|
11
|
-
# @return [
|
11
|
+
# @return [Response]
|
12
12
|
#
|
13
13
|
# @see https://developer.nexmo.com/api/developer/account#get-balance
|
14
14
|
#
|
@@ -30,7 +30,7 @@ module Nexmo
|
|
30
30
|
#
|
31
31
|
# @param [Hash] params
|
32
32
|
#
|
33
|
-
# @return [
|
33
|
+
# @return [Response]
|
34
34
|
#
|
35
35
|
# @see https://developer.nexmo.com/api/developer/account#settings
|
36
36
|
#
|
@@ -45,6 +45,8 @@ module Nexmo
|
|
45
45
|
#
|
46
46
|
# @param [Hash] params
|
47
47
|
#
|
48
|
+
# @return [Response]
|
49
|
+
#
|
48
50
|
# @see https://developer.nexmo.com/api/developer/account#top-up
|
49
51
|
#
|
50
52
|
def topup(params)
|
data/lib/nexmo/alerts.rb
CHANGED
@@ -8,7 +8,7 @@ module Nexmo
|
|
8
8
|
#
|
9
9
|
# @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/subscription
|
10
10
|
#
|
11
|
-
# @return [
|
11
|
+
# @return [Response]
|
12
12
|
#
|
13
13
|
def list
|
14
14
|
request('/sc/us/alert/opt-in/query/json')
|
@@ -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/sms/us-short-codes/alerts/subscription
|
27
27
|
#
|
@@ -56,7 +56,7 @@ module Nexmo
|
|
56
56
|
#
|
57
57
|
# @param [Hash] params
|
58
58
|
#
|
59
|
-
# @return [
|
59
|
+
# @return [Response]
|
60
60
|
#
|
61
61
|
# @see https://developer.nexmo.com/api/sms/us-short-codes/alerts/sending
|
62
62
|
#
|
data/lib/nexmo/applications.rb
CHANGED
@@ -2,9 +2,13 @@
|
|
2
2
|
|
3
3
|
module Nexmo
|
4
4
|
class Applications < Namespace
|
5
|
+
self.authentication = Basic
|
6
|
+
|
5
7
|
self.request_body = JSON
|
6
8
|
|
7
|
-
|
9
|
+
self.request_headers['Content-Type'] = 'application/json'
|
10
|
+
|
11
|
+
# Create an application.
|
8
12
|
#
|
9
13
|
# @example
|
10
14
|
# params = {
|
@@ -17,129 +21,107 @@ module Nexmo
|
|
17
21
|
# response = client.applications.create(params)
|
18
22
|
#
|
19
23
|
# @option params [required, String] :name
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# @option params [required, String] :type
|
23
|
-
# The Nexmo product or products that you access with this application.
|
24
|
-
# Currently only `voice` and `messages` are supported.
|
25
|
-
#
|
26
|
-
# @option params [required, String] :answer_url
|
27
|
-
# The URL where your webhook delivers the Nexmo Call Control Object that governs this call.
|
28
|
-
# As soon as your user answers a call Nexmo makes a request to answer_url.
|
29
|
-
#
|
30
|
-
# @option params [String] :answer_method
|
31
|
-
# The HTTP method used to make the request to answer_url.
|
32
|
-
# The default value is GET.
|
24
|
+
# Application name.
|
33
25
|
#
|
34
|
-
# @option params [
|
35
|
-
#
|
26
|
+
# @option params [Hash] :keys
|
27
|
+
# - **:public_key** (String) Public key
|
36
28
|
#
|
37
|
-
# @option params [
|
38
|
-
#
|
39
|
-
#
|
29
|
+
# @option params [Hash] :capabilities
|
30
|
+
# Your application can use multiple products.
|
31
|
+
# This contains the configuration for each product.
|
32
|
+
# This replaces the application `type` from version 1 of the Application API.
|
40
33
|
#
|
41
34
|
# @param [Hash] params
|
42
35
|
#
|
43
|
-
# @return [
|
36
|
+
# @return [Response]
|
44
37
|
#
|
45
|
-
# @see https://developer.nexmo.com/api/application#
|
38
|
+
# @see https://developer.nexmo.com/api/application.v2#createApplication
|
46
39
|
#
|
47
40
|
def create(params)
|
48
|
-
request('/
|
41
|
+
request('/v2/applications', params: params, type: Post)
|
49
42
|
end
|
50
43
|
|
51
|
-
#
|
44
|
+
# List available applications.
|
52
45
|
#
|
53
46
|
# @example
|
54
47
|
# response = client.applications.list
|
55
|
-
# response.
|
48
|
+
# response.each do |item|
|
56
49
|
# puts "#{item.id} #{item.name}"
|
57
50
|
# end
|
58
51
|
#
|
59
52
|
# @option params [Integer] :page_size
|
60
|
-
#
|
61
|
-
# The default is 10 records.
|
53
|
+
# The number of applications per page.
|
62
54
|
#
|
63
|
-
# @option params [Integer] :
|
64
|
-
#
|
65
|
-
# The default value is 0.
|
55
|
+
# @option params [Integer] :page
|
56
|
+
# The current page number (starts at 1).
|
66
57
|
#
|
67
|
-
# @param [Hash
|
58
|
+
# @param [Hash] params
|
68
59
|
#
|
69
|
-
# @return [
|
60
|
+
# @return [ListResponse]
|
70
61
|
#
|
71
|
-
# @see https://developer.nexmo.com/api/application#
|
62
|
+
# @see https://developer.nexmo.com/api/application.v2#listApplication
|
72
63
|
#
|
73
64
|
def list(params = nil)
|
74
|
-
request('/
|
65
|
+
request('/v2/applications', params: params, response_class: ListResponse)
|
75
66
|
end
|
76
67
|
|
77
|
-
#
|
68
|
+
# Get an application.
|
78
69
|
#
|
79
70
|
# @example
|
80
71
|
# response = client.applications.get(id)
|
81
72
|
#
|
82
73
|
# @param [String] id
|
83
74
|
#
|
84
|
-
# @return [
|
75
|
+
# @return [Response]
|
85
76
|
#
|
86
|
-
# @see https://developer.nexmo.com/api/application#
|
77
|
+
# @see https://developer.nexmo.com/api/application.v2#getApplication
|
87
78
|
#
|
88
79
|
def get(id)
|
89
|
-
request('/
|
80
|
+
request('/v2/applications/' + id)
|
90
81
|
end
|
91
82
|
|
92
|
-
# Update an
|
83
|
+
# Update an application.
|
93
84
|
#
|
94
85
|
# @example
|
95
86
|
# response = client.applications.update(id, answer_method: 'POST')
|
96
87
|
#
|
97
88
|
# @option params [required, String] :name
|
98
|
-
#
|
99
|
-
#
|
100
|
-
# @option params [required, String] :type
|
101
|
-
# The Nexmo product or products that you access with this application.
|
102
|
-
# Currently only `voice` and `messages` are supported.
|
103
|
-
#
|
104
|
-
# @option params [required, String] :answer_url
|
105
|
-
# The URL where your webhook delivers the Nexmo Call Control Object that governs this call.
|
106
|
-
# As soon as your user answers a call Nexmo makes a request to answer_url.
|
89
|
+
# Application name.
|
107
90
|
#
|
108
|
-
# @option params [
|
109
|
-
#
|
110
|
-
# The default value is GET.
|
91
|
+
# @option params [Hash] :keys
|
92
|
+
# - **:public_key** (String) Public key
|
111
93
|
#
|
112
|
-
# @option params [
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
# The HTTP method used to send event information to event_url.
|
117
|
-
# The default value is POST.
|
94
|
+
# @option params [Hash] :capabilities
|
95
|
+
# Your application can use multiple products.
|
96
|
+
# This contains the configuration for each product.
|
97
|
+
# This replaces the application `type` from version 1 of the Application API.
|
118
98
|
#
|
119
99
|
# @param [String] id
|
120
100
|
# @param [Hash] params
|
121
101
|
#
|
122
|
-
# @return [
|
102
|
+
# @return [Response]
|
123
103
|
#
|
124
|
-
# @see https://developer.nexmo.com/api/application#
|
104
|
+
# @see https://developer.nexmo.com/api/application.v2#updateApplication
|
125
105
|
#
|
126
106
|
def update(id, params)
|
127
|
-
request('/
|
107
|
+
request('/v2/applications/' + id, params: params, type: Put)
|
128
108
|
end
|
129
109
|
|
130
|
-
# Delete
|
110
|
+
# Delete an application.
|
131
111
|
#
|
132
112
|
# @example
|
133
113
|
# response = client.applications.delete(id)
|
134
114
|
#
|
115
|
+
# @note Deleting an application cannot be undone.
|
116
|
+
#
|
135
117
|
# @param [String] id
|
136
118
|
#
|
137
|
-
# @return [
|
119
|
+
# @return [Response]
|
138
120
|
#
|
139
|
-
# @see https://developer.nexmo.com/api/application#
|
121
|
+
# @see https://developer.nexmo.com/api/application.v2#deleteApplication
|
140
122
|
#
|
141
123
|
def delete(id)
|
142
|
-
request('/
|
124
|
+
request('/v2/applications/' + id, type: Delete)
|
143
125
|
end
|
144
126
|
end
|
145
127
|
end
|
File without changes
|
data/lib/nexmo/calls.rb
CHANGED
@@ -49,7 +49,7 @@ module Nexmo
|
|
49
49
|
#
|
50
50
|
# @param [Hash] params
|
51
51
|
#
|
52
|
-
# @return [
|
52
|
+
# @return [Response]
|
53
53
|
#
|
54
54
|
# @see https://developer.nexmo.com/api/voice#createCall
|
55
55
|
#
|
@@ -61,7 +61,7 @@ module Nexmo
|
|
61
61
|
#
|
62
62
|
# @example
|
63
63
|
# response = client.calls.list
|
64
|
-
# response.
|
64
|
+
# response.each do |item|
|
65
65
|
# puts "#{item.uuid} #{item.direction} #{item.status}"
|
66
66
|
# end
|
67
67
|
#
|
@@ -88,12 +88,12 @@ module Nexmo
|
|
88
88
|
#
|
89
89
|
# @param [Hash] params
|
90
90
|
#
|
91
|
-
# @return [
|
91
|
+
# @return [ListResponse]
|
92
92
|
#
|
93
93
|
# @see https://developer.nexmo.com/api/voice#getCalls
|
94
94
|
#
|
95
95
|
def list(params = nil)
|
96
|
-
request('/v1/calls', params: params)
|
96
|
+
request('/v1/calls', params: params, response_class: ListResponse)
|
97
97
|
end
|
98
98
|
|
99
99
|
# Get detail of a specific call.
|
@@ -103,7 +103,7 @@ module Nexmo
|
|
103
103
|
#
|
104
104
|
# @param [String] id
|
105
105
|
#
|
106
|
-
# @return [
|
106
|
+
# @return [Response]
|
107
107
|
#
|
108
108
|
# @see https://developer.nexmo.com/api/voice#getCall
|
109
109
|
#
|
@@ -124,7 +124,7 @@ module Nexmo
|
|
124
124
|
# @param [String] id
|
125
125
|
# @param [Hash] params
|
126
126
|
#
|
127
|
-
# @return [
|
127
|
+
# @return [Response]
|
128
128
|
#
|
129
129
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
130
130
|
#
|
@@ -139,7 +139,7 @@ module Nexmo
|
|
139
139
|
#
|
140
140
|
# @param [String] id
|
141
141
|
#
|
142
|
-
# @return [
|
142
|
+
# @return [Response]
|
143
143
|
#
|
144
144
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
145
145
|
#
|
@@ -154,7 +154,7 @@ module Nexmo
|
|
154
154
|
#
|
155
155
|
# @param [String] id
|
156
156
|
#
|
157
|
-
# @return [
|
157
|
+
# @return [Response]
|
158
158
|
#
|
159
159
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
160
160
|
#
|
@@ -169,7 +169,7 @@ module Nexmo
|
|
169
169
|
#
|
170
170
|
# @param [String] id
|
171
171
|
#
|
172
|
-
# @return [
|
172
|
+
# @return [Response]
|
173
173
|
#
|
174
174
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
175
175
|
#
|
@@ -184,7 +184,7 @@ module Nexmo
|
|
184
184
|
#
|
185
185
|
# @param [String] id
|
186
186
|
#
|
187
|
-
# @return [
|
187
|
+
# @return [Response]
|
188
188
|
#
|
189
189
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
190
190
|
#
|
@@ -199,7 +199,7 @@ module Nexmo
|
|
199
199
|
#
|
200
200
|
# @param [String] id
|
201
201
|
#
|
202
|
-
# @return [
|
202
|
+
# @return [Response]
|
203
203
|
#
|
204
204
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
205
205
|
#
|
@@ -220,7 +220,7 @@ module Nexmo
|
|
220
220
|
# @param [String] id
|
221
221
|
# @param [Hash] destination
|
222
222
|
#
|
223
|
-
# @return [
|
223
|
+
# @return [Response]
|
224
224
|
#
|
225
225
|
# @see https://developer.nexmo.com/api/voice#updateCall
|
226
226
|
#
|
@@ -228,22 +228,22 @@ module Nexmo
|
|
228
228
|
update(id, action: 'transfer', destination: destination)
|
229
229
|
end
|
230
230
|
|
231
|
-
# @return [
|
231
|
+
# @return [Stream]
|
232
232
|
#
|
233
233
|
def stream
|
234
|
-
@stream ||=
|
234
|
+
@stream ||= Stream.new(@config)
|
235
235
|
end
|
236
236
|
|
237
|
-
# @return [
|
237
|
+
# @return [Talk]
|
238
238
|
#
|
239
239
|
def talk
|
240
|
-
@talk ||=
|
240
|
+
@talk ||= Talk.new(@config)
|
241
241
|
end
|
242
242
|
|
243
|
-
# @return [
|
243
|
+
# @return [DTMF]
|
244
244
|
#
|
245
245
|
def dtmf
|
246
|
-
@dtmf ||=
|
246
|
+
@dtmf ||= DTMF.new(@config)
|
247
247
|
end
|
248
248
|
end
|
249
249
|
end
|