Class: YouTube::Client
- Inherits:
-
Object
- Object
- YouTube::Client
- Defined in:
- lib/you_tube/client.rb
Constant Summary collapse
- BASE_URL =
"https://www.googleapis.com/youtube/v3/"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #channels ⇒ Object
- #connection ⇒ Object
-
#initialize(api_key:, access_token: nil, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #playlist_items ⇒ Object
- #playlists ⇒ Object
- #search ⇒ Object
- #videos ⇒ Object
Constructor Details
#initialize(api_key:, access_token: nil, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/you_tube/client.rb', line 7 def initialize(api_key:, access_token: nil, adapter: Faraday.default_adapter) @api_key = api_key @access_token = access_token @adapter = adapter end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/you_tube/client.rb', line 5 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/you_tube/client.rb', line 5 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/you_tube/client.rb', line 5 def api_key @api_key end |
Instance Method Details
#channels ⇒ Object
13 14 15 |
# File 'lib/you_tube/client.rb', line 13 def channels ChannelsResource.new(self) end |
#connection ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/you_tube/client.rb', line 33 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :authorization, :Bearer, access_token conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#playlist_items ⇒ Object
25 26 27 |
# File 'lib/you_tube/client.rb', line 25 def playlist_items PlaylistItemsResource.new(self) end |
#playlists ⇒ Object
21 22 23 |
# File 'lib/you_tube/client.rb', line 21 def playlists PlaylistsResource.new(self) end |
#search ⇒ Object
29 30 31 |
# File 'lib/you_tube/client.rb', line 29 def search SearchResource.new(self) end |
#videos ⇒ Object
17 18 19 |
# File 'lib/you_tube/client.rb', line 17 def videos VideosResource.new(self) end |