class Yt::Collections::Subscriptions
@private
Public Instance Methods
insert(options = {})
click to toggle source
# File lib/yt/collections/subscriptions.rb, line 9 def insert(options = {}) do_insert rescue Yt::Error => error ignorable_error = error.reasons.include? 'subscriptionDuplicate' ignorable_error ||= (@parent.id == @auth.channel.id) if @auth raise error unless options[:ignore_errors] && ignorable_error end
Private Instance Methods
attributes_for_new_item(data)
click to toggle source
# File lib/yt/collections/subscriptions.rb, line 19 def attributes_for_new_item(data) {id: data['id'], auth: @auth} end
insert_params()
click to toggle source
@return [Hash] the parameters to submit to YouTube to add a subscriptions. @see developers.google.com/youtube/v3/docs/subscriptions/insert
Calls superclass method
Yt::Actions::Insert#insert_params
# File lib/yt/collections/subscriptions.rb, line 42 def insert_params super.tap do |params| params[:params] = {part: 'snippet'} params[:body] = {snippet: {resourceId: {channelId: @parent.id, kind: 'youtube#channel'}}} end end
list_params()
click to toggle source
@return [Hash] the parameters to submit to YouTube to list subscriptions. @see developers.google.com/youtube/v3/docs/subscriptions/list
Calls superclass method
Yt::Actions::List#list_params
# File lib/yt/collections/subscriptions.rb, line 25 def list_params super.tap do |params| params[:params] = subscriptions_params end end
subscriptions_params()
click to toggle source
# File lib/yt/collections/subscriptions.rb, line 31 def subscriptions_params {}.tap do |params| params[:max_results] = 50 params[:for_channel_id] = @parent.id params[:mine] = true params[:part] = 'snippet' end end