add rna type de champ to harmonize api with rnf
This commit is contained in:
parent
a756ab0a63
commit
f09ab62620
8 changed files with 98 additions and 7 deletions
|
@ -63,6 +63,7 @@ class API::V2::Schema < GraphQL::Schema
|
|||
Types::Champs::DepartementChampType,
|
||||
Types::Champs::DossierLinkChampType,
|
||||
Types::Champs::EpciChampType,
|
||||
Types::Champs::RNAChampType,
|
||||
Types::Champs::RNFChampType,
|
||||
Types::Champs::IntegerNumberChampType,
|
||||
Types::Champs::LinkedDropDownListChampType,
|
||||
|
|
|
@ -3620,6 +3620,35 @@ type Query {
|
|||
): GroupeInstructeurWithDossiers!
|
||||
}
|
||||
|
||||
type RNA {
|
||||
address: Address
|
||||
id: String!
|
||||
title: String
|
||||
}
|
||||
|
||||
type RNAChamp implements Champ {
|
||||
commune: Commune
|
||||
departement: Departement
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
prefilled: Boolean!
|
||||
rna: RNA
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
|
||||
"""
|
||||
Date de dernière modification du champ.
|
||||
"""
|
||||
updatedAt: ISO8601DateTime!
|
||||
}
|
||||
|
||||
type RNAChampDescriptor implements ChampDescriptor {
|
||||
"""
|
||||
Description des champs d’un bloc répétable.
|
||||
|
|
|
@ -75,6 +75,8 @@ module Types
|
|||
Types::Champs::TitreIdentiteChampType
|
||||
when ::Champs::EpciChamp
|
||||
Types::Champs::EpciChampType
|
||||
when ::Champs::RNAChamp
|
||||
Types::Champs::RNAChampType
|
||||
when ::Champs::RNFChamp
|
||||
Types::Champs::RNFChampType
|
||||
when ::Champs::EngagementJuridiqueChamp
|
||||
|
|
23
app/graphql/types/champs/rna_champ_type.rb
Normal file
23
app/graphql/types/champs/rna_champ_type.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Types::Champs
|
||||
class RNAChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
class RNAType < Types::BaseObject
|
||||
field :id, String, null: false, method: :value
|
||||
field :title, String, null: true, method: :title
|
||||
field :address, Types::AddressType, null: true, method: :rna_address
|
||||
end
|
||||
|
||||
field :rna, RNAType, null: true
|
||||
field :commune, Types::Champs::CommuneChampType::CommuneType, null: true
|
||||
field :departement, Types::Champs::DepartementChampType::DepartementType, null: true
|
||||
|
||||
def rna_id
|
||||
object.value
|
||||
end
|
||||
|
||||
def rna
|
||||
object if object.value.present?
|
||||
end
|
||||
end
|
||||
end
|
|
@ -24,7 +24,7 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
|||
# see: https://mattermost.incubateur.net/betagouv/pl/r6txumw9cpyx58rt7iq5dte9qe
|
||||
"association_date_declaration" => meta[:date_derniere_mise_a_jour_rna],
|
||||
"association_date_publication" => data[:date_publication_journal_officiel],
|
||||
"address" => data[:adresse_siege]
|
||||
"adresse" => data[:adresse_siege]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,11 +11,6 @@ class Champs::RNAChamp < Champ
|
|||
data&.dig("association_titre")
|
||||
end
|
||||
|
||||
def full_address
|
||||
address = data&.dig("address")
|
||||
"#{address["numero_voie"]} #{address["type_voie"]} #{address["libelle_voie"]} #{address["code_postal"]} #{address["commune"]}"
|
||||
end
|
||||
|
||||
def identifier
|
||||
title.present? ? "#{value} (#{title})" : value
|
||||
end
|
||||
|
@ -27,4 +22,25 @@ class Champs::RNAChamp < Champ
|
|||
def search_terms
|
||||
etablissement.present? ? etablissement.search_terms : [value]
|
||||
end
|
||||
|
||||
def full_address
|
||||
address = data&.dig("adresse")
|
||||
return if address.blank?
|
||||
"#{address["numero_voie"]} #{address["type_voie"]} #{address["libelle_voie"]} #{address["code_postal"]} #{address["commune"]}"
|
||||
end
|
||||
|
||||
def rna_address
|
||||
address = data&.dig("adresse")
|
||||
return if address.blank?
|
||||
{
|
||||
label: full_address,
|
||||
type: "housenumber",
|
||||
street_address: address["libelle_voie"] ? [address["numero_voie"], address["type_voie"], address["libelle_voie"]].compact.join(' ') : nil,
|
||||
street_number: address["numero_voie"],
|
||||
street_name: [address["type_voie"], address["libelle_voie"]].compact.join(' '),
|
||||
postal_code: address["code_postal"],
|
||||
city_name: address["commune"],
|
||||
city_code: address["code_insee"]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,16 @@ describe APIEntreprise::RNAAdapter do
|
|||
expect(subject["association_objet"]).to eq("L'association a pour objet de promouvoir la pratique du sport de haut niveau et de contribuer à la formation des jeunes sportifs.")
|
||||
expect(subject["association_date_declaration"]).to eq("2019-01-01")
|
||||
expect(subject["association_date_publication"]).to eq("2018-01-01")
|
||||
expect(subject["adresse"]).to eq({
|
||||
complement: "",
|
||||
numero_voie: "33",
|
||||
type_voie: "rue",
|
||||
libelle_voie: "de Modagor",
|
||||
distribution: "dummy",
|
||||
code_insee: "75108",
|
||||
code_postal: "75009",
|
||||
commune: "Paris"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,17 @@ RSpec.describe RNAChampAssociationFetchableConcern do
|
|||
"association_date_creation" => "2015-01-01",
|
||||
"association_date_declaration" => "2019-01-01",
|
||||
"association_date_publication" => "2018-01-01",
|
||||
"association_rna" => "W751080001"
|
||||
"association_rna" => "W751080001",
|
||||
"adresse" => {
|
||||
"complement" => "",
|
||||
"numero_voie" => "33",
|
||||
"type_voie" => "rue",
|
||||
"libelle_voie" => "de Modagor",
|
||||
"distribution" => "dummy",
|
||||
"code_insee" => "75108",
|
||||
"code_postal" => "75009",
|
||||
"commune" => "Paris"
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue