Commit 55d792ba94abcdbf7545ef5e677fa41a820d31ba
Committed by
Rodrigo Souto
1 parent
ecfb99f8
Exists in
master
and in
29 other branches
Removed trailing spaces from api
Showing
5 changed files
with
21 additions
and
21 deletions
Show diff stats
lib/api/api.rb
@@ -9,7 +9,7 @@ module API | @@ -9,7 +9,7 @@ module API | ||
9 | content_type :txt, "text/plain" | 9 | content_type :txt, "text/plain" |
10 | 10 | ||
11 | helpers APIHelpers | 11 | helpers APIHelpers |
12 | - | 12 | + |
13 | mount V1::Articles | 13 | mount V1::Articles |
14 | mount V1::Comments | 14 | mount V1::Comments |
15 | mount V1::Users | 15 | mount V1::Users |
lib/api/helpers.rb
lib/api/v1/articles.rb
@@ -3,7 +3,7 @@ module API | @@ -3,7 +3,7 @@ module API | ||
3 | class Articles < Grape::API | 3 | class Articles < Grape::API |
4 | before { detect_stuff_by_domain } | 4 | before { detect_stuff_by_domain } |
5 | before { authenticate! } | 5 | before { authenticate! } |
6 | - | 6 | + |
7 | resource :articles do | 7 | resource :articles do |
8 | 8 | ||
9 | # Collect comments from articles | 9 | # Collect comments from articles |
@@ -19,18 +19,18 @@ module API | @@ -19,18 +19,18 @@ module API | ||
19 | # :params => API::Entities::Article.documentation | 19 | # :params => API::Entities::Article.documentation |
20 | # } | 20 | # } |
21 | get do | 21 | get do |
22 | - | 22 | + |
23 | conditions = make_conditions_with_parameter(params) | 23 | conditions = make_conditions_with_parameter(params) |
24 | - | 24 | + |
25 | if params[:reference_id] | 25 | if params[:reference_id] |
26 | articles = environment.articles.send("#{params.key?(:oldest) ? 'older_than' : 'newer_than'}", params[:reference_id]).find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") | 26 | articles = environment.articles.send("#{params.key?(:oldest) ? 'older_than' : 'newer_than'}", params[:reference_id]).find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") |
27 | else | 27 | else |
28 | articles = environment.articles.find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") | 28 | articles = environment.articles.find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") |
29 | end | 29 | end |
30 | - present articles, :with => Entities::Article | 30 | + present articles, :with => Entities::Article |
31 | end | 31 | end |
32 | - | ||
33 | - desc "Return the article id" | 32 | + |
33 | + desc "Return the article id" | ||
34 | get ':id' do | 34 | get ':id' do |
35 | present environment.articles.find(params[:id]), :with => Entities::Article | 35 | present environment.articles.find(params[:id]), :with => Entities::Article |
36 | end | 36 | end |
@@ -45,7 +45,7 @@ module API | @@ -45,7 +45,7 @@ module API | ||
45 | else | 45 | else |
46 | articles = environment.articles.find(params[:id]).children.find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") | 46 | articles = environment.articles.find(params[:id]).children.find(:all, :conditions => conditions, :limit => limit, :order => "created_at DESC") |
47 | end | 47 | end |
48 | - present articles, :with => Entities::Article | 48 | + present articles, :with => Entities::Article |
49 | end | 49 | end |
50 | 50 | ||
51 | get ':id/children/:child_id' do | 51 | get ':id/children/:child_id' do |
@@ -54,7 +54,7 @@ module API | @@ -54,7 +54,7 @@ module API | ||
54 | 54 | ||
55 | 55 | ||
56 | end | 56 | end |
57 | - | 57 | + |
58 | end | 58 | end |
59 | end | 59 | end |
60 | end | 60 | end |
lib/api/v1/comments.rb
1 | module API | 1 | module API |
2 | module V1 | 2 | module V1 |
3 | class Comments < Grape::API | 3 | class Comments < Grape::API |
4 | - | 4 | + |
5 | before { detect_stuff_by_domain } | 5 | before { detect_stuff_by_domain } |
6 | before { authenticate! } | 6 | before { authenticate! } |
7 | - | 7 | + |
8 | resource :articles do | 8 | resource :articles do |
9 | # Collect comments from articles | 9 | # Collect comments from articles |
10 | # | 10 | # |
@@ -27,18 +27,18 @@ module API | @@ -27,18 +27,18 @@ module API | ||
27 | present comments, :with => Entities::Comment | 27 | present comments, :with => Entities::Comment |
28 | 28 | ||
29 | end | 29 | end |
30 | - | 30 | + |
31 | get ":id/comments/:comment_id" do | 31 | get ":id/comments/:comment_id" do |
32 | present environment.articles.find(params[:id]).comments.find(params[:comment_id]), :with => Entities::Comment | 32 | present environment.articles.find(params[:id]).comments.find(params[:comment_id]), :with => Entities::Comment |
33 | end | 33 | end |
34 | - | 34 | + |
35 | # Example Request: | 35 | # Example Request: |
36 | # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment | 36 | # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment |
37 | post ":id/comments" do | 37 | post ":id/comments" do |
38 | present environment.articles.find(params[:id]).comments.create(:author => current_person, :body => params[:body]), :with => Entities::Comment | 38 | present environment.articles.find(params[:id]).comments.create(:author => current_person, :body => params[:body]), :with => Entities::Comment |
39 | end | 39 | end |
40 | end | 40 | end |
41 | - | 41 | + |
42 | end | 42 | end |
43 | end | 43 | end |
44 | end | 44 | end |
lib/api/v1/users.rb
1 | module API | 1 | module API |
2 | module V1 | 2 | module V1 |
3 | class Users < Grape::API | 3 | class Users < Grape::API |
4 | - | 4 | + |
5 | before { authenticate! } | 5 | before { authenticate! } |
6 | - | 6 | + |
7 | resource :users do | 7 | resource :users do |
8 | - | 8 | + |
9 | #FIXME make the pagination | 9 | #FIXME make the pagination |
10 | #FIXME put it on environment context | 10 | #FIXME put it on environment context |
11 | get do | 11 | get do |
12 | present User.all, :with => Entities::User | 12 | present User.all, :with => Entities::User |
13 | end | 13 | end |
14 | - | 14 | + |
15 | get ":id" do | 15 | get ":id" do |
16 | present User.find(params[:id]), :with => Entities::User | 16 | present User.find(params[:id]), :with => Entities::User |
17 | end | 17 | end |
18 | - | 18 | + |
19 | end | 19 | end |
20 | - | 20 | + |
21 | end | 21 | end |
22 | end | 22 | end |
23 | end | 23 | end |