From 8938a5b40df53d121fadd7f11993f4b479a8499a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 29 Mar 2018 12:15:33 +0200 Subject: [PATCH 1/2] Delete SiretService.siren, move its code to EntrepriseAdapter#get_resource --- app/lib/api_entreprise/entreprise_adapter.rb | 3 ++- app/services/siret_service.rb | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/lib/api_entreprise/entreprise_adapter.rb b/app/lib/api_entreprise/entreprise_adapter.rb index 3758e065b..377b7afb2 100644 --- a/app/lib/api_entreprise/entreprise_adapter.rb +++ b/app/lib/api_entreprise/entreprise_adapter.rb @@ -2,7 +2,8 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter private def get_resource - ApiEntreprise::API.entreprise(@siret_or_siren, @procedure_id) + siren = @siret_or_siren[0..8] + ApiEntreprise::API.entreprise(siren, @procedure_id) end def process_params diff --git a/app/services/siret_service.rb b/app/services/siret_service.rb index 869039ea5..1aa089e01 100644 --- a/app/services/siret_service.rb +++ b/app/services/siret_service.rb @@ -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( { From 094ccecc01408f88aba625f688d4cb87ba0c3238 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 29 Mar 2018 12:16:46 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Rename=20Adapter=E2=80=99s=20siret=5For=5Fs?= =?UTF-8?q?iren=20to=20siret?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/api_entreprise/adapter.rb | 4 ++-- app/lib/api_entreprise/entreprise_adapter.rb | 2 +- app/lib/api_entreprise/etablissement_adapter.rb | 2 +- app/lib/api_entreprise/exercices_adapter.rb | 2 +- app/lib/api_entreprise/rna_adapter.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/lib/api_entreprise/adapter.rb b/app/lib/api_entreprise/adapter.rb index 21b2ff182..bf0645b0f 100644 --- a/app/lib/api_entreprise/adapter.rb +++ b/app/lib/api_entreprise/adapter.rb @@ -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 diff --git a/app/lib/api_entreprise/entreprise_adapter.rb b/app/lib/api_entreprise/entreprise_adapter.rb index 377b7afb2..015c64ec2 100644 --- a/app/lib/api_entreprise/entreprise_adapter.rb +++ b/app/lib/api_entreprise/entreprise_adapter.rb @@ -2,7 +2,7 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter private def get_resource - siren = @siret_or_siren[0..8] + siren = @siret[0..8] ApiEntreprise::API.entreprise(siren, @procedure_id) end diff --git a/app/lib/api_entreprise/etablissement_adapter.rb b/app/lib/api_entreprise/etablissement_adapter.rb index accfa5fe6..a1eacd7c6 100644 --- a/app/lib/api_entreprise/etablissement_adapter.rb +++ b/app/lib/api_entreprise/etablissement_adapter.rb @@ -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 diff --git a/app/lib/api_entreprise/exercices_adapter.rb b/app/lib/api_entreprise/exercices_adapter.rb index a64258580..4807e205f 100644 --- a/app/lib/api_entreprise/exercices_adapter.rb +++ b/app/lib/api_entreprise/exercices_adapter.rb @@ -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 diff --git a/app/lib/api_entreprise/rna_adapter.rb b/app/lib/api_entreprise/rna_adapter.rb index 74b21ba39..333a382cc 100644 --- a/app/lib/api_entreprise/rna_adapter.rb +++ b/app/lib/api_entreprise/rna_adapter.rb @@ -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