Merge pull request #9098 from demarches-simplifiees/8472-migrer-attestation-fiscale
API Entreprise : migration "attestation fiscale"
This commit is contained in:
commit
3161f90662
6 changed files with 30 additions and 14 deletions
|
@ -8,7 +8,7 @@ class APIEntreprise::API
|
|||
EFFECTIFS_RESOURCE_NAME = "v2/effectifs_mensuels_acoss_covid"
|
||||
EFFECTIFS_ANNUELS_RESOURCE_NAME = "v2/effectifs_annuels_acoss_covid/%{id}"
|
||||
ATTESTATION_SOCIALE_RESOURCE_NAME = "v4/urssaf/unites_legales/%{id}/attestation_vigilance"
|
||||
ATTESTATION_FISCALE_RESOURCE_NAME = "v2/attestations_fiscales_dgfip/%{id}"
|
||||
ATTESTATION_FISCALE_RESOURCE_NAME = "v4/dgfip/unites_legales/%{id}/attestation_fiscale"
|
||||
BILANS_BDF_RESOURCE_NAME = "v2/bilans_entreprises_bdf/%{id}"
|
||||
PRIVILEGES_RESOURCE_NAME = "v2/privileges"
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class APIEntreprise::AttestationFiscaleAdapter < APIEntreprise::Adapter
|
||||
# Doc métier : https://entreprise.api.gouv.fr/catalogue/dgfip/attestations_fiscales
|
||||
# Swagger : https://entreprise.api.gouv.fr/developpeurs/openapi#tag/Attestations-sociales-et-fiscales/paths/~1v4~1dgfip~1unites_legales~1%7Bsiren%7D~1attestation_fiscale/get
|
||||
|
||||
def initialize(siret, procedure_id, user_id)
|
||||
@siret = siret
|
||||
@procedure_id = procedure_id
|
||||
|
@ -12,12 +15,19 @@ class APIEntreprise::AttestationFiscaleAdapter < APIEntreprise::Adapter
|
|||
end
|
||||
|
||||
def process_params
|
||||
if data_source[:url].present?
|
||||
{
|
||||
entreprise_attestation_fiscale_url: data_source[:url]
|
||||
}
|
||||
else
|
||||
{}
|
||||
data = data_source[:data]
|
||||
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(siret: @siret)
|
||||
scope.set_extras(source: data)
|
||||
|
||||
if data && data[:document_url].present?
|
||||
{
|
||||
entreprise_attestation_fiscale_url: data[:document_url]
|
||||
}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
{
|
||||
"url":
|
||||
"https://storage.entreprise.api.gouv.fr/siade/1569156756-f6b7779f99fa95cd60dc03c04fcb-attestation_fiscale_dgfip.pdf"
|
||||
"data": {
|
||||
"document_url": "https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_fiscale_dgfip.pdf",
|
||||
"document_url_expires_in": 86400,
|
||||
"date_delivrance_attestation": "2023-04-11",
|
||||
"date_periode_analysee": "2023-03-31"
|
||||
},
|
||||
"links": {},
|
||||
"meta": {}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ RSpec.describe APIEntreprise::AttestationFiscaleJob, type: :job do
|
|||
let(:status) { 200 }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/dgfip\/unites_legales\/#{siren}\/attestation_fiscale/)
|
||||
.to_return(body: body, status: status)
|
||||
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569156756-f6b7779f99fa95cd60dc03c04fcb-attestation_fiscale_dgfip.pdf")
|
||||
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_fiscale_dgfip.pdf")
|
||||
.to_return(body: "body attestation", status: 200)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["attestations_fiscales"])
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
|
|
|
@ -211,7 +211,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_fiscales_dgfip\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/dgfip\/unites_legales\/#{siren}\/attestation_fiscale/)
|
||||
.to_return(body: body, status: status)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ describe APIEntreprise::AttestationFiscaleAdapter do
|
|||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/dgfip\/unites_legales\/#{siren}\/attestation_fiscale/)
|
||||
.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(:expired?).and_return(false)
|
||||
|
@ -22,7 +22,7 @@ describe APIEntreprise::AttestationFiscaleAdapter do
|
|||
end
|
||||
|
||||
it "returns url of attestation_fiscale" do
|
||||
expect(subject[:entreprise_attestation_fiscale_url]).to eq("https://storage.entreprise.api.gouv.fr/siade/1569156756-f6b7779f99fa95cd60dc03c04fcb-attestation_fiscale_dgfip.pdf")
|
||||
expect(subject[:entreprise_attestation_fiscale_url]).to eq("https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_fiscale_dgfip.pdf")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue