Class: YouTube::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/you_tube/client.rb

Constant Summary collapse

BASE_URL =
"https://www.googleapis.com/youtube/v3/"

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject (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

#adapterObject (readonly)

Returns the value of attribute adapter.



5
6
7
# File 'lib/you_tube/client.rb', line 5

def adapter
  @adapter
end

#api_keyObject (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

#channelsObject



13
14
15
# File 'lib/you_tube/client.rb', line 13

def channels
  ChannelsResource.new(self)
end

#connectionObject



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_itemsObject



25
26
27
# File 'lib/you_tube/client.rb', line 25

def playlist_items
  PlaylistItemsResource.new(self)
end

#playlistsObject



21
22
23
# File 'lib/you_tube/client.rb', line 21

def playlists
  PlaylistsResource.new(self)
end

#searchObject



29
30
31
# File 'lib/you_tube/client.rb', line 29

def search
  SearchResource.new(self)
end

#videosObject



17
18
19
# File 'lib/you_tube/client.rb', line 17

def videos
  VideosResource.new(self)
end