-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Active l'abonnement HubEE et ajoute la collectivité sur FQF
Les abonnements HubEE doivent être créées avant d'être activés, ce commit met en place cette séparation. Pour associer un éditeur le webhook envoie maintenant le service_provider associé à la demande (stocké dans extra_infos). Une méthode pour récupérer un abonnement existant a aussi été ajoutée pour rendre le webhook plus robuste. La collectivité est aussi créée du côté du FormulaireQF.
- Loading branch information
Showing
17 changed files
with
195 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class FormulaireQFAPIClient | ||
def create_collectivity(authorization_request) | ||
organization = authorization_request.organization | ||
editor_name = authorization_request.extra_infos.dig('service_provider', 'id') | ||
|
||
params = { | ||
siret: organization.siret, | ||
code_cog: organization.code_commune_etablissement, | ||
departement: organization.code_postal_etablissement[0..1], | ||
name: organization.denomination, | ||
status: 'active', | ||
editor: editor_name | ||
} | ||
|
||
http_connection.post("#{host}/api/collectivites", params.to_json) | ||
end | ||
|
||
private | ||
|
||
def host | ||
Rails.application.credentials.formulaire_qf.host | ||
end | ||
|
||
def http_connection(&block) | ||
Faraday.new do |conn| | ||
conn.headers['Content-Type'] = 'application/json' | ||
conn.request :authorization, 'Bearer', -> { secret } | ||
yield(conn) if block | ||
end | ||
end | ||
|
||
def secret | ||
Rails.application.credentials.formulaire_qf.secret | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class CreateFormulaireQFCollectivityJob < ApplicationJob | ||
def perform(authorization_request_id) | ||
authorization_request = AuthorizationRequest.find(authorization_request_id) | ||
FormulaireQFAPIClient.new.create_collectivity(authorization_request) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
zCEivVYu4bj2l1LSnXFlbXhTNV5NFRoA09/3q+9PwPcEtrLMZBIlr31hs0yWzXvWluCqNoH9N5ybeYGX28UgZhJypoURARvO9LK27B59a+e/uv5KMAAPmVkVlCe/TBHnFbBGnFzJWs/T4JziOAkJc1pTLRFMDv5RbFCC3rz9NPo469N2zl9U+44waK6UBdONwJn6Af/SEa0Ay7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E8EU43byA/vtHiVRjZ1bF23Hiiyq9XWchS--1iVrN2uZYhSZST7Q--wTX5GsuCHbFXF8Ki2bYStA== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe CreateFormulaireQFCollectivityJob, type: :job do | ||
describe '#perform' do | ||
subject(:job) { described_class.perform_now(authorization_request.id) } | ||
|
||
let(:api_client) { instance_double(FormulaireQFAPIClient) } | ||
let(:authorization_request) { create(:authorization_request, :with_demandeur, api: 'particulier') } | ||
|
||
before do | ||
allow(FormulaireQFAPIClient).to receive(:new).and_return(api_client) | ||
end | ||
|
||
it 'creates collectivity on Formulaire QF' do | ||
expect(api_client).to receive(:create_collectivity).with(authorization_request) | ||
|
||
job | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.