Merge pull request #9740 from demarches-simplifiees/9670-expose-rnf-api
En tant que consommateur de l'API DS, je peux récupérer les infos RNF
This commit is contained in:
commit
61654d65a2
6 changed files with 92 additions and 0 deletions
|
@ -63,6 +63,7 @@ class API::V2::Schema < GraphQL::Schema
|
||||||
Types::Champs::DepartementChampType,
|
Types::Champs::DepartementChampType,
|
||||||
Types::Champs::DossierLinkChampType,
|
Types::Champs::DossierLinkChampType,
|
||||||
Types::Champs::EpciChampType,
|
Types::Champs::EpciChampType,
|
||||||
|
Types::Champs::RNFChampType,
|
||||||
Types::Champs::IntegerNumberChampType,
|
Types::Champs::IntegerNumberChampType,
|
||||||
Types::Champs::LinkedDropDownListChampType,
|
Types::Champs::LinkedDropDownListChampType,
|
||||||
Types::Champs::MultipleDropDownListChampType,
|
Types::Champs::MultipleDropDownListChampType,
|
||||||
|
|
|
@ -564,6 +564,11 @@ class API::V2::StoredQuery
|
||||||
...PersonneMoraleFragment
|
...PersonneMoraleFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
... on RNFChamp {
|
||||||
|
rnf {
|
||||||
|
...RNFFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment PersonneMoraleFragment on PersonneMorale {
|
fragment PersonneMoraleFragment on PersonneMorale {
|
||||||
|
@ -666,6 +671,14 @@ class API::V2::StoredQuery
|
||||||
postalCode
|
postalCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment RNFFragment on RNF {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
address {
|
||||||
|
...AddressFragment
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fragment PageInfoFragment on PageInfo {
|
fragment PageInfoFragment on PageInfo {
|
||||||
hasPreviousPage
|
hasPreviousPage
|
||||||
hasNextPage
|
hasNextPage
|
||||||
|
|
|
@ -3582,6 +3582,33 @@ type RNAChampDescriptor implements ChampDescriptor {
|
||||||
type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.")
|
type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RNF {
|
||||||
|
address: Address
|
||||||
|
id: String!
|
||||||
|
title: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type RNFChamp implements Champ {
|
||||||
|
id: ID!
|
||||||
|
|
||||||
|
"""
|
||||||
|
Libellé du champ.
|
||||||
|
"""
|
||||||
|
label: String!
|
||||||
|
prefilled: Boolean!
|
||||||
|
rnf: RNF
|
||||||
|
|
||||||
|
"""
|
||||||
|
La valeur du champ sous forme texte.
|
||||||
|
"""
|
||||||
|
stringValue: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Date de dernière modification du champ.
|
||||||
|
"""
|
||||||
|
updatedAt: ISO8601DateTime!
|
||||||
|
}
|
||||||
|
|
||||||
type RNFChampDescriptor implements ChampDescriptor {
|
type RNFChampDescriptor implements ChampDescriptor {
|
||||||
"""
|
"""
|
||||||
Description des champs d’un bloc répétable.
|
Description des champs d’un bloc répétable.
|
||||||
|
|
|
@ -75,6 +75,8 @@ module Types
|
||||||
Types::Champs::TitreIdentiteChampType
|
Types::Champs::TitreIdentiteChampType
|
||||||
when ::Champs::EpciChamp
|
when ::Champs::EpciChamp
|
||||||
Types::Champs::EpciChampType
|
Types::Champs::EpciChampType
|
||||||
|
when ::Champs::RNFChamp
|
||||||
|
Types::Champs::RNFChampType
|
||||||
else
|
else
|
||||||
Types::Champs::TextChampType
|
Types::Champs::TextChampType
|
||||||
end
|
end
|
||||||
|
|
45
app/graphql/types/champs/rnf_champ_type.rb
Normal file
45
app/graphql/types/champs/rnf_champ_type.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
module Types::Champs
|
||||||
|
class RNFChampType < Types::BaseObject
|
||||||
|
implements Types::ChampType
|
||||||
|
|
||||||
|
class RNFType < Types::BaseObject
|
||||||
|
field :id, String, null: false
|
||||||
|
field :title, String, null: true
|
||||||
|
field :address, Types::AddressType, null: true
|
||||||
|
|
||||||
|
def id
|
||||||
|
object.value
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
object.data["title"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def address
|
||||||
|
address = object.data["address"]
|
||||||
|
if address
|
||||||
|
{
|
||||||
|
label: address["label"],
|
||||||
|
type: address["type"],
|
||||||
|
street_address: address["streetAddress"],
|
||||||
|
street_number: address["streetNumber"],
|
||||||
|
street_name: address["streetName"],
|
||||||
|
postal_code: address["postalCode"],
|
||||||
|
city_name: address["cityName"],
|
||||||
|
city_code: address["cityCode"],
|
||||||
|
department_name: address["departmentName"],
|
||||||
|
department_code: address["departmentCode"],
|
||||||
|
region_name: address["regionName"],
|
||||||
|
region_code: address["regionCode"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
field :rnf, RNFType, null: true
|
||||||
|
|
||||||
|
def rnf
|
||||||
|
object if object.external_id.present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,6 +5,10 @@ class Champs::RNFChamp < Champ
|
||||||
external_id
|
external_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def value
|
||||||
|
rnf_id
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_external_data
|
def fetch_external_data
|
||||||
RNFService.new.(rnf_id:)
|
RNFService.new.(rnf_id:)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue