call api_entreprise adapters with siret
This commit is contained in:
parent
f7201dd17b
commit
e3ee423197
12 changed files with 34 additions and 26 deletions
|
@ -25,4 +25,8 @@ class ApiEntreprise::Adapter
|
||||||
def valid_params?(params)
|
def valid_params?(params)
|
||||||
!params.has_value?(UNAVAILABLE)
|
!params.has_value?(UNAVAILABLE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def siren
|
||||||
|
@siret[0..8]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class ApiEntreprise::AttestationFiscaleAdapter < ApiEntreprise::Adapter
|
class ApiEntreprise::AttestationFiscaleAdapter < ApiEntreprise::Adapter
|
||||||
def initialize(siren, procedure_id, user_id)
|
def initialize(siret, procedure_id, user_id)
|
||||||
@siren = siren
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
@user_id = user_id
|
@user_id = user_id
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ class ApiEntreprise::AttestationFiscaleAdapter < ApiEntreprise::Adapter
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
ApiEntreprise::API.attestation_fiscale(@siren, @procedure_id, @user_id)
|
ApiEntreprise::API.attestation_fiscale(siren, @procedure_id, @user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
class ApiEntreprise::AttestationSocialeAdapter < ApiEntreprise::Adapter
|
class ApiEntreprise::AttestationSocialeAdapter < ApiEntreprise::Adapter
|
||||||
def initialize(siren, procedure_id)
|
def initialize(siret, procedure_id)
|
||||||
@siren = siren
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
ApiEntreprise::API.attestation_sociale(@siren, @procedure_id)
|
ApiEntreprise::API.attestation_sociale(siren, @procedure_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
class ApiEntreprise::BilansBdfAdapter < ApiEntreprise::Adapter
|
class ApiEntreprise::BilansBdfAdapter < ApiEntreprise::Adapter
|
||||||
def initialize(siren, procedure_id)
|
def initialize(siret, procedure_id)
|
||||||
@siren = siren
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
ApiEntreprise::API.bilans_bdf(@siren, @procedure_id)
|
ApiEntreprise::API.bilans_bdf(siren, @procedure_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class ApiEntreprise::EffectifsAdapter < ApiEntreprise::Adapter
|
class ApiEntreprise::EffectifsAdapter < ApiEntreprise::Adapter
|
||||||
def initialize(siren, procedure_id, annee, mois)
|
def initialize(siret, procedure_id, annee, mois)
|
||||||
@siren = siren
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
@annee = annee
|
@annee = annee
|
||||||
@mois = mois
|
@mois = mois
|
||||||
|
@ -9,7 +9,7 @@ class ApiEntreprise::EffectifsAdapter < ApiEntreprise::Adapter
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
ApiEntreprise::API.effectifs(@siren, @procedure_id, @annee, @mois)
|
ApiEntreprise::API.effectifs(siren, @procedure_id, @annee, @mois)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
class ApiEntreprise::EffectifsAnnuelsAdapter < ApiEntreprise::Adapter
|
class ApiEntreprise::EffectifsAnnuelsAdapter < ApiEntreprise::Adapter
|
||||||
def initialize(siren, procedure_id)
|
def initialize(siret, procedure_id)
|
||||||
@siren = siren
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
ApiEntreprise::API.effectifs_annuels(@siren, @procedure_id)
|
ApiEntreprise::API.effectifs_annuels(siren, @procedure_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
|
|
|
@ -2,7 +2,6 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_resource
|
def get_resource
|
||||||
siren = @siret[0..8]
|
|
||||||
ApiEntreprise::API.entreprise(siren, @procedure_id)
|
ApiEntreprise::API.entreprise(siren, @procedure_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
describe ApiEntreprise::AttestationFiscaleAdapter do
|
describe ApiEntreprise::AttestationFiscaleAdapter do
|
||||||
|
let(:siret) { '41816609600069' }
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:user_id) { 1 }
|
let(:user_id) { 1 }
|
||||||
let(:adapter) { described_class.new(siren, procedure.id, user_id) }
|
let(:adapter) { described_class.new(siret, procedure.id, user_id) }
|
||||||
subject { adapter.to_params }
|
subject { adapter.to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}\?.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_fiscales"])
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_fiscales"])
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
describe ApiEntreprise::AttestationSocialeAdapter do
|
describe ApiEntreprise::AttestationSocialeAdapter do
|
||||||
|
let(:siret) { '41816609600069' }
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:adapter) { described_class.new(siren, procedure.id) }
|
let(:adapter) { described_class.new(siret, procedure.id) }
|
||||||
subject { adapter.to_params }
|
subject { adapter.to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}\?.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
describe ApiEntreprise::BilansBdfAdapter do
|
describe ApiEntreprise::BilansBdfAdapter do
|
||||||
|
let(:siret) { '41816609600069' }
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:procedure_id) { procedure.id }
|
let(:procedure_id) { procedure.id }
|
||||||
let(:adapter) { described_class.new(siren, procedure_id) }
|
let(:adapter) { described_class.new(siret, procedure_id) }
|
||||||
subject { adapter.to_params }
|
subject { adapter.to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}\?.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
describe ApiEntreprise::EffectifsAdapter do
|
describe ApiEntreprise::EffectifsAdapter do
|
||||||
|
let(:siret) { '41816609600069' }
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:procedure_id) { procedure.id }
|
let(:procedure_id) { procedure.id }
|
||||||
let(:annee) { "2020" }
|
let(:annee) { "2020" }
|
||||||
let(:mois) { "02" }
|
let(:mois) { "02" }
|
||||||
let(:adapter) { described_class.new(siren, procedure_id, annee, mois) }
|
let(:adapter) { described_class.new(siret, procedure_id, annee, mois) }
|
||||||
subject { adapter.to_params }
|
subject { adapter.to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}\?.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
describe ApiEntreprise::EffectifsAnnuelsAdapter do
|
describe ApiEntreprise::EffectifsAnnuelsAdapter do
|
||||||
|
let(:siret) { '41816609600069' }
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:procedure_id) { procedure.id }
|
let(:procedure_id) { procedure.id }
|
||||||
let(:adapter) { described_class.new(siren, procedure_id) }
|
let(:adapter) { described_class.new(siret, procedure_id) }
|
||||||
subject { adapter.to_params }
|
subject { adapter.to_params }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}\?.*token=/)
|
||||||
.to_return(body: body, status: status)
|
.to_return(body: body, status: status)
|
||||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue