demarches-normaliennes/app/lib/api_entreprise/rna_adapter.rb

37 lines
799 B
Ruby
Raw Normal View History

class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
private
def get_resource
ApiEntreprise::API.rna(@siret, @procedure_id)
end
def process_params
# Responses with a 206 codes are sometimes not useable,
# as the RNA calls often return a 206 with an error message,
# not a partial response
if !data_source.key?(:association)
{}
else
params = data_source[:association].slice(*attr_to_fetch)
if params[:id].present? && valid_params?(params)
params[:rna] = params[:id]
params.except(:id).transform_keys { |k| :"association_#{k}" }
else
{}
end
2018-02-28 17:16:03 +01:00
end
2015-12-11 10:36:16 +01:00
end
def attr_to_fetch
[
:id,
:titre,
:objet,
:date_creation,
:date_declaration,
:date_publication
2015-12-11 10:36:16 +01:00
]
end
end