commit
0d7197392a
2 changed files with 10 additions and 8 deletions
|
@ -10,7 +10,7 @@ class ApiEntreprise::ExercicesAdapter < ApiEntreprise::Adapter
|
||||||
exercice.slice(*attr_to_fetch)
|
exercice.slice(*attr_to_fetch)
|
||||||
end
|
end
|
||||||
|
|
||||||
if exercices_array == exercices_array.select { |params| valid_params?(params) }
|
if exercices_array.all? { |params| valid_params?(params) }
|
||||||
{ exercices_attributes: exercices_array }
|
{ exercices_attributes: exercices_array }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -6,17 +6,20 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
# Responses with a 206 codes are sometimes not useable,
|
# Sometimes the associations endpoints responses with a 206,
|
||||||
# as the RNA calls often return a 206 with an error message,
|
# and these response are often useable as the they only
|
||||||
# not a partial response
|
# contain an error message.
|
||||||
|
# Therefore here we make sure that our response seems valid
|
||||||
|
# by checking that there is an association attribute.
|
||||||
if !data_source.key?(:association)
|
if !data_source.key?(:association)
|
||||||
{}
|
{}
|
||||||
else
|
else
|
||||||
|
association_id = data_source[:association][:id]
|
||||||
params = data_source[:association].slice(*attr_to_fetch)
|
params = data_source[:association].slice(*attr_to_fetch)
|
||||||
|
|
||||||
if params[:id].present? && valid_params?(params)
|
if association_id.present? && valid_params?(params)
|
||||||
params[:rna] = params[:id]
|
params[:rna] = association_id
|
||||||
params.except(:id).transform_keys { |k| :"association_#{k}" }
|
params.transform_keys { |k| :"association_#{k}" }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
@ -25,7 +28,6 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
[
|
[
|
||||||
:id,
|
|
||||||
:titre,
|
:titre,
|
||||||
:objet,
|
:objet,
|
||||||
:date_creation,
|
:date_creation,
|
||||||
|
|
Loading…
Reference in a new issue