Module: Catch::Comment
- Included in:
- Client
- Defined in:
- lib/catch/comment.rb
Instance Method Summary collapse
-
#add_comment(note_id, params = {}) ⇒ Object
Adds a new comment to a note.
-
#comment(note_id, comment_id) ⇒ Object
Retrieves a single comment from the server.
-
#comments(note_id) ⇒ Object
Retrieve a list of all comments for a note.
-
#delete_comment(note_id, comment_id) ⇒ Object
Remove a single comment from a note.
-
#modify_comment(note_id, comment_id, params = {}) ⇒ Object
Edits an existing comment.
Instance Method Details
#add_comment(note_id, params = {}) ⇒ Object
Adds a new comment to a note.
33 34 35 36 37 |
# File 'lib/catch/comment.rb', line 33 def add_comment(note_id, params={}) payload = params.map {|k,v| "#{k}=#{v}"}.join("&") response = connection.post "comments/#{note_id}", payload response.body.notes.first end |
#comment(note_id, comment_id) ⇒ Object
Retrieves a single comment from the server.
17 18 19 20 21 22 23 |
# File 'lib/catch/comment.rb', line 17 def comment(note_id, comment_id) params = {:comment => comment_id} connection.get do |req| req.url("comment/#{note_id}") req.params.merge!(params) end.body.notes.first end |
#comments(note_id) ⇒ Object
Retrieve a list of all comments for a note.
7 8 9 10 11 |
# File 'lib/catch/comment.rb', line 7 def comments(note_id) connection.get do |req| req.url("comments/#{note_id}") end.body.notes end |
#delete_comment(note_id, comment_id) ⇒ Object
Remove a single comment from a note.
62 63 64 |
# File 'lib/catch/comment.rb', line 62 def delete_comment(note_id, comment_id) connection.delete("comments/#{note_id}?comment=#{comment_id}").body.status == 'ok' end |
#modify_comment(note_id, comment_id, params = {}) ⇒ Object
Edits an existing comment.
48 49 50 51 52 53 54 55 56 |
# File 'lib/catch/comment.rb', line 48 def modify_comment(note_id, comment_id, params={}) payload = {:comment => comment_id } payload.merge! params response = connection.post do |req| req.url("comments/#{note_id}") req.params.merge!(payload) end.body.notes.first end |