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)


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

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


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

def active?
  status == 'active'
end

#appealed?Boolean


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

def appealed?
  status == 'appealed'
end

#assetYt::Models::Asset


134
135
136
# File 'lib/yt/models/claim.rb', line 134

def asset
  @asset
end

#asset_idString


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

has_attribute :asset_id

#audio?Boolean


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

def audio?
  content_type == 'audio'
end

#audiovisual?Boolean


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

def audiovisual?
  content_type == 'audiovisual'
end

#block_outside_ownership?Boolean

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


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

has_attribute :block_outside_ownership?, from: :block_outside_ownership

#content_typeString

Returns the audiovisual portion of the claimed content.


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

has_attribute :content_type

#created_atTime


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

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.


37
38
39
40
41
# File 'lib/yt/models/claim.rb', line 37

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

#disputed?Boolean


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

def disputed?
  status == 'disputed'
end

#has_unknown_status?Boolean


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

def has_unknown_status?
  status == 'unknown'
end

#idString


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

has_attribute :id

#inactive?Boolean


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

def inactive?
  status == 'inactive'
end

#match_reference_idString


161
162
163
# File 'lib/yt/models/claim.rb', line 161

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

#pending?Boolean


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

def pending?
  status == 'pending'
end

#potential?Boolean


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

def potential?
  status == 'potential'
end

#sourceString


129
130
131
# File 'lib/yt/models/claim.rb', line 129

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.


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

has_attribute :status

#takedown?Boolean


97
98
99
# File 'lib/yt/models/claim.rb', line 97

def takedown?
  status == 'takedown'
end

#third_party?Boolean


142
143
144
# File 'lib/yt/models/claim.rb', line 142

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

#update(attributes = {}) ⇒ Boolean

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.

Updates the attributes of a claim.


22
23
24
25
26
# File 'lib/yt/models/claim.rb', line 22

def update(attributes = {})
  underscore_keys! attributes
  do_patch body: attributes
  true
end

#video?Boolean


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

def video?
  content_type == 'video'
end

#video_idString


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

has_attribute :video_id