Class: Zype::Subtitles

Inherits:
BaseModel show all
Defined in:
lib/zype/models/subtitles.rb

Overview

Work with subtitles for a specific video. Read more at docs.zype.com/v1.0/reference#subtitles

Since:

  • 0.7.0

Constant Summary

Constants inherited from BaseModel

BaseModel::ACCEPTED_KEYS

Instance Attribute Summary

Attributes inherited from BaseModel

#client, #path

Instance Method Summary collapse

Methods inherited from BaseModel

#auth=, #initialize

Constructor Details

This class inherits a constructor from Zype::BaseModel

Instance Method Details

#all(video_id:, params: {}) ⇒ Array<Hash>

Returns all subtitles for given video - add params to filter

Parameters:

  • video_id (String)

    ID of video to get subtitles for

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

    the metadata to filter objects by

Returns:

  • (Array<Hash>)

    the subtitles returned from the API

Since:

  • 0.7.0



12
13
14
# File 'lib/zype/models/subtitles.rb', line 12

def all(video_id:, params: {})
  client.execute(method: :get, path: "/videos/#{video_id}/subtitles", params: params)
end

#create(video_id:, params:) ⇒ Hash

Creates a new subtitle via the API. Files must be base64 encoded

Examples:

to base64 encode a file with Ruby

require 'base64'
Base64.encode64(File.open("file_path", "rb").read)

Parameters:

  • video_id (String)

    ID of the video to assign to the subtitle

  • params (Hash)

    the properties of the subtitle

Returns:

  • (Hash)

    the newly created subtitle

Since:

  • 0.7.0



34
35
36
# File 'lib/zype/models/subtitles.rb', line 34

def create(video_id:, params:)
  client.execute(method: :post, path: "/videos/#{video_id}/subtitles", params: params)
end

#delete(id:, video_id:) ⇒ Hash

Deletes an existing subtitle via the API

Parameters:

  • id (String)

    the ID of the object

  • video_id (String)

    ID of the video the subtitle belongs to

Returns:

  • (Hash)

    the deleted subtitle

Since:

  • 0.7.0



53
54
55
# File 'lib/zype/models/subtitles.rb', line 53

def delete(id:, video_id:)
  client.execute(method: :delete, path: "/videos/#{video_id}/subtitles/#{id}")
end

#find(id:, video_id:) ⇒ Hash

Returns subtitle matching ID

Parameters:

  • id (String)

    the ID of the object

  • video_id (String)

    ID of the video the subtitle belongs to

Returns:

  • (Hash)

    the object returned from the API

Since:

  • 0.7.0



21
22
23
# File 'lib/zype/models/subtitles.rb', line 21

def find(id:, video_id:)
  client.execute(method: :get, path: "/videos/#{video_id}/subtitles/#{id}")
end

#update(id:, video_id:, params:) ⇒ Hash

Updates an existing subtitle via the API

Parameters:

  • id (String)

    the ID of the object

  • video_id (String)

    ID of the video the subtitle belongs to

  • params (Hash)

    the properties to be updated

Returns:

  • (Hash)

    the updated subtitle

Since:

  • 0.7.0



44
45
46
# File 'lib/zype/models/subtitles.rb', line 44

def update(id:, video_id:, params:)
  client.execute(method: :put, path: "/videos/#{video_id}/subtitles/#{id}", params: params)
end