From 5658aae96ba4297bcc90f8c32f50e6154c9397dc Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 15 Mar 2018 16:56:21 +0100 Subject: [PATCH] SIADE -> ApiEntreprise --- app/lib/{siade => api_entreprise}/api.rb | 2 +- app/lib/{siade => api_entreprise}/entreprise_adapter.rb | 4 ++-- .../{siade => api_entreprise}/etablissement_adapter.rb | 4 ++-- app/lib/{siade => api_entreprise}/exercices_adapter.rb | 4 ++-- app/lib/{siade => api_entreprise}/rna_adapter.rb | 4 ++-- app/services/siret_service.rb | 8 ++++---- spec/lib/{siade => api_entreprise}/api_spec.rb | 2 +- .../{siade => api_entreprise}/entreprise_adapter_spec.rb | 2 +- .../etablissement_adapter_spec.rb | 2 +- .../{siade => api_entreprise}/exercices_adapter_spec.rb | 2 +- spec/lib/{siade => api_entreprise}/rna_adapter_spec.rb | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) rename app/lib/{siade => api_entreprise}/api.rb (98%) rename app/lib/{siade => api_entreprise}/entreprise_adapter.rb (87%) rename app/lib/{siade => api_entreprise}/etablissement_adapter.rb (88%) rename app/lib/{siade => api_entreprise}/exercices_adapter.rb (77%) rename app/lib/{siade => api_entreprise}/rna_adapter.rb (83%) rename spec/lib/{siade => api_entreprise}/api_spec.rb (99%) rename spec/lib/{siade => api_entreprise}/entreprise_adapter_spec.rb (98%) rename spec/lib/{siade => api_entreprise}/etablissement_adapter_spec.rb (98%) rename spec/lib/{siade => api_entreprise}/exercices_adapter_spec.rb (95%) rename spec/lib/{siade => api_entreprise}/rna_adapter_spec.rb (96%) diff --git a/app/lib/siade/api.rb b/app/lib/api_entreprise/api.rb similarity index 98% rename from app/lib/siade/api.rb rename to app/lib/api_entreprise/api.rb index fc3680fde..ad1086371 100644 --- a/app/lib/siade/api.rb +++ b/app/lib/api_entreprise/api.rb @@ -1,4 +1,4 @@ -class SIADE::API +class ApiEntreprise::API class << self attr_accessor :token end diff --git a/app/lib/siade/entreprise_adapter.rb b/app/lib/api_entreprise/entreprise_adapter.rb similarity index 87% rename from app/lib/siade/entreprise_adapter.rb rename to app/lib/api_entreprise/entreprise_adapter.rb index c59e384d0..2cdd65624 100644 --- a/app/lib/siade/entreprise_adapter.rb +++ b/app/lib/api_entreprise/entreprise_adapter.rb @@ -1,4 +1,4 @@ -class SIADE::EntrepriseAdapter +class ApiEntreprise::EntrepriseAdapter def initialize(siren, procedure_id) @siren = siren @procedure_id = procedure_id @@ -21,7 +21,7 @@ class SIADE::EntrepriseAdapter private def data_source - @data_source ||= SIADE::API.entreprise(@siren, @procedure_id) + @data_source ||= ApiEntreprise::API.entreprise(@siren, @procedure_id) rescue @data_source = nil end diff --git a/app/lib/siade/etablissement_adapter.rb b/app/lib/api_entreprise/etablissement_adapter.rb similarity index 88% rename from app/lib/siade/etablissement_adapter.rb rename to app/lib/api_entreprise/etablissement_adapter.rb index 79551a009..4f993cd72 100644 --- a/app/lib/siade/etablissement_adapter.rb +++ b/app/lib/api_entreprise/etablissement_adapter.rb @@ -1,4 +1,4 @@ -class SIADE::EtablissementAdapter +class ApiEntreprise::EtablissementAdapter def initialize(siret, procedure_id) @siret = siret @procedure_id = procedure_id @@ -23,7 +23,7 @@ class SIADE::EtablissementAdapter private def data_source - @data_source ||= SIADE::API.etablissement(@siret, @procedure_id) + @data_source ||= ApiEntreprise::API.etablissement(@siret, @procedure_id) end def attr_to_fetch diff --git a/app/lib/siade/exercices_adapter.rb b/app/lib/api_entreprise/exercices_adapter.rb similarity index 77% rename from app/lib/siade/exercices_adapter.rb rename to app/lib/api_entreprise/exercices_adapter.rb index db8dbeb42..1bdb961f3 100644 --- a/app/lib/siade/exercices_adapter.rb +++ b/app/lib/api_entreprise/exercices_adapter.rb @@ -1,4 +1,4 @@ -class SIADE::ExercicesAdapter +class ApiEntreprise::ExercicesAdapter def initialize(siret, procedure_id) @siret = siret @procedure_id = procedure_id @@ -15,7 +15,7 @@ class SIADE::ExercicesAdapter private def data_source - @data_source ||= SIADE::API.exercices(@siret, @procedure_id) + @data_source ||= ApiEntreprise::API.exercices(@siret, @procedure_id) rescue @data_source = nil end diff --git a/app/lib/siade/rna_adapter.rb b/app/lib/api_entreprise/rna_adapter.rb similarity index 83% rename from app/lib/siade/rna_adapter.rb rename to app/lib/api_entreprise/rna_adapter.rb index d168684ab..3fde60b77 100644 --- a/app/lib/siade/rna_adapter.rb +++ b/app/lib/api_entreprise/rna_adapter.rb @@ -1,4 +1,4 @@ -class SIADE::RNAAdapter +class ApiEntreprise::RNAAdapter def initialize(siret, procedure_id) @siret = siret @procedure_id = procedure_id @@ -18,7 +18,7 @@ class SIADE::RNAAdapter private def data_source - @data_source ||= SIADE::API.rna(@siret, @procedure_id) + @data_source ||= ApiEntreprise::API.rna(@siret, @procedure_id) end def attr_to_fetch diff --git a/app/services/siret_service.rb b/app/services/siret_service.rb index 613f1c36c..797420935 100644 --- a/app/services/siret_service.rb +++ b/app/services/siret_service.rb @@ -1,11 +1,11 @@ class SIRETService def self.fetch(siret, dossier = nil) - etablissement = SIADE::EtablissementAdapter.new(siret, dossier&.procedure_id) - entreprise = SIADE::EntrepriseAdapter.new(siren(siret), dossier&.procedure_id) + etablissement = ApiEntreprise::EtablissementAdapter.new(siret, dossier&.procedure_id) + entreprise = ApiEntreprise::EntrepriseAdapter.new(siren(siret), dossier&.procedure_id) if etablissement.success? && entreprise.success? - association = SIADE::RNAAdapter.new(siret, dossier&.procedure_id) - exercices = SIADE::ExercicesAdapter.new(siret, dossier&.procedure_id) + association = ApiEntreprise::RNAAdapter.new(siret, dossier&.procedure_id) + exercices = ApiEntreprise::ExercicesAdapter.new(siret, dossier&.procedure_id) params = etablissement.to_params .merge(entreprise.to_params.map { |k,v| ["entreprise_#{k}", v] }.to_h) diff --git a/spec/lib/siade/api_spec.rb b/spec/lib/api_entreprise/api_spec.rb similarity index 99% rename from spec/lib/siade/api_spec.rb rename to spec/lib/api_entreprise/api_spec.rb index b7edb4f0c..ded04e7d5 100644 --- a/spec/lib/siade/api_spec.rb +++ b/spec/lib/api_entreprise/api_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SIADE::API do +describe ApiEntreprise::API do let(:procedure_id) { 12 } describe '.entreprise' do subject { described_class.entreprise(siren, procedure_id) } diff --git a/spec/lib/siade/entreprise_adapter_spec.rb b/spec/lib/api_entreprise/entreprise_adapter_spec.rb similarity index 98% rename from spec/lib/siade/entreprise_adapter_spec.rb rename to spec/lib/api_entreprise/entreprise_adapter_spec.rb index c1248c5b5..94dfbc759 100644 --- a/spec/lib/siade/entreprise_adapter_spec.rb +++ b/spec/lib/api_entreprise/entreprise_adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SIADE::EntrepriseAdapter do +describe ApiEntreprise::EntrepriseAdapter do let(:siren) { '418166096' } let(:procedure_id) { 22 } let(:adapter) { described_class.new(siren, procedure_id) } diff --git a/spec/lib/siade/etablissement_adapter_spec.rb b/spec/lib/api_entreprise/etablissement_adapter_spec.rb similarity index 98% rename from spec/lib/siade/etablissement_adapter_spec.rb rename to spec/lib/api_entreprise/etablissement_adapter_spec.rb index d078fbeb9..17695a4e8 100644 --- a/spec/lib/siade/etablissement_adapter_spec.rb +++ b/spec/lib/api_entreprise/etablissement_adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SIADE::EtablissementAdapter do +describe ApiEntreprise::EtablissementAdapter do let(:procedure_id) { 33 } context 'SIRET valide' do diff --git a/spec/lib/siade/exercices_adapter_spec.rb b/spec/lib/api_entreprise/exercices_adapter_spec.rb similarity index 95% rename from spec/lib/siade/exercices_adapter_spec.rb rename to spec/lib/api_entreprise/exercices_adapter_spec.rb index 303650322..9e9d29bb8 100644 --- a/spec/lib/siade/exercices_adapter_spec.rb +++ b/spec/lib/api_entreprise/exercices_adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SIADE::ExercicesAdapter do +describe ApiEntreprise::ExercicesAdapter do let(:siret) { '41816609600051' } let(:procedure_id) { 11 } subject { described_class.new(siret, procedure_id).to_params } diff --git a/spec/lib/siade/rna_adapter_spec.rb b/spec/lib/api_entreprise/rna_adapter_spec.rb similarity index 96% rename from spec/lib/siade/rna_adapter_spec.rb rename to spec/lib/api_entreprise/rna_adapter_spec.rb index 835280433..b57f2450f 100644 --- a/spec/lib/siade/rna_adapter_spec.rb +++ b/spec/lib/api_entreprise/rna_adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SIADE::RNAAdapter do +describe ApiEntreprise::RNAAdapter do let(:siret) { '50480511000013' } let(:procedure_id) { 22 } let(:body) { File.read('spec/support/files/rna.json') }