[fix #872] apientrepise: use v2 endpoints
This commit is contained in:
parent
f279341737
commit
fe9ac727de
10 changed files with 25 additions and 25 deletions
|
@ -17,12 +17,12 @@ class SIADE::API
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.exercices(siret)
|
def self.exercices(siret)
|
||||||
endpoint = "/v1/etablissements/exercices/#{siret}"
|
endpoint = "/v2/exercices/#{siret}"
|
||||||
call(base_url + endpoint)
|
call(base_url + endpoint)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rna(siret)
|
def self.rna(siret)
|
||||||
endpoint = "/v1/associations/#{siret}"
|
endpoint = "/v2/associations/#{siret}"
|
||||||
call(base_url + endpoint)
|
call(base_url + endpoint)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ class SIADE::ExercicesAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_params
|
def to_params
|
||||||
data_source[:exercices]
|
data_source[:exercices].map do |exercice|
|
||||||
|
{
|
||||||
|
ca: exercice[:ca],
|
||||||
|
dateFinExercice: exercice[:date_fin_exercice],
|
||||||
|
date_fin_exercice_timestamp: exercice[:date_fin_exercice_timestamp]
|
||||||
|
}
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
|
||||||
[:ca,
|
|
||||||
:dateFinExercice,
|
|
||||||
:date_fin_exercice_timestamp]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -187,10 +187,10 @@ describe Users::DossiersController, type: :controller do
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: status_entreprise_call, body: File.read('spec/support/files/entreprise.json'))
|
.to_return(status: status_entreprise_call, body: File.read('spec/support/files/entreprise.json'))
|
||||||
|
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: exercices_status, body: exercices_body)
|
.to_return(status: exercices_status, body: exercices_body)
|
||||||
|
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/associations/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: rna_status, body: rna_body)
|
.to_return(status: rna_status, body: rna_body)
|
||||||
|
|
||||||
dossier
|
dossier
|
||||||
|
|
|
@ -35,9 +35,9 @@ feature 'user path for dossier creation' do
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||||
|
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/associations/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 404, body: '')
|
.to_return(status: 404, body: '')
|
||||||
|
|
||||||
page.find_by_id('dossier-siret').set siret
|
page.find_by_id('dossier-siret').set siret
|
||||||
|
|
|
@ -50,9 +50,9 @@ feature 'As a User I wanna create a dossier' do
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/associations/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 404, body: '')
|
.to_return(status: 404, body: '')
|
||||||
page.find_by_id('dossier-siret').set siret
|
page.find_by_id('dossier-siret').set siret
|
||||||
page.find_by_id('submit-siret').trigger('click')
|
page.find_by_id('submit-siret').trigger('click')
|
||||||
|
|
|
@ -30,9 +30,9 @@ feature 'user arrive on siret page' do
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
|
stub_request(:get, "https://api-dev.apientreprise.fr/v2/associations/#{siret}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 404, body: '')
|
.to_return(status: 404, body: '')
|
||||||
|
|
||||||
page.find_by_id('dossier-siret').set siret
|
page.find_by_id('dossier-siret').set siret
|
||||||
|
|
|
@ -57,7 +57,7 @@ describe SIADE::API do
|
||||||
|
|
||||||
describe '.exercices' do
|
describe '.exercices' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
|
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v2\/exercices\/.*token=/)
|
||||||
.to_return(status: status, body: body)
|
.to_return(status: status, body: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ describe SIADE::API do
|
||||||
|
|
||||||
describe '.rna' do
|
describe '.rna' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
|
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v2\/associations\/.*token=/)
|
||||||
.to_return(status: status, body: body)
|
.to_return(status: status, body: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe SIADE::ExercicesAdapter do
|
||||||
subject { described_class.new(siret).to_params }
|
subject { described_class.new(siret).to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
|
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v2\/exercices\/.*token=/)
|
||||||
.to_return(body: File.read('spec/support/files/exercices.json', status: 200))
|
.to_return(body: File.read('spec/support/files/exercices.json', status: 200))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe SIADE::RNAAdapter do
|
||||||
subject { described_class.new(siret).to_params }
|
subject { described_class.new(siret).to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
|
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v2\/associations\/.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
"exercices":[
|
"exercices":[
|
||||||
{
|
{
|
||||||
"ca":"21009417",
|
"ca":"21009417",
|
||||||
"dateFinExercice":"2013-12-31T00:00:00+01:00",
|
"date_fin_exercice":"2013-12-31T00:00:00+01:00",
|
||||||
"date_fin_exercice_timestamp": 1388444400
|
"date_fin_exercice_timestamp": 1388444400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ca":"18968298",
|
"ca":"18968298",
|
||||||
"dateFinExercice":"2012-12-31T00:00:00+01:00",
|
"date_fin_exercice":"2012-12-31T00:00:00+01:00",
|
||||||
"date_fin_exercice_timestamp": 1356908400
|
"date_fin_exercice_timestamp": 1356908400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ca":"17768838",
|
"ca":"17768838",
|
||||||
"dateFinExercice":"2011-12-31T00:00:00+01:00",
|
"date_fin_exercice":"2011-12-31T00:00:00+01:00",
|
||||||
"date_fin_exercice_timestamp": 1325286000
|
"date_fin_exercice_timestamp": 1325286000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue