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