-
Notifications
You must be signed in to change notification settings - Fork 0
decouple ssavlp error handling #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4b5e674
handle vlp transformation failure by updating the transmittable objects
charlienparker 2e15f07
allow ssa/vlp requests to fail piecemeal
charlienparker dff682a
remove response transmission/transaction params from processor module
charlienparker 02f7927
add new module to be shared across request/response processors to con…
charlienparker 0c5f669
add spec coverage, fix non-monad return of handle_failed_transaction …
charlienparker 7bd4826
fix determined applicant tracking
charlienparker ae44f1a
modify determined applicants in place
charlienparker 695c366
add spec for process_applicant_responses
charlienparker 75c4984
lint fixes
charlienparker d07500a
remove response helper
charlienparker 48aec5e
fix arity mismatch
charlienparker c65261d
remove comments
charlienparker 49513b9
introduce intermediate orchestrator to dry constant usage while allow…
charlienparker 834db41
use attr_reader for service_name member, other lint fixes
charlienparker c6f536e
remove required relative
charlienparker 243929a
add spec for new orchestrator
charlienparker d1ebf71
lint fix
charlienparker 0edff47
fix validation by removing transmission
charlienparker bfdafb9
lint fix
charlienparker 39d7657
more spec fixes
charlienparker 636fa51
only fail on true requested failures
charlienparker 9bcf326
remove transmission
charlienparker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
83 changes: 83 additions & 0 deletions
83
app/operations/fdsh/ssa_vlp/rj3/process_applicant_response.rb
This file contains hidden or 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,83 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Fdsh | ||
| module SsaVlp | ||
| module Rj3 | ||
| # This class processes a single applicant's verification response for a specific service (SSA or VLP). | ||
| # It handles transaction fetching, skip logic, tracking, and delegates to the appropriate processor. | ||
| class ProcessApplicantResponse | ||
| include Dry::Monads[:result, :do, :try] | ||
| include ServiceConstants | ||
|
|
||
| SERVICE_CONFIGURATION = { | ||
| "SSA" => Fdsh::SsaVlp::Rj3::Ssa::ProcessVerificationResponse, | ||
| "VLP" => Fdsh::SsaVlp::Rj3::Vlp::ProcessVerificationResponse | ||
| }.freeze | ||
|
|
||
| def call(params) | ||
| yield validate_params(params) | ||
|
|
||
| request_transaction, response_transaction = fetch_transactions | ||
| return Success(@application_hash) if applicant_unrequested?(request_transaction, response_transaction) | ||
|
|
||
| track_applicant_determination(response_transaction) | ||
|
|
||
| result = yield process_verification_response(request_transaction, response_transaction) | ||
| Success(result) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def validate_params(params) | ||
| return Failure('Application hash not provided') unless params[:application_hash] | ||
| return Failure('Applicant not provided') unless params[:applicant] | ||
| return Failure('Application type not provided') unless params[:application_type] | ||
| return Failure('Service name not provided') unless params[:service_name] | ||
| return Failure('Determined applicants hash not provided') unless params[:determined_applicants] | ||
| return Failure('Invalid service name') unless SERVICE_CONFIGURATION.key?(params[:service_name]) | ||
|
|
||
| @application_hash = params[:application_hash] | ||
| @applicant = params[:applicant] | ||
| @application_type = params[:application_type] | ||
| @service_name = params[:service_name] | ||
| @determined_applicants = params[:determined_applicants] | ||
|
|
||
| Success(params) | ||
| end | ||
|
|
||
| def fetch_transactions | ||
| request_transaction = @applicant.transactions.where(key: request_key).last | ||
| response_transaction = @applicant.transactions.where(key: response_key).last | ||
| [request_transaction, response_transaction] | ||
| end | ||
|
|
||
| def applicant_unrequested?(request_transaction, response_transaction) | ||
| request_transaction.nil? && response_transaction.nil? | ||
| end | ||
|
|
||
| def track_applicant_determination(response_transaction) | ||
| return unless @applicant.hbx_id | ||
| return unless response_transaction&.process_status&.latest_state == :succeeded | ||
|
|
||
| service_key = @service_name.downcase.to_sym | ||
| @determined_applicants[service_key] ||= [] | ||
| @determined_applicants[service_key] << @applicant.hbx_id | ||
| end | ||
|
|
||
| def process_verification_response(request_transaction, response_transaction) | ||
| processor_class = SERVICE_CONFIGURATION[@service_name] | ||
|
|
||
| processor_class.new.call( | ||
| application_hash: @application_hash, | ||
| applicant: @applicant, | ||
| application_type: @application_type, | ||
| request_transaction: request_transaction, | ||
| response_transaction: response_transaction | ||
| ) | ||
| end | ||
|
|
||
| attr_reader :service_name | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,29 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Fdsh | ||
| module SsaVlp | ||
| module Rj3 | ||
| # This module contains service constants for SSA and VLP verification processing. | ||
| module ServiceConstants | ||
| private | ||
|
|
||
| def base_transaction_key | ||
| case service_name | ||
| when "SSA" | ||
| :ssa_verification | ||
| when "VLP" | ||
| :vlp_verification | ||
| end | ||
| end | ||
|
|
||
| def request_key | ||
| :"#{base_transaction_key}_request" | ||
| end | ||
|
|
||
| def response_key | ||
| :"#{base_transaction_key}_response" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.