Skip to content

Commit 5b9de34

Browse files
authored
Include more attributes (#457)
* Add player data when player part added * email_verified field to UserInfo * Add custom_url field of channel snippet * Add id_token
1 parent fb8e9f9 commit 5b9de34

6 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/yt/collections/channels.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def channels_params
2828
end
2929
end
3030
end
31-
end
31+
end

lib/yt/collections/videos.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def attributes_for_new_item(data)
2727
attributes[:statistics] = data['statistics']
2828
attributes[:video_category] = data['videoCategory']
2929
attributes[:claim] = data['claim']
30+
attributes[:player] = data['player']
3031
attributes[:auth] = @auth
3132
end
3233
end

lib/yt/models/authentication.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Yt
22
module Models
33
# Provides methods to authenticate with YouTube (and Google) API.
4-
# @see https://developers.google.com/accounts/docs/OAuth2
4+
# @see https://developers.google.com/identity/protocols/oauth2
55
class Authentication
66

77
# Before your application can access private data using a Google API,
@@ -52,11 +52,15 @@ class Authentication
5252
# @return [Time] the time when access token no longer works.
5353
attr_reader :expires_at
5454

55+
# @return [String] the OAuth2 Google id_token.
56+
attr_reader :id_token
57+
5558
def initialize(data = {})
5659
@access_token = data['access_token']
5760
@refresh_token = data['refresh_token']
5861
@error = data['error']
5962
@expires_at = expiration_date data.slice('expires_at', 'expires_in')
63+
@id_token = data['id_token']
6064
end
6165

6266
# @return [Boolean] whether the access token has expired.
@@ -80,4 +84,4 @@ def expiration_date(options = {})
8084
end
8185
end
8286
end
83-
end
87+
end

lib/yt/models/channel.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Channel < Resource
1212
# @return [String] the channel’s title.
1313
delegate :title, to: :snippet
1414

15+
# @!attribute [r] custom_url
16+
# @return [String] the channel’s handle or custom identifier.
17+
delegate :custom_url, to: :snippet
18+
1519
# @!attribute [r] description
1620
# @return [String] the channel’s description.
1721
delegate :description, to: :snippet

lib/yt/models/snippet.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def initialize(options = {})
1919
end
2020

2121
has_attribute :title, default: ''
22+
has_attribute :custom_url, default: ''
2223
has_attribute :description, default: ''
2324
has_attribute :published_at, type: Time
2425
has_attribute :channel_id

lib/yt/models/user_info.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def initialize(options = {})
2222
has_attribute :gender, default: ''
2323
has_attribute :locale, default: ''
2424
has_attribute :hd, default: ''
25+
has_attribute :email_verified, default: false, camelize: false
2526
end
2627
end
2728
end

0 commit comments

Comments
 (0)