diff --git a/modules/mobile/app/controllers/mobile/v0/vet_verification_statuses_controller.rb b/modules/mobile/app/controllers/mobile/v0/vet_verification_statuses_controller.rb new file mode 100644 index 00000000000..ee10e46f8f7 --- /dev/null +++ b/modules/mobile/app/controllers/mobile/v0/vet_verification_statuses_controller.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Mobile + module V0 + class VetVerificationStatusesController < ApplicationController + def show + response = service.get_vet_verification_status(@current_user.icn) + response['data']['id'] = '' + + render json: response + end + + private + + def service + @service ||= VeteranVerification::Service.new + end + end + end +end diff --git a/modules/mobile/config/routes.rb b/modules/mobile/config/routes.rb index 07fdcd99213..addd08f9e51 100644 --- a/modules/mobile/config/routes.rb +++ b/modules/mobile/config/routes.rb @@ -104,6 +104,7 @@ get '/health/rx/prescriptions', to: 'prescriptions#index' put '/health/rx/prescriptions/refill', to: 'prescriptions#refill' get '/health/rx/prescriptions/:id/tracking', to: 'prescriptions#tracking' + get '/vet_verification_status', to: 'vet_verification_statuses#show' end namespace :v1 do diff --git a/modules/mobile/docs/openapi.json b/modules/mobile/docs/openapi.json index 9cd7c21b133..ca20d294311 100644 --- a/modules/mobile/docs/openapi.json +++ b/modules/mobile/docs/openapi.json @@ -8147,6 +8147,53 @@ "summary": "/v0/user/phones" } }, + "/v0/vet_verification_status": { + "get": { + "description": "Returns the veteran's Title 38 status as 'confirmed' or 'not confirmed'.", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VetVerificationStatus" + } + } + }, + "description": "OK" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "408": { + "$ref": "#/components/responses/408" + }, + "500": { + "$ref": "#/components/responses/500" + }, + "502": { + "$ref": "#/components/responses/502" + }, + "503": { + "$ref": "#/components/responses/503" + }, + "504": { + "$ref": "#/components/responses/504" + } + }, + "security": [ + { + "Bearer": [] + } + ], + "summary": "/v0/vet_verification_status" + } + }, "/v1/health/immunizations": { "get": { "description": "Returns a paginated list of immunization records for given user", @@ -23759,6 +23806,41 @@ } } } + }, + "VetVerificationStatus": { + "type": "object", + "additionalProperties": false, + "required": [ + "data" + ], + "properties": { + "data": { + "type": "object", + "additionalProperties": false, + "required": [ + "attributes" + ], + "properties": { + "attributes": { + "type": "object", + "additionalProperties": false, + "required": [ + "veteranStatus" + ], + "properties": { + "veteranStatus": { + "type": "string", + "example": "confirmed" + }, + "notConfirmedReason": { + "type": "string", + "example": "PERSON_NOT_FOUND" + } + } + } + } + } + } } } } diff --git a/modules/mobile/docs/openapi.yaml b/modules/mobile/docs/openapi.yaml index 38c06d8cef2..28e9fce9683 100644 --- a/modules/mobile/docs/openapi.yaml +++ b/modules/mobile/docs/openapi.yaml @@ -4723,6 +4723,37 @@ paths: security: - Bearer: [] summary: /v0/user/phones + /v0/vet_verification_status: + get: + description: Returns the veteran's Title 38 status as 'confirmed' or 'not confirmed'. + responses: + '200': + content: + application/json: + schema: + $ref: ./schemas/VetVerificationStatus.yml + description: OK + '401': + $ref: '#/components/responses/401' + '403': + $ref: '#/components/responses/403' + '404': + $ref: '#/components/responses/404' + '408': + $ref: '#/components/responses/408' + '422': + $ref: '#/components/responses/422' + '500': + $ref: '#/components/responses/500' + '502': + $ref: '#/components/responses/502' + '503': + $ref: '#/components/responses/503' + '504': + $ref: '#/components/responses/504' + security: + - Bearer: [] + summary: /v0/vet_verification_status /v1/health/immunizations: get: description: Returns a paginated list of immunization records for given user diff --git a/modules/mobile/docs/schemas/VetVerificationStatus.yml b/modules/mobile/docs/schemas/VetVerificationStatus.yml new file mode 100644 index 00000000000..5def0fd030f --- /dev/null +++ b/modules/mobile/docs/schemas/VetVerificationStatus.yml @@ -0,0 +1,23 @@ +type: object +additionalProperties: false +required: + - data +properties: + data: + type: object + additionalProperties: false + required: + - attributes + properties: + attributes: + type: object + additionalProperties: false + required: + - veteranStatus + properties: + veteranStatus: + type: string + example: confirmed + notConfirmedReason: + type: string + example: PERSON_NOT_FOUND diff --git a/modules/mobile/spec/requests/mobile/v0/vet_verification_statuses_spec.rb b/modules/mobile/spec/requests/mobile/v0/vet_verification_statuses_spec.rb new file mode 100644 index 00000000000..8a7e5a8b83b --- /dev/null +++ b/modules/mobile/spec/requests/mobile/v0/vet_verification_statuses_spec.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +# require 'rails_helper' +require_relative '../../../support/helpers/rails_helper' + +RSpec.describe 'Mobile::V0::VetVerificationStatuses', type: :request do + let!(:user) { sis_user(icn: '1012667145V762142') } + + before do + sign_in_as(user) + allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech') + end + + describe '#show' do + context 'when successful' do + it 'returns a status of 200' do + VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + expect(response).to have_http_status(:ok) + end + + it 'returns veteran confirmation status' do + VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + parsed_body = JSON.parse(response.body) + expect(parsed_body['data']['attributes']['veteranStatus']).to eq('confirmed') + end + + it 'removes the Veterans ICN from the response before sending' do + VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + parsed_body = JSON.parse(response.body) + expect(parsed_body['data']['id']).to eq('') + end + end + + context 'when not authorized' do + it 'returns a status of 401' do + VCR.use_cassette('lighthouse/veteran_verification/status/401_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + expect(response).to have_http_status(:unauthorized) + end + end + + context 'when ICN not found' do + let(:user) { sis_user(icn: '1012667145V762141') } + + before do + sign_in_as(user) + allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech') + end + + it 'returns a status of 200' do + VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + expect(response).to have_http_status(:ok) + end + + it 'returns a person_not_found reason' do + VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do + get '/mobile/v0/vet_verification_status', headers: sis_headers + end + + parsed_body = JSON.parse(response.body) + expect(parsed_body['data']['attributes']['veteranStatus']).to eq('not confirmed') + expect(parsed_body['data']['attributes']['notConfirmedReason']).to eq('PERSON_NOT_FOUND') + expect(parsed_body['data']['message']).to eq(VeteranVerification::Constants::NOT_FOUND_MESSAGE) + end + end + end +end