Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Fullscreen/feature/content-owners-list
Add account.content_owners to list Content Owners
- Loading branch information
Showing
8 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
yt (0.8.2) | ||
yt (0.8.3) | ||
activesupport | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'yt/collections/base' | ||
require 'yt/models/content_owner' | ||
|
||
module Yt | ||
module Collections | ||
# Provides methods to interact with a collection of Content Owners. | ||
# | ||
# Resources with content_owners are: {Yt::Models::Account accounts}. | ||
class ContentOwners < Base | ||
|
||
private | ||
|
||
def new_item(data) | ||
Yt::ContentOwner.new owner_name: data['id'], authentication: @auth.authentication | ||
end | ||
|
||
# @return [Hash] the parameters to submit to YouTube to list content | ||
# owners administered by the account. | ||
# @see https://developers.google.com/youtube/partner/docs/v1/contentOwners/list | ||
def list_params | ||
super.tap do |params| | ||
params[:params] = content_owners_params | ||
params[:path] = '/youtube/partner/v1/contentOwners' | ||
end | ||
end | ||
|
||
def content_owners_params | ||
{fetchMine: true} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Yt | ||
VERSION = '0.8.2' | ||
VERSION = '0.8.3' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# encoding: UTF-8 | ||
require 'spec_helper' | ||
require 'yt/models/account' | ||
|
||
describe Yt::Account, :partner do | ||
subject(:account) { Yt::Account.new id: id, authentication: $content_owner.authentication } | ||
|
||
describe '.content_owners' do | ||
let(:content_owners) { account.content_owners } | ||
|
||
context 'given a partenered account with content owners', :partner do | ||
let(:id) { $content_owner.id } | ||
|
||
specify 'returns the associated content owners' do | ||
expect(content_owners.size).to be > 0 | ||
expect(content_owners.first).to be_a Yt::ContentOwner | ||
end | ||
|
||
specify 'ensures the content owners have the same credentials as the account' do | ||
expect(content_owners.first.access_token).to eq account.access_token | ||
expect(content_owners.first.refresh_token).to eq account.refresh_token | ||
end | ||
end | ||
end | ||
end |