Sha256: 0ac0648891f3c3a77f0011f60abe2ac0a3be3d1796b2ab945ca65b9bce6f3656

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require 'flattr/user'

module Flattr
  class Client
    module Users

      # Public: Get a user or the one currently authenticated
      #
      # username - username of the user you want to get (optional)
      #
      # Examples
      #
      #   f = Flattr.new
      #   f.user("smgt")
      #   # => #<Flattr::User...
      #
      # Returns a Flattr::User if successful
      # Raises a ERROR on failure
      def user(username=nil)
        user = username || self.current_user.username
        user = get("/rest/v2/users/#{user}")
        Flattr::User.new(user)
      end

      # Public: Get a users things
      #
      # username - username of the user you want to get (optional)
      #
      # Examples
      #
      #   f = Flattr.new
      #   f.user_things("smgt")
      #   # => [#<Flattr::Thing...
      #
      # Returns a Array with Flattr::User's inside if successful
      # Raises a ERROR on failure
      def user_things(username=nil, args={})
        user = username || self.current_user.username
        get("/rest/v2/users/#{user}/things", args).map do |thing|
          Flattr::Thing.new(thing)
        end
      end

      # Public: Get a users flattrs
      #
      # username - username of the user you want to get (optional)
      #
      # Examples
      #
      #   f = Flattr.new
      #   f.user_flattrs("smgt")
      #   # => [{"type" => "flattr"....
      #
      # Returns a Array with flattrs if successful
      # Raises a ERROR on failure
      def user_flattrs(username=nil, args={})
        user = username || self.current_user.username
        get("/rest/v2/users/#{user}/flattrs").map do |flattr|
          flattr
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flattr-0.2.3 lib/flattr/client/users.rb