Module: Camper::Client::CommentsAPI
- Included in:
- Camper::Client
- Defined in:
- lib/camper/api/comments.rb
Overview
Defines methods related to comments.
Instance Method Summary collapse
-
#comment(resource, comment_id) ⇒ Resource
Get a comment within a resource.
-
#comments(resource) ⇒ PaginatedResponse<Resource>
Get a paginated list of active comments for a given resource.
-
#create_comment(resource, content) ⇒ Resource
Create a new comment for a given resource.
-
#trash_comment(comment) ⇒ Object
Trash a comment it calls the trash_recording endpoint under the hood.
-
#update_comment(comment, content) ⇒ Resource
Update the content in a comment.
Instance Method Details
#comment(resource, comment_id) ⇒ Resource
Get a comment within a resource
35 36 37 38 39 40 41 |
# File 'lib/camper/api/comments.rb', line 35 def comment(resource, comment_id) raise Error::ResourceCannotBeCommented, resource unless resource.can_be_commented? bucket_id = resource.bucket.id get("/buckets/#{bucket_id}/comments/#{comment_id}") end |
#comments(resource) ⇒ PaginatedResponse<Resource>
Get a paginated list of active comments for a given resource
17 18 19 20 21 |
# File 'lib/camper/api/comments.rb', line 17 def comments(resource) raise Error::ResourceCannotBeCommented, resource unless resource.can_be_commented? get(resource.comments_url, override_path: true) end |
#create_comment(resource, content) ⇒ Resource
Create a new comment for a given resource
53 54 55 56 57 |
# File 'lib/camper/api/comments.rb', line 53 def create_comment(resource, content) raise Error::ResourceCannotBeCommented, resource unless resource.can_be_commented? post(resource.comments_url, override_path: true, body: { content: content }) end |
#trash_comment(comment) ⇒ Object
Trash a comment
it calls the trash_recording endpoint under the hood
82 83 84 |
# File 'lib/camper/api/comments.rb', line 82 def trash_comment(comment) trash_recording(comment) end |
#update_comment(comment, content) ⇒ Resource
Update the content in a comment
68 69 70 71 72 |
# File 'lib/camper/api/comments.rb', line 68 def update_comment(comment, content) bucket_id = comment.bucket.id put("/buckets/#{bucket_id}/comments/#{comment.id}", body: { content: content }) end |