-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PBP 95481 ZSF VA Email Notification (#19022)
- Loading branch information
1 parent
1673a37
commit b97a189
Showing
15 changed files
with
475 additions
and
90 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
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,72 @@ | ||
# frozen_string_literal: true | ||
|
||
# Library for VA Notify | ||
module VANotify | ||
# module functions for sending a VaNotify notification email | ||
module NotificationEmail | ||
# statsd metric prefix | ||
STATSD = 'api.va_notify.notification_email' | ||
|
||
# notification type constants | ||
module Type | ||
# confirmation | ||
CONFIRMATION = :confirmation | ||
# error | ||
ERROR = :error | ||
# received | ||
RECEIVED = :received | ||
end | ||
|
||
# error indicating failure to send email | ||
class FailureToSend < StandardError; end | ||
|
||
module_function | ||
|
||
# monitor send failure | ||
# | ||
# @param error_message [String] the error message to be logged | ||
# @param tags [Array<String>] array of tags for StatsD; ["tag_name:tag_value", ...] | ||
# @param context [Hash] additional information to send with the log | ||
def monitor_send_failure(error_message, tags:, context: nil) | ||
metric = "#{VANotify::NotificationEmail::STATSD}.send_failure" | ||
payload = { | ||
statsd: metric, | ||
error_message:, | ||
context: | ||
} | ||
|
||
StatsD.increment(metric, tags:) | ||
Rails.logger.error('VANotify::NotificationEmail send failure!', **payload) | ||
end | ||
|
||
# monitor attempting a duplicate notification for the same item | ||
# | ||
# @param tags [Array<String>] array of tags for StatsD; ["tag_name:tag_value", ...] | ||
# @param context [Hash] additional information to send with the log | ||
def monitor_duplicate_attempt(tags:, context: nil) | ||
metric = "#{VANotify::NotificationEmail::STATSD}.duplicate_attempt" | ||
payload = { | ||
statsd: metric, | ||
context: | ||
} | ||
|
||
StatsD.increment(metric, tags:) | ||
Rails.logger.warn('VANotify::NotificationEmail duplicate attempt', **payload) | ||
end | ||
|
||
# monitor delivery successful | ||
# | ||
# @param tags [Array<String>] array of tags for StatsD; ["tag_name:tag_value", ...] | ||
# @param context [Hash] additional information to send with the log | ||
def monitor_deliver_success(tags:, context: nil) | ||
metric = "#{VANotify::NotificationEmail::STATSD}.deliver_success" | ||
payload = { | ||
statsd: metric, | ||
context: | ||
} | ||
|
||
StatsD.increment(metric, tags:) | ||
Rails.logger.info('VANotify::NotificationEmail deliver success!', **payload) | ||
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,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'va_notify/notification_email/saved_claim' | ||
|
||
# Form 21P-530EZ | ||
module Burials | ||
# @see VANotify::NotificationEmail::SavedClaim | ||
class NotificationEmail < ::VANotify::NotificationEmail::SavedClaim | ||
# @see VANotify::NotificationEmail::SavedClaim#new | ||
def initialize(saved_claim) | ||
super(saved_claim, service_name: 'burials') | ||
end | ||
|
||
private | ||
|
||
# @see VANotify::NotificationEmail::SavedClaim#personalization | ||
def personalization | ||
default = super | ||
|
||
facility_name, street_address, city_state_zip = claim.regional_office | ||
veteran_name = "#{claim.veteran_first_name} #{claim.veteran_last_name&.first}" | ||
benefits_claimed = " - #{claim.benefits_claimed.join(" \n - ")}" | ||
|
||
burials = { | ||
'form_name' => 'Burial Benefit Claim (Form 21P-530)', | ||
'deceased_veteran_first_name_last_initial' => veteran_name, | ||
'benefits_claimed' => benefits_claimed, | ||
'facility_name' => facility_name, | ||
'street_address' => street_address, | ||
'city_state_zip' => city_state_zip, | ||
'first_name' => claim.claimaint_first_name&.upcase | ||
} | ||
|
||
default.merge(burials) | ||
end | ||
end | ||
end |
Oops, something went wrong.