vonage 7.18.0 → 8.0.0.beta

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -271
  3. data/lib/vonage/applications.rb +4 -12
  4. data/lib/vonage/client.rb +4 -32
  5. data/lib/vonage/client_error.rb +1 -1
  6. data/lib/vonage/config.rb +3 -7
  7. data/lib/vonage/errors.rb +20 -37
  8. data/lib/vonage/gsm7.rb +1 -1
  9. data/lib/vonage/jwt.rb +0 -17
  10. data/lib/vonage/keys.rb +7 -1
  11. data/lib/vonage/logger.rb +3 -5
  12. data/lib/vonage/messaging/channels/viber.rb +1 -8
  13. data/lib/vonage/messaging/channels/whats_app.rb +1 -3
  14. data/lib/vonage/messaging.rb +0 -11
  15. data/lib/vonage/namespace.rb +58 -128
  16. data/lib/vonage/numbers.rb +6 -29
  17. data/lib/vonage/server_error.rb +1 -1
  18. data/lib/vonage/signature.rb +5 -5
  19. data/lib/vonage/sms.rb +20 -20
  20. data/lib/vonage/version.rb +1 -1
  21. data/lib/vonage/video/archives.rb +187 -0
  22. data/lib/vonage/video/list_response.rb +11 -0
  23. data/lib/vonage/video/moderation.rb +73 -0
  24. data/lib/vonage/video/signals.rb +55 -0
  25. data/lib/vonage/video/streams.rb +76 -0
  26. data/lib/vonage/video.rb +91 -0
  27. data/lib/vonage/voice/actions/connect.rb +3 -27
  28. data/lib/vonage/voice/actions/pay.rb +107 -0
  29. data/lib/vonage/voice/actions/talk.rb +2 -11
  30. data/lib/vonage/voice/talk.rb +1 -11
  31. data/lib/vonage/voice.rb +0 -22
  32. data/lib/vonage.rb +0 -1
  33. data/vonage.gemspec +1 -2
  34. metadata +14 -59
  35. data/lib/vonage/api_error.rb +0 -33
  36. data/lib/vonage/meetings/applications.rb +0 -25
  37. data/lib/vonage/meetings/dial_in_numbers/list_response.rb +0 -11
  38. data/lib/vonage/meetings/dial_in_numbers.rb +0 -23
  39. data/lib/vonage/meetings/recordings.rb +0 -36
  40. data/lib/vonage/meetings/rooms/list_response.rb +0 -11
  41. data/lib/vonage/meetings/rooms.rb +0 -155
  42. data/lib/vonage/meetings/sessions/list_response.rb +0 -11
  43. data/lib/vonage/meetings/sessions.rb +0 -28
  44. data/lib/vonage/meetings/themes/list_response.rb +0 -11
  45. data/lib/vonage/meetings/themes.rb +0 -218
  46. data/lib/vonage/meetings.rb +0 -38
  47. data/lib/vonage/proactive_connect/events/list_response.rb +0 -11
  48. data/lib/vonage/proactive_connect/events.rb +0 -68
  49. data/lib/vonage/proactive_connect/item.rb +0 -104
  50. data/lib/vonage/proactive_connect/items/file_response.rb +0 -32
  51. data/lib/vonage/proactive_connect/items/list_response.rb +0 -11
  52. data/lib/vonage/proactive_connect/items.rb +0 -107
  53. data/lib/vonage/proactive_connect/list.rb +0 -168
  54. data/lib/vonage/proactive_connect/lists/list_response.rb +0 -11
  55. data/lib/vonage/proactive_connect/lists.rb +0 -35
  56. data/lib/vonage/proactive_connect.rb +0 -33
  57. data/lib/vonage/subaccounts/balance_transfers/list_response.rb +0 -11
  58. data/lib/vonage/subaccounts/credit_transfers/list_response.rb +0 -11
  59. data/lib/vonage/subaccounts/list_response.rb +0 -15
  60. data/lib/vonage/subaccounts.rb +0 -203
  61. data/lib/vonage/users/list_response.rb +0 -11
  62. data/lib/vonage/users.rb +0 -156
  63. data/lib/vonage/verify2/channels/email.rb +0 -38
  64. data/lib/vonage/verify2/channels/silent_auth.rb +0 -32
  65. data/lib/vonage/verify2/channels/sms.rb +0 -39
  66. data/lib/vonage/verify2/channels/voice.rb +0 -32
  67. data/lib/vonage/verify2/channels/whats_app.rb +0 -38
  68. data/lib/vonage/verify2/channels/whats_app_interactive.rb +0 -32
  69. data/lib/vonage/verify2/start_verification_options.rb +0 -62
  70. data/lib/vonage/verify2/workflow.rb +0 -39
  71. data/lib/vonage/verify2/workflow_builder.rb +0 -25
  72. data/lib/vonage/verify2.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1efb8423ce5ccb2549f6f3d65ddc659ab8c28a965888372b06845911b3e598ff
