Class: Viki::Client

Inherits:
Object
  • Object
show all
Includes:
Transport
Defined in:
lib/viki/client.rb

Constant Summary collapse

HOST =
"http://www.viki.com"

Constants included from Utilities

Utilities::URL_NAMESPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, host = nil) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
# File 'lib/viki/client.rb', line 12

def initialize(client_id, client_secret, host = nil)
  @host = host || HOST
  @client_id = client_id
  @client_secret = client_secret
  @access_token = auth_request(client_id, client_secret, @host)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)

Raises:

  • (NoMethodError)


22
23
24
25
26
27
28
# File 'lib/viki/client.rb', line 22

def method_missing(name, *args)
   raise NoMethodError if not URL_NAMESPACES.include? name
   Viki::Request.new({client_id: @client_id,
                      client_secret: @client_secret,
                      access_token: @access_token,
                      host: @host}, name, *args)
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



19
20
21
# File 'lib/viki/client.rb', line 19

def access_token
  @access_token
end