Class: WeiboApi::User

Inherits:
Object
  • Object
show all
Includes:
Endpoint
Defined in:
lib/weibo_api/user.rb

Constant Summary

Constants included from Endpoint

Endpoint::BASE_API_URI

Instance Method Summary collapse

Constructor Details

#initialize(access_token, uid) ⇒ User

Returns a new instance of User.



5
6
7
8
# File 'lib/weibo_api/user.rb', line 5

def initialize(access_token, uid)
  @access_token = access_token
  @uid = uid
end

Instance Method Details

#custom_request(path, options = {}) ⇒ Object



35
36
37
38
# File 'lib/weibo_api/user.rb', line 35

def custom_request(path, options = {})
  params = options.merge(access_token: @access_token) { |_, important, _| important }
  make_request resource_path(path, params), {}
end

#info(options = {}) ⇒ Object

Return the authenticating user’s personnal infos or the one specified on the options (uid).



11
12
13
14
# File 'lib/weibo_api/user.rb', line 11

def info(options = {})
  params = options.merge(access_token: @access_token, uid: @uid) { |_, important, _| important }
  make_request resource_path('users/show', params), {}
end

#show_status(id) ⇒ Object

Return the single weibo’s content by its ID



30
31
32
33
# File 'lib/weibo_api/user.rb', line 30

def show_status(id)
  params = { access_token: @access_token, id: id }
  make_request resource_path('statuses/show', params), {}
end

#statistics(options = {}) ⇒ Object

Return the authenticating user’s followers statistics.

WIP


18
19
20
21
# File 'lib/weibo_api/user.rb', line 18

def statistics(options = {})
  params = options.merge(access_token: @access_token, uid: @uid) { |_, important, _| important }
  make_request resource_path('friendships/followers', params), {}
end

#timeline(options = {}) ⇒ Object

Return the authenticating user’s latest weibos.



24
25
26
27
# File 'lib/weibo_api/user.rb', line 24

def timeline(options = {})
  params = options.merge(access_token: @access_token, trim_user: 1) { |_, important, _| important }
  make_request resource_path('statuses/user_timeline', params), {}
end