Skip to content

Commit

Permalink
Merge pull request #11114 from mfo/US/switch-to-new-rnf-api-endpoint
Browse files Browse the repository at this point in the history
ETQ ds, j'utilise le nouvel endpoint pour les API rnf
  • Loading branch information
mfo authored Dec 12, 2024
2 parents 6e5aa90 + cb2fd59 commit fe7c19f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/lib/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 9 additions & 1 deletion app/services/rnf_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -21,6 +21,14 @@ def call(rnf_id:)

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
Expand Down
3 changes: 3 additions & 0 deletions config/env.example.optional
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/02_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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")
Expand Down

0 comments on commit fe7c19f

Please sign in to comment.