Skip to content

Commit

Permalink
Documenting .... @wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Medina committed Feb 18, 2010
1 parent 2ee2145 commit 0989986
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/read_it_later.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,35 @@ def add(user, url)
@last_response = query(:add, user, :url => url)
end

# Send several changes to readitlaterlist.com
# The params hash is built as described in http://readitlaterlist.com/api/docs/#send, but in ruby a Ruby Hash.
# Example:
#
# params = {
# :new => [
# { :url => "http://www.url1.com/", :title => "URL New 1" },
# { :url => "http://www.url2.com/", :title => "URL New 2" },
# { :url => "http://www.url3.com/", :title => "URL New 3" }
# ],
# :read => [
# { :url => "http://www.url1.com/" },
# { :url => "http://www.url2.com/" },
# { :url => "http://www.url3.com/" }
# ],
# :update_title => [
# { :url => "http://www.url1.com/", :title => "Updated URL New 1" },
# { :url => "http://www.url2.com/", :title => "Updated URL New 2" },
# { :url => "http://www.url3.com/", :title => "Updated URL New 3" }
# ],
# :update_tags => [
# { :url => "http://www.url1.com/", :tags => "url1tag1, url1tag2, url1tag3" },
# { :url => "http://www.url2.com/", :tags => "url2tag1, url2tag2, url2tag3" },
# { :url => "http://www.url3.com/", :tags => "url3tag1, url3tag2, url3tag3" }
# ]
# }
#
# @param [ReadItLater::User] user The ReadItLater::User instance representing the user
# @param [Hash] params The changes to be sent as described in http://readitlaterlist.com/api/docs/#send, in Ruby hash format
def send(user, params)
%w(new read update_title update_tags).map(&:to_sym).each do |param|
params[param] = URI.escape((0..params[param].size-1).to_a.map{|n|{n.to_s=>params[param][n]}}.inject(){|a,b|a.merge(b)}.to_json) if params[param]
Expand Down

0 comments on commit 0989986

Please sign in to comment.