Class: RaindropIo::User

Inherits:
Base
  • Object
show all
Defined in:
lib/raindrop_io/user.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

delete, get, #initialize, #initialize_attributes, post, put, #to_h, #to_hash, #to_json

Constructor Details

This class inherits a constructor from RaindropIo::Base

Class Method Details

.current_userObject



5
6
7
8
9
10
11
12
# File 'lib/raindrop_io/user.rb', line 5

def current_user
  response = get("/user")
  if response.status.success? && response.parse["result"] == true
    User.new response.parse["user"]
  else
    RaindropIo::ApiError.new response
  end
end

.find_by_name(name) ⇒ Object

Get user by name



16
17
18
19
20
21
22
23
# File 'lib/raindrop_io/user.rb', line 16

def find_by_name(name)
  response = get("/user/#{ERB::Util.url_encode(name)}")
  if response.status.success? && response.parse["result"] == true
    User.new response.parse["user"]
  else
    RaindropIo::ApiError.new response
  end
end

Instance Method Details

#collectionsObject

end class << self



26
27
28
# File 'lib/raindrop_io/user.rb', line 26

def collections
  @groups[0]["collections"].map { |id| RaindropIo::Collection.find(id) }
end