Class: Telnyx::Resources::Media

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

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:



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

def initialize(client:)
  @client = client
end

Instance Method Details

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

Permanently deletes the specified media file from storage.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

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

Returns:

  • (nil)

See Also:



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

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 the raw content of the specified stored media file.

Parameters:

  • media_name (String)

    Uniquely identifies a media resource.

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

Returns:

  • (StringIO)

See Also:



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

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 the media files stored on your account, with support for filtering.

Parameters:

Returns:

See Also:



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

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 the specified stored media file and returns the updated resource.

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:



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

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