From 09128cb85e27aff5cc974c7d6360dde43d4f8710 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 24 Sep 2020 12:02:14 +0200 Subject: [PATCH] Add titre identite champ to GraphQL --- app/graphql/api/v2/schema.rb | 1 + app/graphql/schema.graphql | 27 +++++++++++++++++++ app/graphql/types/champ_type.rb | 2 ++ .../types/champs/titre_identite_champ_type.rb | 16 +++++++++++ .../titre_identite_type_de_champ.rb | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 app/graphql/types/champs/titre_identite_champ_type.rb diff --git a/app/graphql/api/v2/schema.rb b/app/graphql/api/v2/schema.rb index fe527c03c..d734c00d7 100644 --- a/app/graphql/api/v2/schema.rb +++ b/app/graphql/api/v2/schema.rb @@ -50,6 +50,7 @@ class Api::V2::Schema < GraphQL::Schema Types::Champs::RepetitionChampType, Types::Champs::SiretChampType, Types::Champs::TextChampType, + Types::Champs::TitreIdentiteChampType, Types::GeoAreas::ParcelleCadastraleType, Types::GeoAreas::SelectionUtilisateurType, Types::PersonneMoraleType, diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 81b5acf78..859d157ca 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -1197,6 +1197,33 @@ type TextChamp implements Champ { value: String } +type TitreIdentiteChamp implements Champ { + grantType: TitreIdentiteGrantType! + id: ID! + + """ + Libellé du champ. + """ + label: String! + + """ + La valeur du champ sous forme texte. + """ + stringValue: String +} + +enum TitreIdentiteGrantType { + """ + Françe Connect + """ + france_connect + + """ + Pièce justificative + """ + piece_justificative +} + enum TypeDeChamp { """ Adresse diff --git a/app/graphql/types/champ_type.rb b/app/graphql/types/champ_type.rb index 928e5f582..e0cee2ea6 100644 --- a/app/graphql/types/champ_type.rb +++ b/app/graphql/types/champ_type.rb @@ -33,6 +33,8 @@ module Types Types::Champs::LinkedDropDownListChampType when ::Champs::CiviliteChamp Types::Champs::CiviliteChampType + when ::Champs::TitreIdentiteChamp + Types::Champs::TitreIdentiteChampType else Types::Champs::TextChampType end diff --git a/app/graphql/types/champs/titre_identite_champ_type.rb b/app/graphql/types/champs/titre_identite_champ_type.rb new file mode 100644 index 000000000..df137607b --- /dev/null +++ b/app/graphql/types/champs/titre_identite_champ_type.rb @@ -0,0 +1,16 @@ +module Types::Champs + class TitreIdentiteChampType < Types::BaseObject + implements Types::ChampType + + class TitreIdentiteGrantTypeType < Types::BaseEnum + value(TypesDeChamp::TitreIdentiteTypeDeChamp::FRANCE_CONNECT, "Françe Connect") + value(TypesDeChamp::TitreIdentiteTypeDeChamp::PIECE_JUSTIFICATIVE, "Pièce justificative") + end + + field :grant_type, TitreIdentiteGrantTypeType, null: false + + def grant_type + TypesDeChamp::TitreIdentiteTypeDeChamp::PIECE_JUSTIFICATIVE + end + end +end diff --git a/app/models/types_de_champ/titre_identite_type_de_champ.rb b/app/models/types_de_champ/titre_identite_type_de_champ.rb index 7118fed08..febd8e065 100644 --- a/app/models/types_de_champ/titre_identite_type_de_champ.rb +++ b/app/models/types_de_champ/titre_identite_type_de_champ.rb @@ -1,2 +1,4 @@ class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase + FRANCE_CONNECT = 'france_connect' + PIECE_JUSTIFICATIVE = 'piece_justificative' end