class Yt::Models::Claim

Provides methods to interact with YouTube ContentID claims. @see developers.google.com/youtube/partner/docs/v1/claims

Attributes

auth[R]
data[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/yt/models/claim.rb, line 10
def initialize(options = {})
  @data = options[:data]
  @id = options[:id]
  @auth = options[:auth]
  @asset = options[:asset] if options[:asset]
end

Public Instance Methods

active?() click to toggle source

@return [Boolean] whether the claim is active.

# File lib/yt/models/claim.rb, line 67
def active?
  status == 'active'
end
appealed?() click to toggle source

@return [Boolean] whether the claim is appealed.

# File lib/yt/models/claim.rb, line 72
def appealed?
  status == 'appealed'
end
asset() click to toggle source

@return [Yt::Models::Asset] the asset of the claim

# File lib/yt/models/claim.rb, line 134
def asset
  @asset
end
audio?() click to toggle source

@return [Boolean] whether the claim covers only the audio.

# File lib/yt/models/claim.rb, line 114
def audio?
  content_type == 'audio'
end
audiovisual?() click to toggle source

@return [Boolean] whether the claim covers both audio and video.

# File lib/yt/models/claim.rb, line 124
def audiovisual?
  content_type == 'audiovisual'
end
delete() click to toggle source

Soft-deletes the claim. @note YouTube API does not provide a delete method for the Asset

resource, but only an +update+ method. Updating the +status+ of a
Asset to "inactive" can be considered a soft-deletion.

@return [Boolean] whether the claim is inactive.

# File lib/yt/models/claim.rb, line 37
def delete
  body = {status: :inactive}
  do_patch(body: body) {|data| @data = data}
  inactive?
end
disputed?() click to toggle source

@return [Boolean] whether the claim is disputed.

# File lib/yt/models/claim.rb, line 77
def disputed?
  status == 'disputed'
end
has_unknown_status?() click to toggle source

@return [Boolean] whether the claim status is unknown.

# File lib/yt/models/claim.rb, line 102
def has_unknown_status?
  status == 'unknown'
end
inactive?() click to toggle source

@return [Boolean] whether the claim is inactive.

# File lib/yt/models/claim.rb, line 82
def inactive?
  status == 'inactive'
end
pending?() click to toggle source

@return [Boolean] whether the claim is pending.

# File lib/yt/models/claim.rb, line 87
def pending?
  status == 'pending'
end
potential?() click to toggle source

@return [Boolean] whether the claim is potential.

# File lib/yt/models/claim.rb, line 92
def potential?
  status == 'potential'
end
source() click to toggle source

@return [String] the source of the claim

# File lib/yt/models/claim.rb, line 129
def source
  @data.fetch('origin', {})['source']
end
takedown?() click to toggle source

@return [Boolean] whether the claim is takedown.

# File lib/yt/models/claim.rb, line 97
def takedown?
  status == 'takedown'
end
update(attributes = {}) click to toggle source

Updates the attributes of a claim. @note If you are submitting an update request, and your request does

not specify a value for a property that already has a value, the
property's existing value will be deleted.

@return [Boolean] whether the claim was successfully updated.

# File lib/yt/models/claim.rb, line 22
def update(attributes = {})
  underscore_keys! attributes
  do_patch body: attributes
  true
end
video?() click to toggle source

@return [Boolean] whether the claim covers only the video.

# File lib/yt/models/claim.rb, line 119
def video?
  content_type == 'video'
end

Private Instance Methods

patch_params() click to toggle source

@see developers.google.com/youtube/partner/docs/v1/claims/update

Calls superclass method Yt::Actions::Patch#patch_params
# File lib/yt/models/claim.rb, line 169
def patch_params
  super.tap do |params|
    params[:expected_response] = Net::HTTPOK
    params[:path] = "/youtube/partner/v1/claims/#{id}"
    params[:params] = {on_behalf_of_content_owner: @auth.owner_name}
  end
end