Merge pull request #9084 from demarches-simplifiees/8472-migration-attestation-sociale
8472 migration attestation sociale
This commit is contained in:
commit
601fde2147
7 changed files with 36 additions and 22 deletions
|
@ -1,14 +1,14 @@
|
||||||
class APIEntreprise::API
|
class APIEntreprise::API
|
||||||
ENTREPRISE_RESOURCE_NAME = "entreprises"
|
ENTREPRISE_RESOURCE_NAME = "v2/entreprises/%{id}"
|
||||||
ETABLISSEMENT_RESOURCE_NAME = "etablissements"
|
ETABLISSEMENT_RESOURCE_NAME = "v2/etablissements/%{id}"
|
||||||
EXERCICES_RESOURCE_NAME = "exercices"
|
EXERCICES_RESOURCE_NAME = "v2/exercices/%{id}"
|
||||||
RNA_RESOURCE_NAME = "associations"
|
RNA_RESOURCE_NAME = "v2/associations/%{id}"
|
||||||
EFFECTIFS_RESOURCE_NAME = "effectifs_mensuels_acoss_covid"
|
EFFECTIFS_RESOURCE_NAME = "v2/effectifs_mensuels_acoss_covid"
|
||||||
EFFECTIFS_ANNUELS_RESOURCE_NAME = "effectifs_annuels_acoss_covid"
|
EFFECTIFS_ANNUELS_RESOURCE_NAME = "v2/effectifs_annuels_acoss_covid/%{id}"
|
||||||
ATTESTATION_SOCIALE_RESOURCE_NAME = "attestations_sociales_acoss"
|
ATTESTATION_SOCIALE_RESOURCE_NAME = "v4/urssaf/unites_legales/%{id}/attestation_vigilance"
|
||||||
ATTESTATION_FISCALE_RESOURCE_NAME = "attestations_fiscales_dgfip"
|
ATTESTATION_FISCALE_RESOURCE_NAME = "v2/attestations_fiscales_dgfip/%{id}"
|
||||||
BILANS_BDF_RESOURCE_NAME = "bilans_entreprises_bdf"
|
BILANS_BDF_RESOURCE_NAME = "v2/bilans_entreprises_bdf/%{id}"
|
||||||
PRIVILEGES_RESOURCE_NAME = "privileges"
|
PRIVILEGES_RESOURCE_NAME = "v2/privileges"
|
||||||
|
|
||||||
TIMEOUT = 20
|
TIMEOUT = 20
|
||||||
DEFAULT_API_ENTREPRISE_DELAY = 0.0
|
DEFAULT_API_ENTREPRISE_DELAY = 0.0
|
||||||
|
@ -41,7 +41,7 @@ class APIEntreprise::API
|
||||||
end
|
end
|
||||||
|
|
||||||
def effectifs(siren, annee, mois)
|
def effectifs(siren, annee, mois)
|
||||||
endpoint = [EFFECTIFS_RESOURCE_NAME, annee, mois, "entreprise"].join('/')
|
endpoint = [EFFECTIFS_RESOURCE_NAME, annee, mois, "entreprise", "%{id}"].join('/')
|
||||||
call_with_siret(endpoint, siren)
|
call_with_siret(endpoint, siren)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class APIEntreprise::API
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_url(resource_name, siret_or_siren = nil)
|
def make_url(resource_name, siret_or_siren = nil)
|
||||||
[API_ENTREPRISE_URL, resource_name, siret_or_siren].compact.join("/")
|
[API_ENTREPRISE_URL, format(resource_name, id: siret_or_siren)].compact.join("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_params(user_id)
|
def build_params(user_id)
|
||||||
|
|
|
@ -11,9 +11,9 @@ class APIEntreprise::AttestationSocialeAdapter < APIEntreprise::Adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
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
|
else
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# rubocop:disable DS/ApplicationName
|
# rubocop:disable DS/ApplicationName
|
||||||
# API URLs
|
# API URLs
|
||||||
API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr")
|
API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr")
|
||||||
API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr/v2")
|
API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr")
|
||||||
API_EDUCATION_URL = ENV.fetch("API_EDUCATION_URL", "https://data.education.gouv.fr/api/records/1.0")
|
API_EDUCATION_URL = ENV.fetch("API_EDUCATION_URL", "https://data.education.gouv.fr/api/records/1.0")
|
||||||
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
|
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
|
||||||
API_PARTICULIER_URL = ENV.fetch("API_PARTICULIER_URL", "https://particulier.api.gouv.fr/api")
|
API_PARTICULIER_URL = ENV.fetch("API_PARTICULIER_URL", "https://particulier.api.gouv.fr/api")
|
||||||
|
|
|
@ -1,4 +1,18 @@
|
||||||
{
|
{
|
||||||
"url":
|
"data": {
|
||||||
"https://storage.entreprise.api.gouv.fr/siade/1569156881-f749d75e2bfd443316e2e02d59015f-attestation_vigilance_acoss.pdf"
|
"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": {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ RSpec.describe APIEntreprise::AttestationSocialeJob, type: :job do
|
||||||
let(:status) { 200 }
|
let(:status) { 200 }
|
||||||
|
|
||||||
before do
|
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)
|
.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)
|
.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(: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)
|
||||||
|
|
|
@ -182,7 +182,7 @@ describe APIEntreprise::API do
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(roles)
|
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(roles)
|
||||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
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)
|
.to_return(body: body, status: status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe APIEntreprise::AttestationSocialeAdapter do
|
||||||
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}/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/urssaf\/unites_legales\/#{siren}\/attestation_vigilance/)
|
||||||
.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)
|
||||||
|
@ -21,7 +21,7 @@ describe APIEntreprise::AttestationSocialeAdapter do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renvoie l'url de l'attestation sociale" do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue