Skip to content

Commit

Permalink
Add Claims#list and ClaimSearch#list
Browse files Browse the repository at this point in the history
  • Loading branch information
stavro committed Jul 22, 2014
1 parent 7859af9 commit 620ae5f
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/yt.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'yt/config'
require 'yt/models/account'
require 'yt/models/channel'
require 'yt/models/claim'
require 'yt/models/content_owner'
require 'yt/models/playlist'
require 'yt/models/playlist_item'
Expand Down
22 changes: 22 additions & 0 deletions lib/yt/collections/claim_searches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Yt
module Collections
class ClaimSearches < Base

private

def new_item(data)
Yt::Models::Claim.new data: data
end

# @return [Hash] the parameters to submit to YouTube to list claims that match the search criteria.
# @see https://developers.google.com/youtube/partner/docs/v1/claimSearch/list
def list_params
super.tap do |params|
params[:path] = "/youtube/partner/v1/claimSearch"
params[:params] = {onBehalfOfContentOwner: @parent.owner_name}.merge(@extra_params || {})
end
end

end
end
end
22 changes: 22 additions & 0 deletions lib/yt/collections/claims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Yt
module Collections
class Claims < Base

private

def new_item(data)
Yt::Models::Claim.new data: data
end

# @return [Hash] the parameters to submit to YouTube to list claims administered by the content owner.
# @see https://developers.google.com/youtube/partner/docs/v1/claims/list
def list_params
super.tap do |params|
params[:path] = "/youtube/partner/v1/claims"
params[:params] = {onBehalfOfContentOwner: @parent.owner_name}.merge(@extra_params || {})
end
end

end
end
end
48 changes: 48 additions & 0 deletions lib/yt/models/claim.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'yt/models/resource'

module Yt
module Models
class Claim < Base
def initialize(options = {})
@data = options[:data]
end

def id
@data["id"]
end

def asset_id
@data["assetId"]
end

def video_id
@data["videoId"]
end

def status
@data["status"]
end

def policy
@data["policy"]
end

def content_type
@data["contentType"]
end

def time_created
@data["timeCreated"]
end

def block_outside_ownership
@data["blockOutsideOwnership"]
end

def origin
@data["origin"]
end

end
end
end
8 changes: 8 additions & 0 deletions lib/yt/models/content_owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class ContentOwner < Account
# @return [Yt::Collection::PartneredChannels] the channels managed by the CMS account.
has_many :partnered_channels

# @!attribute [r] claims
# @return [Yt::Collection::Claim] the claims administered by the content owner.
has_many :claims

# @!attribute [r] claim_searches
# @return [Yt::Collection::ClaimSearches] the claims that match search criteria.
has_many :claim_searches

def initialize(options = {})
super options
@owner_name = options[:owner_name]
Expand Down

0 comments on commit 620ae5f

Please sign in to comment.