vonage 7.8.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.
- checksums.yaml +4 -4
- data/lib/vonage/client.rb +7 -0
- data/lib/vonage/config.rb +4 -0
- data/lib/vonage/jwt.rb +3 -3
- data/lib/vonage/keys.rb +7 -1
- data/lib/vonage/namespace.rb +16 -2
- data/lib/vonage/version.rb +1 -1
- data/lib/vonage/video/archives.rb +187 -0
- data/lib/vonage/video/list_response.rb +11 -0
- data/lib/vonage/video/moderation.rb +73 -0
- data/lib/vonage/video/signals.rb +55 -0
- data/lib/vonage/video/streams.rb +76 -0
- data/lib/vonage/video.rb +91 -0
- data/vonage.gemspec +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e003a6ed3211d3eace84884bf3fb03d21b81f097b13aba079f1906daf95380ff
|
4
|
+
data.tar.gz: 956c6921b50df45aaf2f1901b08ccd3cb164c2553b23d8e45570f63dcdf6f960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1500879cd4a974009f6510cf12ea15b4ce60a9163f916b8a5e07fe785323c24c6909134163b21e29afc9c251550fd36a9e348c2ff7eac3b18b45f0e4ef7e1be1
|
7
|
+
data.tar.gz: fe368d23b897a7f1b2b9ba473c993a351ffb1233ef80304c16ec69ed28692c93e422c7a453f8d0da14b6e038424c215026a945d7ccee9b4a26412e3ecbe5435f
|
data/lib/vonage/client.rb
CHANGED
@@ -131,6 +131,13 @@ module Vonage
|
|
131
131
|
@verify ||= T.let(Verify.new(config), T.nilable(Vonage::Verify))
|
132
132
|
end
|
133
133
|
|
134
|
+
# @return [Video]
|
135
|
+
#
|
136
|
+
sig { returns(T.nilable(Vonage::Video)) }
|
137
|
+
def video
|
138
|
+
@video ||= T.let(Video.new(config), T.nilable(Vonage::Video))
|
139
|
+
end
|
140
|
+
|
134
141
|
# @return [Voice]
|
135
142
|
#
|
136
143
|
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
|
end
|
22
23
|
|
23
24
|
# Merges the config with the given options hash.
|
@@ -198,6 +199,9 @@ module Vonage
|
|
198
199
|
sig { params(token: T.nilable(String)).returns(T.nilable(String)) }
|
199
200
|
attr_writer :token
|
200
201
|
|
202
|
+
sig { returns(String) }
|
203
|
+
attr_accessor :video_host
|
204
|
+
|
201
205
|
protected
|
202
206
|
|
203
207
|
sig { params(name: Symbol, value: T.untyped).void }
|
data/lib/vonage/jwt.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
require 'securerandom'
|
4
4
|
require 'openssl'
|
5
|
-
require '
|
5
|
+
require 'vonage-jwt'
|
6
6
|
|
7
7
|
module Vonage
|
8
8
|
class JWT
|
@@ -15,7 +15,7 @@ module Vonage
|
|
15
15
|
# attribute on the client object.
|
16
16
|
#
|
17
17
|
# Documentation for the Vonage Ruby JWT generator gem can be found at
|
18
|
-
# https://www.rubydoc.info/github/
|
18
|
+
# https://www.rubydoc.info/github/Vonage/vonage-jwt-ruby
|
19
19
|
#
|
20
20
|
# @example
|
21
21
|
# claims = {
|
@@ -37,7 +37,7 @@ module Vonage
|
|
37
37
|
raise "Expecting 'private_key' in either the payload or as a separate parameter" if !payload[:private_key] && !private_key
|
38
38
|
|
39
39
|
payload[:private_key] = private_key if private_key && !payload[:private_key]
|
40
|
-
@token =
|
40
|
+
@token = Vonage::JWTBuilder.new(payload).jwt.generate
|
41
41
|
end
|
42
42
|
end
|
43
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/namespace.rb
CHANGED
@@ -8,7 +8,7 @@ module Vonage
|
|
8
8
|
def initialize(config)
|
9
9
|
@config = config
|
10
10
|
|
11
|
-
@host =
|
11
|
+
@host = set_host
|
12
12
|
|
13
13
|
@http = Net::HTTP.new(@host, Net::HTTP.https_default_port, p_addr = nil)
|
14
14
|
@http.use_ssl = true
|
@@ -21,7 +21,7 @@ module Vonage
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.host=(host)
|
24
|
-
raise ArgumentError unless host == :rest_host
|
24
|
+
raise ArgumentError unless host == :rest_host || host == :video_host
|
25
25
|
|
26
26
|
@host = host
|
27
27
|
end
|
@@ -51,6 +51,7 @@ module Vonage
|
|
51
51
|
|
52
52
|
Get = Net::HTTP::Get
|
53
53
|
Put = Net::HTTP::Put
|
54
|
+
Patch = Net::HTTP::Patch
|
54
55
|
Post = Net::HTTP::Post
|
55
56
|
Delete = Net::HTTP::Delete
|
56
57
|
|
@@ -217,6 +218,19 @@ module Vonage
|
|
217
218
|
def logger
|
218
219
|
@config.logger
|
219
220
|
end
|
221
|
+
|
222
|
+
private
|
223
|
+
|
224
|
+
def set_host
|
225
|
+
case self.class.host
|
226
|
+
when :rest_host
|
227
|
+
@config.rest_host
|
228
|
+
when :video_host
|
229
|
+
@config.video_host
|
230
|
+
else
|
231
|
+
@config.api_host
|
232
|
+
end
|
233
|
+
end
|
220
234
|
end
|
221
235
|
|
222
236
|
private_constant :Namespace
|
data/lib/vonage/version.rb
CHANGED
@@ -0,0 +1,187 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Video::Archives < Namespace
|
6
|
+
include Keys
|
7
|
+
|
8
|
+
self.authentication = BearerToken
|
9
|
+
|
10
|
+
self.request_body = JSON
|
11
|
+
|
12
|
+
self.host = :video_host
|
13
|
+
|
14
|
+
# Get a list of archives for a specified Vonage application.
|
15
|
+
#
|
16
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
17
|
+
#
|
18
|
+
# @param [optional, Integer] :offset
|
19
|
+
#
|
20
|
+
# @param [optional, Integer] :count
|
21
|
+
#
|
22
|
+
# @param [optional, String] :session_id
|
23
|
+
#
|
24
|
+
# TODO: add auto_advance option
|
25
|
+
#
|
26
|
+
# @return [ListResponse]
|
27
|
+
#
|
28
|
+
# @see TODO: add docs link
|
29
|
+
#
|
30
|
+
def list(application_id: @config.application_id, **params)
|
31
|
+
# TODO: raise error if application_id is nil
|
32
|
+
|
33
|
+
request('/v2/project/' + application_id + '/archive', params: params, response_class: Video::ListResponse)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Return information for specified archive.
|
37
|
+
#
|
38
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
39
|
+
#
|
40
|
+
# @param [required, String] archive_id
|
41
|
+
#
|
42
|
+
# @return [Response]
|
43
|
+
#
|
44
|
+
# @see TODO: add docs link
|
45
|
+
#
|
46
|
+
def info(application_id: @config.application_id, archive_id:)
|
47
|
+
# TODO: raise error if application_id is nil
|
48
|
+
|
49
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Create a new archive.
|
53
|
+
#
|
54
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
55
|
+
#
|
56
|
+
# @param [required, String] :session_id
|
57
|
+
#
|
58
|
+
# @param [optional, String] :hasAudio
|
59
|
+
#
|
60
|
+
# @param [optional, String] :hasVideo
|
61
|
+
#
|
62
|
+
# @param [optional, String] :name
|
63
|
+
#
|
64
|
+
# @param [optional, String] :outputMode
|
65
|
+
#
|
66
|
+
# @param [optional, String] :resolution
|
67
|
+
#
|
68
|
+
# @param [optional, String] :streamMode
|
69
|
+
#
|
70
|
+
# @param [optional, String] :multiArchiveTag
|
71
|
+
#
|
72
|
+
# @param [optional, Hash] :layout
|
73
|
+
#
|
74
|
+
# @option layout [optional, String] :type
|
75
|
+
#
|
76
|
+
# @option layout [optional, String] :stylesheet
|
77
|
+
#
|
78
|
+
# @option layout [optional, String] :screenshareType
|
79
|
+
#
|
80
|
+
# @return [Response]
|
81
|
+
#
|
82
|
+
# @see TODO: add docs link
|
83
|
+
#
|
84
|
+
def start(application_id: @config.application_id, **params)
|
85
|
+
# TODO: raise error if application_id is nil
|
86
|
+
# TODO: raise error if session_id is nil
|
87
|
+
|
88
|
+
request('/v2/project/' + application_id + '/archive', params: params, type: Post)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Stop recording a specified archive.
|
92
|
+
#
|
93
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
94
|
+
#
|
95
|
+
# @param [required, String] archive_id
|
96
|
+
#
|
97
|
+
# @return [Response]
|
98
|
+
#
|
99
|
+
# @see TODO: add docs link
|
100
|
+
#
|
101
|
+
def stop(application_id: @config.application_id, archive_id:)
|
102
|
+
# TODO: raise error if application_id is nil
|
103
|
+
|
104
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id + '/stop', type: Post)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Delete a specified archive.
|
108
|
+
#
|
109
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
110
|
+
#
|
111
|
+
# @param [required, String] archive_id
|
112
|
+
#
|
113
|
+
# @return [Response]
|
114
|
+
#
|
115
|
+
# @see TODO: add docs link
|
116
|
+
#
|
117
|
+
def delete(application_id: @config.application_id, archive_id:)
|
118
|
+
# TODO: raise error if application_id is nil
|
119
|
+
|
120
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id, type: Delete)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Add a stream to a composed archive that was started with the streamMode set to "manual".
|
124
|
+
#
|
125
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
126
|
+
#
|
127
|
+
# @param [required, String] archive_id
|
128
|
+
#
|
129
|
+
# @param [required, String] add_stream The ID of the stream to be added
|
130
|
+
#
|
131
|
+
# @param [optional, Boolean] has_audio
|
132
|
+
#
|
133
|
+
# @param [optional, Boolean] has_video
|
134
|
+
#
|
135
|
+
# @return [Response]
|
136
|
+
#
|
137
|
+
# @see TODO: add docs link
|
138
|
+
#
|
139
|
+
def add_stream(application_id: @config.application_id, archive_id:, **params)
|
140
|
+
# TODO: raise error if application_id is nil
|
141
|
+
# TODO: raise error if add_stream is nil
|
142
|
+
|
143
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id + '/streams', params: camelcase(params), type: Patch)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Remove a stream from a composed archive that was started with the streamMode set to "manual".
|
147
|
+
#
|
148
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
149
|
+
#
|
150
|
+
# @param [required, String] archive_id
|
151
|
+
#
|
152
|
+
# @param [required, String] remove_stream The ID of the stream to be removed
|
153
|
+
#
|
154
|
+
# @return [Response]
|
155
|
+
#
|
156
|
+
# @see TODO: add docs link
|
157
|
+
#
|
158
|
+
def remove_stream(application_id: @config.application_id, archive_id:, **params)
|
159
|
+
# TODO: raise error if application_id is nil
|
160
|
+
# TODO: raise error if remove_stream is nil
|
161
|
+
|
162
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id + '/streams', params: camelcase(params), type: Patch)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Change the layout of a composed archive while it is being recorded.
|
166
|
+
#
|
167
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
168
|
+
#
|
169
|
+
# @param [required, String] archive_id
|
170
|
+
#
|
171
|
+
# @param [optional, String] type
|
172
|
+
#
|
173
|
+
# @param [optional, String] stylesheet
|
174
|
+
#
|
175
|
+
# @param [optional, String] screenshare_type
|
176
|
+
#
|
177
|
+
# @return [Response]
|
178
|
+
#
|
179
|
+
# @see TODO: add docs link
|
180
|
+
#
|
181
|
+
def change_layout(application_id: @config.application_id, archive_id:, **params)
|
182
|
+
# TODO: raise error if application_id is nil
|
183
|
+
|
184
|
+
request('/v2/project/' + application_id + '/archive/' + archive_id + '/layout', params: camelcase(params), type: Put)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Video::Moderation < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
self.host = :video_host
|
11
|
+
|
12
|
+
# Force a client to disconnect from a session.
|
13
|
+
#
|
14
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
15
|
+
#
|
16
|
+
# @param [required, String] :session_id
|
17
|
+
#
|
18
|
+
# @param [required, String] :connection_id The connection ID of the specific participant to be disconnected from the session.
|
19
|
+
#
|
20
|
+
# @return [Response]
|
21
|
+
#
|
22
|
+
# @see TODO: add docs link
|
23
|
+
#
|
24
|
+
def force_disconnect(application_id: @config.application_id, session_id:, connection_id:)
|
25
|
+
# TODO: raise error if application_id is nil
|
26
|
+
|
27
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/connection/' + connection_id, type: Delete)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Force mute a specific publisher stream in a session.
|
31
|
+
#
|
32
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
33
|
+
#
|
34
|
+
# @param [required, String] :session_id
|
35
|
+
#
|
36
|
+
# @param [required, String] :stream_id The stream ID of the specific stream to be muted.
|
37
|
+
#
|
38
|
+
# @return [Response]
|
39
|
+
#
|
40
|
+
# @see TODO: add docs link
|
41
|
+
#
|
42
|
+
def mute_single_stream(application_id: @config.application_id, session_id:, stream_id:)
|
43
|
+
application_id ||= @config.application_id
|
44
|
+
# TODO: raise error if application_id is nil
|
45
|
+
|
46
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/stream/' + stream_id + '/mute', type: Post)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Force mute all publisher stream for a specific session.
|
50
|
+
#
|
51
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
52
|
+
#
|
53
|
+
# @param [required, String] :session_id
|
54
|
+
#
|
55
|
+
# @param [required, String] :active
|
56
|
+
#
|
57
|
+
# @param [required, Array<String>] :excludedStreamIds
|
58
|
+
#
|
59
|
+
# @return [Response]
|
60
|
+
#
|
61
|
+
# @see TODO: add docs link
|
62
|
+
#
|
63
|
+
def mute_multiple_streams(application_id: @config.application_id, session_id:, **params)
|
64
|
+
# TODO: raise error if application_id is nil
|
65
|
+
# TODO: camelcase params
|
66
|
+
|
67
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/mute', params: params, type: Post)
|
68
|
+
end
|
69
|
+
|
70
|
+
# TODO: add disable_force_mute ??
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vonage
|
5
|
+
class Video::Signals < Namespace
|
6
|
+
self.authentication = BearerToken
|
7
|
+
|
8
|
+
self.request_body = JSON
|
9
|
+
|
10
|
+
self.host = :video_host
|
11
|
+
|
12
|
+
# Send a signal to a specific participant in an active Vonage Video session.
|
13
|
+
#
|
14
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
15
|
+
#
|
16
|
+
# @param [required, String] :session_id
|
17
|
+
#
|
18
|
+
# @param [required, String] :connection_id The connection ID of the specific participant.
|
19
|
+
#
|
20
|
+
# @param [required, String] :type Type of data that is being sent to the client.
|
21
|
+
#
|
22
|
+
# @param [required, String] :data Payload that is being sent to the client.
|
23
|
+
#
|
24
|
+
# @return [Response]
|
25
|
+
#
|
26
|
+
# @see TODO: add docs link
|
27
|
+
#
|
28
|
+
def send_to_one(application_id: @config.application_id, session_id:, connection_id:, **params)
|
29
|
+
# TODO: raise error if application_id is nil
|
30
|
+
|
31
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/connection/' + connection_id + '/signal', params: params, type: Post)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Send a signal to all participants in an active Vonage Video session.
|
35
|
+
#
|
36
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
37
|
+
#
|
38
|
+
# @param [required, String] :session_id
|
39
|
+
#
|
40
|
+
# @param [required, String] :type Type of data that is being sent to the client.
|
41
|
+
#
|
42
|
+
# @param [required, String] :data Payload that is being sent to the client.
|
43
|
+
#
|
44
|
+
# @return [Response]
|
45
|
+
#
|
46
|
+
# @see TODO: add docs link
|
47
|
+
#
|
48
|
+
def send_to_all(application_id: @config.application_id, session_id:, **params)
|
49
|
+
# TODO: raise error if application_id is nil
|
50
|
+
|
51
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/signal', params: params, type: Post)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,76 @@
|
|
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(application_id: @config.application_id, session_id:)
|
26
|
+
# TODO: raise error if application_id is nil
|
27
|
+
|
28
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/stream', response_class: Video::ListResponse)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get information about a specified stream.
|
32
|
+
#
|
33
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
34
|
+
#
|
35
|
+
# @param [required, String] :session_id
|
36
|
+
#
|
37
|
+
# @param [required, String] :stream_id
|
38
|
+
#
|
39
|
+
# @return [Response]
|
40
|
+
#
|
41
|
+
# @see TODO: add docs link
|
42
|
+
#
|
43
|
+
def info(application_id: @config.application_id, session_id:, stream_id:)
|
44
|
+
# TODO: raise error if application_id is nil
|
45
|
+
|
46
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/stream/' + stream_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Change the layout for a list of specified streams.
|
50
|
+
#
|
51
|
+
# @param [optional, String] :application_id (Required unless already set at Client instantiation or set in ENV)
|
52
|
+
#
|
53
|
+
# @param [required, String] :session_id
|
54
|
+
#
|
55
|
+
# @param [optional, Array<Hash>] :items An array of hashes representing streams and the layout classes for those streams
|
56
|
+
#
|
57
|
+
# @option items [required, String] :id The stream ID
|
58
|
+
#
|
59
|
+
# @option items [required, Array<String>] :layoutClassList Array of CSS class names as strings
|
60
|
+
#
|
61
|
+
# @return [Response]
|
62
|
+
#
|
63
|
+
# @see TODO: add docs link
|
64
|
+
#
|
65
|
+
def change_layout(application_id: @config.application_id, session_id:, **params)
|
66
|
+
# TODO: raise error if application_id is nil
|
67
|
+
# TODO camelcase layout_class_list
|
68
|
+
# if params[:items]
|
69
|
+
# params[:items] = params[:items].map {|item| camelcase(item)}
|
70
|
+
# end
|
71
|
+
|
72
|
+
request('/v2/project/' + application_id + '/session/' + session_id + '/stream', params: params, type: Put)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/lib/vonage/video.rb
ADDED
@@ -0,0 +1,91 @@
|
|
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[: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 = {session_id: session_id, application_id: @config.application_id, scope: scope, role: role}
|
58
|
+
claims[:data] = params[:data] if params[:data]
|
59
|
+
claims[:initial_layout_class_list] = params[:initial_layout_class_list].join(' ') if params[:initial_layout_class_list]
|
60
|
+
claims[:exp] = params[:expire_time].to_i if params[:expire_time]
|
61
|
+
|
62
|
+
JWT.generate(claims, @config.private_key)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Streams]
|
66
|
+
#
|
67
|
+
def streams
|
68
|
+
@streams ||= Streams.new(@config)
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [Archives]
|
72
|
+
#
|
73
|
+
def archives
|
74
|
+
@archives ||= Archives.new(@config)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Archives]
|
78
|
+
#
|
79
|
+
def moderation
|
80
|
+
@moderation ||= Moderation.new(@config)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [Archives]
|
84
|
+
#
|
85
|
+
def signals
|
86
|
+
@signals ||= Signals.new(@config)
|
87
|
+
end
|
88
|
+
|
89
|
+
# TODO: add token generator
|
90
|
+
end
|
91
|
+
end
|
data/vonage.gemspec
CHANGED
@@ -12,7 +12,7 @@ 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('
|
15
|
+
s.add_dependency('vonage-jwt', '~> 0.1.0')
|
16
16
|
s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
|
17
17
|
s.add_dependency('sorbet-runtime', '~> 0.5')
|
18
18
|
s.add_runtime_dependency('rexml')
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vonage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vonage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: vonage-jwt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.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.
|
26
|
+
version: 0.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: zeitwerk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +153,12 @@ files:
|
|
153
153
|
- lib/vonage/user_agent.rb
|
154
154
|
- lib/vonage/verify.rb
|
155
155
|
- lib/vonage/version.rb
|
156
|
+
- lib/vonage/video.rb
|
157
|
+
- lib/vonage/video/archives.rb
|
158
|
+
- lib/vonage/video/list_response.rb
|
159
|
+
- lib/vonage/video/moderation.rb
|
160
|
+
- lib/vonage/video/signals.rb
|
161
|
+
- lib/vonage/video/streams.rb
|
156
162
|
- lib/vonage/voice.rb
|
157
163
|
- lib/vonage/voice/actions/connect.rb
|
158
164
|
- lib/vonage/voice/actions/conversation.rb
|
@@ -188,11 +194,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
194
|
version: 2.5.0
|
189
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
196
|
requirements:
|
191
|
-
- - "
|
197
|
+
- - ">"
|
192
198
|
- !ruby/object:Gem::Version
|
193
|
-
version:
|
199
|
+
version: 1.3.1
|
194
200
|
requirements: []
|
195
|
-
rubygems_version: 3.3.
|
201
|
+
rubygems_version: 3.3.26
|
196
202
|
signing_key:
|
197
203
|
specification_version: 4
|
198
204
|
summary: This is the Ruby Server SDK for Vonage APIs. To use it you'll need a Vonage
|