Sha256: ce15674f213f2b6763c432a1daa30d9fe208f41452103aa00959bc3f56679690

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Zype
  class Playlists < Zype::BaseModel
    # Returns videos for a playlist
    #
    # @param id [String] the ID of the playlist
    # @return [Array<Hash>] an array of video objects
    def videos(id:)
      client.execute(method: :get, path: "/playlists/#{id}/videos")
    end

    # Adds videos to a playlist
    #
    # @param id [String] the ID of the playlist
    # @param video_ids [Array<String>] the video IDs to add to the playlist
    # @return [Array<Hash>] an array of video objects
    def add_videos(id:, video_ids:)
      client.execute(method: :put, path: "/playlists/#{id}/add_videos", params: { video_id: video_ids })
    end

    # Removes videos from a playlist
    #
    # @param id [String] the ID of the playlist
    # @param video_ids [Array<String>] the video IDs to remove to the playlist
    # @return [Array<Hash>] an array of video objects
    def remove_videos(id:, video_ids:)
      client.execute(method: :put, path: "/playlists/#{id}/remove_videos", params: { video_id: video_ids })
    end

    # Returns all playlists from the API
    #
    # @return [Array<Hash>] all playlists in relational order
    def relationships
      client.execute(method: :get, path: '/playlists/relationships')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zype-0.5.0 lib/zype/models/playlists.rb
zype-0.4.0 lib/zype/models/playlists.rb