Module: Lapse::Client::Users

Included in:
Lapse::Client
Defined in:
lib/lapse/client/users.rb

Overview

Client methods for working with users

Instance Method Summary collapse

Instance Method Details

#authenticate(twitter_access_token) ⇒ Hashie::Mash

Authenticates a user

Requires authenticatied client.

Examples:

client.me

Returns:

  • (Hashie::Mash)

See Also:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lapse/client/users.rb', line 13

def authenticate(twitter_access_token)
  result = post('authenticate', twitter_access_token: twitter_access_token)
  hash = {
    :user => result.body,
    :access_token => result.headers['x-access-token']
  }

  case @result_format
  when :mashie
    Hashie::Mash.new(hash)
  else
    hash
  end
end

#badges(since) ⇒ Object



40
41
42
# File 'lib/lapse/client/users.rb', line 40

def badges(since)
  get('me/badges', since: since).body
end

#block(user_id) ⇒ Object



71
72
73
# File 'lib/lapse/client/users.rb', line 71

def block(user_id)
  boolean_from_response(:post, "users/#{user_id}/block")
end

#follow(user_id) ⇒ Object



55
56
57
# File 'lib/lapse/client/users.rb', line 55

def follow(user_id)
  boolean_from_response(:post, "users/#{user_id}/follow")
end

#followers(user_id, params = {}) ⇒ Object



67
68
69
# File 'lib/lapse/client/users.rb', line 67

def followers(user_id, params = {})
  get("users/#{user_id}/followers", params).body
end

#following(user_id, params = {}) ⇒ Object



63
64
65
# File 'lib/lapse/client/users.rb', line 63

def following(user_id, params = {})
  get("users/#{user_id}/following", params).body
end

#meHashie::Mash

Get the current user

Requires authenticatied client.

Examples:

client.me

Returns:

  • (Hashie::Mash)

See Also:

  • Totter::Client


36
37
38
# File 'lib/lapse/client/users.rb', line 36

def me
  get('me').body
end

#unfollow(user_id) ⇒ Object



59
60
61
# File 'lib/lapse/client/users.rb', line 59

def unfollow(user_id)
  boolean_from_response(:post, "users/#{user_id}/unfollow")
end

#update_me(options = {}) ⇒ Object



44
45
46
47
48
49
# File 'lib/lapse/client/users.rb', line 44

def update_me(options = {})
  params = {
    user: options
  }
  patch('me', params).body
end

#user(user_id) ⇒ Object



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

def user(user_id, params = {})
  get("users/#{user_id}", params).body
end