Merge pull request #1761 from betagouv/simplify-api-entreprise
Simplify API Entreprise
This commit is contained in:
commit
96a0e1dbd2
6 changed files with 8 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue