vonage 7.17.0 → 7.19.0.exp.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Video::Streams < Namespace
6
+
7
+ self.authentication = BearerToken
8
+
9
+ self.request_body = JSON
10
+
11
+ self.host = :video_host
12
+
13
+ # Get a list of streams for a specified session.
14
+ #
15
+ # @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
16
+ #
17
+ # @param [required, String] :session_id
18
+ #
19
+ # TODO: add auto_advance option
20
+ #
21
+ # @return [ListResponse]
22
+ #
23
+ # @see TODO: add docs link
24
+ #
25
+ def list(session_id:)
26
+ request('/v2/project/' + @config.application_id + '/session/' + session_id + '/stream', response_class: ListResponse)
27
+ end
28
+
29
+ # Get information about a specified stream.
30
+ #
31
+ # @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
32
+ #
33
+ # @param [required, String] :session_id
34
+ #
35
+ # @param [required, String] :stream_id
36
+ #
37
+ # @return [Response]
38
+ #
39
+ # @see TODO: add docs link
40
+ #
41
+ def info(session_id:, stream_id:)
42
+ request('/v2/project/' + @config.application_id + '/session/' + session_id + '/stream/' + stream_id)
43
+ end
44
+
45
+ # Change the layout for a list of specified streams.
46
+ #
47
+ # @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
48
+ #
49
+ # @param [required, String] :session_id
50
+ #
51
+ # @param [optional, Array<Hash>] :items An array of hashes representing streams and the layout classes for those streams
52
+ #
53
+ # @option items [required, String] :id The stream ID
54
+ #
55
+ # @option items [required, Array<String>] :layoutClassList Array of CSS class names as strings
56
+ #
57
+ # @return [Response]
58
+ #
59
+ # @see TODO: add docs link
60
+ #
61
+ def change_layout(session_id:, **params)
62
+ # TODO camelcase layout_class_list
63
+ # if params[:items]
64
+ # params[:items] = params[:items].map {|item| camelcase(item)}
65
+ # end
66
+
67
+ request('/v2/project/' + @config.application_id + '/session/' + session_id + '/stream', params: params, type: Put)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,109 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Video < Namespace
6
+ include Keys
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.host = :video_host
11
+
12
+ # Generate a new session.
13
+ #
14
+ # @example
15
+ # session = client.video.create_session({
16
+ # archive_mode: 'always',
17
+ # location: '10.1.200.30',
18
+ # media_mode: 'routed'
19
+ # })
20
+ #
21
+ # @params [optional, String] :archive_mode (either 'always' or 'manual')
22
+ #
23
+ # @param [optional, String] :location
24
+ #
25
+ # @params [optional, String] :media_mode (either 'routed' or 'relayed')
26
+ #
27
+ # @return [Response]
28
+ #
29
+ # @see TODO: Add document link here
30
+ #
31
+ def create_session(**params)
32
+ request_params = params.clone
33
+ request_params[:archive_mode] ||= 'manual'
34
+ media_mode = request_params.delete(:media_mode) || 'routed'
35
+
36
+ if media_mode == 'relayed' && request_params[:archive_mode] == 'manual'
37
+ request_params['p2p.preference'] = 'enabled'
38
+ else
39
+ request_params['p2p.preference'] = 'disabled'
40
+ end
41
+
42
+ response = request('/session/create', params: camelcase(request_params), type: Post)
43
+
44
+ public_response_data = {
45
+ session_id: response.entity.first.session_id,
46
+ archive_mode: request_params[:archive_mode],
47
+ media_mode: media_mode,
48
+ location: request_params[:location]
49
+ }
50
+
51
+ entity = Entity.new(public_response_data)
52
+
53
+ response.class.new(entity, response.http_response)
54
+ end
55
+
56
+ def generate_client_token(session_id:, scope: 'session.connect', role: 'publisher', **params)
57
+ claims = {
58
+ application_id: @config.application_id,
59
+ scope: scope,
60
+ session_id: session_id,
61
+ role: role,
62
+ initial_layout_class_list: '',
63
+ sub: 'video',
64
+ acl: {
65
+ paths: {'/session/**' => {}}
66
+ }
67
+ }
68
+
69
+
70
+ claims[:data] = params[:data] if params[:data]
71
+ claims[:initial_layout_class_list] = params[:initial_layout_class_list].join(' ') if params[:initial_layout_class_list]
72
+ claims[:exp] = params[:expire_time].to_i if params[:expire_time]
73
+
74
+ JWT.generate(claims, @config.private_key)
75
+ end
76
+
77
+ # @return [Archives]
78
+ #
79
+ def archives
80
+ @archives ||= Archives.new(@config)
81
+ end
82
+
83
+ # @return [Broadcasts]
84
+ #
85
+ def broadcasts
86
+ @broadcasts ||= Broadcasts.new(@config)
87
+ end
88
+
89
+ # @return [Moderation]
90
+ #
91
+ def moderation
92
+ @moderation ||= Moderation.new(@config)
93
+ end
94
+
95
+ # @return [Signals]
96
+ #
97
+ def signals
98
+ @signals ||= Signals.new(@config)
99
+ end
100
+
101
+ # @return [Streams]
102
+ #
103
+ def streams
104
+ @streams ||= Streams.new(@config)
105
+ end
106
+
107
+
108
+ end
109
+ end
@@ -1,7 +1,7 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
-
4
- module Vonage
3
+
4
+ module Vonage
5
5
  class Voice::Actions::Conversation
