vonage 7.15.0 → 8.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -129
  3. data/lib/vonage/client.rb +4 -32
  4. data/lib/vonage/config.rb +2 -2
  5. data/lib/vonage/errors.rb +17 -31
  6. data/lib/vonage/gsm7.rb +1 -1
  7. data/lib/vonage/keys.rb +7 -1
  8. data/lib/vonage/messaging/channels/viber.rb +1 -8
  9. data/lib/vonage/messaging/channels/whats_app.rb +1 -3
  10. data/lib/vonage/namespace.rb +58 -128
  11. data/lib/vonage/numbers.rb +6 -29
  12. data/lib/vonage/signature.rb +1 -1
  13. data/lib/vonage/sms.rb +20 -0
  14. data/lib/vonage/version.rb +1 -1
  15. data/lib/vonage/video/archives.rb +187 -0
  16. data/lib/vonage/video/list_response.rb +11 -0
  17. data/lib/vonage/video/moderation.rb +73 -0
  18. data/lib/vonage/video/signals.rb +55 -0
  19. data/lib/vonage/video/streams.rb +76 -0
  20. data/lib/vonage/video.rb +91 -0
  21. data/lib/vonage/voice/actions/connect.rb +3 -27
  22. data/lib/vonage/voice/actions/pay.rb +107 -0
  23. data/lib/vonage/voice/actions/talk.rb +2 -11
  24. data/lib/vonage/voice/talk.rb +1 -11
  25. data/lib/vonage/voice.rb +0 -11
  26. data/vonage.gemspec +1 -2
  27. metadata +14 -58
  28. data/lib/vonage/meetings/applications.rb +0 -25
  29. data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
  30. data/lib/vonage/meetings/dial_in_numbers.rb +0 -23
  31. data/lib/vonage/meetings/recordings.rb +0 -36
  32. data/lib/vonage/meetings/rooms/list_response.rb +0 -11
  33. data/lib/vonage/meetings/rooms.rb +0 -155
  34. data/lib/vonage/meetings/sessions/list_response.rb +0 -11
  35. data/lib/vonage/meetings/sessions.rb +0 -28
  36. data/lib/vonage/meetings/themes/list_response.rb +0 -11
  37. data/lib/vonage/meetings/themes.rb +0 -218
  38. data/lib/vonage/meetings.rb +0 -38
  39. data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
  40. data/lib/vonage/proactive_connect/events.rb +0 -68
  41. data/lib/vonage/proactive_connect/item.rb +0 -104
  42. data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
  43. data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
  44. data/lib/vonage/proactive_connect/items.rb +0 -107
  45. data/lib/vonage/proactive_connect/list.rb +0 -168
  46. data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
  47. data/lib/vonage/proactive_connect/lists.rb +0 -35
  48. data/lib/vonage/proactive_connect.rb +0 -33
  49. data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
  50. data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
  51. data/lib/vonage/subaccounts/list_response.rb +0 -15
  52. data/lib/vonage/subaccounts.rb +0 -203
  53. data/lib/vonage/users/list_response.rb +0 -11
  54. data/lib/vonage/users.rb +0 -156
  55. data/lib/vonage/verify2/channels/email.rb +0 -38
  56. data/lib/vonage/verify2/channels/silent_auth.rb +0 -32
  57. data/lib/vonage/verify2/channels/sms.rb +0 -39
  58. data/lib/vonage/verify2/channels/voice.rb +0 -32
  59. data/lib/vonage/verify2/channels/whats_app.rb +0 -38
  60. data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
  61. data/lib/vonage/verify2/start_verification_options.rb +0 -71
  62. data/lib/vonage/verify2/workflow.rb +0 -39
  63. data/lib/vonage/verify2/workflow_builder.rb +0 -25
  64. data/lib/vonage/verify2.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe42d262916665b0528b89b25fc9094ff4009739cea53ec28a416afe2ec232c8
4
- data.tar.gz: d1bb14fcc3e8c862dedd87a32b80034d9914c0cafcc2c53f071b05a9c640a644
3
+ metadata.gz: e003a6ed3211d3eace84884bf3fb03d21b81f097b13aba079f1906daf95380ff
4
+ data.tar.gz: 956c6921b50df45aaf2f1901b08ccd3cb164c2553b23d8e45570f63dcdf6f960
5
5
  SHA512:
