Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

253 | mobile vshe connection #21024

Merged
merged 11 commits into from
Mar 5, 2025
Merged
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions modules/mobile/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
82 changes: 82 additions & 0 deletions modules/mobile/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question as the schema do we need to include anything about the notConfirmedReason

"type": "string",
"example": "confirmed"
},
"notConfirmedReason": {
"type": "string",
"example": "PERSON_NOT_FOUND"
}
}
}
}
}
}
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions modules/mobile/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions modules/mobile/docs/schemas/VetVerificationStatus.yml
Original file line number Diff line number Diff line change
@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to include anything about the notConfirmedReason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ATeal I don't believe there's a way to include optional properties, and notConfirmedReason is optional, only appearing when status is 'not confirmed'. I did set the additionalProperties: true statement to show that other properties are allowed

type: string
example: confirmed
notConfirmedReason:
type: string
example: PERSON_NOT_FOUND
Original file line number Diff line number Diff line change
@@ -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
Loading