2020-08-05 18:40:47 +02:00
|
|
|
class APIEntreprise::Adapter
|
2018-10-04 16:22:19 +02:00
|
|
|
UNAVAILABLE = 'Donnée indisponible'
|
|
|
|
|
2018-03-29 12:16:46 +02:00
|
|
|
def initialize(siret, procedure_id)
|
|
|
|
@siret = siret
|
2018-03-28 15:24:43 +02:00
|
|
|
@procedure_id = procedure_id
|
|
|
|
end
|
2018-03-19 15:05:56 +01:00
|
|
|
|
|
|
|
def data_source
|
2019-04-30 16:36:40 +02:00
|
|
|
begin
|
|
|
|
@data_source ||= get_resource
|
2020-08-05 18:40:47 +02:00
|
|
|
rescue APIEntreprise::API::Error::ResourceNotFound
|
2019-04-30 16:36:40 +02:00
|
|
|
@data_source = nil
|
|
|
|
end
|
2018-03-19 15:05:56 +01:00
|
|
|
end
|
2018-03-19 15:45:55 +01:00
|
|
|
|
|
|
|
def to_params
|
|
|
|
if data_source.present?
|
|
|
|
process_params
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
end
|
2018-10-04 16:22:19 +02:00
|
|
|
|
|
|
|
def valid_params?(params)
|
|
|
|
!params.has_value?(UNAVAILABLE)
|
|
|
|
end
|
2020-05-14 14:41:54 +02:00
|
|
|
|
|
|
|
def siren
|
|
|
|
@siret[0..8]
|
|
|
|
end
|
2018-03-28 15:24:43 +02:00
|
|
|
end
|