4
- data.tar.gz: 4bc50573bada4e41fa89bb63ea02633435426f482722caafd10a904ca7a6b3ea
3
+ metadata.gz: e003a6ed3211d3eace84884bf3fb03d21b81f097b13aba079f1906daf95380ff
4
+ data.tar.gz: 956c6921b50df45aaf2f1901b08ccd3cb164c2553b23d8e45570f63dcdf6f960
5
5
  SHA512:
6
- metadata.gz: 296c28e8d4a3f469f938ee2b5cad316a6e3a08696fbce2d17b8afcc3abac5a6d135be9acdb589f3ca4ab73d3ff25d77d37d1457d774bc1149043c6684c0387a4
7
- data.tar.gz: 2cea85e954c16bd217efad49454183a68aac48aabb4d995eb1db5376902ff1fe13e296867ffadea0695c8586b6bc06e953004894e35cb487701a8327073315ec
6
+ metadata.gz: 1500879cd4a974009f6510cf12ea15b4ce60a9163f916b8a5e07fe785323c24c6909134163b21e29afc9c251550fd36a9e348c2ff7eac3b18b45f0e4ef7e1be1
7
+ data.tar.gz: fe368d23b897a7f1b2b9ba473c993a351ffb1233ef80304c16ec69ed28692c93e422c7a453f8d0da14b6e038424c215026a945d7ccee9b4a26412e3ecbe5435f
data/README.md CHANGED
@@ -12,14 +12,11 @@ need a Vonage account. Sign up [for free at vonage.com][signup].
12
12
  * [Installation](#installation)
13
13
  * [Usage](#usage)
14
14
  * [Logging](#logging)
15
- * [Exceptions](#exceptions)
16
15
  * [Overriding the default hosts](#overriding-the-default-hosts)
17
16
  * [JWT authentication](#jwt-authentication)
18
17
  * [Webhook signatures](#webhook-signatures)
19
18
  * [Pagination](#pagination)
20
19
  * [NCCO Builder](#ncco-builder)
21
- * [Messages API](#messages-api)
22
- * [Verify API v2](#verify-api-v2)
23
20
  * [Documentation](#documentation)
24
21
  * [Frequently Asked Questions](#frequently-asked-questions)
25
22
  * [Supported APIs](#supported-apis)
@@ -83,46 +80,6 @@ By default the library sets the logger to `Rails.logger` if it is defined.
83
80
 
84
81
  To disable logging set the logger to `nil`.
85
82
 
86
- ## Exceptions
87
-
88
- Where exceptions result from an error response from the Vonage API (HTTP responses that aren't ion the range `2xx` or `3xx`), the `Net::HTTPResponse` object will be available as a property of the `Exception` object via a `http_response` getter method (where there is no `Net::HTTPResponse` object associated with the exception, the value of `http_response` will be `nil`).
89
-
90
- You can rescue the the exception to access the `http_response`, as well as use other getters provided for specific parts of the response. For example:
91
-
92
- ```ruby
93
- begin
94
- verification_request = client.verify2.start_verification(
95
- brand: 'Acme',
96
- workflow: [{channel: 'sms', to: '44700000000'}]
97
- )
98
- rescue Vonage::APIError => error
99
- if error.http_response
100
- error.http_response # => #<Net::HTTPUnauthorized 401 Unauthorized readbody=true>
101
- error.http_response_code # => "401"
102
- error.http_response_headers # => {"date"=>["Sun, 24 Sep 2023 11:08:47 GMT"], ...rest of headers}
103
- error.http_response_body # => {"title"=>"Unauthorized", ...rest of body}
104
- end
105
- end
106
- ```
107
-
108
- For certain legacy API products, such as the [SMS API](https://developer.vonage.com/en/messaging/sms/overview), [Verify v1 API](https://developer.vonage.com/en/verify/verify-v1/overview) and [Number Insight v1 API](https://developer.vonage.com/en/number-insight/overview), a `200` response is received even in situations where there is an API-related error. For exceptions raised in these situation, rather than a `Net::HTTPResponse` object, a `Vonage::Response` object will be made available as a property of the exception via a `response` getter method. The properties on this object will depend on the response data provided by the API endpoint. For example:
109
-
110
- ```ruby
111
- begin
112
- sms = client.sms.send(
113
- from: 'Vonage',
114
- to: '44700000000',
115
- text: 'Hello World!'
116
- )
117
- rescue Vonage::Error => error
118
- if error.is_a? Vonage::ServiceError
119
- error.response # => #<Vonage::Response:0x0000555b2e49d4f8>
120
- error.response.messages.first.status # => "4"
121
- error.response.messages.first.error_text # => "Bad Credentials"
122
- error.response.http_response # => #<Net::HTTPOK 200 OK readbody=true>
123
- end
124
- end
125
- ```
126
83
 
127
84
  ## Overriding the default hosts
128
85
 
@@ -168,7 +125,7 @@ claims = {
168
125
  token = Vonage::JWT.generate(claims)
169
126
 
170
127
  client = Vonage::Client.new(token: token)
171
- ```
128
+ ````
172
129
 
173
130
  Documentation for the Vonage Ruby JWT generator gem can be found at
174
131
  [https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby](https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby).
@@ -176,115 +133,23 @@ The documentation outlines all the possible parameters you can use to customize
176
133
 
177
134
  ## Webhook signatures
178
135
 
179
- Certain Vonage APIs provide signed [webhooks](https://developer.vonage.com/en/getting-started/concepts/webhooks) as a means of verifying the origin of the webhooks. The exact signing mechanism varies depending on the API.
180
-
181
- ### Signature in Request Body
182
-
183
- The [SMS API](https://developer.vonage.com/en/messaging/sms/overview) signs the webhook request using a hash digest. This is assigned to a `sig` parameter in the request body.
184
-
185
- You can verify the webhook request using the `Vonage::SMS#verify_webhook_sig` method. As well as the **request params** from the received webhook, the method also needs access to the signature secret associated with the Vonage account (available from the [Vonage Dashboard](https://dashboard.nexmo.com/settings)), and the signature method used for signing (e.g. `sha512`), again this is based on thes setting in the Dashboard.
186
-
187
- There are a few different ways of providing these values to the method:
188
-
189
- 1. Pass all values to the method invocation.
190
-
191
- ```ruby
192
- client = Vonage::Client.new
193
-
194
- client.sms.verify_webhook_sig(
195
- webhook_params: params,
196
- signature_secret: 'secret',
197
- signature_method: 'sha512'
198
- ) # => returns true if the signature is valid, false otherwise
199
- ```
200
-
201
- 2. Set `signature_secret` and `signature_method` at `Client` instantiation.
202
-
203
- ```ruby
204
- client = Vonage::Client.new(
205
- signature_secret: 'secret',
206
- signature_method: 'sha512'
207
- )
208
-
209
- client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
210
- ```
211
-
212
- 3. Set `signature_secret` and `signature_method` on the `Config` object.
136
+ To check webhook signatures you'll also need to specify the `signature_secret` option. For example:
213
137
 
214
138
  ```ruby
215
139
  client = Vonage::Client.new
216
140
  client.config.signature_secret = 'secret'
217
141
  client.config.signature_method = 'sha512'
218
142
 
219
- client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
220
- ```
221
-
222
- 4. Set `signature_secret` and `signature_method` as environment variables named `VONAGE_SIGNATURE_SECRET` and `VONAGE_SIGNATURE_METHOD`
223
-
224
- ```ruby
225
- client = Vonage::Client.new
226
-
227
- client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
228
- ```
229
-
230
- **Note:** Webhook signing for the SMS API is not switched on by default. You'll need to contact support@vonage.com to enable message signing on your account.
231
-
232
- ### Signed JWT in Header
233
-
234
- The [Voice API](https://developer.vonage.com/en/voice/voice-api/overview) and [Messages API](https://developer.vonage.com/en/messages/overview) both include an `Authorization` header in their webhook requests. The value of this header includes a JSON Web Token (JWT) signed using the Signature Secret associated with your Vonage account.
235
-
236
- The `Vonage::Voice` and `Vonage::Messaging` classes both define a `verify_webhook_token` method which can be used to verify the JWT received in the webhook `Authorization` header.
237
-
238
- To verify the JWT, you'll first need to extract it from the `Authorization` header. The header value will look something like the following:
239
-
240
- ```ruby
241
- "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1OTUyN" # remainder of token omitted for brevity
242
- ```
243
-
244
- Note: we are only interested in the token itself, which comes *after* the word `Bearer` and the space.
245
-
246
- Once you have extrated the token, you can pass it to the `verify_webhook_token` method in order to verify it.
247
-
248
- The method also needs access to the the method also needs access to the signature secret associated with the Vonage account (available from the [Vonage Dashboard](https://dashboard.nexmo.com/settings)). There are a few different ways of providing this value to the method:
249
-
250
- 1. Pass all values to the method invocation.
251
-
252
- ```ruby
253
- client = Vonage::Client.new
254
-
255
- client.voice.verify_webhook_token(
256
- token: extracted_token,
257
- signature_secret: 'secret'
258
- ) # => returns true if the token is valid, false otherwise
259
- ```
260
-
261
- 2. Set `signature_secret` at `Client` instantiation.
262
-
263
- ```ruby
264
- client = Vonage::Client.new(
265
- signature_secret: 'secret'
266
- )
267
-
268
- client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
269
- ```
270
-
271
- 3. Set `signature_secret` on the `Config` object.
272
-
273
- ```ruby
274
- client = Vonage::Client.new
275
- client.config.signature_secret = 'secret'
276
- client.config.signature_method = 'sha512'
277
-
278
- client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
143
+ if client.signature.check(request.GET)
144
+ # valid signature
145
+ else
146
+ # invalid signature
147
+ end
279
148
  ```
280
149
 
281
- 4. Set `signature_secret` as an environment variable named `VONAGE_SIGNATURE_SECRET`
150
+ Alternatively you can set the `VONAGE_SIGNATURE_SECRET` environment variable.
282
151
 
283
- ```ruby
284
- client = Vonage::Client.new
285
-
286
- client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
287
- ```
152
+ Note: you'll need to contact support@nexmo.com to enable message signing on your account.
288
153
 
289
154
  ## Pagination
290
155
 
@@ -355,136 +220,11 @@ Once the message data is created, you can then send the message.
355
220
  response = client.messaging.send(to: "447700900000", from: "447700900001", **message)
356
221
  ```
357
222
 
358
- ## Verify API v2
359
-
360
- 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.
361
-
362
- The Ruby SDK provides two methods for interacting with the Verify v2 API:
363
-
364
- - `Verify2#start_verification`: starts a new verification request. Here you can specify options for the request and the workflow to be used.
365
- - `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.
366
-
367
- ### Creating a Verify2 Object
368
-
369
- ```ruby
370
- verify = client.verify2
371
- ```
372
-
373
- ### Making a verification request
374
-
375
- 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.
376
-
377
- Example with the required `:brand` and `:workflow` arguments:
378
-
379
- ```ruby
380
- verification_request = verify.start_verification(
381
- brand: 'Acme',
382
- workflow: [{channel: 'sms', to: '447000000000'}]
383
- )
384
- ```
385
-
386
- Example with the required `:brand` and `:workflow` arguments, and an optional `code_length`:
387
-
388
- ```ruby
389
- verification_request = verify.start_verification(
390
- brand: 'Acme',
391
- workflow: [{channel: 'sms', to: '447000000000'}],
392
- code_length: 6
393
- )
394
- ```
395
-
396
- 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`:
397
-
398
- #### Create options using StartVerificationOptions object
399
-
400
- ```ruby
401
- opts = verify.start_verification_options(
402
- locale: 'fr-fr',
403
- code_length: 6,
404
- client_ref: 'abc-123'
405
- ).to_h
406
-
407
- verification_request = verify.start_verification(
408
- brand: 'Acme',
409
- workflow: [{channel: 'email', to: 'alice.example.com'}],
410
- **opts
411
- )
412
- ```
413
-
414
- #### Create workflow using Workflow and Channel objects
415
-
416
- ```ruby
417
- # Instantiate a Workflow object
418
- workflow = verify.workflow
419
-
420
- # Add channels to the workflow
421
- workflow << workflow.sms(to: '447000000000')
422
- workflow << workflow.email(to: 'alice.example.com')
423
-
424
- # Channel data is encpsulated in channel objects stored in the Workflow list array
425
- workflow.list
426
- # => [ #<Vonage::Verify2::Channels::SMS:0x0000561474a74778 @channel="sms", @to="447000000000">,
427
- #<Vonage::Verify2::Channels::Email:0x0000561474c51a28 @channel="email", @to="alice.example.com">]
428
-
429
- # To use the list as the value for `:workflow` in a `start_verification` request call,
430
- # the objects must be hashified
431
- workflow_list = workflow.hashified_list
432
- # => [{:channel=>"sms", :to=>"447000000000"}, {:channel=>"email", :to=>"alice.example.com"}]
433
-
434
- verification_request = verify.start_verification(brand: 'Acme', workflow: workflow_list)
435
- ```
436
-
437
- #### Create a workflow using the WorkflowBuilder
438
-
439
- ```ruby
440
- workflow = verify.workflow_builder.build do |builder|
441
- builder.add_voice(to: '447000000001')
442
- builder.add_whatsapp(to: '447000000000')
443
- end
444
-
445
- workflow_list = workflow.hashified_list
446
- # => [{:channel=>"voice", :to=>"447000000001"}, {:channel=>"whatsapp", :to=>"447000000000"}]
447
-
448
- verification_request = verify.start_verification(brand: 'Acme', workflow: workflow_list)
449
- ```
450
-
451
- ### Cancelling a request
452
-
453
- You can cancel in in-progress verification request
454
-
455
- ```ruby
456
- # Get the `request_id` from the Vonage#Response object returned by the `start_verification` method call
457
- request_id = verification_request.request_id
458
-
459
- verify.cancel_verification_request(request_id: request_id)
460
- ```
461
-
462
- ### Checking a code
463
-
464
- ```ruby
465
- # Get the `request_id` from the Vonage#Response object returned by the `start_verification` method call
466
- request_id = verification_request.request_id
467
-
468
- # Get the one-time code via user input
469
- # e.g. from params in a route handler or controller action for a form input
470
- code = params[:code]
471
-
472
- begin
473
- code_check = verify.check_code(request_id: request_id, code: code)
474
- rescue => error
475
- # an invalid code will raise an exception of type Vonage::ClientError
476
- end
477
-
478
- if code_check.http_response.code == '200'
479
- # code is valid
480
- end
481
- ```
482
-
483
223
  ## Documentation
484
224
 
485
225
  Vonage Ruby documentation: https://www.rubydoc.info/github/Vonage/vonage-ruby-sdk
486
226
 
487
- 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
488
228
 
489
229
  Vonage APIs API reference: https://developer.nexmo.com/api
490
230
 
@@ -512,7 +252,6 @@ The following is a list of Vonage APIs and whether the Ruby SDK provides support
512
252
  | Reports API | Beta |❌|
513
253
  | SMS API | General Availability |✅|
514
254
  | Verify API | General Availability |✅|
515
- | Verify API v2 | General Availability |✅|
516
255
  | Voice API | General Availability |✅|
517
256
 
518
257
  ## License
@@ -33,8 +33,6 @@ module Vonage
33
33
  #
34
34
  # response = client.applications.create(params)
35
35
  #
36
- # @param [Hash] params
37
- #
38
36
  # @option params [required, String] :name
39
37
  # Application name.
40
38
  #
@@ -46,9 +44,7 @@ module Vonage
46
44
  # This contains the configuration for each product.
47
45
  # This replaces the application `type` from version 1 of the Application API.
48
46
  #
49
- # @option params [Hash] :privacy
50
- # - **:improve_ai** (Boolean) If set to `true``, Vonage may store and use your content and data for the improvement
51
- # of Vonage's AI based services and technologies.
47
+ # @param [Hash] params
52
48
  #
53
49
  # @return [Response]
54
50
  #
@@ -77,7 +73,7 @@ module Vonage
77
73
  # Set this to `false` to not auto-advance through all the pages in the record
78
74
  # and collect all the data. The default is `true`.
79
75
  # @param [Hash] params
80
- #
76
+ #
81
77
  # @return [ListResponse]
82
78
  #
83
79
  # @see https://developer.nexmo.com/api/application.v2#listApplication
@@ -113,9 +109,6 @@ module Vonage
113
109
  # @example
114
110
  # response = client.applications.update(id, answer_method: 'POST')
115
111
  #
116
- # @param [String] id
117
- # @param [Hash] params
118
- #
119
112
  # @option params [required, String] :name
120
113
  # Application name.
121
114
  #
@@ -127,9 +120,8 @@ module Vonage
127
120
  # This contains the configuration for each product.
128
121
  # This replaces the application `type` from version 1 of the Application API.
129
122
  #
130
- # @option params [Hash] :privacy
131
- # - **:improve_ai** (Boolean) If set to `true``, Vonage may store and use your content and data for the improvement
132
- # of Vonage's AI based services and technologies.
123
+ # @param [String] id
124
+ # @param [Hash] params
133
125
  #
134
126
  # @return [Response]
135
127
  #
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]
@@ -1,6 +1,6 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- class ClientError < APIError
4
+ class ClientError < Error
5
5
  end
6
6
  end
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.
@@ -130,11 +130,7 @@ module Vonage
130
130
 
131
131
  # @return [Vonage::Logger]
132
132
  #
133
- sig { params(logger: T.nilable(
134
- defined?(ActiveSupport::BroadcastLogger) ?
135
- T.any(::Logger, Vonage::Logger, ActiveSupport::BroadcastLogger)
136
- : T.any(::Logger, Vonage::Logger)
137
- )).returns(T.nilable(Vonage::Logger)) }
133
+ sig { params(logger: T.nilable(T.any(::Logger, Vonage::Logger))).returns(T.nilable(Vonage::Logger)) }
138
134
  def logger=(logger)
139
135
  @logger = T.let(Logger.new(logger), T.nilable(Vonage::Logger))
140
136
  end
@@ -204,7 +200,7 @@ module Vonage
204
200
  attr_writer :token
205
201
 
206
202
  sig { returns(String) }
207
- attr_accessor :vonage_host
203
+ attr_accessor :video_host
208
204
 
209
205
  protected
210
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
@@ -27,40 +16,34 @@ module Vonage
27
16
  when Net::HTTPServerError
28
17
  ServerError
29
18
  else
30
- APIError
19
+ Error
31
20
  end
32
21
 
33
- message = response.content_type.to_s.include?("json") ? set_message(response) : ""
34
-
35
- exception_class.new(message, http_response: response)
36
- end
37
-
38
- def self.set_message(response)
39
- hash = ::JSON.parse(response.body)
40
-
41
- if hash.key?("error_title")
42
- hash["error_title"]
43
- elsif hash.key?("error-code-label")
44
- hash["error-code-label"]
45
- elsif hash.key?("description")
46
- hash["description"]
47
- elsif hash.key?("message")
48
- hash["message"]
49
- elsif problem_details?(hash)
50
- problem_details_message(hash)
51
- else
52
- ""
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)
33
+ end
53
34
  end
35
+
36
+ exception_class.new(message)
54
37
  end
55
38
 
56
39
  sig { params(hash: T::Hash[String, T.untyped]).returns(T::Boolean) }
57
40
  def self.problem_details?(hash)
58
- hash.key?("title") && hash.key?("detail") && hash.key?("type")
41
+ hash.key?('title') && hash.key?('detail') && hash.key?('type')
59
42
  end
60
43
 
61
44
  sig { params(hash: T::Hash[String, T.untyped]).returns(String) }
62
45
  def self.problem_details_message(hash)
63
- "#{hash["title"]}. #{hash["detail"]} See #{hash["type"]} for more info, or email support@vonage.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."
64
47
  end
65
48
  end
66
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/jwt.rb CHANGED
@@ -39,22 +39,5 @@ module Vonage
39
39
  payload[:private_key] = private_key if private_key && !payload[:private_key]
40
40
  @token = Vonage::JWTBuilder.new(payload).jwt.generate
41
41
  end
42
-
43
- # Validate a JSON Web Token from a Vonage Webhook.
44
- #
45
- # Certain Vonage APIs include a JWT signed with a user's account signature secret in
46
- # the Authorization header of Webhook requests. This method can be used to verify that those requests originate
47
- # from the Vonage API.
48
- #
49
- # @param [String, required] :token The JWT from the Webhook's Authorization header
50
- # @param [String, required] :signature_secret The account signature secret
51
- #
52
- # @return [Boolean] true, if the JWT is verified, false otherwise
53
- #
54
- # @see https://developer.vonage.com/en/getting-started/concepts/webhooks#decoding-signed-webhooks
55
- #
56
- def self.verify_hs256_signature(token:, signature_secret:)
57
- verify_signature(token, signature_secret, 'HS256')
58
- end
59
42
  end
60
43
  end
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)
data/lib/vonage/logger.rb CHANGED
@@ -7,11 +7,7 @@ module Vonage
7
7
  class Logger
8
8
  extend T::Sig
9
9
 
10
- sig { params(logger: T.nilable(
11
- defined?(ActiveSupport::BroadcastLogger) ?
12
- T.any(::Logger, Vonage::Logger, ActiveSupport::BroadcastLogger)
13
- : T.any(::Logger, Vonage::Logger)
14
- )).void }
10
+ sig { params(logger: T.nilable(T.any(::Logger, Vonage::Logger))).void }
15
11
  def initialize(logger)
16
12
  @logger = logger || ::Logger.new(nil)
17
13
  end
@@ -24,6 +20,8 @@ module Vonage
24
20
 
25
21
  sig { params(request: T.any(Net::HTTP::Post, Net::HTTP::Get, Net::HTTP::Delete, Net::HTTP::Put, Net::HTTP::Patch)).void }
26
22
  def log_request_info(request)
23
+ @logger = T.let(@logger, T.nilable(T.any(::Logger, Vonage::Logger)))
24
+
27
25
  T.must(@logger).info do
28
26
  format('Vonage API request', {
29
27
  method: request.method,