module Totter class Client # Client methods for working with users module Users # Get the current user # # Requires authenticatied client. # # @return [Hashie::Mash] # @see Totter::Client # @example # client.me def me get('me').body end # Get a single user # # @param user [String] A Seeaw username or ID. # @return [Hashie::Mash] # @example # Totter.user('soffes') def user(user) get("users/#{user}").body end # Updates the authenticating user # # @param options [Hash] Properties to be updated # @option options [String] :given_name The given name of the user # @option options [String] :family_name The Family name of the user # @option options [String] :email The email address of the user # @option options [String] :username The username of the user # @param preferences [Hash] Preferences to be set # @option preferences [Boolean] :notification_friends Notify when friends post a decision # @option preferences [Boolean] :notification_invitee_votes Notify when invitee votes # @option preferences [Boolean] :notification_comments Notify when someone comments on user's decision # @option preferences [Boolean] :notification_following_votes Notify when user is following other_user who votes # @option preferences [Boolean] :notification_other_votes Notify using throttled notifier when non-invited users vote on your post # @option preferences [Boolean] :notification_after_votes Notify when other_user votes after user has already voted on a decision # @option preferences [Boolean] :notification_following Notify when other_user starts follwing user def update_me(options = {}, preferences = {}) data = { :user => options.merge({:preferences => preferences}) } put("me", data).body end # Follow a user. # # Requires authenticatied client. # # @param user [String] Username or ID of the user to follow. # @return [Boolean] True if follow was successful, false otherwise. # @see Totter::Client # @example # client.follow('gotwalt') def follow(user) boolean_from_response(:post, "users/#{user}/follow") end # Unfollow a user. # # Requires authenticatied client. # # @param user [String] Username or ID of the user to unfollow. # @return [Boolean] True if unfollow was successful, false otherwise. # @see Totter::Client # @example # client.unfollow('kyle') def unfollow(user) boolean_from_response(:post, "users/#{user}/unfollow") end # @return Array of [Hashie::Mash] # @param user_id [String] ID of the user # @example # client.followers('5') def followers(user_id) get("users/#{user_id}/followers").body end # @return Array of [Hashie::Mash] # @param user_id [String] ID of the user # @example # client.following('5') def following(user_id) get("users/#{user_id}/following").body end # @return Array of [Hashie::Mash] # @param user_id [String] ID of the user # @example # client.user_votes('5') def votes(user_id) get("users/#{user_id}/votes").body end # Find friends on social networks # # @return Array of [Hashie::Mash] # @param user_id [String] ID of the user # @example # client.following('5') def social_find_friends(user_id) post("users/#{user_id}/social_find_friends").body end end end end