Class: Quandora::Comment
- Inherits:
-
Object
- Object
- Quandora::Comment
- Defined in:
- lib/quandora/comment.rb
Instance Method Summary collapse
- #create(args) ⇒ Object
- #delete(hash) ⇒ Object
-
#initialize(conn, api, id) ⇒ Comment
constructor
A new instance of Comment.
- #update(args) ⇒ Object
Constructor Details
#initialize(conn, api, id) ⇒ Comment
Returns a new instance of Comment.
2 3 4 5 6 |
# File 'lib/quandora/comment.rb', line 2 def initialize(conn, api, id) @conn = conn @api = api @id = id end |
Instance Method Details
#create(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/quandora/comment.rb', line 8 def create(args) args = args.stringify_keys body = { "type": "post-comment", "data": { "content": args["comment"] } } resp = @conn.post("#{@api}/#{@id}/comment") do |req| req.body = body.to_s req.headers['Content-Type'] = 'application/json' end end |
#delete(hash) ⇒ Object
41 42 43 |
# File 'lib/quandora/comment.rb', line 41 def delete(hash) resp = @conn.delete("#{@api}/#{@id}/comment/#{hash}") end |
#update(args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/quandora/comment.rb', line 24 def update(args) args = args.stringify_keys body = { "type": "post-comment", "data": { "content": args["comment"], "hash": args["hash"] } } resp = @conn.put("#{@api}/#{@id}/comment") do |req| req.body = body.to_s req.headers['Content-Type'] = 'application/json' end end |