Module: Ronnie::Client::Users

Included in:
Ronnie::Client
Defined in:
lib/ronnie/client/users.rb

Instance Method Summary collapse

Instance Method Details

#find_user(email, options = {}) ⇒ Object

Find User by E-mail Address

Examples:

Ronnie.find_user('[email protected]')

Parameters:

  • email (String)


20
21
22
# File 'lib/ronnie/client/users.rb', line 20

def find_user(email, options={})
  post('findUser', { email: email })
end

#follow(user_id, options = {}) ⇒ Object

Follow a User

Requires authorized client.

Examples:

@client.follow('s2913931')

Parameters:

  • user_id (String)


77
78
79
# File 'lib/ronnie/client/users.rb', line 77

def follow(user_id, options={})
  post('addFriend', { user: user_id })
end

#followers(user_id = nil, options = {}) ⇒ Object

Retrieve Followers of a User

Examples:

Ronnie.followers('s2913931')
@client.followers

Parameters:

  • user_id (String) (defaults to: nil)


40
41
42
43
44
# File 'lib/ronnie/client/users.rb', line 40

def followers(user_id=nil, options={})
  user_id = user_id ? user_id : user[:key]

  post('userFollowers', { user: user_id })
end

#following(user_id = nil, options = {}) ⇒ Object

Retrieve Users Following Another User

Examples:

Ronnie.following('s2913931')
@client.following

Parameters:

  • user_id (String) (defaults to: nil)


53
54
55
56
57
# File 'lib/ronnie/client/users.rb', line 53

def following(user_id=nil, options={})
  user_id = user_id ? user_id : user[:key]

  post('userFollowing', { user: user_id })
end

#follows?(user_id, options = {}) ⇒ Boolean

Authorized User is Following a User

Requires authorized client.

Examples:

@client.follows?('s2684102')

Parameters:

  • user_id (String)

Returns:

  • (Boolean)


66
67
68
# File 'lib/ronnie/client/users.rb', line 66

def follows?(user_id, options={})
  !following.select { |f| f[:key] == user_id }.empty? ? true : false
end

#search_users(query, options = {}) ⇒ Object

Search Users

Examples:

Ronnie.search_users('Allen Goodman')

Parameters:

  • query (String)


29
30
31
# File 'lib/ronnie/client/users.rb', line 29

def search_users(query, options={})
  post('search', { query: query, types: 'User' })
end

#unfollow(user_id, options = {}) ⇒ Object

Unfollow a User

Requires authorized client.

Examples:

@client.unfollow('s2913931')

Parameters:

  • user_id (String)


88
89
90
# File 'lib/ronnie/client/users.rb', line 88

def unfollow(user_id, options={})
  post('removeFriend', { user: user_id })
end

#user(user_id = nil, options = {}) ⇒ Object

Retrieve User

Examples:

Ronnie.user('s2913931')
@client.user

Parameters:

  • user_id (String) (defaults to: nil)


11
12
13
# File 'lib/ronnie/client/users.rb', line 11

def user(user_id=nil, options={})
  user_id ? post('get', { keys: user_id }) : post('currentUser')
end