Class: Wavix::CallControl::Streams::Client
- Inherits:
-
Object
- Object
- Wavix::CallControl::Streams::Client
- Defined in:
- lib/wavix/call_control/streams/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Wavix::Types::CallStreamResponse
Starts streaming the media of the call identified by
call_idto the configured destination. -
#delete(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse
Stops the media stream identified by
idon the call identified bycall_id. - #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/wavix/call_control/streams/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Wavix::Types::CallStreamResponse
Starts streaming the media of the call identified by call_id to the configured destination. Returns the
stream_id.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wavix/call_control/streams/client.rb', line 27 def create(request_options: {}, **params) params = Wavix::Internal::Types::Utils.normalize_keys(params) request_data = Wavix::CallControl::Streams::Types::CallStreamCreateRequest.new(params).to_h non_body_param_names = %w[call_id] body = request_data.except(*non_body_param_names) request = Wavix::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/calls/#{URI.encode_uri_component(params[:call_id].to_s)}/streams", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Wavix::Types::CallStreamResponse.load(response.body) else error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse
Stops the media stream identified by id on the call identified by call_id.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/wavix/call_control/streams/client.rb', line 67 def delete(request_options: {}, **params) params = Wavix::Internal::Types::Utils.normalize_keys(params) request = Wavix::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "v1/calls/#{URI.encode_uri_component(params[:call_id].to_s)}/streams/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Wavix::Types::SuccessResponse.load(response.body) else error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |