From 8f45596f550e994c56b44de6706ced8a490ddbff Mon Sep 17 00:00:00 2001 From: Aubrey Holland Date: Wed, 26 Apr 2017 15:52:05 -0400 Subject: [PATCH] feat: add form 1990meb confirmation email trigger * getting started with emis * make emis work for veteran status * handle errors, refactor services, make all services * Add Josh to EDU Daily stats mailer * fixes the issue with vets-api not passing through params (#917) * Add Claim IDs to the logs so we can track them down more quickly if needed * Update vets json schema (#914) * update vets json schema * add previous benefits va file number to 5490 spool * Evss failed upload job (#919) * add aws gem * add failed claims report and mailer * job will send email * add entry in sidekiq scheduler * report mailer spec * lint * failed claims report spec * lint * Update vets json schema (#922) * update json schema * fix 5495 spec * add training end date 5495 * Route EDU claims based on the school being applied to and applicant address * Route EDU claims based on disbursement location, then vet location * Update edu benefits api documentation (#925) * Update edu-benefits.md * Update edu-benefits.md * Update Routing for the 1995 and 5495 * Swagger documentation (#910) * Swagger documentation * subclass the controller correctly * and now the actual correct class * no auth for api docs * add the rest of the responses * bunch of emis fixes * finalize emis * remove unused module * refactor SSL configs for SOAP configurations * remove cruft * fix coverage * no more openstruct * add tests for error conditions Verify veteran status (#992) * extracted response caching to CacheAside concern * adding veteran status delegate (eMIS veteran status) to user * updated user serializer to return veteran status rerun tests Update veteran status determination, VIC eligibility (#1536) * Updated veteran eligibility logic and corresponding ID card changes Military service episodes may have a nil end date. Treat as ending in (#1567) future for sorting purposes. VCR cassette reflecting a collection of multiple service episodes An episode is inside of an `militaryServiceEpisode` element. Sibling `militaryServiceEpisode` elements reflect a collection of these episodes. Meaning, nothing is nested in an array, etc., to illustrate a collection. Siblings of this `militaryServiceEpisode` type indicate a collection of them. And if there is just one `militaryServiceEpisode`, then the collection contains only one episode. Add reserves guard to prefill (#2108) * Add retrieving reserves information to military_information model * Add reserves/guard date period to 526ez prefill Update vets-json-schema version (#2937) Correct gemfile (#3239) * revert changes to Gemfile.lock #3200 * don't change bundler version Create v2 of eMIS payment service to get pay grade history data (#3499) * Create v2 of eMIS payment service to get pay grade history data * Change settings file to split apart payment service v1 and v2 config Upgrade eMIS Military Information Service to v2 (#3590) * Create eMIS Military Information Service V2 * Create tests for Military Information Service V2 * Create v2 response and model * Test v2 response * Add version to service_name for breakers * Fix casettes * Add attribute expectations * Update response v2 file name * Add ability to use v2 response to eMIS services * Extract get_endpoint_attributes method Create Veteran Confirmation /status endpoint (#3676) * Add the implementation for an endpoint in the Veteran Confirmation API which queries MVI and eMIS with passed in attributes to return veteran status Co-authored-by: Katherine Rodriguez Add deployments method to MilitaryInformationServiceV2 (#4014) * Add deployment method to MilitaryInformationServiceV2 to retrieve pay grade information * Added more detailed deployment expects * Fixed spacing lint issue. Co-authored-by: drown-va Update to Concatenate Pay Plan and Pay Grade (#4054) * Update to Concatenate Pay Plan and Pay Grade * Added null & blank checking. * Added unit testing. * Removed unnecessary return statements * Fixed lint issue * Corrected spec schemas expected json * Added missing pay plan unit test. * Corrected minor swagger spacing issue Co-authored-by: dbrown-va Service history pact tests (#5052) * build_user_and_stub_session allows passed in user * working on service history pact * add at least one entry in the service history exists state * one service history entry spec working * no service history records spec * finish not a veteran spec * lint * dont need to pass anything into build_user_and_stub_session Mobile API docs: update user, add address update (#4980) All emis services are converted to soap 1.2 (#5216) * All emis services are converted to soap 1.2 * linting * changed emis vcr_cassettes to reflect change to soap 1.2 * Reverted Gemfile.lock 21584 mobile delete email fix (#6229) * call merge on controller params to properly add effective_end_date * cast controller params to hash first Add simple last name and social stamp to hlr v2 form (#6987) Created Check for service history null dates (#7300) * Created Check for service history null dates * new logic will order service history episodes from earliest to latest so spec needed to be changed * created test for end_date null * fixed service history episode spec Api 9107 service history gras integration (#7685) * added Gras V2 endpoint * added guard_reserve_service_periods * basic implementation of gras filtering * Added personnel_organization_code and personnel_segment_identifier to military service episode v2 response * added key data to guard reserver service period v2 * map episode to guard service by key data * Will filter out if guar.trainin indicator code is Y * fixed linting issues * added end_date check for episode period matching * default tests wil not be service guard * added intial tests * Cleaned up unit tests * added emis guard v2 to betamocks config * fixed tests * new gras logic * fixed tests * modified service history v0 tests * branch of service logic for guard * fixed bug * fixed test * Linting Co-authored-by: Derek Brown Api 12952 vba docs kevin daily report update (#8976) * Logging for the action_mailer * Adding Processing column to daily report * Lint adjustments * Lint adjustments RRD: increase RRD job retry limit (#9670) * increase RRD job retry limit * consistent hash keys Bump google-protobuf from 3.21.12 to 3.22.0 (#11878) Bumps [google-protobuf](https://github.com/protocolbuffers/protobuf) from 3.21.12 to 3.22.0. - [Release notes](https://github.com/protocolbuffers/protobuf/releases) - [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/generate_changelog.py) - [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.21.12...v3.22.0) --- updated-dependencies: - dependency-name: google-protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Adds tracked items status to oas (#11909) fix spec (#12037) fix failure (#12043) fix failing test (#12075) fix failing test (#12076) API 27878 secondary dsabilities not requred (#13270) Removes min-items indicator for secondaryDisabilities property * Updates 526.jsn, request.json and submssion.json to remove the mnItems indicator for secondary disabilities * Updates swagger docs to reflect change Changes to be committed: modified: modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json modified: modules/claims_api/config/schemas/v2/526.json modified: modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/request.json modified: spec/support/schemas/claims_api/v2/forms/disability/submission.json feat: add form 1990meb confirmation email trigger Update logic to handle separate templates Lint Split out logic for retrieving template id Move confirmation email to separate sidekiq job Lint Re-lint Fix education benefits spec Move sidekiq job to meb_api module Also updates job to take relevant data rather than entire form Move email logic to separate method remove invalid files --- config/features.yml | 4 + config/settings.yml | 3 + .../v0/education_benefits_controller.rb | 14 +++ .../v0/submit_1990meb_form_confirmation.rb | 47 ++++++++ .../meb_api/v0/education_benefits_spec.rb | 108 ++++++++++++++++++ .../dgi/get_claim_status_denied.yml | 67 +++++++++++ .../dgi/get_claim_status_in_progress.yml | 67 +++++++++++ .../dgi/submit_claim_failure.yml | 34 ++++++ 8 files changed, 344 insertions(+) create mode 100644 modules/meb_api/app/workers/meb_api/v0/submit_1990meb_form_confirmation.rb create mode 100644 spec/support/vcr_cassettes/dgi/get_claim_status_denied.yml create mode 100644 spec/support/vcr_cassettes/dgi/get_claim_status_in_progress.yml create mode 100644 spec/support/vcr_cassettes/dgi/submit_claim_failure.yml diff --git a/config/features.yml b/config/features.yml index e31b9061d73..1e21fb54ba9 100644 --- a/config/features.yml +++ b/config/features.yml @@ -513,6 +513,10 @@ features: actor_type: user description: Enables form 21-4142 email submission confirmation (VaNotify) enable_in_development: true + form1990meb_confirmation_email: + actor_type: user + description: Enables form 1990meb email submission confirmation (VaNotify) + enable_in_development: true form5490_confirmation_email: actor_type: user description: Enables form 5490 email submission confirmation (VaNotify) diff --git a/config/settings.yml b/config/settings.yml index 0dc3d96e717..f1065e3a533 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -1304,6 +1304,9 @@ vanotify: form0994_extra_action_confirmation_email: form0994_extra_action_confirmation_email_template_id form1990_confirmation_email: form1990_confirmation_email_template_id form1990e_confirmation_email: form1990e_confirmation_email_template_id + form1990meb_approved_confirmation_email: form1990meb_approved_confirmation_email_template_id + form1990meb_offramp_confirmation_email: form1990meb_offramp_confirmation_email_template_id + form1990meb_denied_confirmation_email: form1990meb_denied_confirmation_email_template_id form1995_confirmation_email: form1995_confirmation_email_template_id form21_0972_confirmation_email: form21_0972_confirmation_email_template_id form21_10203_confirmation_email: form21_10203_confirmation_email_template_id diff --git a/modules/meb_api/app/controllers/meb_api/v0/education_benefits_controller.rb b/modules/meb_api/app/controllers/meb_api/v0/education_benefits_controller.rb index 38a0fb04980..a71d8448856 100644 --- a/modules/meb_api/app/controllers/meb_api/v0/education_benefits_controller.rb +++ b/modules/meb_api/app/controllers/meb_api/v0/education_benefits_controller.rb @@ -61,6 +61,8 @@ def submit_claim clear_saved_form(params[:form_id]) if params[:form_id] + send_confirmation_email if response.ok? && Flipper.enabled?(:form1990meb_confirmation_email) + render json: { data: { 'status': response.status @@ -139,6 +141,18 @@ def enrollment_service def exclusion_period_service MebApi::DGI::ExclusionPeriod::Service.new(@current_user) end + + def send_confirmation_email + form_data = params[:education_benefit] + email = form_data.dig('claimant', 'contact_info', 'email_address') + first_name = form_data.dig('claimant', 'first_name')&.upcase.presence + + if email.present? + MebApi::V0::Submit1990MEBFormConfirmation.perform_async( + @current_user.uuid, email, first_name + ) + end + end end end end diff --git a/modules/meb_api/app/workers/meb_api/v0/submit_1990meb_form_confirmation.rb b/modules/meb_api/app/workers/meb_api/v0/submit_1990meb_form_confirmation.rb new file mode 100644 index 00000000000..eaa5f57db62 --- /dev/null +++ b/modules/meb_api/app/workers/meb_api/v0/submit_1990meb_form_confirmation.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'sidekiq' +require 'dgi/claimant/service' +require 'dgi/status/service' + +module MebApi + module V0 + class Submit1990MEBFormConfirmation + include Sidekiq::Worker + include SentryLogging + sidekiq_options retry: 14 + + def perform(user_uuid, email, first_name) + @current_user = User.find(user_uuid) + + VANotify::EmailJob.perform_async( + email, + confirmation_email_template_id, + { + 'first_name' => first_name, + 'date_submitted' => Time.zone.today.strftime('%B %d, %Y') + } + ) + end + + private + + def confirmation_email_template_id + claimant_service = MebApi::DGI::Claimant::Service.new(@current_user) + claimant_response = claimant_service.get_claimant_info + claimant_id = claimant_response['claimant_id'] + claim_status_service = MebApi::DGI::Status::Service.new(@current_user) + claim_status_response = claim_status_service.get_claim_status({ latest: false }, claimant_id) + claim_status = claim_status_response['claim_status'] + + if claim_status.eql? 'ELIGIBLE' + Settings.vanotify.services.va_gov.template_id.form1990meb_approved_confirmation_email + elsif claim_status.eql? 'DENIED' + Settings.vanotify.services.va_gov.template_id.form1990meb_denied_confirmation_email + else + Settings.vanotify.services.va_gov.template_id.form1990meb_offramp_confirmation_email + end + end + end + end +end diff --git a/modules/meb_api/spec/requests/meb_api/v0/education_benefits_spec.rb b/modules/meb_api/spec/requests/meb_api/v0/education_benefits_spec.rb index 688f7f40368..b815488eec1 100644 --- a/modules/meb_api/spec/requests/meb_api/v0/education_benefits_spec.rb +++ b/modules/meb_api/spec/requests/meb_api/v0/education_benefits_spec.rb @@ -140,5 +140,113 @@ end end end + + describe 'POST /meb_api/v0/submit_claim' do + let(:claimant_params) do + { + form_id: 1, + education_benefit: { + claimant: { + first_name: 'Herbert', + middle_name: 'Hoover', + last_name: 'Hoover', + date_of_birth: '1980-03-11', + contact_info: { + address_line1: '503 upper park', + address_line2: '', + city: 'falls church', + zipcode: '22046', + email_address: 'hhover@test.com', + address_type: 'DOMESTIC', + mobile_phone_number: '4409938894', + country_code: 'US', + state_code: 'VA' + }, + notification_method: 'EMAIL' + } + }, + relinquished_benefit: { + eff_relinquish_date: '2021-10-15', + relinquished_benefit: 'Chapter30' + }, + additional_considerations: { + active_duty_kicker: 'N/A', + academy_rotc_scholarship: 'YES', + reserve_kicker: 'N/A', + senior_rotc_scholarship: 'YES', + active_duty_dod_repay_loan: 'YES' + }, + comments: { + disagree_with_service_period: false + }, + direct_deposit: { + account_number: '123123123123', + account_type: 'savings', + routing_number: '123123123' + } + } + end + + context 'confirmation email' do + it 'delegates to submit_0994_form_confirmation job' do + VCR.use_cassette('dgi/submit_claim') do + allow(MebApi::V0::Submit1990MEBFormConfirmation).to receive(:perform_async) + + post '/meb_api/v0/submit_claim', params: claimant_params + + expect(MebApi::V0::Submit1990MEBFormConfirmation).to have_received(:perform_async) + .with('b2fab2b5-6af0-45e1-a9e2-394347af91ef', 'hhover@test.com', 'HERBERT') + end + end + + it 'does not delegate when claim submission fails' do + VCR.use_cassette('dgi/submit_claim_failure') do + allow(MebApi::V0::Submit1990MEBFormConfirmation).to receive(:perform_async) + + response = post '/meb_api/v0/submit_claim', params: claimant_params + + expect(response).to be(503) + expect(MebApi::V0::Submit1990MEBFormConfirmation).not_to have_received(:perform_async) + end + end + + it 'does not delegate when feature is disabled' do + VCR.use_cassette('dgi/submit_claim') do + allow(MebApi::V0::Submit1990MEBFormConfirmation).to receive(:perform_async) + Flipper.disable(:form1990meb_confirmation_email) + + post '/meb_api/v0/submit_claim', params: claimant_params + + expect(MebApi::V0::Submit1990MEBFormConfirmation).not_to have_received(:perform_async) + + Flipper.enable(:form1990meb_confirmation_email) + end + end + + it 'does not delegate when email is missing' do + VCR.use_cassette('dgi/submit_claim') do + claimant_params_without_email = { + **claimant_params, + education_benefit: { + **claimant_params[:education_benefit], + claimant: { + **claimant_params[:education_benefit][:claimant], + contact_info: { + **claimant_params[:education_benefit][:claimant][:contact_info], + email_address: nil + } + } + } + } + + allow(MebApi::V0::Submit1990MEBFormConfirmation).to receive(:perform_async) + + post '/meb_api/v0/submit_claim', params: claimant_params_without_email + + expect(MebApi::V0::Submit1990MEBFormConfirmation).not_to have_received(:perform_async) + end + end + end + end end end diff --git a/spec/support/vcr_cassettes/dgi/get_claim_status_denied.yml b/spec/support/vcr_cassettes/dgi/get_claim_status_denied.yml new file mode 100644 index 00000000000..8f8d37f0fe9 --- /dev/null +++ b/spec/support/vcr_cassettes/dgi/get_claim_status_denied.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: https://jenkins.ld.afsp.io:32512/vets-service/v1/claimType/Chapter33/claimants/claimantId + body: + encoding: UTF-8 + string: '{"ssn":"796121200"}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Authorization: + - removed + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: '' + headers: + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Date: + - Wed, 15 Jun 2022 18:42:37 GMT + body: + encoding: UTF-8 + string: '{"claimantId":600000001}' + recorded_at: Wed, 15 Jun 2022 18:42:36 GMT +- request: + method: get + uri: https://jenkins.ld.afsp.io:32512/vets-service/v1/claimant/600000001/claimType/Chapter33/claimstatus?latest=false + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Authorization: + - removed + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Date: + - Wed, 15 Jun 2022 18:42:37 GMT + body: + encoding: UTF-8 + string: '{"claimantId":600000001,"claimServiceId":99000000113358369,"claimStatus":"DENIED","confirmationNumber":null,"receivedDate":"2022-06-13"}' + recorded_at: Thu, 07 Sep 2023 19:36:00 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/support/vcr_cassettes/dgi/get_claim_status_in_progress.yml b/spec/support/vcr_cassettes/dgi/get_claim_status_in_progress.yml new file mode 100644 index 00000000000..0a658509b4c --- /dev/null +++ b/spec/support/vcr_cassettes/dgi/get_claim_status_in_progress.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: https://jenkins.ld.afsp.io:32512/vets-service/v1/claimType/Chapter33/claimants/claimantId + body: + encoding: UTF-8 + string: '{"ssn":"796121200"}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Authorization: + - removed + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: '' + headers: + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Date: + - Wed, 15 Jun 2022 18:42:37 GMT + body: + encoding: UTF-8 + string: '{"claimantId":600000001}' + recorded_at: Wed, 15 Jun 2022 18:42:36 GMT +- request: + method: get + uri: https://jenkins.ld.afsp.io:32512/vets-service/v1/claimant/600000001/claimType/Chapter33/claimstatus?latest=false + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Authorization: + - removed + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: '' + headers: + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Date: + - Wed, 15 Jun 2022 18:42:37 GMT + body: + encoding: UTF-8 + string: '{"claimantId":600000001,"claimServiceId":99000000113358369,"claimStatus":"IN_PROGRESS","confirmationNumber":null,"receivedDate":"2022-06-13"}' + recorded_at: Thu, 07 Sep 2023 19:36:00 GMT +recorded_with: VCR 6.1.0 diff --git a/spec/support/vcr_cassettes/dgi/submit_claim_failure.yml b/spec/support/vcr_cassettes/dgi/submit_claim_failure.yml new file mode 100644 index 00000000000..4366099b023 --- /dev/null +++ b/spec/support/vcr_cassettes/dgi/submit_claim_failure.yml @@ -0,0 +1,34 @@ +--- +http_interactions: +- request: + method: post + uri: https://jenkins.ld.afsp.io:32512/vets-service/v1/claimType/Chapter33/claimsubmission + body: + encoding: UTF-8 + string: '{"claimant":{"claimantId":99900000200000000,"suffix":"","dateOfBirth":"1970-01-01","firstName":"Hoover","lastName":"Hoover","middleName":"Hoover","notificationMethod":"EMAIL","contactInfo":{"addressLine1":"503 + upper park","addressLine2":"","city":"falls church","zipcode":"22046","emailAddress":"hhover@test.com","addressType":"DOMESTIC","mobilePhoneNumber":"4409938894","homePhoneNumber":null,"countryCode":"US","stateCode":"VA"},"preferredContact":"EMAIL"},"relinquishedBenefit":{"effRelinquishDate":"2021-10-15","relinquishedBenefit":"Chapter30"},"additionalConsiderations":{"activeDutyKicker":"N/A","reserveKicker":"N/A","academyRotcScholarship":"YES","seniorRotcScholarship":"YES","activeDutyDodRepayLoan":"YES","terminalLeave":null},"comments":{"disagreeWithServicePeriod":true}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Vets.gov Agent + Authorization: + - removed + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 424 + message: 'An unexpected error has occurred' + headers: + Content-Length: + - '0' + Date: + - Thu, 13 Jul 2023 18:43:30 GMT + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 13 Jul 2023 18:43:30 GMT +recorded_with: VCR 6.0.0