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:
krichtof 2023-11-23 12:55:58 +00:00 committed by GitHub
commit 61654d65a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 0 deletions

View file

@ -63,6 +63,7 @@ class API::V2::Schema < GraphQL::Schema
Types::Champs::DepartementChampType,
Types::Champs::DossierLinkChampType,
Types::Champs::EpciChampType,
Types::Champs::RNFChampType,
Types::Champs::IntegerNumberChampType,
Types::Champs::LinkedDropDownListChampType,
Types::Champs::MultipleDropDownListChampType,

View file

@ -564,6 +564,11 @@ class API::V2::StoredQuery
...PersonneMoraleFragment
}
}
... on RNFChamp {
rnf {
...RNFFragment
}
}
}
fragment PersonneMoraleFragment on PersonneMorale {
@ -666,6 +671,14 @@ class API::V2::StoredQuery
postalCode
}
fragment RNFFragment on RNF {
id
title
address {
...AddressFragment
}
}
fragment PageInfoFragment on PageInfo {
hasPreviousPage
hasNextPage

View file

@ -3582,6 +3582,33 @@ type RNAChampDescriptor implements ChampDescriptor {
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 {
"""
Description des champs dun bloc répétable.

View file

@ -75,6 +75,8 @@ module Types
Types::Champs::TitreIdentiteChampType
when ::Champs::EpciChamp
Types::Champs::EpciChampType
when ::Champs::RNFChamp
Types::Champs::RNFChampType
else
Types::Champs::TextChampType
end

View 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

View file

@ -5,6 +5,10 @@ class Champs::RNFChamp < Champ
external_id
end
def value
rnf_id
end
def fetch_external_data
RNFService.new.(rnf_id:)
end