Commit a7004e28 authored by Yorick Peterse's avatar Yorick Peterse

Add method to API::Variables for filtering params

This allows EE to customize the parameters used in two places, without
having to modify the source code directly.
parent 3f629b8d
...@@ -7,6 +7,14 @@ module API ...@@ -7,6 +7,14 @@ module API
before { authenticate! } before { authenticate! }
before { authorize! :admin_build, user_project } before { authorize! :admin_build, user_project }
helpers do
def filter_variable_parameters(params)
# This method exists so that EE can more easily filter out certain
# parameters, without having to modify the source code directly.
params
end
end
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
...@@ -50,6 +58,7 @@ module API ...@@ -50,6 +58,7 @@ module API
end end
post ':id/variables' do post ':id/variables' do
variable_params = declared_params(include_missing: false) variable_params = declared_params(include_missing: false)
variable_params = filter_variable_parameters(variable_params)
variable = user_project.variables.create(variable_params) variable = user_project.variables.create(variable_params)
...@@ -75,6 +84,7 @@ module API ...@@ -75,6 +84,7 @@ module API
break not_found!('Variable') unless variable break not_found!('Variable') unless variable
variable_params = declared_params(include_missing: false).except(:key) variable_params = declared_params(include_missing: false).except(:key)
variable_params = filter_variable_parameters(variable_params)
if variable.update(variable_params) if variable.update(variable_params)
present variable, with: Entities::Variable present variable, with: Entities::Variable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment