-
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.
Merge remote-tracking branch 'origin' into settings_for_DC
- Loading branch information
Showing
4 changed files
with
211 additions
and
67 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
56 changes: 56 additions & 0 deletions
56
...ibers/families/notices/faa_totally_ineligible/faa_totally_ineligible_notice_subscriber.rb
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module Subscribers | ||
module Families | ||
module Notices | ||
module FaaTotallyIneligible | ||
# Subscriber will receive response payload from medicaid gateway and generate documents | ||
class FaaTotallyIneligibleNoticeSubscriber | ||
include EventSource::Logging | ||
include ::EventSource::Subscriber[amqp: 'enroll.families.notices.faa_totally_ineligible_notice'] | ||
|
||
subscribe( | ||
:on_enroll_families_notices_faa_totally_ineligible_notice | ||
) do |delivery_info, _metadata, response| | ||
routing_key = delivery_info[:routing_key] | ||
logger.info "Polypress: invoked FaaTotallyIneligibleNoticeSubscriber with delivery_info: #{delivery_info} routing_key: #{routing_key}" | ||
|
||
payload = JSON.parse(response, symbolize_names: true) | ||
results = | ||
MagiMedicaid::GenerateAndPublishEligibilityDocuments.new.call( | ||
{ payload: payload, event_key: routing_key } | ||
) | ||
if results.all?(&:success) | ||
logger.info "Polypress: FaaTotallyIneligibleNoticeSubscriber; acked for #{routing_key}" | ||
else | ||
results | ||
.map(&:failure) | ||
.compact | ||
.each do |result| | ||
errors = | ||
if result.is_a?(String) | ||
result | ||
elsif result.failure.is_a?(String) | ||
result.failure | ||
else | ||
result.failure.errors.to_h | ||
end | ||
logger.error( | ||
"Polypress: FaaTotallyIneligibleNoticeSubscriber_error; | ||
nacked due to:#{errors}; for routing_key: #{routing_key}, payload: #{payload}" | ||
) | ||
end | ||
end | ||
ack(delivery_info.delivery_tag) | ||
rescue StandardError, SystemStackError => e | ||
logger.error( | ||
"Polypress: FaaTotallyIneligibleNoticeSubscriber_error: nacked due to error: #{e}; backtrace: | ||
#{e.backtrace}; for routing_key: #{routing_key}, response: #{response}" | ||
) | ||
ack(delivery_info.delivery_tag) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.