-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
1,324 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--require spec_helper |
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 |
---|---|---|
@@ -1,4 +1,28 @@ | ||
class ClaimsController < ApplicationController | ||
def index | ||
end | ||
|
||
def quotient_familial | ||
result = GetFamilyQuotient.call(identity: Current.user) | ||
|
||
if result.success? | ||
session["qf"] = result.qf | ||
Current.quotient_familial = result.qf | ||
else | ||
raise | ||
end | ||
end | ||
|
||
def send_qf | ||
recipient = Hubee::Recipient.new(siren: "21040107100019", branch_code: "04107") | ||
|
||
result = StoreQuotientFamilial.call(identity: Current.user, quotient_familial: Current.quotient_familial, recipient: recipient) | ||
|
||
if result.success? | ||
Rails.logger.debug "Noïce" | ||
@folder = result.folder | ||
else | ||
raise | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class BaseInteractor | ||
include Interactor | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class BaseOrganizer | ||
include Interactor::Organizer | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class GetFamilyQuotient < BaseInteractor | ||
def call | ||
context.qf = { | ||
regime: "CNAF", | ||
enfants: [ | ||
{ | ||
nomNaissance: "ROUX", | ||
nomUsage: "ROUX", | ||
prenoms: "ALEXIS VINCENT", | ||
anneeDateDeNaissance: "2006", | ||
moisDateDeNaissance: "04", | ||
jourDateDeNaissance: "20", | ||
sexe: "M", | ||
}, | ||
], | ||
quotientFamilial: 2550, | ||
annee: 2024, | ||
mois: 2, | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Hubee::CleanAttachments < BaseInteractor | ||
def call | ||
context.folder.attachments.each do |attachment| | ||
attachment.close_file | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Hubee::Create < BaseInteractor | ||
before do | ||
context.session ||= Hubee::Api.session | ||
end | ||
|
||
def call | ||
context.folder = context.session.create_folder(folder: context.folder) | ||
end | ||
|
||
def rollback | ||
context.session.delete_folder(folder_id: context.folder.id) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Hubee | ||
class CreateFolder < BaseOrganizer | ||
organize PrepareFolder, PrepareAttachments, Create, UploadAttachments, MarkFolderComplete, CleanAttachments | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Hubee::MarkFolderComplete < BaseInteractor | ||
def call | ||
context.session.mark_folder_complete(folder_id: context.folder.id) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class Hubee::PrepareAttachments < BaseInteractor | ||
def call | ||
context.folder = context.folder.with(attachments:) | ||
end | ||
|
||
def rollback | ||
context.folder.attachments.each do |attachment| | ||
attachment.close_file | ||
end | ||
end | ||
|
||
private | ||
|
||
def attachments | ||
context.folder.attachments.map do |attachment| | ||
file = Tempfile.create | ||
file.write(attachment.file_content) | ||
file.rewind | ||
attachment.with(file:, file_size: file.size) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Hubee::PrepareFolder < BaseInteractor | ||
def call | ||
context.folder = ::Hubee::Folder.new(**folder_params) | ||
end | ||
|
||
private | ||
|
||
def case_external_id | ||
@case_external_id ||= "#{external_id}-01" | ||
end | ||
|
||
def external_id | ||
# HubEE's portal view greps 13 chars after two dashes | ||
@external_id ||= "Formulaire-QF-#{SecureRandom.hex[0...13].upcase}" | ||
end | ||
|
||
def folder_params | ||
{ | ||
applicant: context.identity, | ||
attachments: [ | ||
json_file, | ||
text_file, | ||
], | ||
cases: [ | ||
external_id: case_external_id, | ||
recipient: context.recipient, | ||
], | ||
external_id:, | ||
process_code:, | ||
} | ||
end | ||
|
||
def json_file | ||
::Hubee::Attachment.new( | ||
file_name: "FormulaireQF.json", | ||
mime_type: "application/json", | ||
recipients: [case_external_id], | ||
type: process_code, | ||
file_content: '{"identite": "pivot"}' | ||
) | ||
end | ||
|
||
def process_code | ||
"FormulaireQF" | ||
end | ||
|
||
def text_file | ||
::Hubee::Attachment.new( | ||
file_name: "FormulaireQF.pdf", | ||
mime_type: "application/pdf", | ||
recipients: [case_external_id], | ||
type: process_code, | ||
file_content: "Identité pivot" | ||
) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Hubee::UploadAttachments < BaseInteractor | ||
def call | ||
context.folder.attachments.each do |attachment| | ||
context.session.upload_attachment(folder_id: context.folder.id, attachment:) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class StoreQuotientFamilial < BaseOrganizer | ||
organize Hubee::CreateFolder | ||
end |
Oops, something went wrong.