Class: Telnyx::Resources::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/media.rb

Overview

Media Storage operations

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Media

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Media.

Parameters:



155
156
157
# File 'lib/telnyx/resources/media.rb', line 155

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(media_name, request_options: {}) ⇒ nil

Deletes a stored media file.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



93
94
95
96
97
98
99
100
# File 'lib/telnyx/resources/media.rb', line 93

def delete(media_name, params = {})
  @client.request(
    method: :delete,
    path: ["media/%1$s", media_name],
    model: NilClass,
    options: params[:request_options]
  )
end

#download(media_name, request_options: {}) ⇒ StringIO

Downloads a stored media file.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (StringIO)

See Also:



113
114
115
116
117
118
119
120
121
# File 'lib/telnyx/resources/media.rb', line 113

def download(media_name, params = {})
  @client.request(
    method: :get,
    path: ["media/%1$s/download", media_name],
    headers: {"accept" => "application/octet-stream"},
    model: StringIO,
    options: params[:request_options]
  )
end

#list(filter: nil, request_options: {}) ⇒ Telnyx::Models::MediaListResponse

Some parameter documentations has been truncated, see Models::MediaListParams for more details.

Returns a list of stored media files.

Parameters:

Returns:

See Also:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/telnyx/resources/media.rb', line 70

def list(params = {})
  parsed, options = Telnyx::MediaListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "media",
    query: query,
    model: Telnyx::Models::MediaListResponse,
    options: options
  )
end

#retrieve(media_name, request_options: {}) ⇒ Telnyx::Models::MediaRetrieveResponse

Returns the information about a stored media file.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



18
19
20
21
22
23
24
25
# File 'lib/telnyx/resources/media.rb', line 18

def retrieve(media_name, params = {})
  @client.request(
    method: :get,
    path: ["media/%1$s", media_name],
    model: Telnyx::Models::MediaRetrieveResponse,
    options: params[:request_options]
  )
end

#update(media_name, media_url: nil, ttl_secs: nil, request_options: {}) ⇒ Telnyx::Models::MediaUpdateResponse

Some parameter documentations has been truncated, see Models::MediaUpdateParams for more details.

Updates a stored media file.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

  • media_url (String)

    The URL where the media to be stored in Telnyx network is currently hosted. The

  • ttl_secs (Integer)

    The number of seconds after which the media resource will be deleted, defaults t

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
# File 'lib/telnyx/resources/media.rb', line 45

def update(media_name, params = {})
  parsed, options = Telnyx::MediaUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["media/%1$s", media_name],
    body: parsed,
    model: Telnyx::Models::MediaUpdateResponse,
    options: options
  )
end

#upload(media_url:, media_name: nil, ttl_secs: nil, request_options: {}) ⇒ Telnyx::Models::MediaUploadResponse

Some parameter documentations has been truncated, see Models::MediaUploadParams for more details.

Upload media file to Telnyx so it can be used with other Telnyx services

Parameters:

  • media_url (String)

    The URL where the media to be stored in Telnyx network is currently hosted. The

  • media_name (String)

    The unique identifier of a file.

  • ttl_secs (Integer)

    The number of seconds after which the media resource will be deleted, defaults t

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



141
142
143
144
145
146
147
148
149
150
# File 'lib/telnyx/resources/media.rb', line 141

def upload(params)
  parsed, options = Telnyx::MediaUploadParams.dump_request(params)
  @client.request(
    method: :post,
    path: "media",
    body: parsed,
    model: Telnyx::Models::MediaUploadResponse,
    options: options
  )
end