Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #872] apientrpise: use v2 endpoints #1025

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/lib/siade/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def self.etablissement(siret)
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

Expand Down
14 changes: 7 additions & 7 deletions app/lib/siade/exercices_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def data_source
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
4 changes: 2 additions & 2 deletions spec/controllers/users/dossiers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@
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
Expand Down
4 changes: 2 additions & 2 deletions spec/features/users/complete_demande_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
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
Expand Down
4 changes: 2 additions & 2 deletions spec/features/users/dossier_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
.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')
Expand Down
4 changes: 2 additions & 2 deletions spec/features/users/start_demande_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
.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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/siade/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

Expand Down Expand Up @@ -88,7 +88,7 @@

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

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/siade/exercices_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/siade/rna_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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

Expand Down
8 changes: 4 additions & 4 deletions spec/support/files/exercices.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"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
}
]
}
}