Skip to content

Commit

Permalink
253 | mobile vshe connection (#21024)
Browse files Browse the repository at this point in the history
* 253 | Added route, controller, and specs for VetVerificationStatus

* 253 | Updated mobile docs with new VetVerificationStatus route

* 253 | Add description to json docs

* Remove debug puts

* 253 | Add schema to openapi.json

* 253 | Updated parameters in docs

---------

Co-authored-by: ATeal <[email protected]>
  • Loading branch information
mtharmer-wc and ATeal authored Mar 5, 2025
1 parent 6f5da72 commit a564784
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 0 deletions.
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": {
"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:
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

0 comments on commit a564784

Please sign in to comment.