migrate attestation_sociale to v4

This commit is contained in:
Christophe Robillard 2023-05-22 14:56:40 +02:00
parent 9a38ec1184
commit 247ad49ab7
6 changed files with 24 additions and 10 deletions

View file

@ -5,7 +5,7 @@ class APIEntreprise::API
RNA_RESOURCE_NAME = "v2/associations/%{id}"
EFFECTIFS_RESOURCE_NAME = "v2/effectifs_mensuels_acoss_covid"
EFFECTIFS_ANNUELS_RESOURCE_NAME = "v2/effectifs_annuels_acoss_covid/%{id}"
ATTESTATION_SOCIALE_RESOURCE_NAME = "v2/attestations_sociales_acoss/%{id}"
ATTESTATION_SOCIALE_RESOURCE_NAME = "v4/urssaf/unites_legales/%{id}/attestation_vigilance"
ATTESTATION_FISCALE_RESOURCE_NAME = "v2/attestations_fiscales_dgfip/%{id}"
BILANS_BDF_RESOURCE_NAME = "v2/bilans_entreprises_bdf/%{id}"
PRIVILEGES_RESOURCE_NAME = "v2/privileges"

View file

@ -11,9 +11,9 @@ class APIEntreprise::AttestationSocialeAdapter < APIEntreprise::Adapter
end
def process_params
if data_source[:url].present?
if data_source[:data] && data_source[:data][:document_url].present?
{
entreprise_attestation_sociale_url: data_source[:url]
entreprise_attestation_sociale_url: data_source[:data][:document_url]
}
else
{}

View file

@ -1,4 +1,18 @@
{
"url":
"https://storage.entreprise.api.gouv.fr/siade/1569156881-f749d75e2bfd443316e2e02d59015f-attestation_vigilance_acoss.pdf"
"data": {
"entity_status": {
"code": "ok",
"libelle": "Attestation délivrée par l'Urssaf",
"description": "La délivrance de l'attestation de vigilance a été refusée par l'Urssaf car l'entité n'est pas à jour de ses cotisations sociales."
},
"date_debut_validite": "ipsum",
"date_fin_validite": "ipsum",
"code_securite": "GB1QWERTYJJEX1O",
"document_url": "https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_vigilance_acoss.pdf",
"document_url_expires_in": 86400
},
"links": {
},
"meta": {
}
}

View file

@ -9,9 +9,9 @@ RSpec.describe APIEntreprise::AttestationSocialeJob, type: :job do
let(:status) { 200 }
before do
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}/)
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/urssaf\/unites_legales\/#{siren}\/attestation_vigilance/)
.to_return(body: body, status: status)
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569156881-f749d75e2bfd443316e2e02d59015f-attestation_vigilance_acoss.pdf")
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_vigilance_acoss.pdf")
.to_return(body: "body attestation", status: 200)
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)

View file

@ -182,7 +182,7 @@ describe APIEntreprise::API do
before do
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(roles)
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}/)
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/urssaf\/unites_legales\/#{siren}\/attestation_vigilance/)
.to_return(body: body, status: status)
end

View file

@ -6,7 +6,7 @@ describe APIEntreprise::AttestationSocialeAdapter do
subject { adapter.to_params }
before do
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}/)
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/urssaf\/unites_legales\/#{siren}\/attestation_vigilance/)
.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(:expired?).and_return(false)
@ -21,7 +21,7 @@ describe APIEntreprise::AttestationSocialeAdapter do
end
it "renvoie l'url de l'attestation sociale" do
expect(subject[:entreprise_attestation_sociale_url]).to eq("https://storage.entreprise.api.gouv.fr/siade/1569156881-f749d75e2bfd443316e2e02d59015f-attestation_vigilance_acoss.pdf")
expect(subject[:entreprise_attestation_sociale_url]).to eq("https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_vigilance_acoss.pdf")
end
end
end