Class: RaindropIo::Raindrop
Overview
Raindrop class (a bookmark)
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .default_page_size ⇒ Object
-
.raindrop(raindrop_id) ⇒ Object
Get raindrop.
-
.raindrops(collection_id, options = {}) ⇒ Array<RaindropIo::Raindrop>
Get multiple raindrops in a collection.
-
.remove(raindrop_id) ⇒ Object
Remove raindrop DELETE https://api.raindrop.io/rest/v1/raindrop/id.
-
.suggest(raindrop_id) ⇒ Object
Suggest collection and tags for existing bookmark GET https://api.raindrop.io/rest/v1/raindrop/id/suggest.
-
.update(raindrop_id, attributes) ⇒ Object
Update raindrop PUT https://api.raindrop.io/rest/v1/raindrop/id.
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
.default_page_size ⇒ Object
7 8 9 |
# File 'lib/raindrop_io/raindrop.rb', line 7 def default_page_size 25 end |
.raindrop(raindrop_id) ⇒ Object
Get raindrop
33 34 35 36 37 38 39 40 |
# File 'lib/raindrop_io/raindrop.rb', line 33 def raindrop(raindrop_id) response = get("/raindrop/#{raindrop_id}") if response.status.success? && response.parse["item"] Raindrop.new response.parse["item"] else RaindropIo::ApiError.new response end end |
.raindrops(collection_id, options = {}) ⇒ Array<RaindropIo::Raindrop>
Get multiple raindrops in a collection
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/raindrop_io/raindrop.rb', line 20 def raindrops(collection_id, = {}) response = get("/raindrops/#{collection_id}", ) if response.status.success? && response.parse["items"] drops = response.parse["items"].map { |attributes| Raindrop.new(attributes) } total = response.parse["count"] {total: total, items: drops} else RaindropIo::ApiError.new response end end |
.remove(raindrop_id) ⇒ Object
Remove raindrop DELETE https://api.raindrop.io/rest/v1/raindrop/id
61 62 63 64 65 66 67 68 |
# File 'lib/raindrop_io/raindrop.rb', line 61 def remove(raindrop_id) response = delete("/raindrop/#{raindrop_id}") if response.status.success? true else RaindropIo::ApiError.new response end end |
.suggest(raindrop_id) ⇒ Object
Suggest collection and tags for existing bookmark GET https://api.raindrop.io/rest/v1/raindrop/id/suggest
80 81 82 83 84 85 86 87 |
# File 'lib/raindrop_io/raindrop.rb', line 80 def suggest(raindrop_id) response = get("/raindrop/#{raindrop_id}/suggest") if response.status.success? && response.parse["item"] response.parse["item"] else RaindropIo::ApiError.new response end end |
.update(raindrop_id, attributes) ⇒ Object
Update raindrop PUT https://api.raindrop.io/rest/v1/raindrop/id
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/raindrop_io/raindrop.rb', line 44 def update(raindrop_id, attributes) # strip out any attributes not listed in the docs allowed = %w[created lastUpdate pleaseParse order important tags media cover collection type excerpt title link highlights extra_data] # extra_data is a hash of key-value pairs is a catch all for unkown attributes, # since we don't know about them, we'll not pass them to the API for now. attrs = attributes.except(*allowed)[:data] response = put("/raindrop/#{raindrop_id}", json: attrs) if response.status.success? && response.parse["item"] Raindrop.new response.parse["item"] else RaindropIo::ApiError.new response end end |