Merge pull request #5118 from betagouv/5116-expose-attestations

API expose désormais attestationSocialeAttachment et attestationFiscaleAttachment
This commit is contained in:
krichtof 2020-05-06 17:42:55 +02:00 committed by GitHub
commit 083a33bd23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View file

@ -692,6 +692,8 @@ type Effectif {
} }
type Entreprise { type Entreprise {
attestationFiscaleAttachment: File
attestationSocialeAttachment: File
capitalSocial: BigInt! capitalSocial: BigInt!
codeEffectifEntreprise: String! codeEffectifEntreprise: String!
dateCreation: ISO8601Date! dateCreation: ISO8601Date!

View file

@ -21,6 +21,16 @@ module Types
field :nom, String, null: false field :nom, String, null: false
field :prenom, String, null: false field :prenom, String, null: false
field :inline_adresse, String, null: false field :inline_adresse, String, null: false
field :attestation_sociale_attachment, Types::File, null: true
field :attestation_fiscale_attachment, Types::File, null: true
def attestation_sociale_attachment
load_attachment_for(:entreprise_attestation_sociale_attachment)
end
def attestation_fiscale_attachment
load_attachment_for(:entreprise_attestation_fiscale_attachment)
end
def effectif_mensuel def effectif_mensuel
if object.effectif_mensuel.present? if object.effectif_mensuel.present?
@ -39,6 +49,15 @@ module Types
} }
end end
end end
private
def load_attachment_for(key)
Loaders::Association.for(
Etablissement,
key => :blob
).load(object.etablissement)
end
end end
class AssociationType < Types::BaseObject class AssociationType < Types::BaseObject

View file

@ -3,6 +3,7 @@ class Entreprise < Hashie::Dash
self[attribute] self[attribute]
end end
property :etablissement
property :siren property :siren
property :capital_social property :capital_social
property :numero_tva_intracommunautaire property :numero_tva_intracommunautaire

View file

@ -96,6 +96,7 @@ class Etablissement < ApplicationRecord
def entreprise def entreprise
Entreprise.new( Entreprise.new(
etablissement: self,
siren: entreprise_siren, siren: entreprise_siren,
capital_social: entreprise_capital_social, capital_social: entreprise_capital_social,
numero_tva_intracommunautaire: entreprise_numero_tva_intracommunautaire, numero_tva_intracommunautaire: entreprise_numero_tva_intracommunautaire,