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:
commit
fe7c19f1d9
4 changed files with 16 additions and 4 deletions
|
@ -5,13 +5,14 @@ class API::Client
|
||||||
|
|
||||||
TIMEOUT = 10
|
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
|
response = case method
|
||||||
when :get
|
when :get
|
||||||
Typhoeus.get(url,
|
Typhoeus.get(url,
|
||||||
headers: headers_with_authorization(headers, false, authorization_token),
|
headers: headers_with_authorization(headers, false, authorization_token),
|
||||||
params:,
|
params:,
|
||||||
timeout: TIMEOUT)
|
timeout: TIMEOUT,
|
||||||
|
**typhoeus_options)
|
||||||
when :post
|
when :post
|
||||||
Typhoeus.post(url,
|
Typhoeus.post(url,
|
||||||
headers: headers_with_authorization(headers, json, authorization_token),
|
headers: headers_with_authorization(headers, json, authorization_token),
|
||||||
|
|
|
@ -4,7 +4,7 @@ class RNFService
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
|
|
||||||
def call(rnf_id:)
|
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
|
case result
|
||||||
in Success(body:)
|
in Success(body:)
|
||||||
Success(body)
|
Success(body)
|
||||||
|
@ -21,6 +21,14 @@ class RNFService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def headers
|
||||||
|
{ Token: ENV['RNF_TOKEN'] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def typhoeus_options
|
||||||
|
{ ssl_verifyhost: 0 }
|
||||||
|
end
|
||||||
|
|
||||||
def schema
|
def schema
|
||||||
JSONSchemer.schema(Rails.root.join('app/schemas/rnf.json'))
|
JSONSchemer.schema(Rails.root.join('app/schemas/rnf.json'))
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,9 @@ DS_ENV="staging"
|
||||||
# You know, we are a french team
|
# You know, we are a french team
|
||||||
# TEAM_ON_STRIKE='pas content.'
|
# TEAM_ON_STRIKE='pas content.'
|
||||||
|
|
||||||
|
# RNF auth
|
||||||
|
RNF_TOKEN=""
|
||||||
|
|
||||||
# France Connect usage
|
# France Connect usage
|
||||||
# FRANCE_CONNECT_ENABLED="disabled" # "enabled" by default
|
# FRANCE_CONNECT_ENABLED="disabled" # "enabled" by default
|
||||||
# FC_PARTICULIER_ID=""
|
# FC_PARTICULIER_ID=""
|
||||||
|
|
|
@ -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_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_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_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")
|
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")
|
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")
|
SENDINBLUE_API_URL = ENV.fetch("SENDINBLUE_API_URL", "https://in-automate.sendinblue.com/api/v2")
|
||||||
|
|
Loading…
Reference in a new issue