class PocketClient
Public Class Methods
new(consumer_key, consumer_token)
click to toggle source
# File lib/pocket_client.rb, line 4 def initialize(consumer_key, consumer_token) Pocket.configure do |config| config.consumer_key = consumer_key end @consumer_token = consumer_token end
Public Instance Methods
retrieve_untagged()
click to toggle source
# File lib/pocket_client.rb, line 11 def retrieve_untagged info = client.retrieve(detailType: "simple", tag: "_untagged_") info["list"].map { |(item_id, value)| build_item(value) } end
tag_as_bolso_furado(old_items)
click to toggle source
# File lib/pocket_client.rb, line 16 def tag_as_bolso_furado(old_items) old_items .map(&method(:build_item_to_modify)) .tap(&method(:modify_items!)) end
Private Instance Methods
build_item(hash)
click to toggle source
# File lib/pocket_client.rb, line 28 def build_item(hash) timestamp = hash["time_added"].to_i OpenStruct.new(title: hash["given_title"], added_at: Time.at(timestamp).to_date, item_id: hash["item_id"]) end
build_item_to_modify(item)
click to toggle source
# File lib/pocket_client.rb, line 35 def build_item_to_modify(item) { "action" => "tags_add", "item_id" => item.item_id, "tags" => "bolso-furado", "time" => Time.now.to_i } end
client()
click to toggle source
# File lib/pocket_client.rb, line 24 def client @client ||= Pocket.client(access_token: @consumer_token) end
modify_items!(items_to_tag)
click to toggle source
# File lib/pocket_client.rb, line 42 def modify_items!(items_to_tag) client.modify(items_to_tag) if items_to_tag.size > 0 end