6
- metadata.gz: a52f19d149c83ff7cbc2fe73982abaf79901c146fa45d006d19ba9f32b9640bf14065e132362aae591869339109deeafa68e72349a1e6d9f2a6fba173efbf9a6
7
- data.tar.gz: 38f8d3a78930e5b13e8ed71e3bce0ee37789a506f053e9f31c543bdac10760f574dc976fca097f64f47419f9d99c4b912ce32484b389243b96c52f5fa6e7ef4c
6
+ metadata.gz: 1500879cd4a974009f6510cf12ea15b4ce60a9163f916b8a5e07fe785323c24c6909134163b21e29afc9c251550fd36a9e348c2ff7eac3b18b45f0e4ef7e1be1
7
+ data.tar.gz: fe368d23b897a7f1b2b9ba473c993a351ffb1233ef80304c16ec69ed28692c93e422c7a453f8d0da14b6e038424c215026a945d7ccee9b4a26412e3ecbe5435f
data/README.md CHANGED
@@ -17,8 +17,6 @@ need a Vonage account. Sign up [for free at vonage.com][signup].
17
17
  * [Webhook signatures](#webhook-signatures)
18
18
  * [Pagination](#pagination)
19
19
  * [NCCO Builder](#ncco-builder)
20
- * [Messages API](#messages-api)
21
- * [Verify API v2](#verify-api-v2)
22
20
  * [Documentation](#documentation)
23
21
  * [Frequently Asked Questions](#frequently-asked-questions)
24
22
  * [Supported APIs](#supported-apis)
@@ -222,136 +220,11 @@ Once the message data is created, you can then send the message.
222
220
  response = client.messaging.send(to: "447700900000", from: "447700900001", **message)
223
221
  ```
224
222
 
225
- ## Verify API v2
226
-
227
- The [Vonage Verify API v2](https://developer.vonage.com/en/verify/verify-v2/overview) allows you to manage 2FA verification workflows over a number of different channels such as SMS, WhatsApp, WhatsApp Interactive, Voice, Email, and Silent Authentication, either individually or in combination with each other. See the Vonage Developer Documentation for a [complete API reference](https://developer.vonage.com/en/api/verify.v2) listing all the channels, verification options, and callback types.
228
-
229
- The Ruby SDK provides two methods for interacting with the Verify v2 API:
230
-
231
- - `Verify2#start_verification`: starts a new verification request. Here you can specify options for the request and the workflow to be used.
232
- - `Verify2#check_code`: for channels where the end-user is sent a one-time code, this method is used to verify the code against the `request_id` of the verification request created by the `start_verification` method.
233
-
234
- ### Creating a Verify2 Object
235
-
236
- ```ruby
237
- verify = client.verify2
238
- ```
239
-
240
- ### Making a verification request
241
-
242
- For simple requests, you may prefer to manually set the value for `workflow` (an array of one or more hashes containing the settings for a particular channel) and any optional params.
243
-
244
- Example with the required `:brand` and `:workflow` arguments:
245
-
246
- ```ruby
247
- verification_request = verify.start_verification(
248
- brand: 'Acme',
249
- workflow: [{channel: 'sms', to: '447000000000'}]
250
- )
251
- ```
252
-
253
- Example with the required `:brand` and `:workflow` arguments, and an optional `code_length`:
254
-
255
- ```ruby
256
- verification_request = verify.start_verification(
257
- brand: 'Acme',
258
- workflow: [{channel: 'sms', to: '447000000000'}],
259
- code_length: 6
260
- )
261
- ```
262
-
263
- For more complex requests (e.g. with mutliple workflow channels or addtional options), or to take advantage of built-in input validation, you can use the `StartVerificationOptions` object and the `Workflow` and various channel objects or the `WorkflowBuilder`:
264
-
265
- #### Create options using StartVerificationOptions object
266
-
267
- ```ruby
268
- opts = verify.start_verification_options(
269
- locale: 'fr-fr',
270
- code_length: 6,
271
- client_ref: 'abc-123'
272
- ).to_h
273
-
274
- verification_request = verify.start_verification(
275
- brand: 'Acme',
276
- workflow: [{channel: 'email', to: 'alice.example.com'}],
277
- **opts
278
- )
279
- ```
280
-
281
- #### Create workflow using Workflow and Channel objects
282
-
283
- ```ruby
284
- # Instantiate a Workflow object
285
- workflow = verify.workflow
286
-
287
- # Add channels to the workflow
288
- workflow << workflow.sms(to: '447000000000')
289
- workflow << workflow.email(to: 'alice.example.com')
290
-
291
- # Channel data is encpsulated in channel objects stored in the Workflow list array
292
- workflow.list
293
- # => [ #<Vonage::Verify2::Channels::SMS:0x0000561474a74778 @channel="sms", @to="447000000000">,
294
- #<Vonage::Verify2::Channels::Email:0x0000561474c51a28 @channel="email", @to="alice.example.com">]
295
-
296
- # To use the list as the value for `:workflow` in a `start_verification` request call,
297
- # the objects must be hashified
298
- workflow_list = workflow.hashified_list
299
- # => [{:channel=>"sms", :to=>"447000000000"}, {:channel=>"email", :to=>"alice.example.com"}]
300
-
301
- verification_request = verify.start_verification(brand: 'Acme', workflow: workflow_list)
302
- ```
303
-
304
- #### Create a workflow using the WorkflowBuilder
305
-
306
- ```ruby
307
- workflow = verify.workflow_builder.build do |builder|
308
- builder.add_voice(to: '447000000001')
309
- builder.add_whatsapp(to: '447000000000')
310
- end
311
-
312
- workflow_list = workflow.hashified_list
313
- # => [{:channel=>"voice", :to=>"447000000001"}, {:channel=>"whatsapp", :to=>"447000000000"}]
314
-
315
- verification_request = verify.start_verification(brand: 'Acme', workflow: workflow_list)
316
- ```
317
-
318
- ### Cancelling a request
319
-
320
- You can cancel in in-progress verification request
321
-
322
- ```ruby
323
- # Get the `request_id` from the Vonage#Response object returned by the `start_verification` method call
324
- request_id = verification_request.request_id
325
-
326
- verify.cancel_verification_request(request_id: request_id)
327
- ```
328
-
329
- ### Checking a code
330
-
331
- ```ruby
332
- # Get the `request_id` from the Vonage#Response object returned by the `start_verification` method call
333
- request_id = verification_request.request_id
334
-
335
- # Get the one-time code via user input
336
- # e.g. from params in a route handler or controller action for a form input
337
- code = params[:code]
338
-
339
- begin
340
- code_check = verify.check_code(request_id: request_id, code: code)
341
- rescue => error
342
- # an invalid code will raise an exception of type Vonage::ClientError
343
- end
344
-
345
- if code_check.http_response.code == '200'
346
- # code is valid
347
- end
348
- ```
349
-
350
223
  ## Documentation
351
224
 
352
225
  Vonage Ruby documentation: https://www.rubydoc.info/github/Vonage/vonage-ruby-sdk
353
226
 
354
- Vonage Ruby code examples: https://github.com/Vonage/vonage-ruby-code-snippets
227
+ Vonage Ruby code examples: https://github.com/Nexmo/nexmo-ruby-code-snippets
355
228
 
356
229
  Vonage APIs API reference: https://developer.nexmo.com/api
357
230
 
@@ -379,7 +252,6 @@ The following is a list of Vonage APIs and whether the Ruby SDK provides support
379
252
  | Reports API | Beta |❌|
380
253
  | SMS API | General Availability |✅|
381
254
  | Verify API | General Availability |✅|
382
- | Verify API v2 | General Availability |✅|
383
255
  | Voice API | General Availability |✅|
384
256
 
385
257
  ## License
data/lib/vonage/client.rb CHANGED
@@ -61,13 +61,6 @@ module Vonage
61
61
  @files ||= T.let(Files.new(config), T.nilable(Vonage::Files))
62
62
  end
63
63
 
64
- # @return [Meetings]
65
- #
66
- sig { returns(T.nilable(Vonage::Meetings)) }
67
- def meetings
68
- @meetings ||= T.let(Meetings.new(config), T.nilable(Vonage::Meetings))
69
- end
70
-
71
64
  # @return [Messages]
72
65
  #
73
66
  sig { returns(T.nilable(Vonage::Messages)) }
@@ -103,13 +96,6 @@ module Vonage
103
96
  @pricing ||= T.let(PricingTypes.new(config), T.nilable(Vonage::PricingTypes))
104
97
  end
105
98
 
106
- # @return [ProactiveConnect]
107
- #
108
- sig { returns(T.nilable(Vonage::ProactiveConnect)) }
109
- def proactive_connect
110
- @proactive_connect ||= T.let(ProactiveConnect.new(config), T.nilable(Vonage::ProactiveConnect))
111
- end
112
-
113
99
  # @return [Redact]
114
100
  #
115
101
  sig { returns(T.nilable(Vonage::Redact)) }
@@ -131,13 +117,6 @@ module Vonage
131
117
  @sms ||= T.let(SMS.new(config), T.nilable(Vonage::SMS))
132
118
  end
133
119
 
134
- # @return [Subaccounts]
135
- #
136
- sig { returns(T.nilable(Vonage::Subaccounts)) }
137
- def subaccounts
138
- @subaccounts ||= T.let(Subaccounts.new(config), T.nilable(Vonage::Subaccounts))
139
- end
140
-
141
120
  # @return [TFA]
142
121
  #
143
122
  sig { returns(T.nilable(Vonage::TFA)) }
@@ -145,13 +124,6 @@ module Vonage
145
124
  @tfa ||= T.let(TFA.new(config), T.nilable(Vonage::TFA))
146
125
  end
147
126
 
148
- # @return [Users]
149
- #
150
- sig { returns(T.nilable(Vonage::Users)) }
151
- def users
152
- @users ||= T.let(Users.new(config), T.nilable(Vonage::Users))
153
- end
154
-
155
127
  # @return [Verify]
156
128
  #
157
129
  sig { returns(T.nilable(Vonage::Verify)) }
@@ -159,11 +131,11 @@ module Vonage
159
131
  @verify ||= T.let(Verify.new(config), T.nilable(Vonage::Verify))
160
132
  end
161
133
 
162
- # @return [Verify2]
134
+ # @return [Video]
163
135
  #
164
- sig { returns(T.nilable(Vonage::Verify2)) }
165
- def verify2
166
- @verify2 ||= T.let(Verify2.new(config), T.nilable(Vonage::Verify2))
136
+ sig { returns(T.nilable(Vonage::Video)) }
137
+ def video
138
+ @video ||= T.let(Video.new(config), T.nilable(Vonage::Video))
167
139
  end
168
140
 
169
141
  # @return [Voice]
data/lib/vonage/config.rb CHANGED
@@ -18,7 +18,7 @@ module Vonage
18
18
  self.signature_secret = ENV['VONAGE_SIGNATURE_SECRET']
19
19
  self.signature_method = ENV['VONAGE_SIGNATURE_METHOD'] || 'md5hash'
20
20
  self.token = T.let(nil, T.nilable(String))
21
- self.vonage_host = 'api-eu.vonage.com'
21
+ self.video_host = 'video.api.vonage.com'
22
22
  end
23
23
 
24
24
  # Merges the config with the given options hash.
@@ -200,7 +200,7 @@ module Vonage
200
200
  attr_writer :token
201
201
 
202
202
  sig { returns(String) }
203
- attr_accessor :vonage_host
203
+ attr_accessor :video_host
204
204
 
205
205
  protected
206
206
 
data/lib/vonage/errors.rb CHANGED
@@ -1,25 +1,14 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
- require "json"
3
+ require 'json'
4
4
 
5
5
  module Vonage
6
6
  module Errors
7
7
  extend T::Sig
8
8
 
9
- sig do
10
- params(
11
- response:
12
- T.any(
13
- Net::HTTPUnauthorized,
14
- Net::HTTPClientError,
15
- Net::HTTPServerError,
16
- T.untyped
17
- )
18
- ).returns(Vonage::Error)
19
- end
9
+ sig {params(response: T.any(Net::HTTPUnauthorized, Net::HTTPClientError, Net::HTTPServerError, T.untyped)).returns(Vonage::Error)}
20
10
  def self.parse(response)
21
- exception_class =
22
- case response
11
+ exception_class = case response
23
12
  when Net::HTTPUnauthorized
24
13
  AuthenticationError
25
14
  when Net::HTTPClientError
@@ -30,34 +19,31 @@ module Vonage
30
19
  Error
31
20
  end
32
21
 
33
- message =
34
- if response.content_type == "application/json"
35
- hash = ::JSON.parse(response.body)
36
-
37
- if hash.key?("error_title")
38
- hash["error_title"]
39
- elsif hash.key?("error-code-label")
40
- hash["error-code-label"]
41
- elsif hash.key?("description")
42
- hash["description"]
43
- elsif hash.key?("message")
44
- hash["message"]
45
- elsif problem_details?(hash)
46
- problem_details_message(hash)
47
- end
22
+ message = if response.content_type == 'application/json'
23
+ hash = ::JSON.parse(response.body)
24
+
25
+ if hash.key?('error_title')
26
+ hash['error_title']
27
+ elsif hash.key?('error-code-label')
28
+ hash['error-code-label']
29
+ elsif hash.key?('description')
30
+ hash['description']
31
+ elsif problem_details?(hash)
32
+ problem_details_message(hash)
48
33
  end
34
+ end
49
35
 
50
36
  exception_class.new(message)
51
37
  end
52
38
 
53
39
  sig { params(hash: T::Hash[String, T.untyped]).returns(T::Boolean) }
54
40
  def self.problem_details?(hash)
55
- hash.key?("title") && hash.key?("detail") && hash.key?("type")
41
+ hash.key?('title') && hash.key?('detail') && hash.key?('type')
56
42
  end
57
43
 
58
44
  sig { params(hash: T::Hash[String, T.untyped]).returns(String) }
59
45
  def self.problem_details_message(hash)
60
- "#{hash["title"]}. #{hash["detail"]} See #{hash["type"]} for more info, or email support@nexmo.com if you have any questions."
46
+ "#{hash['title']}. #{hash['detail']} See #{hash['type']} for more info, or email support@nexmo.com if you have any questions."
61
47
  end
62
48
  end
63
49
 
data/lib/vonage/gsm7.rb CHANGED
@@ -4,7 +4,7 @@ module Vonage
4
4
  module GSM7
5
5
  extend T::Sig
6
6
 
7
- CHARACTERS = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ ¡£¤¥§¿ÄÅÆÇÉÑÖØÜßàäåæèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€"
7
+ CHARACTERS = "\n\f\r !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ ¡£¤¥§¿ÄÅÆÉÑÖØÜßàäåæçèéìñòöøùüΓΔΘΛΞΠΣΦΨΩ€"
8
8
 
9
9
  REGEXP = /\A[#{Regexp.escape(CHARACTERS)}]*\z/
10
10
 
data/lib/vonage/keys.rb CHANGED
@@ -21,7 +21,13 @@ module Vonage
21
21
  'voice_callback_value',
22
22
  'voice_status_callback',
23
23
  'messages_callback_value',
24
- 'messages_callback_type'
24
+ 'messages_callback_type',
25
+ 'add_stream',
26
+ 'has_audio',
27
+ 'has_video',
28
+ 'remove_stream',
29
+ 'screenshare_type',
30
+ 'archive_mode'
25
31
  ]
26
32
  hash.transform_keys do |k|
27
33
  if exceptions.include?(k.to_s)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Vonage
4
4
  class Messaging::Channels::Viber < Messaging::Message
5
- MESSAGE_TYPES = ['text', 'image', 'video', 'file']
5
+ MESSAGE_TYPES = ['text', 'image']
6
6
 
7
7
  attr_reader :data
8
8
 
@@ -33,13 +33,6 @@ module Vonage
33
33
  when 'image'
34
34
  raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
35
35
  raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
36
- when 'video'
37
- raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
38
- raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
39
- raise Vonage::ClientError.new(":thumb_url is required in :message") unless message[:thumb_url]
40
- when 'file'
41
- raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
42
- raise Vonage::ClientError.new(":url is required in :message") unless message[:url]
43
36
  end
44
37
  end
45
38
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Vonage
4
4
  class Messaging::Channels::WhatsApp < Messaging::Message
5
- MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', 'sticker', 'custom']
5
+ MESSAGE_TYPES = ['text', 'image', 'audio', 'video', 'file', 'template', 'custom']
6
6
 
7
7
  attr_reader :data
8
8
 
@@ -35,8 +35,6 @@ module Vonage
35
35
  raise Vonage::ClientError.new(":name is required in :template") unless message[:name]
36
36
  raise Vonage::ClientError.new(":whatsapp is required in :opts") unless opts[:whatsapp]
37
37
  raise Vonage::ClientError.new(":locale is required in :whatsapp") unless opts[:whatsapp][:locale]
38
- when 'sticker'
39
- raise Vonage::ClientError.new(":message must contain either :id or :url") unless message.has_key?(:id) ^ message.has_key?(:url)
40
38
  when 'custom'
41
39
  raise Vonage::ClientError.new(":message must be a Hash") unless message.is_a? Hash
42
40
  else