Module: Flattr::Client::Users
- Included in:
- Flattr::Client
- Defined in:
- lib/flattr/client/users.rb
Instance Method Summary collapse
-
#user(username = nil) ⇒ Object
Public: Get a user or the one currently authenticated.
-
#user_flattrs(username = nil, args = {}) ⇒ Object
Public: Get a users flattrs.
-
#user_things(username = nil, args = {}) ⇒ Object
Public: Get a users things.
Instance Method Details
#user(username = nil) ⇒ Object
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 Flattr::Error::NotFound if user not found
19 20 21 22 23 24 25 26 |
# File 'lib/flattr/client/users.rb', line 19 def user(username=nil) if username.nil? user = get("/rest/v2/user") else user = get("/rest/v2/users/#{username}") end Flattr::User.new(user) end |
#user_flattrs(username = nil, args = {}) ⇒ Object
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 Flattr::Error::NotFound if user not found
59 60 61 62 63 64 |
# File 'lib/flattr/client/users.rb', line 59 def user_flattrs(username=nil, args={}) user = username || self.current_user.username get("/rest/v2/users/#{user}/flattrs").map do |flattr| flattr end end |
#user_things(username = nil, args = {}) ⇒ Object
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 Flattr::Error::NotFound if user not found
40 41 42 43 44 45 |
# File 'lib/flattr/client/users.rb', line 40 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 |