Commit cdc871a01cea9522647f72b1c6cec684e64f06fa

Authored by Leandro Santos
Committed by Rodrigo Souto
1 parent b8f96691

addding the possibility to add new comments by api

lib/api/v1/articles.rb
@@ -14,7 +14,7 @@ module API @@ -14,7 +14,7 @@ module API
14 # limit - amount of comments returned. The default value is 20 14 # limit - amount of comments returned. The default value is 20
15 # 15 #
16 # Example Request: 16 # Example Request:
17 - # GET /articles?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10&type=Blog 17 + # GET /articles?from=2013-04-04-14:41:43&until=2014-04-04-14:41:43&limit=10&content_type=Hub
18 # desc 'Articles.', { 18 # desc 'Articles.', {
19 # :params => API::Entities::Article.documentation 19 # :params => API::Entities::Article.documentation
20 # } 20 # }
lib/api/v1/comments.rb
@@ -25,6 +25,11 @@ module API @@ -25,6 +25,11 @@ module API
25 present environment.articles.find(params[:id]).comments.find(params[:comment_id]), :with => Entities::Comment 25 present environment.articles.find(params[:id]).comments.find(params[:comment_id]), :with => Entities::Comment
26 end 26 end
27 27
  28 + # Example Request:
  29 + # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment
  30 + post ":id/comments" do
  31 + present environment.articles.find(params[:id]).comments.create(:author => current_user, :body => params[:body]), :with => Entities::Comment
  32 + end
28 end 33 end
29 34
30 end 35 end