6
6
  attr_accessor :name, :musicOnHoldUrl, :startOnEnter, :endOnExit, :record, :canSpeak, :canHear, :mute
7
7
 
data/lib/vonage/voice.rb CHANGED
@@ -279,5 +279,16 @@ module Vonage
279
279
  def dtmf
280
280
  @dtmf ||= DTMF.new(@config)
281
281
  end
282
+
283
+ # Validate a JSON Web Token from a Voice API Webhook.
284
+ #
285
+ # @param [String, required] :token The JWT from the Webhook's Authorization header
286
+ # @param [String, optional] :signature_secret The account signature secret. Required, unless `signature_secret`
287
+ # is set in `Config`
288
+ #
289
+ # @return [Boolean] true, if the JWT is verified, false otherwise
290
+ def verify_webhook_token(token:, signature_secret: @config.signature_secret)
291
+ JWT.verify_hs256_signature(token: token, signature_secret: signature_secret)
292
+ end
282
293
  end
283
294
  end
data/lib/vonage.rb CHANGED
@@ -13,6 +13,7 @@ module Vonage
13
13
  'http' => 'HTTP',
14
14
  'json' => 'JSON',
15
15
  'jwt' => 'JWT',
16
+ 'sip' => 'SIP',
16
17
  'sms' => 'SMS',
17
18
  'mms' => 'MMS',
18
19
  'tfa' => 'TFA',
data/vonage.gemspec CHANGED
@@ -12,10 +12,11 @@ Gem::Specification.new do |s|
12
12
  s.summary = 'This is the Ruby Server SDK for Vonage APIs. To use it you\'ll need a Vonage account. Sign up for free at https://www.vonage.com'
13
13
  s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md vonage.gemspec)
14
14
  s.required_ruby_version = '>= 2.5.0'
15
- s.add_dependency('vonage-jwt', '~> 0.1.3')
15
+ s.add_dependency('vonage-jwt', '~> 0.2.0')
16
16
  s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
17
17
  s.add_dependency('sorbet-runtime', '~> 0.5')
18
18
  s.add_dependency('multipart-post', '~> 2.0')
19
+ s.add_dependency('net-http-persistent', '~> 4.0', '>= 4.0.2')
19
20
  s.add_runtime_dependency('rexml')
20
21
  s.add_runtime_dependency('phonelib')
21
22
  s.require_path = 'lib'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.17.0
4
+ version: 7.19.0.exp.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-23 00:00:00.000000000 Z
11
+ date: 2024-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vonage-jwt
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.3
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.3
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +72,26 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: net-http-persistent
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '4.0'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 4.0.2
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '4.0'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 4.0.2
75
95
  - !ruby/object:Gem::Dependency
76
96
  name: rexml
77
97
  requirement: !ruby/object:Gem::Requirement
@@ -161,6 +181,7 @@ files:
161
181
  - lib/vonage/messaging/message.rb
162
182
  - lib/vonage/namespace.rb
163
183
  - lib/vonage/number_insight.rb
184
+ - lib/vonage/number_insight_2.rb
164
185
  - lib/vonage/numbers.rb
165
186
  - lib/vonage/numbers/list_response.rb
166
187
  - lib/vonage/numbers/response.rb
@@ -205,6 +226,16 @@ files:
205
226
  - lib/vonage/verify2/workflow.rb
206
227
  - lib/vonage/verify2/workflow_builder.rb
207
228
  - lib/vonage/version.rb
229
+ - lib/vonage/video.rb
230
+ - lib/vonage/video/archives.rb
231
+ - lib/vonage/video/archives/list_response.rb
232
+ - lib/vonage/video/broadcasts.rb
233
+ - lib/vonage/video/broadcasts/list_response.rb
234
+ - lib/vonage/video/moderation.rb
235
+ - lib/vonage/video/signals.rb
236
+ - lib/vonage/video/sip.rb
237
+ - lib/vonage/video/streams.rb
238
+ - lib/vonage/video/streams/list_response.rb
208
239
  - lib/vonage/voice.rb
209
240
  - lib/vonage/voice/actions/connect.rb
210
241
  - lib/vonage/voice/actions/conversation.rb
@@ -243,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
274
  - !ruby/object:Gem::Version
244
275
  version: '0'
245
276
  requirements: []
246
- rubygems_version: 3.4.10
277
+ rubygems_version: 3.5.3
247
278
  signing_key:
248
279
  specification_version: 4
249
280
  summary: This is the Ruby Server SDK for Vonage APIs. To use it you'll need a Vonage