-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
1,303 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# typed: strong | ||
|
||
module Vonage | ||
VERSION = "7.18.0" | ||
VERSION = '7.19.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
module Vonage | ||
class Video < Namespace | ||
include Keys | ||
|
||
self.authentication = BearerToken | ||
|
||
self.host = :video_host | ||
|
||
# Generate a new session. | ||
# | ||
# @example | ||
# session = client.video.create_session({ | ||
# archive_mode: 'always', | ||
# location: '10.1.200.30', | ||
# media_mode: 'routed' | ||
# }) | ||
# | ||
# @params [optional, String] :archive_mode (either 'always' or 'manual') | ||
# | ||
# @param [optional, String] :location | ||
# | ||
# @params [optional, String] :media_mode (either 'routed' or 'relayed') | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: Add document link here | ||
# | ||
def create_session(**params) | ||
request_params = params.clone | ||
request_params[:archive_mode] ||= 'manual' | ||
media_mode = request_params.delete(:media_mode) || 'routed' | ||
|
||
if media_mode == 'relayed' && request_params[:archive_mode] == 'manual' | ||
request_params['p2p.preference'] = 'enabled' | ||
else | ||
request_params['p2p.preference'] = 'disabled' | ||
end | ||
|
||
response = request('/session/create', params: camelcase(request_params), type: Post) | ||
|
||
public_response_data = { | ||
session_id: response.entity.first.session_id, | ||
archive_mode: request_params[:archive_mode], | ||
media_mode: media_mode, | ||
location: request_params[:location] | ||
} | ||
|
||
entity = Entity.new(public_response_data) | ||
|
||
response.class.new(entity, response.http_response) | ||
end | ||
|
||
def generate_client_token(session_id:, scope: 'session.connect', role: 'publisher', **params) | ||
claims = { | ||
application_id: @config.application_id, | ||
scope: scope, | ||
session_id: session_id, | ||
role: role, | ||
initial_layout_class_list: '', | ||
sub: 'video', | ||
acl: { | ||
paths: {'/session/**' => {}} | ||
} | ||
} | ||
|
||
|
||
claims[:data] = params[:data] if params[:data] | ||
claims[:initial_layout_class_list] = params[:initial_layout_class_list].join(' ') if params[:initial_layout_class_list] | ||
claims[:exp] = params[:expire_time].to_i if params[:expire_time] | ||
|
||
JWT.generate(claims, @config.private_key) | ||
end | ||
|
||
# @return [Archives] | ||
# | ||
def archives | ||
@archives ||= Archives.new(@config) | ||
end | ||
|
||
# @return [Broadcasts] | ||
# | ||
def broadcasts | ||
@broadcasts ||= Broadcasts.new(@config) | ||
end | ||
|
||
# @return [Moderation] | ||
# | ||
def moderation | ||
@moderation ||= Moderation.new(@config) | ||
end | ||
|
||
# @return [Signals] | ||
# | ||
def signals | ||
@signals ||= Signals.new(@config) | ||
end | ||
|
||
# @return [Streams] | ||
# | ||
def streams | ||
@streams ||= Streams.new(@config) | ||
end | ||
|
||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
module Vonage | ||
class Video::Archives < Namespace | ||
include Keys | ||
|
||
self.authentication = BearerToken | ||
|
||
self.request_body = JSON | ||
|
||
self.host = :video_host | ||
|
||
# Get a list of archives for a specified Vonage application. | ||
# | ||
# @param [optional, Integer] :offset | ||
# | ||
# @param [optional, Integer] :count | ||
# | ||
# @param [optional, String] :session_id | ||
# | ||
# TODO: add auto_advance option | ||
# | ||
# @return [ListResponse] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def list(**params) | ||
request('/v2/project/' + @config.application_id + '/archive', params: params, response_class: ListResponse) | ||
end | ||
|
||
# Return information for specified archive. | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def info(archive_id:) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id) | ||
end | ||
|
||
# Create a new archive. | ||
# | ||
# @param [required, String] :session_id | ||
# | ||
# @param [optional, String] :hasAudio | ||
# | ||
# @param [optional, String] :hasVideo | ||
# | ||
# @param [optional, String] :name | ||
# | ||
# @param [optional, String] :outputMode | ||
# | ||
# @param [optional, String] :resolution | ||
# | ||
# @param [optional, String] :streamMode | ||
# | ||
# @param [optional, String] :multiArchiveTag | ||
# | ||
# @param [optional, Hash] :layout | ||
# | ||
# @option layout [optional, String] :type | ||
# | ||
# @option layout [optional, String] :stylesheet | ||
# | ||
# @option layout [optional, String] :screenshareType | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def start(session_id:, **params) | ||
request('/v2/project/' + @config.application_id + '/archive', params: camelcase(params.merge(session_id: session_id)), type: Post) | ||
end | ||
|
||
# Stop recording a specified archive. | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def stop(archive_id:) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id + '/stop', type: Post) | ||
end | ||
|
||
# Delete a specified archive. | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def delete(archive_id:) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id, type: Delete) | ||
end | ||
|
||
# Add a stream to a composed archive that was started with the streamMode set to "manual". | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @param [required, String] stream_id The ID of the stream to be added | ||
# | ||
# @param [optional, Boolean] has_audio | ||
# | ||
# @param [optional, Boolean] has_video | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def add_stream(archive_id:, stream_id:, **params) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id + '/streams', params: camelcase(params.merge(addStream: stream_id)), type: Patch) | ||
end | ||
|
||
# Remove a stream from a composed archive that was started with the streamMode set to "manual". | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @param [required, String] stream_id The ID of the stream to be removed | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def remove_stream(archive_id:, stream_id:) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id + '/streams', params: {removeStream: stream_id}, type: Patch) | ||
end | ||
|
||
# Change the layout of a composed archive while it is being recorded. | ||
# | ||
# @param [required, String] archive_id | ||
# | ||
# @param [optional, String] type | ||
# | ||
# @param [optional, String] stylesheet | ||
# | ||
# @param [optional, String] screenshare_type | ||
# | ||
# @return [Response] | ||
# | ||
# @see TODO: add docs link | ||
# | ||
def change_layout(archive_id:, **params) | ||
request('/v2/project/' + @config.application_id + '/archive/' + archive_id + '/layout', params: camelcase(params), type: Put) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# typed: true | ||
|
||
class Vonage::Video::Archives::ListResponse < Vonage::Response | ||
include Enumerable | ||
|
||
def each | ||
return enum_for(:each) unless block_given? | ||
|
||
@entity.items.each { |item| yield item } | ||
end | ||
end |
Oops, something went wrong.