Merge pull request #11114 from mfo/US/switch-to-new-rnf-api-endpoint

ETQ ds, j'utilise le nouvel endpoint pour les API rnf
This commit is contained in:
mfo 2024-12-12 14:49:24 +00:00 committed by GitHub
commit fe7c19f1d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 4 deletions

View file

@ -5,13 +5,14 @@ class API::Client
TIMEOUT = 10
def call(url:, params: nil, body: nil, json: nil, headers: nil, method: :get, authorization_token: nil, schema: nil, timeout: TIMEOUT)
def call(url:, params: nil, body: nil, json: nil, headers: nil, method: :get, authorization_token: nil, schema: nil, timeout: TIMEOUT, typhoeus_options: {})
response = case method
when :get
Typhoeus.get(url,
headers: headers_with_authorization(headers, false, authorization_token),
params:,
timeout: TIMEOUT)
timeout: TIMEOUT,
**typhoeus_options)
when :post
Typhoeus.post(url,
headers: headers_with_authorization(headers, json, authorization_token),

View file

@ -4,7 +4,7 @@ class RNFService
include Dry::Monads[:result]
def call(rnf_id:)
result = API::Client.new.(url: "#{url}/#{rnf_id}", schema:)
result = API::Client.new.(url: "#{url}/#{rnf_id}", schema:, headers:, typhoeus_options:)
case result
in Success(body:)
Success(body)
@ -21,6 +21,14 @@ class RNFService
private
def headers
{ Token: ENV['RNF_TOKEN'] }
end
def typhoeus_options
{ ssl_verifyhost: 0 }
end
def schema
JSONSchemer.schema(Rails.root.join('app/schemas/rnf.json'))
end

View file

@ -15,6 +15,9 @@ DS_ENV="staging"
# You know, we are a french team
# TEAM_ON_STRIKE='pas content.'
# RNF auth
RNF_TOKEN=""
# France Connect usage
# FRANCE_CONNECT_ENABLED="disabled" # "enabled" by default
# FC_PARTICULIER_ID=""

View file

@ -9,7 +9,7 @@ API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
API_PARTICULIER_URL = ENV.fetch("API_PARTICULIER_URL", "https://particulier.api.gouv.fr/api")
API_TCHAP_URL = ENV.fetch("API_TCHAP_URL", "https://matrix.agent.tchap.gouv.fr/_matrix/identity/api/v1")
API_COJO_URL = ENV.fetch("API_COJO_URL", nil)
API_RNF_URL = ENV.fetch("API_RNF_URL", "https://rnf.apps.app1.numerique-interieur.com")
API_RNF_URL = ENV.fetch("API_RNF_URL", "https://sir.ines-api-m2m.interieur.gouv.fr/rnf/v1")
API_RECHERCHE_ENTREPRISE_URL = ENV.fetch("API_RECHERCHE_ENTREPRISE_URL", "https://recherche-entreprises.api.gouv.fr")
HELPSCOUT_API_URL = ENV.fetch("HELPSCOUT_API_URL", "https://api.helpscout.net/v2")
SENDINBLUE_API_URL = ENV.fetch("SENDINBLUE_API_URL", "https://in-automate.sendinblue.com/api/v2")