Class: Klout::Client

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Includes:
Singleton
Defined in:
lib/klout/client.rb

Overview

Public: Class with the necessary methods for performing all Klout API operations. All API methods are instance methods but can be called on the Client class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject

Public: Gets/Sets the Klout API key.



22
23
24
# File 'lib/klout/client.rb', line 22

def api_key
  @api_key
end

#proxyObject

Public: Gets/Sets an optional Proxy host to use.



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

def proxy
  @proxy
end

Class Method Details

.configure {|instance| ... } ⇒ Object

Public: Configure Klout Client options.

Yields the Klout::Client instance.

Returns nothing.

Yields:

  • (instance)


35
36
37
# File 'lib/klout/client.rb', line 35

def self.configure
  yield instance if block_given?
end

.endpointObject

Public: Klout REST API endpoint

Returns the Klout REST API endpoint



42
43
44
# File 'lib/klout/client.rb', line 42

def self.endpoint
  'http://api.klout.com'
end

Instance Method Details

#influenced_by(usernames) ⇒ Object

Public: Retrieve users influencers for the given usernames.

usernames - The username or Array of usernames to look for.

Returns an Array of klout users with their corresponding influencers.



78
79
80
# File 'lib/klout/client.rb', line 78

def influenced_by(usernames)
  get("/1/soi/influenced_by.json", :users => [usernames].flatten).users
end

#influencer_of(usernames) ⇒ Object

Public: Retrieve users influencees for the given usernames.

usernames - The username or Array of usernames to look for.

Returns an Array of klout users with their corresponding influencees.



87
88
89
# File 'lib/klout/client.rb', line 87

def influencer_of(usernames)
  get("/1/soi/influencer_of.json", :users => [usernames].flatten).users
end

#profile(usernames) ⇒ Object

Public: Retrieve users Klout profile for the given usernames.

usernames - The username or Array of usernames to look for.

Returns an Array of user klout profile objects.



60
61
62
# File 'lib/klout/client.rb', line 60

def profile(usernames)
  get("/1/users/show.json", :users => [usernames].flatten).users
end

#score(usernames) ⇒ Object

Public: Retrieve Klout score for the given usernames.

usernames - The username or Array of usernames to look for.

Returns an Array of user klout score objects.



51
52
53
# File 'lib/klout/client.rb', line 51

def score(usernames)
  get("/1/klout.json", :users => [usernames].flatten).users
end

#topics(usernames) ⇒ Object

Public: Retrieve users topics for the given usernames.

usernames - The username or Array of usernames to look for.

Returns an Array of user klout topics objects.



69
70
71
# File 'lib/klout/client.rb', line 69

def topics(usernames)
  get("/1/users/topics.json", :users => [usernames].flatten).users
end