Class: Picasa::API::Comment
Instance Attribute Summary
Attributes inherited from Base
#access_token, #authorization_header, #user_id
Instance Method Summary collapse
-
#create(params = {}) ⇒ Presenter::Tag
Creates a comment for a photo.
-
#destroy(comment_id, params = {}) ⇒ true
(also: #delete)
Removes a comment from given photo.
-
#list(options = {}) ⇒ Presenter::CommentList
Returns comment list - when album_id is not specified, list of user comments will be returned.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Picasa::API::Base
Instance Method Details
#create(params = {}) ⇒ Presenter::Tag
Creates a comment for a photo.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/picasa/api/comment.rb', line 35 def create(params = {}) album_id = params.delete(:album_id) || raise(ArgumentError, "You must specify album_id") photo_id = params.delete(:photo_id) || raise(ArgumentError, "You must specify photo_id") params[:content] || raise(ArgumentError, "You must specify content") path = "/data/feed/api/user/#{user_id}/albumid/#{album_id}/photoid/#{photo_id}" template = Template.new("new_comment", params) response = Connection.new.post(path: path, body: template.render, headers: auth_header) Presenter::Comment.new(response.parsed_response["entry"]) end |
#destroy(comment_id, params = {}) ⇒ true Also known as: delete
Removes a comment from given photo.
57 58 59 60 61 62 63 64 |
# File 'lib/picasa/api/comment.rb', line 57 def destroy(comment_id, params = {}) album_id = params.delete(:album_id) || raise(ArgumentError, "You must specify album_id") photo_id = params.delete(:photo_id) || raise(ArgumentError, "You must specify photo_id") path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}/photoid/#{photo_id}/commentid/#{comment_id}" Connection.new.delete(path: path, headers: auth_header) true end |
#list(options = {}) ⇒ Presenter::CommentList
Returns comment list - when album_id is not specified, list of user comments will be returned
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/picasa/api/comment.rb', line 13 def list( = {}) album_id = .delete(:album_id) photo_id = .delete(:photo_id) raise(ArgumentError, "You must specify album_id when providing photo_id") if photo_id && !album_id path = "/data/feed/api/user/#{user_id}" path << "/albumid/#{album_id}" if album_id path << "/photoid/#{photo_id}" if photo_id response = Connection.new.get(path: path, query: .merge(kind: "comment"), headers: auth_header) Presenter::CommentList.new(response.parsed_response["feed"]) end |