vonage 7.17.0 → 7.19.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 +219 -89
- data/lib/vonage/applications.rb +12 -4
- data/lib/vonage/client.rb +14 -0
- data/lib/vonage/config.rb +4 -0
- data/lib/vonage/jwt.rb +17 -0
- data/lib/vonage/keys.rb +9 -1
- data/lib/vonage/meetings/rooms.rb +1 -1
- data/lib/vonage/meetings/sessions/list_response.rb +1 -1
- data/lib/vonage/messaging.rb +11 -0
- data/lib/vonage/namespace.rb +4 -3
- data/lib/vonage/number_insight_2.rb +36 -0
- data/lib/vonage/signature.rb +5 -5
- data/lib/vonage/sms.rb +20 -0
- data/lib/vonage/verify2/channels/email.rb +1 -3
- data/lib/vonage/verify2/channels/silent_auth.rb +15 -2
- data/lib/vonage/verify2/channels/sms.rb +1 -1
- data/lib/vonage/verify2/channels/whats_app.rb +1 -1
- data/lib/vonage/verify2.rb +3 -3
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives/list_response.rb +11 -0
- data/lib/vonage/video/archives.rb +152 -0
- data/lib/vonage/video/broadcasts/list_response.rb +11 -0
- data/lib/vonage/video/broadcasts.rb +75 -0
- data/lib/vonage/video/moderation.rb +58 -0
- data/lib/vonage/video/signals.rb +50 -0
- data/lib/vonage/video/sip.rb +48 -0
- data/lib/vonage/video/streams/list_response.rb +11 -0
- data/lib/vonage/video/streams.rb +70 -0
- data/lib/vonage/video.rb +109 -0
- data/lib/vonage/voice/actions/conversation.rb +2 -2
- data/lib/vonage/voice.rb +11 -0
- data/lib/vonage.rb +1 -0
- data/vonage.gemspec +1 -1
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 748a3a579f5c7c4a263b7b840234b0489e7b895e63d43d939f01bdc177616a53
|
4
|
+
data.tar.gz: 6e2b5d3d0a8135aff72a1314c33a833c1a77384f7a6047e6147c013e29e6ea45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 913f6f7f81f667513740f61849db751dfdd9dc60ca6366c81b6e621564e53719f3503a5085ed38f7c48570dd55a33a26b5037af136387aa2226ed7c8a4542b2c
|
7
|
+
data.tar.gz: 636e92166449f951489340b2cb00a00c7f72225fd2239f4ba9faba6919e72bd17ba24454f8a2be9ed2be8c6f76382045490a2d24b13e09bb1323dbb5dbadcb81
|
data/README.md
CHANGED
@@ -17,13 +17,15 @@ need a Vonage account. Sign up [for free at vonage.com][signup].
|
|
17
17
|
* [JWT authentication](#jwt-authentication)
|
18
18
|
* [Webhook signatures](#webhook-signatures)
|
19
19
|
* [Pagination](#pagination)
|
20
|
-
* [NCCO Builder](#ncco-builder)
|
21
20
|
* [Messages API](#messages-api)
|
22
21
|
* [Verify API v2](#verify-api-v2)
|
22
|
+
* [Voice API](#voice-api)
|
23
|
+
* [NCCO Builder](#ncco-builder)
|
23
24
|
* [Documentation](#documentation)
|
24
|
-
* [
|
25
|
-
|
25
|
+
* [Supported APIs](#supported-apis)
|
26
|
+
* [Other SDKs and Tools](#other-sdks-and-tools)
|
26
27
|
* [License](#license)
|
28
|
+
* [Contribute](#contribute)
|
27
29
|
|
28
30
|
|
29
31
|
## Requirements
|
@@ -66,8 +68,47 @@ For production you can specify the `VONAGE_API_KEY` and `VONAGE_API_SECRET`
|
|
66
68
|
environment variables instead of specifying the key and secret explicitly,
|
67
69
|
keeping your credentials out of source control.
|
68
70
|
|
71
|
+
For APIs which use a JWT for authentication you'll need to pass `application_id` and `private_key` arguments to the
|
72
|
+
`Client` constructor as well as or instead of `api_key` and `api_secret`. See [JWT Authentication](#jwt-authentication).
|
69
73
|
|
70
|
-
|
74
|
+
It is also possible to over-ride the default hosts at `Client` instantiation. See [Overriding the default hosts](overriding-the-default-hosts).
|
75
|
+
|
76
|
+
### JWT authentication
|
77
|
+
|
78
|
+
To call newer endpoints that support JWT authentication such as the Voice API and Messages API you'll
|
79
|
+
also need to specify the `application_id` and `private_key` options. For example:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
client = Vonage::Client.new(application_id: application_id, private_key: private_key)
|
83
|
+
```
|
84
|
+
|
85
|
+
Both arguments should have string values corresponding to the `id` and `private_key`
|
86
|
+
values returned in a ["create an application"](https://developer.nexmo.com/api/application.v2#createApplication)
|
87
|
+
response. These credentials can be stored in a datastore, in environment variables,
|
88
|
+
on disk outside of source control, or in some kind of key management infrastructure.
|
89
|
+
|
90
|
+
By default the library generates a short lived JWT per request. To generate a long lived
|
91
|
+
JWT for multiple requests or to specify JWT claims directly use `Vonage::JWT.generate` and
|
92
|
+
the token option. For example:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
claims = {
|
96
|
+
application_id: application_id,
|
97
|
+
private_key: 'path/to/private.key',
|
98
|
+
nbf: 1483315200,
|
99
|
+
ttl: 800
|
100
|
+
}
|
101
|
+
|
102
|
+
token = Vonage::JWT.generate(claims)
|
103
|
+
|
104
|
+
client = Vonage::Client.new(token: token)
|
105
|
+
```
|
106
|
+
|
107
|
+
Documentation for the Vonage Ruby JWT generator gem can be found at
|
108
|
+
[https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby](https://www.rubydoc.info/github/nexmo/nexmo-jwt-ruby).
|
109
|
+
The documentation outlines all the possible parameters you can use to customize and build a token with.
|
110
|
+
|
111
|
+
### Logging
|
71
112
|
|
72
113
|
Use the logger option to specify a logger. For example:
|
73
114
|
|
@@ -83,7 +124,7 @@ By default the library sets the logger to `Rails.logger` if it is defined.
|
|
83
124
|
|
84
125
|
To disable logging set the logger to `nil`.
|
85
126
|
|
86
|
-
|
127
|
+
### Exceptions
|
87
128
|
|
88
129
|
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
130
|
|
@@ -124,7 +165,7 @@ rescue Vonage::Error => error
|
|
124
165
|
end
|
125
166
|
```
|
126
167
|
|
127
|
-
|
168
|
+
### Overriding the default hosts
|
128
169
|
|
129
170
|
To override the default hosts that the SDK uses for HTTP requests, you need to
|
130
171
|
specify the `api_host`, `rest_host` or both in the client configuration. For example:
|
@@ -139,104 +180,138 @@ client = Vonage::Client.new(
|
|
139
180
|
By default the hosts are set to `api.nexmo.com` and `rest.nexmo.com`, respectively.
|
140
181
|
|
141
182
|
|
142
|
-
## JWT authentication
|
143
183
|
|
144
|
-
To call newer endpoints that support JWT authentication such as the Voice API and Messages API you'll
|
145
|
-
also need to specify the `application_id` and `private_key` options. For example:
|
146
184
|
|
147
|
-
|
148
|
-
client = Vonage::Client.new(application_id: application_id, private_key: private_key)
|
149
|
-
```
|
185
|
+
### Webhook signatures
|
150
186
|
|
151
|
-
|
152
|
-
values returned in a ["create an application"](https://developer.nexmo.com/api/application.v2#createApplication)
|
153
|
-
response. These credentials can be stored in a datastore, in environment variables,
|
154
|
-
on disk outside of source control, or in some kind of key management infrastructure.
|
187
|
+
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.
|
155
188
|
|
156
|
-
|
157
|
-
|
158
|
-
the
|
189
|
+
#### Signature in Request Body
|
190
|
+
|
191
|
+
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.
|
192
|
+
|
193
|
+
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.
|
194
|
+
|
195
|
+
There are a few different ways of providing these values to the method:
|
196
|
+
|
197
|
+
1. Pass all values to the method invocation.
|
159
198
|
|
160
199
|
```ruby
|
161
|
-
|
162
|
-
application_id: application_id,
|
163
|
-
private_key: 'path/to/private.key',
|
164
|
-
nbf: 1483315200,
|
165
|
-
ttl: 800
|
166
|
-
}
|
200
|
+
client = Vonage::Client.new
|
167
201
|
|
168
|
-
|
202
|
+
client.sms.verify_webhook_sig(
|
203
|
+
webhook_params: params,
|
204
|
+
signature_secret: 'secret',
|
205
|
+
signature_method: 'sha512'
|
206
|
+
) # => returns true if the signature is valid, false otherwise
|
207
|
+
```
|
169
208
|
|
170
|
-
|
171
|
-
````
|
209
|
+
2. Set `signature_secret` and `signature_method` at `Client` instantiation.
|
172
210
|
|
173
|
-
|
174
|
-
|
175
|
-
|
211
|
+
```ruby
|
212
|
+
client = Vonage::Client.new(
|
213
|
+
signature_secret: 'secret',
|
214
|
+
signature_method: 'sha512'
|
215
|
+
)
|
176
216
|
|
177
|
-
|
217
|
+
client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
|
218
|
+
```
|
178
219
|
|
179
|
-
|
220
|
+
3. Set `signature_secret` and `signature_method` on the `Config` object.
|
180
221
|
|
181
222
|
```ruby
|
182
223
|
client = Vonage::Client.new
|
183
224
|
client.config.signature_secret = 'secret'
|
184
225
|
client.config.signature_method = 'sha512'
|
185
226
|
|
186
|
-
|
187
|
-
# valid signature
|
188
|
-
else
|
189
|
-
# invalid signature
|
190
|
-
end
|
227
|
+
client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
|
191
228
|
```
|
192
229
|
|
193
|
-
|
230
|
+
4. Set `signature_secret` and `signature_method` as environment variables named `VONAGE_SIGNATURE_SECRET` and `VONAGE_SIGNATURE_METHOD`
|
194
231
|
|
195
|
-
|
232
|
+
```ruby
|
233
|
+
client = Vonage::Client.new
|
196
234
|
|
197
|
-
|
235
|
+
client.sms.verify_webhook_sig(webhook_params: params) # => returns true if the signature is valid, false otherwise
|
236
|
+
```
|
198
237
|
|
199
|
-
|
238
|
+
**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.
|
200
239
|
|
201
|
-
|
240
|
+
#### Signed JWT in Header
|
202
241
|
|
203
|
-
|
204
|
-
* [Application API](https://developer.nexmo.com/api/application.v2)
|
205
|
-
* [Conversation API](https://developer.nexmo.com/api/conversation)
|
206
|
-
* [Voice API](https://developer.nexmo.com/api/voice)
|
242
|
+
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.
|
207
243
|
|
208
|
-
|
244
|
+
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.
|
245
|
+
|
246
|
+
To verify the JWT, you'll first need to extract it from the `Authorization` header. The header value will look something like the following:
|
209
247
|
|
210
248
|
```ruby
|
211
|
-
|
249
|
+
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1OTUyN" # remainder of token omitted for brevity
|
212
250
|
```
|
213
251
|
|
214
|
-
|
252
|
+
Note: we are only interested in the token itself, which comes *after* the word `Bearer` and the space.
|
215
253
|
|
216
|
-
|
254
|
+
Once you have extrated the token, you can pass it to the `verify_webhook_token` method in order to verify it.
|
217
255
|
|
218
|
-
The
|
256
|
+
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:
|
219
257
|
|
220
|
-
|
258
|
+
1. Pass all values to the method invocation.
|
221
259
|
|
222
260
|
```ruby
|
223
|
-
|
224
|
-
input = Vonage::Voice::Ncco.input(type: ['dtmf'], dtmf: { bargeIn: true })
|
225
|
-
ncco = Vonage::Voice::Ncco.build(talk, input)
|
261
|
+
client = Vonage::Client.new
|
226
262
|
|
227
|
-
|
263
|
+
client.voice.verify_webhook_token(
|
264
|
+
token: extracted_token,
|
265
|
+
signature_secret: 'secret'
|
266
|
+
) # => returns true if the token is valid, false otherwise
|
228
267
|
```
|
229
268
|
|
230
|
-
|
269
|
+
2. Set `signature_secret` at `Client` instantiation.
|
231
270
|
|
232
271
|
```ruby
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
272
|
+
client = Vonage::Client.new(
|
273
|
+
signature_secret: 'secret'
|
274
|
+
)
|
275
|
+
|
276
|
+
client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
|
277
|
+
```
|
278
|
+
|
279
|
+
3. Set `signature_secret` on the `Config` object.
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
client = Vonage::Client.new
|
283
|
+
client.config.signature_secret = 'secret'
|
284
|
+
client.config.signature_method = 'sha512'
|
285
|
+
|
286
|
+
client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
|
287
|
+
```
|
288
|
+
|
289
|
+
4. Set `signature_secret` as an environment variable named `VONAGE_SIGNATURE_SECRET`
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
client = Vonage::Client.new
|
293
|
+
|
294
|
+
client.voice.verify_webhook_token(token: extracted_token) # => returns true if the token is valid, false otherwise
|
295
|
+
```
|
296
|
+
|
297
|
+
### Pagination
|
298
|
+
|
299
|
+
Vonage APIs paginate list requests. This means that if a collection is requested that is larger than the API default, the API will return the first page of items in the collection. The Ruby SDK provides an `auto_advance` parameter that will traverse through the pages and return all the results in one response object.
|
300
|
+
|
301
|
+
The `auto_advance` parameter is set to a default of `true` for the following APIs:
|
302
|
+
|
303
|
+
* [Account API](https://developer.nexmo.com/api/developer/account)
|
304
|
+
* [Application API](https://developer.nexmo.com/api/application.v2)
|
305
|
+
* [Conversation API](https://developer.nexmo.com/api/conversation)
|
306
|
+
* [Voice API](https://developer.nexmo.com/api/voice)
|
307
|
+
|
308
|
+
To modify the `auto_advance` behavior you can specify it in your method:
|
309
|
+
|
310
|
+
```ruby
|
311
|
+
client.applications.list(auto_advance: false)
|
238
312
|
```
|
239
313
|
|
314
|
+
|
240
315
|
## Messages API
|
241
316
|
|
242
317
|
The [Vonage Messages API](https://developer.vonage.com/messages/overview) allows you to send messages over a number of different channels, and various message types within each channel. See the Vonage Developer Documentation for a [complete API reference](https://developer.vonage.com/api/messages-olympus) listing all the channel and message type combinations.
|
@@ -388,40 +463,85 @@ if code_check.http_response.code == '200'
|
|
388
463
|
end
|
389
464
|
```
|
390
465
|
|
466
|
+
## Voice API
|
467
|
+
|
468
|
+
The [Vonage Voice API](The [Vonage Verify API v2](https://developer.vonage.com/en/verify/verify-v2/overview) allows you to automate voice interactions by creating calls, streaming audio, playing text to speech, playing DTMF tones, and other actions. See the Vonage Developer Documentation for a [complete API reference](https://developer.vonage.com/en/api/voice) listing all the Voice API capabilities.
|
469
|
+
|
470
|
+
The Ruby SDK provides numerous methods for interacting with the Voice v2 API. Here's an example of using the `create` method to make an outbound text-to-speech call:
|
471
|
+
|
472
|
+
```ruby
|
473
|
+
response = client.voice.create(
|
474
|
+
to: [{
|
475
|
+
type: 'phone',
|
476
|
+
number: '447700900000'
|
477
|
+
}],
|
478
|
+
from: {
|
479
|
+
type: 'phone',
|
480
|
+
number: '447700900001'
|
481
|
+
},
|
482
|
+
answer_url: [
|
483
|
+
'https://raw.githubusercontent.com/nexmo-community/ncco-examples/gh-pages/text-to-speech.json'
|
484
|
+
]
|
485
|
+
)
|
486
|
+
```
|
487
|
+
|
488
|
+
### NCCO Builder
|
489
|
+
|
490
|
+
The Vonage Voice API accepts instructions via JSON objects called NCCOs. Each NCCO can be made up multiple actions that are executed in the order they are written. The Vonage API Developer Portal contains an [NCCO Reference](https://developer.vonage.com/voice/voice-api/ncco-reference) with instructions and information on all the parameters possible.
|
491
|
+
|
492
|
+
The SDK includes an NCCO builder that you can use to build NCCOs for your Voice API methods.
|
493
|
+
|
494
|
+
For example, to build `talk` and `input` NCCO actions and then combine them into a single NCCO you would do the following:
|
495
|
+
|
496
|
+
```ruby
|
497
|
+
talk = Vonage::Voice::Ncco.talk(text: 'Hello World!')
|
498
|
+
input = Vonage::Voice::Ncco.input(type: ['dtmf'], dtmf: { bargeIn: true })
|
499
|
+
ncco = Vonage::Voice::Ncco.build(talk, input)
|
500
|
+
|
501
|
+
# => [{:action=>"talk", :text=>"Hello World!"}, {:action=>"input", :type=>["dtmf"], :dtmf=>{:bargeIn=>true}}]
|
502
|
+
```
|
503
|
+
|
504
|
+
Once you have the constructed NCCO you can then use it in a Voice API request:
|
505
|
+
|
506
|
+
```ruby
|
507
|
+
response = client.voice.create({
|
508
|
+
to: [{type: 'phone', number: '14843331234'}],
|
509
|
+
from: {type: 'phone', number: '14843335555'},
|
510
|
+
ncco: ncco
|
511
|
+
})
|
512
|
+
```
|
513
|
+
|
391
514
|
## Documentation
|
392
515
|
|
393
|
-
Vonage Ruby documentation: https://www.rubydoc.info/github/Vonage/vonage-ruby-sdk
|
516
|
+
Vonage Ruby SDK documentation: https://www.rubydoc.info/github/Vonage/vonage-ruby-sdk
|
394
517
|
|
395
|
-
Vonage Ruby code examples: https://github.com/Vonage/vonage-ruby-code-snippets
|
518
|
+
Vonage Ruby SDK code examples: https://github.com/Vonage/vonage-ruby-code-snippets
|
396
519
|
|
397
520
|
Vonage APIs API reference: https://developer.nexmo.com/api
|
398
521
|
|
399
|
-
## Frequently Asked Questions
|
400
|
-
|
401
522
|
## Supported APIs
|
402
523
|
|
403
|
-
The following is a list of Vonage APIs
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
| Voice API | General Availability |✅|
|
524
|
+
The following is a list of Vonage APIs for which the Ruby SDK currently provides support:
|
525
|
+
|
526
|
+
* [Account API](https://developer.vonage.com/en/account/overview)
|
527
|
+
* [Application API](https://developer.vonage.com/en/application/overview)
|
528
|
+
* [Meetings API](https://developer.vonage.com/en/meetings/overview)
|
529
|
+
* [Messages API](https://developer.vonage.com/en/messages/overview)
|
530
|
+
* [Number Insight API](https://developer.vonage.com/en/number-insight/overview)
|
531
|
+
* [Numbers API](https://developer.vonage.com/en/numbers/overview)
|
532
|
+
* [Proactive Connect API](https://developer.vonage.com/en/proactive-connect/overview) *
|
533
|
+
* [Redact API](https://developer.vonage.com/en/redact/overview)
|
534
|
+
* [SMS API](https://developer.vonage.com/en/messaging/sms/overview)
|
535
|
+
* [Subaccounts API](https://developer.vonage.com/en/account/subaccounts/overview)
|
536
|
+
* [Verify API](https://developer.vonage.com/en/verify/overview)
|
537
|
+
* [Voice API](https://developer.vonage.com/en/verify/overview)
|
538
|
+
|
539
|
+
\* The Proactive Connect API is partially supported in the SDK. Specifically, the Events, Items, and Lists endpoints are supported.
|
540
|
+
|
541
|
+
## Other SDKs and Tools
|
542
|
+
|
543
|
+
You can find information about other Vonage SDKs and Tooling on our [Developer Portal](https://developer.vonage.com/en/tools).
|
544
|
+
|
425
545
|
|
426
546
|
## License
|
427
547
|
|
@@ -429,3 +549,13 @@ This library is released under the [Apache 2.0 License][license]
|
|
429
549
|
|
430
550
|
[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=ruby-client-library
|
431
551
|
[license]: LICENSE.txt
|
552
|
+
|
553
|
+
## Contribute!
|
554
|
+
|
555
|
+
_We :heart: contributions to this library!_
|
556
|
+
|
557
|
+
It is a good idea to [talk to us](https://developer.vonage.com/community/slack)
|
558
|
+
first if you plan to add any new functionality.
|
559
|
+
Otherwise, [bug reports](https://github.com/Vonage/vonage-ruby-sdk/issues),
|
560
|
+
[bug fixes](https://github.com/Vonage/vonage-ruby-sdk/pulls) and feedback on the
|
561
|
+
library are always appreciated.
|
data/lib/vonage/applications.rb
CHANGED
@@ -33,6 +33,8 @@ module Vonage
|
|
33
33
|
#
|
34
34
|
# response = client.applications.create(params)
|
35
35
|
#
|
36
|
+
# @param [Hash] params
|
37
|
+
#
|
36
38
|
# @option params [required, String] :name
|
37
39
|
# Application name.
|
38
40
|
#
|
@@ -44,7 +46,9 @@ module Vonage
|
|
44
46
|
# This contains the configuration for each product.
|
45
47
|
# This replaces the application `type` from version 1 of the Application API.
|
46
48
|
#
|
47
|
-
# @
|
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.
|
48
52
|
#
|
49
53
|
# @return [Response]
|
50
54
|
#
|
@@ -73,7 +77,7 @@ module Vonage
|
|
73
77
|
# Set this to `false` to not auto-advance through all the pages in the record
|
74
78
|
# and collect all the data. The default is `true`.
|
75
79
|
# @param [Hash] params
|
76
|
-
#
|
80
|
+
#
|
77
81
|
# @return [ListResponse]
|
78
82
|
#
|
79
83
|
# @see https://developer.nexmo.com/api/application.v2#listApplication
|
@@ -109,6 +113,9 @@ module Vonage
|
|
109
113
|
# @example
|
110
114
|
# response = client.applications.update(id, answer_method: 'POST')
|
111
115
|
#
|
116
|
+
# @param [String] id
|
117
|
+
# @param [Hash] params
|
118
|
+
#
|
112
119
|
# @option params [required, String] :name
|
113
120
|
# Application name.
|
114
121
|
#
|
@@ -120,8 +127,9 @@ module Vonage
|
|
120
127
|
# This contains the configuration for each product.
|
121
128
|
# This replaces the application `type` from version 1 of the Application API.
|
122
129
|
#
|
123
|
-
# @
|
124
|
-
#
|
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.
|
125
133
|
#
|
126
134
|
# @return [Response]
|
127
135
|
#
|
data/lib/vonage/client.rb
CHANGED
@@ -89,6 +89,13 @@ module Vonage
|
|
89
89
|
@number_insight ||= T.let(NumberInsight.new(config), T.nilable(Vonage::NumberInsight))
|
90
90
|
end
|
91
91
|
|
92
|
+
# @return [NumberInsight2]
|
93
|
+
#
|
94
|
+
sig { returns(T.nilable(Vonage::NumberInsight2)) }
|
95
|
+
def number_insight_2
|
96
|
+
@number_insight_2 ||= T.let(NumberInsight2.new(config), T.nilable(Vonage::NumberInsight2))
|
97
|
+
end
|
98
|
+
|
92
99
|
# @return [Numbers]
|
93
100
|
#
|
94
101
|
sig { returns(T.nilable(Vonage::Numbers)) }
|
@@ -166,6 +173,13 @@ module Vonage
|
|
166
173
|
@verify2 ||= T.let(Verify2.new(config), T.nilable(Vonage::Verify2))
|
167
174
|
end
|
168
175
|
|
176
|
+
# @return [Video]
|
177
|
+
#
|
178
|
+
sig { returns(T.nilable(Vonage::Video)) }
|
179
|
+
def video
|
180
|
+
@video ||= T.let(Video.new(config), T.nilable(Vonage::Video))
|
181
|
+
end
|
182
|
+
|
169
183
|
# @return [Voice]
|
170
184
|
#
|
171
185
|
sig { returns(T.nilable(Vonage::Voice)) }
|
data/lib/vonage/config.rb
CHANGED
@@ -18,6 +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.video_host = 'video.api.vonage.com'
|
21
22
|
self.vonage_host = 'api-eu.vonage.com'
|
22
23
|
end
|
23
24
|
|
@@ -203,6 +204,9 @@ module Vonage
|
|
203
204
|
sig { params(token: T.nilable(String)).returns(T.nilable(String)) }
|
204
205
|
attr_writer :token
|
205
206
|
|
207
|
+
sig { returns(String) }
|
208
|
+
attr_accessor :video_host
|
209
|
+
|
206
210
|
sig { returns(String) }
|
207
211
|
attr_accessor :vonage_host
|
208
212
|
|
data/lib/vonage/jwt.rb
CHANGED
@@ -39,5 +39,22 @@ 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
|
42
59
|
end
|
43
60
|
end
|
data/lib/vonage/keys.rb
CHANGED
@@ -21,7 +21,15 @@ 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
|
+
'session_id',
|
31
|
+
'stream_mode',
|
32
|
+
'archive_mode'
|
25
33
|
]
|
26
34
|
hash.transform_keys do |k|
|
27
35
|
if exceptions.include?(k.to_s)
|
@@ -89,7 +89,7 @@ module Vonage
|
|
89
89
|
# @param [optional, Hash] :ui_settings Provides options to customize the user interface
|
90
90
|
# @option :ui_settings [String] :language
|
91
91
|
# The desired language of the UI. The default is `en` (English).
|
92
|
-
# Must be one of: `
|
92
|
+
# Must be one of: `ar`, `pt-br`, `ca`, `zh-tw`, `zh-cn`, `en`, `fr`, `de`, `he`, `it`, `es`
|
93
93
|
#
|
94
94
|
# @return [Response]
|
95
95
|
#
|
data/lib/vonage/messaging.rb
CHANGED
@@ -25,5 +25,16 @@ module Vonage
|
|
25
25
|
def send(params)
|
26
26
|
request('/v1/messages', params: params, type: Post)
|
27
27
|
end
|
28
|
+
|
29
|
+
# Validate a JSON Web Token from a Messages API Webhook.
|
30
|
+
#
|
31
|
+
# @param [String, required] :token The JWT from the Webhook's Authorization header
|
32
|
+
# @param [String, optional] :signature_secret The account signature secret. Required, unless `signature_secret`
|
33
|
+
# is set in `Config`
|
34
|
+
#
|
35
|
+
# @return [Boolean] true, if the JWT is verified, false otherwise
|
36
|
+
def verify_webhook_token(token:, signature_secret: @config.signature_secret)
|
37
|
+
JWT.verify_hs256_signature(token: token, signature_secret: signature_secret)
|
38
|
+
end
|
28
39
|
end
|
29
40
|
end
|
data/lib/vonage/namespace.rb
CHANGED
@@ -23,8 +23,7 @@ module Vonage
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.host=(host)
|
26
|
-
raise ArgumentError unless %i[rest_host vonage_host].include?(host)
|
27
|
-
|
26
|
+
raise ArgumentError unless %i[rest_host video_host vonage_host].include?(host)
|
28
27
|
@host = host
|
29
28
|
end
|
30
29
|
|
@@ -273,7 +272,7 @@ module Vonage
|
|
273
272
|
when Net::HTTPNoContent
|
274
273
|
response_class.new(nil, response)
|
275
274
|
when Net::HTTPSuccess
|
276
|
-
if response['Content-Type'] && response['Content-Type'].split(';').first == 'application/json'
|
275
|
+
if response['Content-Type'] && response['Content-Type'].split(';').first == 'application/json' && !response.body.empty?
|
277
276
|
entity = ::JSON.parse(response.body, object_class: Vonage::Entity)
|
278
277
|
|
279
278
|
response_class.new(entity, response)
|
@@ -295,6 +294,8 @@ module Vonage
|
|
295
294
|
case self.class.host
|
296
295
|
when :rest_host
|
297
296
|
@config.rest_host
|
297
|
+
when :video_host
|
298
|
+
@config.video_host
|
298
299
|
when :vonage_host
|
299
300
|
@config.vonage_host
|
300
301
|
else
|