Commit e93a8be9f4c1bfc67b40c338454281c3483612b4

Authored by Caio Almeida
1 parent 11b7bff4

API: Add environment endpoint

lib/noosfero/api/api.rb
@@ -9,7 +9,7 @@ module Noosfero @@ -9,7 +9,7 @@ module Noosfero
9 9
10 logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log")) 10 logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
11 logger.formatter = GrapeLogging::Formatters::Default.new 11 logger.formatter = GrapeLogging::Formatters::Default.new
12 - use RequestLogger, { logger: logger } 12 + use GrapeLogging::Middleware::RequestLogger, { logger: logger }
13 13
14 rescue_from :all do |e| 14 rescue_from :all do |e|
15 logger.error e 15 logger.error e
@@ -45,6 +45,7 @@ module Noosfero @@ -45,6 +45,7 @@ module Noosfero
45 mount V1::Enterprises 45 mount V1::Enterprises
46 mount V1::Categories 46 mount V1::Categories
47 mount V1::Tasks 47 mount V1::Tasks
  48 + mount V1::Environments
48 mount Session 49 mount Session
49 50
50 # hook point which allow plugins to add Grape::API extensions to API::API 51 # hook point which allow plugins to add Grape::API extensions to API::API
lib/noosfero/api/entities.rb
@@ -114,6 +114,10 @@ module Noosfero @@ -114,6 +114,10 @@ module Noosfero
114 expose :type 114 expose :type
115 end 115 end
116 116
  117 + class Environment < Entity
  118 + expose :name
  119 + end
  120 +
117 end 121 end
118 end 122 end
119 end 123 end
lib/noosfero/api/v1/environments.rb 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +module Noosfero
  2 + module API
  3 + module V1
  4 + class Environments < Grape::API
  5 + before { authenticate! }
  6 +
  7 + resource :environment do
  8 +
  9 + # Get environment object
  10 + #
  11 + # Example Request:
  12 + # GET /environment
  13 + get do
  14 + present environment, :with => Entities::Environment
  15 + end
  16 +
  17 + desc "Return the person information"
  18 + get '/signup_person_fields' do
  19 + present environment.signup_person_fields
  20 + end
  21 +
  22 + end
  23 +
  24 + end
  25 + end
  26 + end
  27 +end