Class: Wavix::CallRecording::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/wavix/call_recording/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/wavix/call_recording/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse

Deletes the call recording identified by id. Deletion is permanent and removes the recording file.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (Integer)

Returns:



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/wavix/call_recording/client.rb', line 145

def delete(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "v1/recordings/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: 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

#get(request_options: {}, **params) ⇒ Wavix::Types::Recording

Returns the call recording identified by id, including its metadata and download URL.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (Integer)

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/wavix/call_recording/client.rb', line 111

def get(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/recordings/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: 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::Recording.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_by_call(request_options: {}, **params) ⇒ untyped

Redirects to the recording file for the call identified by call_id. The download URL is returned in the Location header.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :call_id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/wavix/call_recording/client.rb', line 79

def get_by_call(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/recordings/#{URI.encode_uri_component(params[:call_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#list(request_options: {}, **params) ⇒ Wavix::Types::CallRecordingListResponse

Returns a paginated list of call recordings for the authenticated account, filtered by date range, number, call, or SIP trunk.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :from_date (String, nil)
  • :to_date (String, nil)
  • :from (String, nil)
  • :to (String, nil)
  • :call_uuid (String, nil)
  • :sip_trunks (String, nil)
  • :page (Integer, nil)
  • :per_page (Integer, nil)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wavix/call_recording/client.rb', line 33

def list(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["from_date"] = params[:from_date] if params.key?(:from_date)
  query_params["to_date"] = params[:to_date] if params.key?(:to_date)
  query_params["from"] = params[:from] if params.key?(:from)
  query_params["to"] = params[:to] if params.key?(:to)
  query_params["call_uuid"] = params[:call_uuid] if params.key?(:call_uuid)
  query_params["sip_trunks"] = params[:sip_trunks] if params.key?(:sip_trunks)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["per_page"] = params[:per_page] if params.key?(:per_page)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v1/recordings",
    query: query_params,
    request_options: 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::CallRecordingListResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end