Class: Yt::Models::Claim
- Inherits:
-
Base
- Object
- Base
- Yt::Models::Claim
- Defined in:
- lib/yt/models/claim.rb
Overview
Provides methods to interact with YouTube ContentID claims.
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#claim_history ⇒ Yt::Collections::ClaimHistories
readonly
The claim’s history.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Whether the claim is active.
-
#appealed? ⇒ Boolean
Whether the claim is appealed.
-
#asset ⇒ Yt::Models::Asset
The asset of the claim.
-
#asset_id ⇒ String
The unique YouTube asset ID that identifies the asset associated with the claim.
-
#audio? ⇒ Boolean
Whether the claim covers only the audio.
-
#audiovisual? ⇒ Boolean
Whether the claim covers both audio and video.
-
#block_outside_ownership? ⇒ Boolean
Return whether the video should be blocked where not explicitly owned.
-
#content_type ⇒ String
Returns the audiovisual portion of the claimed content.
-
#created_at ⇒ Time
The date and time that the claim was created.
-
#delete ⇒ Boolean
Soft-deletes the claim.
-
#disputed? ⇒ Boolean
Whether the claim is disputed.
-
#has_unknown_status? ⇒ Boolean
Whether the claim status is unknown.
-
#id ⇒ String
The ID that YouTube assigns and uses to uniquely identify the claim.
-
#inactive? ⇒ Boolean
Whether the claim is inactive.
-
#initialize(options = {}) ⇒ Claim
constructor
A new instance of Claim.
-
#match_reference_id ⇒ String
The unique ID that YouTube uses to identify the reference that generated the match.
-
#pending? ⇒ Boolean
Whether the claim is pending.
-
#potential? ⇒ Boolean
Whether the claim is potential.
-
#source ⇒ String
The source of the claim.
-
#status ⇒ String
Returns the claim’s status.
-
#takedown? ⇒ Boolean
Whether the claim is takedown.
-
#third_party? ⇒ Boolean
Whether a third party created the claim.
-
#update(attributes = {}) ⇒ Boolean
Updates the attributes of a claim.
-
#video? ⇒ Boolean
Whether the claim covers only the video.
-
#video_id ⇒ String
The unique YouTube video ID that identifies the video associated with the claim.
Constructor Details
#initialize(options = {}) ⇒ Claim
Returns a new instance of Claim.
10 11 12 13 14 15 |
# File 'lib/yt/models/claim.rb', line 10 def initialize( = {}) @data = [:data] @id = [:id] @auth = [:auth] @asset = [:asset] if [:asset] end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
8 9 10 |
# File 'lib/yt/models/claim.rb', line 8 def auth @auth end |
#claim_history ⇒ Yt::Collections::ClaimHistories (readonly)
Returns the claim’s history.
30 |
# File 'lib/yt/models/claim.rb', line 30 has_one :claim_history |
#data ⇒ Object (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
Returns whether the claim is active.
67 68 69 |
# File 'lib/yt/models/claim.rb', line 67 def active? status == 'active' end |
#appealed? ⇒ Boolean
Returns whether the claim is appealed.
72 73 74 |
# File 'lib/yt/models/claim.rb', line 72 def appealed? status == 'appealed' end |
#asset ⇒ Yt::Models::Asset
Returns the asset of the claim.
134 135 136 |
# File 'lib/yt/models/claim.rb', line 134 def asset @asset end |
#asset_id ⇒ String
Returns the unique YouTube asset ID that identifies the asset associated with the claim.
49 |
# File 'lib/yt/models/claim.rb', line 49 has_attribute :asset_id |
#audio? ⇒ Boolean
Returns whether the claim covers only the audio.
114 115 116 |
# File 'lib/yt/models/claim.rb', line 114 def audio? content_type == 'audio' end |
#audiovisual? ⇒ Boolean
Returns whether the claim covers both audio and video.
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_type ⇒ String
Returns the audiovisual portion of the claimed content.
111 |
# File 'lib/yt/models/claim.rb', line 111 has_attribute :content_type |
#created_at ⇒ Time
Returns the date and time that the claim was created.
139 |
# File 'lib/yt/models/claim.rb', line 139 has_attribute :created_at, type: Time, from: :time_created |
#delete ⇒ Boolean
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
Returns whether the claim is disputed.
77 78 79 |
# File 'lib/yt/models/claim.rb', line 77 def disputed? status == 'disputed' end |
#has_unknown_status? ⇒ Boolean
Returns whether the claim status is unknown.
102 103 104 |
# File 'lib/yt/models/claim.rb', line 102 def has_unknown_status? status == 'unknown' end |
#id ⇒ String
Returns the ID that YouTube assigns and uses to uniquely identify the claim.
45 |
# File 'lib/yt/models/claim.rb', line 45 has_attribute :id |
#inactive? ⇒ Boolean
Returns whether the claim is inactive.
82 83 84 |
# File 'lib/yt/models/claim.rb', line 82 def inactive? status == 'inactive' end |
#match_reference_id ⇒ String
Returns The unique ID that YouTube uses to identify the reference that generated the match.
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
Returns whether the claim is pending.
87 88 89 |
# File 'lib/yt/models/claim.rb', line 87 def pending? status == 'pending' end |
#potential? ⇒ Boolean
Returns whether the claim is potential.
92 93 94 |
# File 'lib/yt/models/claim.rb', line 92 def potential? status == 'potential' end |
#source ⇒ String
Returns the source of the claim.
129 130 131 |
# File 'lib/yt/models/claim.rb', line 129 def source @data.fetch('origin', {})['source'] end |
#status ⇒ String
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
Returns whether the claim is takedown.
97 98 99 |
# File 'lib/yt/models/claim.rb', line 97 def takedown? status == 'takedown' end |
#third_party? ⇒ Boolean
Returns whether a third party created the claim.
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
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
Returns whether the claim covers only the video.
119 120 121 |
# File 'lib/yt/models/claim.rb', line 119 def video? content_type == 'video' end |
#video_id ⇒ String
Returns the unique YouTube video ID that identifies the video associated with the claim.
53 |
# File 'lib/yt/models/claim.rb', line 53 has_attribute :video_id |