Skip to content

Commit

Permalink
add email content and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tycol7 committed Nov 12, 2024
1 parent 8766401 commit dfd3a2d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
6 changes: 4 additions & 2 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,10 @@ claims_api:
poa_v2:
disable_jobs: false
vanotify:
representative_template_id: ~
service_organization_template_id: ~
accepted_representative_template_id: ~
accepted_service_organization_template_id: ~
declined_representative_template_id: ~
declined_service_organization_template_id: ~
services:
lighthouse:
api_key: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def individual_accepted_email_contents(poa, rep)
email: value_or_default_for_field(rep.email),
phone: rep_phone(rep)
},
template_id: Settings.claims_api.vanotify.representative_template_id
template_id: Settings.claims_api.vanotify.accepted_representative_template_id
}
end

Expand All @@ -78,7 +78,7 @@ def organization_accepted_email_contents(poa, org)
location: value_or_default_for_field(org_location(org)),
phone: value_or_default_for_field(org.phone)
},
template_id: Settings.claims_api.vanotify.service_organization_template_id
template_id: Settings.claims_api.vanotify.accepted_service_organization_template_id
}
end

Expand Down
41 changes: 19 additions & 22 deletions modules/claims_api/app/sidekiq/claims_api/va_notify_declined_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ClaimsApi
class VANotifyDeclinedJob < ClaimsApi::ServiceBase
LOG_TAG = 'va_notify_declined_job'

def perform(poa_id, rep)
def perform(poa_id)
return if Rails.env.test?

poa = ClaimsApi::PowerOfAttorney.find(poa_id)
Expand All @@ -16,7 +16,7 @@ def perform(poa_id, rep)
end

begin
res = send_declined_notification(poa, rep)
res = send_declined_notification(poa)

ClaimsApi::VANotifyFollowUpJob.perform_async(res.id) if res.present?
rescue => e
Expand All @@ -34,49 +34,46 @@ def perform(poa_id, rep)

private

def send_declined_notification(poa, rep)
form_data = poa.form_data
def send_declined_notification(poa)
return send_organization_notification(poa) if poa.form_data['serviceOrganization'].present?

if form_data['serviceOrganization']
poa_code = form_data['serviceOrganization']['poaCode']
org = ::Veteran::Service::Organization.find_by(poa: poa_code)

return send_organization_notification(poa, org)
end

send_representative_notification(poa, rep)
send_representative_notification(poa)
end

# TODO: Discover if we need org
def send_organization_notification(poa, _org)
def send_organization_notification(poa)
content = {
recipient_identifier: recipient_identifier(poa),
personalisation: {
first_name: poa.auth_headers['va_eauth_firstName'] || '',
form_type: 'TODO' # TODO: Add form type, i.e., VSO or Individual
form_type: "Appointment of Veterans Service Organization as Claimant's Representative (VA Form 21-22)"
},
template_id: Settings.claims_api.vanotify.organization_declined_template_id
template_id: Settings.claims_api.vanotify.declined_service_organization_template_id
}

vanotify_service.send_email(content)
end

# TODO: Discover if we need rep
def send_representative_notification(poa, _rep)
def send_representative_notification(poa)
representative_type = poa.form_data.dig('representative', 'type')

content = {
recipient_identifier: recipient_identifier(poa),
personalisation: {
first_name: poa.auth_headers['va_eauth_firstName'] || '',
representative_type: poa.form_data.dig('representative', 'type') || '',
representative_type_abbreviated: 'TODO', # TODO: Add representative type abbreviated
form_type: 'TODO' # TODO: Add form type, i.e., VSO or Individual
representative_type: representative_type || '',
representative_type_abbreviated: representative_type_abbreviated(representative_type),
form_type: "Appointment of Individual as Claimant's Representative (VA Form 21-22a)"
},
template_id: Settings.claims_api.vanotify.representative_declined_template_id
template_id: Settings.claims_api.vanotify.declined_representative_template_id
}

vanotify_service.send_email(content)
end

def representative_type_abbreviated(representative_type)
representative_type == 'Veteran Service Organization (VSO)' ? 'VSO' : representative_type
end

def recipient_identifier(poa)
poa.auth_headers[ClaimsApi::V2::Veterans::PowerOfAttorney::BaseController::VA_NOTIFY_KEY]
end
Expand Down

0 comments on commit dfd3a2d

Please sign in to comment.