Module: Totter::Client::Users

Included in:
Totter::Client
Defined in:
lib/totter/client/users.rb

Overview

Client methods for working with users

Instance Method Summary collapse

Instance Method Details

#follow(user) ⇒ Boolean

Follow a user.

Requires authenticatied client.

Examples:

client.follow('gotwalt')

Parameters:

  • user (String)

    Username or ID of the user to follow.

Returns:

  • (Boolean)

    True if follow was successful, false otherwise.

See Also:



58
59
60
# File 'lib/totter/client/users.rb', line 58

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

#followers(user_id) ⇒ Object

Returns Array of [Hashie::Mash].

Examples:

client.followers('5')

Parameters:

  • user_id (String)

    ID of the user

Returns:

  • Array of [Hashie::Mash]



79
80
81
# File 'lib/totter/client/users.rb', line 79

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

#following(user_id) ⇒ Object

Returns Array of [Hashie::Mash].

Examples:

client.following('5')

Parameters:

  • user_id (String)

    ID of the user

Returns:

  • Array of [Hashie::Mash]



87
88
89
# File 'lib/totter/client/users.rb', line 87

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

#meHashie::Mash

Get the current user

Requires authenticatied client.

Examples:

client.me

Returns:

  • (Hashie::Mash)

See Also:



13
14
15
# File 'lib/totter/client/users.rb', line 13

def me
  get('me').body
end

#unfollow(user) ⇒ Boolean

Unfollow a user.

Requires authenticatied client.

Examples:

client.unfollow('kyle')

Parameters:

  • user (String)

    Username or ID of the user to unfollow.

Returns:

  • (Boolean)

    True if unfollow was successful, false otherwise.

See Also:



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

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

#update_me(options = {}, preferences = {}) ⇒ Object

Updates the authenticating user

Parameters:

  • options (Hash) (defaults to: {})

    Properties to be updated

  • preferences (Hash) (defaults to: {})

    Preferences to be set

Options Hash (options):

  • :given_name (String)

    The given name of the user

  • :family_name (String)

    The Family name of the user

  • :email (String)

    The email address of the user

  • :username (String)

    The username of the user

Options Hash (preferences):

  • :notification_friends (Boolean)

    Notify when friends post a decision

  • :notification_invitee_votes (Boolean)

    Notify when invitee votes

  • :notification_comments (Boolean)

    Notify when someone comments on user’s decision

  • :notification_following_votes (Boolean)

    Notify when user is following other_user who votes

  • :notification_other_votes (Boolean)

    Notify using throttled notifier when non-invited users vote on your post

  • :notification_after_votes (Boolean)

    Notify when other_user votes after user has already voted on a decision

  • :notification_following (Boolean)

    Notify when other_user starts follwing user



42
43
44
45
46
47
# File 'lib/totter/client/users.rb', line 42

def update_me(options = {}, preferences = {})
  data = {
    :user => options.merge({:preferences => preferences})
  }
  put("me", data).body
end

#user(user) ⇒ Hashie::Mash

Get a single user

Examples:

Totter.user('soffes')

Parameters:

  • user (String)

    A Seeaw username or ID.

Returns:

  • (Hashie::Mash)


23
24
25
# File 'lib/totter/client/users.rb', line 23

def user(user)
  get("users/#{user}").body
end

#votes(user_id) ⇒ Object

Returns Array of [Hashie::Mash].

Examples:

client.user_votes('5')

Parameters:

  • user_id (String)

    ID of the user

Returns:

  • Array of [Hashie::Mash]



95
96
97
# File 'lib/totter/client/users.rb', line 95

def votes(user_id)
  get("users/#{user_id}/votes").body
end