Class: Polar::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key, secret_key, session_key) ⇒ Client

Returns a new instance of Client.



4
5
6
# File 'lib/polar/client.rb', line 4

def initialize(api_key, secret_key, session_key)
  @api_key, @secret_key, @session_key = api_key, secret_key, session_key
end

Instance Method Details

#get_friendsObject



8
9
10
11
12
13
14
15
# File 'lib/polar/client.rb', line 8

def get_friends
  params = {
    :method => "friends.getFriends",
    :v => "1.0"
  }

  Polar::Cursor.new(@api_key, @secret_key, @session_key, Polar::User, params)
end

#get_info(uids, fields) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/polar/client.rb', line 17

def get_info(uids, fields)
  params = {
    :method => "users.getInfo",
    :v => "1.0",
    :fields => fields * ",",
    :uids => uids * ","
  }
  
   = request(params)
  if .count == 1 
    return Polar::User.new(.first)
  else
    friend_list = []
    .each { |current_user| friend_list << Polar::User.new(current_user) }
    return friend_list
  end
end

#set_status(status) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/polar/client.rb', line 35

def set_status(status)
  params = {
    :method => "status.set",
    :v => "1.0",
    :status => status
  }
  Polar::Response.new request(params) 
end