Merge pull request #1761 from betagouv/simplify-api-entreprise

Simplify API Entreprise
This commit is contained in:
gregoirenovel 2018-03-29 16:09:01 +02:00 committed by GitHub
commit 96a0e1dbd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 11 deletions

View file

@ -1,6 +1,6 @@
class ApiEntreprise::Adapter
def initialize(siret_or_siren, procedure_id)
@siret_or_siren = siret_or_siren
def initialize(siret, procedure_id)
@siret = siret
@procedure_id = procedure_id
end

View file

@ -2,7 +2,8 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
private
def get_resource
ApiEntreprise::API.entreprise(@siret_or_siren, @procedure_id)
siren = @siret[0..8]
ApiEntreprise::API.entreprise(siren, @procedure_id)
end
def process_params

View file

@ -2,7 +2,7 @@ class ApiEntreprise::EtablissementAdapter < ApiEntreprise::Adapter
private
def get_resource
ApiEntreprise::API.etablissement(@siret_or_siren, @procedure_id)
ApiEntreprise::API.etablissement(@siret, @procedure_id)
end
def process_params

View file

@ -2,7 +2,7 @@ class ApiEntreprise::ExercicesAdapter < ApiEntreprise::Adapter
private
def get_resource
ApiEntreprise::API.exercices(@siret_or_siren, @procedure_id)
ApiEntreprise::API.exercices(@siret, @procedure_id)
end
def process_params

View file

@ -2,7 +2,7 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
private
def get_resource
ApiEntreprise::API.rna(@siret_or_siren, @procedure_id)
ApiEntreprise::API.rna(@siret, @procedure_id)
end
def process_params

View file

@ -3,7 +3,7 @@ class SIRETService
procedure_id = dossier&.procedure_id
etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, procedure_id).to_params
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siren(siret), procedure_id).to_params
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params
if etablissement_params.present? && entreprise_params.present?
association_params = ApiEntreprise::RNAAdapter.new(siret, procedure_id).to_params
@ -23,10 +23,6 @@ class SIRETService
end
end
def self.siren(siret)
siret[0..8]
end
def self.handle_legacy_models!(params, entreprise_params, dossier, association_params)
params[:entreprise_attributes] = entreprise_params.merge(
{