demarches-normaliennes/app/jobs/api_entreprise/attestation_sociale_job.rb

10 lines
559 B
Ruby

class ApiEntreprise::AttestationSocialeJob < ApiEntreprise::Job
retry_on ApiEntreprise::API::ServiceUnavailable, wait: 1.day
def perform(etablissement_id, procedure_id)
etablissement = Etablissement.find(etablissement_id)
etablissement_params = ApiEntreprise::AttestationSocialeAdapter.new(etablissement.siret, procedure_id).to_params
attestation_sociale_url = etablissement_params.delete(:entreprise_attestation_sociale_url)
etablissement.upload_attestation_sociale(attestation_sociale_url) if attestation_sociale_url.present?
end
end