Class: Viki::Client

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

Constant Summary

Constants included from Utilities

Utilities::URL_NAMESPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret) ⇒ Client

Returns a new instance of Client.



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

def initialize(client_id, client_secret)
  @client_id = client_id
  @client_secret = client_secret
  @access_token = auth_request(client_id, client_secret)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Raises:

  • (NoMethodError)


20
21
22
23
24
25
# File 'lib/viki/client.rb', line 20

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}, name, *args)
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



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

def access_token
  @access_token
end