SIADE -> ApiEntreprise
This commit is contained in:
parent
96f78b6213
commit
5658aae96b
11 changed files with 18 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
|||
class SIADE::API
|
||||
class ApiEntreprise::API
|
||||
class << self
|
||||
attr_accessor :token
|
||||
end
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -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) }
|
|
@ -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) }
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EtablissementAdapter do
|
||||
describe ApiEntreprise::EtablissementAdapter do
|
||||
let(:procedure_id) { 33 }
|
||||
|
||||
context 'SIRET valide' do
|
|
@ -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 }
|
|
@ -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') }
|
Loading…
Reference in a new issue