[GraphQL]: informations du demandeur du dossier
This commit is contained in:
parent
04b1879916
commit
fd42fafcb4
11 changed files with 305 additions and 55 deletions
|
@ -26,6 +26,10 @@ class Api::V2::Schema < GraphQL::Schema
|
|||
Types::MessageType
|
||||
when Instructeur, User
|
||||
Types::ProfileType
|
||||
when Individual
|
||||
Types::PersonnePhysiqueType
|
||||
when Etablissement
|
||||
Types::PersonneMoraleType
|
||||
else
|
||||
raise GraphQL::ExecutionError.new("Unexpected object: #{obj}")
|
||||
end
|
||||
|
@ -33,6 +37,7 @@ class Api::V2::Schema < GraphQL::Schema
|
|||
|
||||
orphan_types Types::Champs::CarteChampType,
|
||||
Types::Champs::CheckboxChampType,
|
||||
Types::Champs::CiviliteChampType,
|
||||
Types::Champs::DateChampType,
|
||||
Types::Champs::DecimalNumberChampType,
|
||||
Types::Champs::DossierLinkChampType,
|
||||
|
@ -45,7 +50,9 @@ class Api::V2::Schema < GraphQL::Schema
|
|||
Types::Champs::TextChampType,
|
||||
Types::GeoAreas::ParcelleCadastraleType,
|
||||
Types::GeoAreas::QuartierPrioritaireType,
|
||||
Types::GeoAreas::SelectionUtilisateurType
|
||||
Types::GeoAreas::SelectionUtilisateurType,
|
||||
Types::PersonneMoraleType,
|
||||
Types::PersonnePhysiqueType
|
||||
|
||||
def self.unauthorized_object(error)
|
||||
# Add a top-level error to the response instead of returning nil:
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
type Association {
|
||||
dateCreation: ISO8601Date!
|
||||
dateDeclaration: ISO8601Date!
|
||||
datePublication: ISO8601Date!
|
||||
objet: String!
|
||||
rna: String!
|
||||
titre: String!
|
||||
}
|
||||
|
||||
type Avis {
|
||||
attachmentUrl: URL
|
||||
dateQuestion: ISO8601DateTime!
|
||||
|
@ -76,6 +85,33 @@ type CheckboxChamp implements Champ {
|
|||
value: Boolean!
|
||||
}
|
||||
|
||||
enum Civilite {
|
||||
"""
|
||||
Monsieur
|
||||
"""
|
||||
M
|
||||
|
||||
"""
|
||||
Madame
|
||||
"""
|
||||
Mme
|
||||
}
|
||||
|
||||
type CiviliteChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: Civilite
|
||||
}
|
||||
|
||||
"""
|
||||
GeoJSON coordinates
|
||||
"""
|
||||
|
@ -157,6 +193,10 @@ type DecimalNumberChamp implements Champ {
|
|||
value: Float
|
||||
}
|
||||
|
||||
interface Demandeur {
|
||||
id: ID!
|
||||
}
|
||||
|
||||
"""
|
||||
Une demarche
|
||||
"""
|
||||
|
@ -327,6 +367,7 @@ type Dossier {
|
|||
Date de traitement.
|
||||
"""
|
||||
dateTraitement: ISO8601DateTime
|
||||
demandeur: Demandeur!
|
||||
id: ID!
|
||||
instructeurs: [Profile!]!
|
||||
messages: [Message!]!
|
||||
|
@ -595,6 +636,22 @@ enum DossierState {
|
|||
sans_suite
|
||||
}
|
||||
|
||||
type Entreprise {
|
||||
capitalSocial: Int!
|
||||
codeEffectifEntreprise: String!
|
||||
dateCreation: ISO8601Date!
|
||||
formeJuridique: String!
|
||||
formeJuridiqueCode: String!
|
||||
inlineAdresse: String!
|
||||
nom: String!
|
||||
nomCommercial: String!
|
||||
numeroTvaIntracommunautaire: String!
|
||||
prenom: String!
|
||||
raisonSociale: String!
|
||||
siren: String!
|
||||
siretSiegeSocial: String!
|
||||
}
|
||||
|
||||
interface GeoArea {
|
||||
geometry: GeoJSON!
|
||||
id: ID!
|
||||
|
@ -632,6 +689,11 @@ type GroupeInstructeur {
|
|||
label: String!
|
||||
}
|
||||
|
||||
"""
|
||||
An ISO 8601-encoded date
|
||||
"""
|
||||
scalar ISO8601Date
|
||||
|
||||
"""
|
||||
An ISO 8601-encoded datetime
|
||||
"""
|
||||
|
@ -775,21 +837,32 @@ type ParcelleCadastrale implements GeoArea {
|
|||
surfaceParcelle: Float!
|
||||
}
|
||||
|
||||
type PersonneMorale {
|
||||
type PersonneMorale implements Demandeur {
|
||||
adresse: String!
|
||||
association: Association
|
||||
codeInseeLocalite: String!
|
||||
codePostal: String!
|
||||
complementAdresse: String!
|
||||
entreprise: Entreprise
|
||||
id: ID!
|
||||
libelleNaf: String!
|
||||
localite: String!
|
||||
naf: String!
|
||||
nomVoie: String!
|
||||
numeroVoie: String!
|
||||
siegeSocial: String!
|
||||
siegeSocial: Boolean!
|
||||
siret: String!
|
||||
typeVoie: String!
|
||||
}
|
||||
|
||||
type PersonnePhysique implements Demandeur {
|
||||
civilite: Civilite
|
||||
dateDeNaissance: ISO8601Date
|
||||
id: ID!
|
||||
nom: String!
|
||||
prenom: String!
|
||||
}
|
||||
|
||||
type PieceJustificativeChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ module Types
|
|||
Types::Champs::MultipleDropDownListChampType
|
||||
when ::Champs::LinkedDropDownListChamp
|
||||
Types::Champs::LinkedDropDownListChampType
|
||||
when ::Champs::CiviliteChamp
|
||||
Types::Champs::CiviliteChampType
|
||||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
|
|
7
app/graphql/types/champs/civilite_champ_type.rb
Normal file
7
app/graphql/types/champs/civilite_champ_type.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module Types::Champs
|
||||
class CiviliteChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
field :value, Types::Civilite, null: true
|
||||
end
|
||||
end
|
6
app/graphql/types/civilite.rb
Normal file
6
app/graphql/types/civilite.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
module Types
|
||||
class Civilite < Types::BaseEnum
|
||||
value("M", "Monsieur", value: Individual::GENDER_MALE)
|
||||
value("Mme", "Madame", value: Individual::GENDER_FEMALE)
|
||||
end
|
||||
end
|
18
app/graphql/types/demandeur_type.rb
Normal file
18
app/graphql/types/demandeur_type.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Types
|
||||
module DemandeurType
|
||||
include Types::BaseInterface
|
||||
|
||||
global_id_field :id
|
||||
|
||||
definition_methods do
|
||||
def resolve_type(object, context)
|
||||
case object
|
||||
when Individual
|
||||
Types::PersonnePhysiqueType
|
||||
when Etablissement
|
||||
Types::PersonneMoraleType
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -24,6 +24,8 @@ module Types
|
|||
{ Extensions::Attachment => { attachment: :justificatif_motivation } }
|
||||
]
|
||||
|
||||
field :demandeur, Types::DemandeurType, null: false
|
||||
|
||||
field :usager, Types::ProfileType, null: false
|
||||
field :instructeurs, [Types::ProfileType], null: false
|
||||
|
||||
|
@ -61,6 +63,14 @@ module Types
|
|||
Loaders::Association.for(object.class, :champs_private).load(object)
|
||||
end
|
||||
|
||||
def demandeur
|
||||
if object.procedure.for_individual
|
||||
Loaders::Association.for(object.class, :individual).load(object)
|
||||
else
|
||||
Loaders::Association.for(object.class, :etablissement).load(object)
|
||||
end
|
||||
end
|
||||
|
||||
def self.authorized?(object, context)
|
||||
authorized_demarche?(object.procedure, context)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,34 @@
|
|||
module Types
|
||||
class PersonneMoraleType < Types::BaseObject
|
||||
class EntrepriseType < Types::BaseObject
|
||||
field :siren, String, null: false
|
||||
field :capital_social, Int, null: false
|
||||
field :numero_tva_intracommunautaire, String, null: false
|
||||
field :forme_juridique, String, null: false
|
||||
field :forme_juridique_code, String, null: false
|
||||
field :nom_commercial, String, null: false
|
||||
field :raison_sociale, String, null: false
|
||||
field :siret_siege_social, String, null: false
|
||||
field :code_effectif_entreprise, String, null: false
|
||||
field :date_creation, GraphQL::Types::ISO8601Date, null: false
|
||||
field :nom, String, null: false
|
||||
field :prenom, String, null: false
|
||||
field :inline_adresse, String, null: false
|
||||
end
|
||||
|
||||
class AssociationType < Types::BaseObject
|
||||
field :rna, String, null: false
|
||||
field :titre, String, null: false
|
||||
field :objet, String, null: false
|
||||
field :date_creation, GraphQL::Types::ISO8601Date, null: false
|
||||
field :date_declaration, GraphQL::Types::ISO8601Date, null: false
|
||||
field :date_publication, GraphQL::Types::ISO8601Date, null: false
|
||||
end
|
||||
|
||||
implements Types::DemandeurType
|
||||
|
||||
field :siret, String, null: false
|
||||
field :siege_social, String, null: false
|
||||
field :siege_social, Boolean, null: false
|
||||
field :naf, String, null: false
|
||||
field :libelle_naf, String, null: false
|
||||
field :adresse, String, null: false
|
||||
|
@ -12,5 +39,26 @@ module Types
|
|||
field :code_postal, String, null: false
|
||||
field :localite, String, null: false
|
||||
field :code_insee_localite, String, null: false
|
||||
field :entreprise, EntrepriseType, null: true
|
||||
field :association, AssociationType, null: true
|
||||
|
||||
def entreprise
|
||||
if object.entreprise_siren.present?
|
||||
object.entreprise
|
||||
end
|
||||
end
|
||||
|
||||
def association
|
||||
if object.association?
|
||||
{
|
||||
rna: object.association_rna,
|
||||
titre: object.association_titre,
|
||||
objet: object.association_objet,
|
||||
date_creation: object.association_date_creation,
|
||||
date_declaration: object.association_date_declaration,
|
||||
date_publication: object.association_date_publication
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
app/graphql/types/personne_physique_type.rb
Normal file
10
app/graphql/types/personne_physique_type.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Types
|
||||
class PersonnePhysiqueType < Types::BaseObject
|
||||
implements Types::DemandeurType
|
||||
|
||||
field :nom, String, null: false
|
||||
field :prenom, String, null: false
|
||||
field :civilite, Types::Civilite, null: true, method: :gender
|
||||
field :date_de_naissance, GraphQL::Types::ISO8601Date, null: true, method: :birthdate
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue