Class: Yt::Collections::PlaylistItems

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/collections/playlist_items.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, of, #where

Methods included from Actions::List

#first!

Constructor Details

This class inherits a constructor from Yt::Collections::Base

Instance Method Details

#delete_all(params = {}) ⇒ Object



19
20
21
# File 'lib/yt/collections/playlist_items.rb', line 19

def delete_all(params = {})
  do_delete_all params
end

#insert(attrs = {}, options = {}) ⇒ Object

attrs are id and kind



9
10
11
12
13
14
15
16
17
# File 'lib/yt/collections/playlist_items.rb', line 9

def insert(attrs = {}, options = {}) #
  resource = {kind: "youtube##{attrs[:kind]}"}
  resource["#{attrs[:kind]}Id"] = attrs[:id]
  snippet = {playlistId: @parent.id, resourceId: resource}
  do_insert body: {snippet: snippet}, params: {part: 'snippet,status'}
rescue Yt::Error => error
  ignorable_errors = error.reasons & ['videoNotFound', 'forbidden']
  raise error unless options[:ignore_errors] && ignorable_errors.any?
end