Class: DogapiDemo::V1::CommentService
- Inherits:
-
APIService
- Object
- APIService
- DogapiDemo::V1::CommentService
- Defined in:
- lib/dogapi-demo/v1/comment.rb
Constant Summary collapse
- API_VERSION =
"v1"
Instance Method Summary collapse
-
#comment(message, options = {}) ⇒ Object
Submit a comment.
- #delete_comment(comment_id) ⇒ Object
-
#update_comment(comment_id, options = {}) ⇒ Object
Update a comment.
Methods inherited from APIService
#connect, #initialize, #request, #suppress_error_if_silent
Constructor Details
This class inherits a constructor from DogapiDemo::APIService
Instance Method Details
#comment(message, options = {}) ⇒ Object
Submit a comment.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dogapi-demo/v1/comment.rb', line 11 def comment(, = {}) begin params = { :api_key => @api_key, :application_key => @application_key } body = { 'message' => , }.merge request(Net::HTTP::Post, "/api/#{API_VERSION}/comments", params, body, true) rescue Exception => e suppress_error_if_silent e end end |
#delete_comment(comment_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dogapi-demo/v1/comment.rb', line 46 def delete_comment(comment_id) begin params = { :api_key => @api_key, :application_key => @application_key } request(Net::HTTP::Delete, "/api/#{API_VERSION}/comments/#{comment_id}", params, nil, false) rescue Exception => e suppress_error_if_silent e end end |
#update_comment(comment_id, options = {}) ⇒ Object
Update a comment.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dogapi-demo/v1/comment.rb', line 29 def update_comment(comment_id, = {}) begin params = { :api_key => @api_key, :application_key => @application_key } if .empty? raise "Must update something." end request(Net::HTTP::Put, "/api/#{API_VERSION}/comments/#{comment_id}", params, , true) rescue Exception => e suppress_error_if_silent e end end |