Class: Social::Network::Graph::Vk::User
- Inherits:
-
Base
- Object
- Base
- Social::Network::Graph::Vk::User
show all
- Defined in:
- lib/social/network/graph/vk/user.rb
Constant Summary
collapse
- FIELDS =
'uid,first_name,last_name,nickname,domain,sex,birthdate,city,country,timezone,photo,photo_medium,photo_big,has_mobile,rate,contacts,education'
Instance Method Summary
collapse
Methods inherited from Base
#config, #http_query, #process, #process_secure
Methods included from Tail
#root=
Instance Method Details
#balance(uid) {|result| ... } ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/social/network/graph/vk/user.rb', line 49
def balance(uid)
throw 'Not give uid for balance request' unless uid
params = { "method" => 'secure.getBalance', :uid => uid }
result = send(:process_secure, params)
result = ((result / 100).to_f.round(2) * root.rate)
return result unless block_given?
yield(result) if block_given?
end
|
#charge_off_balance(uid, balance) {|result| ... } ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/social/network/graph/vk/user.rb', line 40
def charge_off_balance(uid, balance)
amount = (((balance).floor / root.rate.to_f).round(2) * 100).round
params = { "method" => 'secure.withdrawVotes', :uid => uid, :votes => amount }
result = send(:process_secure, params)
return result unless block_given?
yield(result) if block_given?
end
|
#get_friends(uid) {|result| ... } ⇒ Object
Also known as:
get_friends_uids
21
22
23
24
25
26
27
28
29
|
# File 'lib/social/network/graph/vk/user.rb', line 21
def get_friends(uid)
throw 'Not give uid for friends request' unless uid
params = { "method" => 'friends.get', :uid => uid, "fields" => FIELDS}
result = send(:process_secure, params)
return result unless block_given?
yield(result) if block_given?
end
|
#get_friends_profiles(uid) {|friend_profiles| ... } ⇒ Object
Also known as:
get_friends_info
31
32
33
34
35
36
37
38
|
# File 'lib/social/network/graph/vk/user.rb', line 31
def get_friends_profiles(uid)
friend_uids = get_friends_uids(uid)
friend_profiles = friend_uids.map { |uid| get_info(uid) }.flatten.compact
return friend_profiles unless block_given?
yield(friend_profiles) if block_given?
end
|
#get_info(*args) {|results| ... } ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/social/network/graph/vk/user.rb', line 6
def get_info(*args)
uids = Array.wrap(args)
params = { "method" => 'getProfiles', "fields" => FIELDS, :uids => uids.join(",")}
results = send(:process, params)
results.each_with_index { |result, i|
results[i]['birthday'] = result['bdate'] || result['birthday']
}
return results unless block_given?
yield(results) if block_given?
end
|