Class: BenefitsIntake::SubmissionHandler::SavedClaim
- Inherits:
-
Object
- Object
- BenefitsIntake::SubmissionHandler::SavedClaim
- Defined in:
- lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb
Direct Known Subclasses
Dependents::BenefitsIntake::SubmissionHandler, PCPG::BenefitsIntake::SubmissionHandler, VRE::BenefitsIntake::SubmissionHandler
Instance Attribute Summary collapse
-
#additional_context ⇒ Object
readonly
private
Returns the value of attribute additional_context.
-
#call_location ⇒ Object
readonly
private
Returns the value of attribute call_location.
-
#claim ⇒ Object
readonly
private
Returns the value of attribute claim.
-
#context ⇒ Object
readonly
private
Returns the value of attribute context.
Instance Method Summary collapse
-
#claim_class ⇒ Object
private
the type of SavedClaim to be queried.
-
#handle(result, call_location: nil, **additional_context) ⇒ Object
respond to result of a submission status.
-
#initialize(saved_claim_id) ⇒ SavedClaim
constructor
constructor.
-
#monitor ⇒ Object
private
the monitor to be used.
-
#notification_email ⇒ Object
private
the email handler to be used.
-
#on_failure ⇒ Object
private
handle a failure result.
-
#on_stale ⇒ Object
private
handle a stale result.
-
#on_success ⇒ Object
private
handle a success result.
Constructor Details
#initialize(saved_claim_id) ⇒ SavedClaim
constructor
10 11 12 13 14 15 16 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 10 def initialize(saved_claim_id) @claim = claim_class.find(saved_claim_id) @context = { form_id: claim.form_id, claim_id: claim.id } end |
Instance Attribute Details
#additional_context ⇒ Object (readonly, private)
Returns the value of attribute additional_context.
39 40 41 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 39 def additional_context @additional_context end |
#call_location ⇒ Object (readonly, private)
Returns the value of attribute call_location.
39 40 41 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 39 def call_location @call_location end |
#claim ⇒ Object (readonly, private)
Returns the value of attribute claim.
39 40 41 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 39 def claim @claim end |
#context ⇒ Object (readonly, private)
Returns the value of attribute context.
39 40 41 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 39 def context @context end |
Instance Method Details
#claim_class ⇒ Object (private)
the type of SavedClaim to be queried
42 43 44 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 42 def claim_class ::SavedClaim end |
#handle(result, call_location: nil, **additional_context) ⇒ Object
respond to result of a submission status
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 23 def handle(result, call_location: nil, **additional_context) @call_location = call_location @additional_context = context.merge(additional_context) case result when 'failure' on_failure when 'success' on_success when 'stale' on_stale end end |
#monitor ⇒ Object (private)
the monitor to be used
48 49 50 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 48 def monitor @monitor ||= ZeroSilentFailures::Monitor.new('benefits-intake') end |
#notification_email ⇒ Object (private)
the email handler to be used
54 55 56 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 54 def notification_email nil end |
#on_failure ⇒ Object (private)
handle a failure result
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 59 def on_failure avoided = false if notification_email notification_email.deliver(:error) avoided = true elsif claim.respond_to?('send_failure_email') claim.send_failure_email avoided = true end if avoided monitor.log_silent_failure_avoided(additional_context, nil, call_location:) else monitor.log_silent_failure(additional_context, nil, call_location:) end rescue => e @additional_context = additional_context.merge({ message: e. }) monitor.log_silent_failure(additional_context, nil, call_location:) raise e end |
#on_stale ⇒ Object (private)
handle a stale result
86 87 88 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 86 def on_stale true end |
#on_success ⇒ Object (private)
handle a success result
81 82 83 |
# File 'lib/lighthouse/benefits_intake/submission_handler/saved_claim.rb', line 81 def on_success true end |