Module: Shikimori::API::V1::Comments
- Included in:
- Shikimori::API::V1
- Defined in:
- lib/shikimori/api/v1/comments.rb
Overview
Methods for the Comments API
Instance Method Summary collapse
-
#comment(id, headers: nil, **query) ⇒ Hash
Get a comment by id.
-
#comments(headers: nil, **query) ⇒ Array<Hash>
Get list of comments.
-
#create_comment(comment, broadcast: nil, frontend: nil, headers: nil, **query) ⇒ Hash
Create a comment Requires ‘comments` oauth scope.
-
#delete_comment(id, headers: nil, **query) ⇒ Boolean
Delete Comment.
-
#update_comment(id, comment, headers: nil, **query) ⇒ Hash
Update Comment.
Instance Method Details
#comment(id, headers: nil, **query) ⇒ Hash
Get a comment by id
55 56 57 |
# File 'lib/shikimori/api/v1/comments.rb', line 55 def comment(id, headers: nil, **query) rest.get base_url.join('comments', id.to_s).url, headers: headers, query: query end |
#comments(headers: nil, **query) ⇒ Array<Hash>
Get list of comments
33 34 35 |
# File 'lib/shikimori/api/v1/comments.rb', line 33 def comments(headers: nil, **query) rest.get base_url.join('comments').url, headers: headers, query: query end |
#create_comment(comment, broadcast: nil, frontend: nil, headers: nil, **query) ⇒ Hash
Create a comment Requires ‘comments` oauth scope
89 90 91 92 93 94 95 |
# File 'lib/shikimori/api/v1/comments.rb', line 89 def create_comment(comment, broadcast: nil, frontend: nil, headers: nil, **query) rest.post( base_url.join('comments').url, { broadcast: broadcast, comment: comment, frontend: frontend }.compact, headers: headers, query: query ) end |
#delete_comment(id, headers: nil, **query) ⇒ Boolean
Delete Comment. Requires ‘comments` oauth scope
155 156 157 |
# File 'lib/shikimori/api/v1/comments.rb', line 155 def delete_comment(id, headers: nil, **query) rest.delete base_url.join('comments', id.to_s).url, headers: headers, query: query end |
#update_comment(id, comment, headers: nil, **query) ⇒ Hash
Update Comment. Requires ‘comments` oauth scope. Use Shikimori::API::V2::AbuseRequests#abuse_offtopic_request to change is_offtopic field.
128 129 130 131 132 133 134 |
# File 'lib/shikimori/api/v1/comments.rb', line 128 def update_comment(id, comment, headers: nil, **query) rest.put( base_url.join('comments', id.to_s).url, { broadcast: query.delete(:broadcast), comment: comment, frontend: query.delete(:frontend) }.compact, headers: headers, query: query ) end |