Class: YouTube::ChannelsResource
- Defined in:
- lib/you_tube/resources/channels.rb
Constant Summary collapse
- PARTS =
"id,snippet,status,statistics,contentDetails"
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#mine ⇒ Object
Retrieve the channel of the currently authenticated user.
-
#retrieve(id: nil, username: nil) ⇒ Object
Retrieve a Channel by its ID or Username.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from YouTube::Resource
Instance Method Details
#mine ⇒ Object
Retrieve the channel of the currently authenticated user
7 8 9 10 11 |
# File 'lib/you_tube/resources/channels.rb', line 7 def mine response = get_request "channels", params: {mine: true, part: PARTS} return nil if response.body["pageInfo"]["totalResults"] == 0 Channel.new(response.body["items"][0]) end |
#retrieve(id: nil, username: nil) ⇒ Object
Retrieve a Channel by its ID or Username
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/you_tube/resources/channels.rb', line 14 def retrieve(id: nil, username: nil) attrs = {} attrs[:id] = id if id attrs[:forUsername] = username if username raise ArgumentError, "Must provide either an ID or Username" if attrs.empty? response = get_request "channels", params: attrs.merge({part: PARTS}) return nil if response.body["pageInfo"]["totalResults"] == 0 Channel.new(response.body["items"][0]) end |