Class: Yt::Models::Claim

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/claim.rb

Overview

Provides methods to interact with YouTube ContentID claims.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Claim


10
11
12
13
14
15
# 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

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth


8
9
10
# File 'lib/yt/models/claim.rb', line 8

def auth
  @auth
end

#claim_historyYt::Collections::ClaimHistories (readonly)


19
# File 'lib/yt/models/claim.rb', line 19

has_one :claim_history

#dataObject (readonly)

Returns the value of attribute data


8
9
10
# File 'lib/yt/models/claim.rb', line 8

def data
  @data
end

Instance Method Details

#active?Boolean


56
57
58
# File 'lib/yt/models/claim.rb', line 56

def active?
  status == 'active'
end

#appealed?Boolean


61
62
63
# File 'lib/yt/models/claim.rb', line 61

def appealed?
  status == 'appealed'
end

#assetYt::Models::Asset


123
124
125
# File 'lib/yt/models/claim.rb', line 123

def asset
  @asset
end

#asset_idString


38
# File 'lib/yt/models/claim.rb', line 38

has_attribute :asset_id

#audio?Boolean


103
104
105
# File 'lib/yt/models/claim.rb', line 103

def audio?
  content_type == 'audio'
end

#audiovisual?Boolean


113
114
115
# File 'lib/yt/models/claim.rb', line 113

def audiovisual?
  content_type == 'audiovisual'
end

#block_outside_ownership?Boolean

Return whether the video should be blocked where not explicitly owned.


146
# File 'lib/yt/models/claim.rb', line 146

has_attribute :block_outside_ownership?, from: :block_outside_ownership

#content_typeString

Returns the audiovisual portion of the claimed content.


100
# File 'lib/yt/models/claim.rb', line 100

has_attribute :content_type

#created_atTime


128
# File 'lib/yt/models/claim.rb', line 128

has_attribute :created_at, type: Time, from: :time_created

#deleteBoolean

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.

Soft-deletes the claim.


26
27
28
29
30
# File 'lib/yt/models/claim.rb', line 26

def delete
  body = {status: :inactive}
  do_patch(body: body) {|data| @data = data}
  inactive?
end

#disputed?Boolean


66
67
68
# File 'lib/yt/models/claim.rb', line 66

def disputed?
  status == 'disputed'
end

#has_unknown_status?Boolean


91
92
93
# File 'lib/yt/models/claim.rb', line 91

def has_unknown_status?
  status == 'unknown'
end

#idString


34
# File 'lib/yt/models/claim.rb', line 34

has_attribute :id

#inactive?Boolean


71
72
73
# File 'lib/yt/models/claim.rb', line 71

def inactive?
  status == 'inactive'
end

#match_reference_idString


150
151
152
# File 'lib/yt/models/claim.rb', line 150

has_attribute :match_reference_id, from: :match_info do |match_info|
  (match_info || {})['referenceId']
end

#pending?Boolean


76
77
78
# File 'lib/yt/models/claim.rb', line 76

def pending?
  status == 'pending'
end

#potential?Boolean


81
82
83
# File 'lib/yt/models/claim.rb', line 81

def potential?
  status == 'potential'
end

#sourceString


118
119
120
# File 'lib/yt/models/claim.rb', line 118

def source
  @data.fetch('origin', {})['source']
end

#statusString

Note:

When updating a claim, you can update its status from active to inactive to effectively release the claim, but the API does not support other updates to a claim’s status.

Returns the claim’s status.


53
# File 'lib/yt/models/claim.rb', line 53

has_attribute :status

#takedown?Boolean


86
87
88
# File 'lib/yt/models/claim.rb', line 86

def takedown?
  status == 'takedown'
end

#third_party?Boolean


131
132
133
# File 'lib/yt/models/claim.rb', line 131

has_attribute :third_party?, from: :third_party_claim do |value|
  value == true
end

#video?Boolean


108
109
110
# File 'lib/yt/models/claim.rb', line 108

def video?
  content_type == 'video'
end

#video_idString


42
# File 'lib/yt/models/claim.rb', line 42

has_attribute :video_id