Permalink
Browse files

Add 'Google::Reader::Tag.rename' method

The unnoficial docs from pyrfeed don't mention it but by monitoring the
Google Reader webapp requests I was able to discover the existence of an
'rename-tag' API endpoing, used to (suprise!) rename tags/labels. I've
added a method to the Tag class that wraps it.
  • Loading branch information...
1 parent 2ff6581 commit 023d1b8ccfc54a050071dc171485c9e6e441096a Gustavo Machado Campagnani Gama committed Dec 23, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/google-reader/tag.rb
View
@@ -36,6 +36,20 @@ def unshare
share(false)
end
+ def rename(new_label)
+ label or raise "trying to rename 'unlabeled' tag: \"#{id}\""
+ new_id = new_label.match(/\/label\//) ? new_label : self.class.build_id(new_label, client.user)
+ params = {
+ 's' => id, # current tag id
+ 't' => label, # the current tag label
+ 'dest' => new_id, # the new tag id
+ 'T' => client.token # the write-access token
+ }
+ resp = client.access_token.post('/reader/api/0/rename-tag', params)
+ resp.code_type == Net::HTTPOK or raise "unable to rename tag \"#{id}\": #{resp.inspect}"
+ id = new_id
+ end
+
def disable
params = {
's' => id, # the tag id

0 comments on commit 023d1b8

Please sign in to comment.