Class: Zype::Playlists

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

Overview

Since:

  • 0.4.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

#all, #auth=, #create, #delete, #find, #initialize, #update

Constructor Details

This class inherits a constructor from Zype::BaseModel

Instance Method Details

#add_videos(id:, video_ids:) ⇒ Array<Hash>

Adds videos to a playlist

Parameters:

  • id (String)

    the ID of the playlist

  • video_ids (Array<String>)

    the video IDs to add to the playlist

Returns:

  • (Array<Hash>)

    an array of video objects

Since:

  • 0.4.0



19
20
21
# File 'lib/zype/models/playlists.rb', line 19

def add_videos(id:, video_ids:)
  client.execute(method: :put, path: "/playlists/#{id}/add_videos", params: { video_id: video_ids })
end

#relationshipsArray<Hash>

Returns all playlists from the API

Returns:

  • (Array<Hash>)

    all playlists in relational order

Since:

  • 0.4.0



35
36
37
# File 'lib/zype/models/playlists.rb', line 35

def relationships
  client.execute(method: :get, path: '/playlists/relationships')
end

#remove_videos(id:, video_ids:) ⇒ Array<Hash>

Removes videos from a playlist

Parameters:

  • id (String)

    the ID of the playlist

  • video_ids (Array<String>)

    the video IDs to remove to the playlist

Returns:

  • (Array<Hash>)

    an array of video objects

Since:

  • 0.4.0



28
29
30
# File 'lib/zype/models/playlists.rb', line 28

def remove_videos(id:, video_ids:)
  client.execute(method: :put, path: "/playlists/#{id}/remove_videos", params: { video_id: video_ids })
end

#videos(id:) ⇒ Array<Hash>

Returns videos for a playlist

Parameters:

  • id (String)

    the ID of the playlist

Returns:

  • (Array<Hash>)

    an array of video objects

Since:

  • 0.4.0



10
11
12
# File 'lib/zype/models/playlists.rb', line 10

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