parent
75392272fb
commit
a0b53d7d80
6 changed files with 182 additions and 17 deletions
|
@ -39,7 +39,8 @@ class API::V2::Schema < GraphQL::Schema
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
orphan_types Types::Champs::CarteChampType,
|
orphan_types Types::Champs::AddressChampType,
|
||||||
|
Types::Champs::CarteChampType,
|
||||||
Types::Champs::CheckboxChampType,
|
Types::Champs::CheckboxChampType,
|
||||||
Types::Champs::CiviliteChampType,
|
Types::Champs::CiviliteChampType,
|
||||||
Types::Champs::DateChampType,
|
Types::Champs::DateChampType,
|
||||||
|
|
|
@ -1,3 +1,107 @@
|
||||||
|
type Address {
|
||||||
|
"""
|
||||||
|
code INSEE de la commune
|
||||||
|
"""
|
||||||
|
cityCode: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
nom de la commune
|
||||||
|
"""
|
||||||
|
cityName: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
n° de département
|
||||||
|
"""
|
||||||
|
departmentCode: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
nom de département
|
||||||
|
"""
|
||||||
|
departmentName: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
coordonnées géographique
|
||||||
|
"""
|
||||||
|
geometry: GeoJSON
|
||||||
|
|
||||||
|
"""
|
||||||
|
libellé complet de l’adresse
|
||||||
|
"""
|
||||||
|
label: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
code postal
|
||||||
|
"""
|
||||||
|
postalCode: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
n° de region
|
||||||
|
"""
|
||||||
|
regionCode: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
nom de région
|
||||||
|
"""
|
||||||
|
regionName: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
numéro éventuel et nom de voie ou lieu dit
|
||||||
|
"""
|
||||||
|
streetAddress: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
nom de voie ou lieu dit
|
||||||
|
"""
|
||||||
|
streetName: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
numéro avec indice de répétition éventuel (bis, ter, A, B)
|
||||||
|
"""
|
||||||
|
streetNumber: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
type de résultat trouvé
|
||||||
|
"""
|
||||||
|
type: AddressType!
|
||||||
|
}
|
||||||
|
|
||||||
|
type AddressChamp implements Champ {
|
||||||
|
address: Address
|
||||||
|
id: ID!
|
||||||
|
|
||||||
|
"""
|
||||||
|
Libellé du champ.
|
||||||
|
"""
|
||||||
|
label: String!
|
||||||
|
|
||||||
|
"""
|
||||||
|
La valeur du champ sous forme texte.
|
||||||
|
"""
|
||||||
|
stringValue: String
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AddressType {
|
||||||
|
"""
|
||||||
|
numéro « à la plaque »
|
||||||
|
"""
|
||||||
|
housenumber
|
||||||
|
|
||||||
|
"""
|
||||||
|
lieu-dit
|
||||||
|
"""
|
||||||
|
locality
|
||||||
|
|
||||||
|
"""
|
||||||
|
numéro « à la commune »
|
||||||
|
"""
|
||||||
|
municipality
|
||||||
|
|
||||||
|
"""
|
||||||
|
position « à la voie », placé approximativement au centre de celle-ci
|
||||||
|
"""
|
||||||
|
street
|
||||||
|
}
|
||||||
|
|
||||||
type Association {
|
type Association {
|
||||||
dateCreation: ISO8601Date!
|
dateCreation: ISO8601Date!
|
||||||
dateDeclaration: ISO8601Date!
|
dateDeclaration: ISO8601Date!
|
||||||
|
@ -1362,21 +1466,22 @@ type ParcelleCadastrale implements GeoArea {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PersonneMorale implements Demandeur {
|
type PersonneMorale implements Demandeur {
|
||||||
adresse: String!
|
address: Address!
|
||||||
|
adresse: String! @deprecated(reason: "Utilisez le champ `address.label` à la place.")
|
||||||
association: Association
|
association: Association
|
||||||
codeInseeLocalite: String!
|
codeInseeLocalite: String! @deprecated(reason: "Utilisez le champ `address.city_code` à la place.")
|
||||||
codePostal: String!
|
codePostal: String! @deprecated(reason: "Utilisez le champ `address.postal_code` à la place.")
|
||||||
complementAdresse: String
|
complementAdresse: String @deprecated(reason: "Utilisez le champ `address` à la place.")
|
||||||
entreprise: Entreprise
|
entreprise: Entreprise
|
||||||
id: ID!
|
id: ID!
|
||||||
libelleNaf: String!
|
libelleNaf: String!
|
||||||
localite: String!
|
localite: String! @deprecated(reason: "Utilisez le champ `address.city_name` à la place.")
|
||||||
naf: String!
|
naf: String!
|
||||||
nomVoie: String
|
nomVoie: String @deprecated(reason: "Utilisez le champ `address.street_name` à la place.")
|
||||||
numeroVoie: String
|
numeroVoie: String @deprecated(reason: "Utilisez le champ `address.street_number` à la place.")
|
||||||
siegeSocial: Boolean!
|
siegeSocial: Boolean!
|
||||||
siret: String!
|
siret: String!
|
||||||
typeVoie: String
|
typeVoie: String @deprecated(reason: "Utilisez le champ `address.street_address` à la place.")
|
||||||
}
|
}
|
||||||
|
|
||||||
type PersonnePhysique implements Demandeur {
|
type PersonnePhysique implements Demandeur {
|
||||||
|
|
29
app/graphql/types/address_type.rb
Normal file
29
app/graphql/types/address_type.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
module Types
|
||||||
|
class AddressType < Types::BaseObject
|
||||||
|
class AddressTypeType < Types::BaseEnum
|
||||||
|
value(:housenumber, "numéro « à la plaque »", value: :housenumber)
|
||||||
|
value(:street, "position « à la voie », placé approximativement au centre de celle-ci", value: :street)
|
||||||
|
value(:municipality, "numéro « à la commune »", value: :municipality)
|
||||||
|
value(:locality, "lieu-dit", value: :locality)
|
||||||
|
end
|
||||||
|
|
||||||
|
field :label, String, "libellé complet de l’adresse", null: false
|
||||||
|
field :type, AddressTypeType, "type de résultat trouvé", null: false
|
||||||
|
|
||||||
|
field :street_address, String, "numéro éventuel et nom de voie ou lieu dit", null: false
|
||||||
|
field :street_number, String, "numéro avec indice de répétition éventuel (bis, ter, A, B)", null: true
|
||||||
|
field :street_name, String, "nom de voie ou lieu dit", null: true
|
||||||
|
|
||||||
|
field :postal_code, String, "code postal", null: false
|
||||||
|
field :city_name, String, "nom de la commune", null: false
|
||||||
|
field :city_code, String, "code INSEE de la commune", null: false
|
||||||
|
|
||||||
|
field :department_name, String, "nom de département", null: true
|
||||||
|
field :department_code, String, "n° de département", null: true
|
||||||
|
|
||||||
|
field :region_name, String, "nom de région", null: true
|
||||||
|
field :region_code, String, "n° de region", null: true
|
||||||
|
|
||||||
|
field :geometry, Types::GeoJSON, "coordonnées géographique", null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,6 +9,12 @@ module Types
|
||||||
definition_methods do
|
definition_methods do
|
||||||
def resolve_type(object, context)
|
def resolve_type(object, context)
|
||||||
case object
|
case object
|
||||||
|
when ::Champs::AddressChamp
|
||||||
|
if context.has_fragment?(:AddressChamp)
|
||||||
|
Types::Champs::AddressChampType
|
||||||
|
else
|
||||||
|
Types::Champs::TextChampType
|
||||||
|
end
|
||||||
when ::Champs::EngagementChamp, ::Champs::YesNoChamp, ::Champs::CheckboxChamp
|
when ::Champs::EngagementChamp, ::Champs::YesNoChamp, ::Champs::CheckboxChamp
|
||||||
Types::Champs::CheckboxChampType
|
Types::Champs::CheckboxChampType
|
||||||
when ::Champs::DateChamp
|
when ::Champs::DateChamp
|
||||||
|
|
7
app/graphql/types/champs/address_champ_type.rb
Normal file
7
app/graphql/types/champs/address_champ_type.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module Types::Champs
|
||||||
|
class AddressChampType < Types::BaseObject
|
||||||
|
implements Types::ChampType
|
||||||
|
|
||||||
|
field :address, Types::AddressType, null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -86,17 +86,34 @@ module Types
|
||||||
field :siege_social, Boolean, null: false
|
field :siege_social, Boolean, null: false
|
||||||
field :naf, String, null: false
|
field :naf, String, null: false
|
||||||
field :libelle_naf, String, null: false
|
field :libelle_naf, String, null: false
|
||||||
field :adresse, String, null: false
|
|
||||||
field :numero_voie, String, null: true
|
field :address, Types::AddressType, null: false
|
||||||
field :type_voie, String, null: true
|
|
||||||
field :nom_voie, String, null: true
|
|
||||||
field :complement_adresse, String, null: true
|
|
||||||
field :code_postal, String, null: false
|
|
||||||
field :localite, String, null: false
|
|
||||||
field :code_insee_localite, String, null: false
|
|
||||||
field :entreprise, EntrepriseType, null: true
|
field :entreprise, EntrepriseType, null: true
|
||||||
field :association, AssociationType, null: true
|
field :association, AssociationType, null: true
|
||||||
|
|
||||||
|
field :adresse, String, null: false, deprecation_reason: "Utilisez le champ `address.label` à la place."
|
||||||
|
field :numero_voie, String, null: true, deprecation_reason: "Utilisez le champ `address.street_number` à la place."
|
||||||
|
field :type_voie, String, null: true, deprecation_reason: "Utilisez le champ `address.street_address` à la place."
|
||||||
|
field :nom_voie, String, null: true, deprecation_reason: "Utilisez le champ `address.street_name` à la place."
|
||||||
|
field :code_postal, String, null: false, deprecation_reason: "Utilisez le champ `address.postal_code` à la place."
|
||||||
|
field :localite, String, null: false, deprecation_reason: "Utilisez le champ `address.city_name` à la place."
|
||||||
|
field :code_insee_localite, String, null: false, deprecation_reason: "Utilisez le champ `address.city_code` à la place."
|
||||||
|
field :complement_adresse, String, null: true, deprecation_reason: "Utilisez le champ `address` à la place."
|
||||||
|
|
||||||
|
def address
|
||||||
|
{
|
||||||
|
label: object.adresse,
|
||||||
|
type: :housenumber,
|
||||||
|
street_number: object.numero_voie,
|
||||||
|
street_name: object.nom_voie,
|
||||||
|
street_address: object.nom_voie.present? ? [object.numero_voie, object.type_voie, object.nom_voie].compact.join(' ') : nil,
|
||||||
|
postal_code: object.code_postal,
|
||||||
|
city_name: object.localite,
|
||||||
|
city_code: object.code_insee_localite
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def entreprise
|
def entreprise
|
||||||
if object.entreprise_siren.present?
|
if object.entreprise_siren.present?
|
||||||
object.entreprise
|
object.entreprise
|
||||||
|
|
Loading…
Reference in a new issue