Merge pull request #1025 from sgmap/fix_872_api_entreprise_v2
[fix #872] apientrpise: use v2 endpoints
This commit is contained in:
commit
968576ca57
10 changed files with 25 additions and 25 deletions
|
@ -17,12 +17,12 @@ class SIADE::API
|
|||
end
|
||||
|
||||
def self.exercices(siret)
|
||||
endpoint = "/v1/etablissements/exercices/#{siret}"
|
||||
endpoint = "/v2/exercices/#{siret}"
|
||||
call(base_url + endpoint)
|
||||
end
|
||||
|
||||
def self.rna(siret)
|
||||
endpoint = "/v1/associations/#{siret}"
|
||||
endpoint = "/v2/associations/#{siret}"
|
||||
call(base_url + endpoint)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ class SIADE::ExercicesAdapter
|
|||
end
|
||||
|
||||
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
|
||||
nil
|
||||
end
|
||||
|
||||
def attr_to_fetch
|
||||
[:ca,
|
||||
:dateFinExercice,
|
||||
:date_fin_exercice_timestamp]
|
||||
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}")
|
||||
.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)
|
||||
|
||||
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)
|
||||
|
||||
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}")
|
||||
.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'))
|
||||
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: '')
|
||||
|
||||
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'))
|
||||
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'))
|
||||
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'))
|
||||
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: '')
|
||||
page.find_by_id('dossier-siret').set siret
|
||||
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'))
|
||||
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'))
|
||||
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'))
|
||||
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: '')
|
||||
|
||||
page.find_by_id('dossier-siret').set siret
|
||||
|
|
|
@ -57,7 +57,7 @@ describe SIADE::API do
|
|||
|
||||
describe '.exercices' 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)
|
||||
end
|
||||
|
||||
|
@ -88,7 +88,7 @@ describe SIADE::API do
|
|||
|
||||
describe '.rna' 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)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ describe SIADE::ExercicesAdapter do
|
|||
subject { described_class.new(siret).to_params }
|
||||
|
||||
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))
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe SIADE::RNAAdapter do
|
|||
subject { described_class.new(siret).to_params }
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
"exercices":[
|
||||
{
|
||||
"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
|
||||
},
|
||||
{
|
||||
"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
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue