Skip to content

Commit

Permalink
Create v2 of eMIS payment service to get pay grade history data (#3499)
Browse files Browse the repository at this point in the history
* Create v2 of eMIS payment service to get pay grade history data
* Change settings file to split apart payment service v1 and v2 config
  • Loading branch information
rtravitz authored Nov 14, 2019
1 parent e2377b9 commit 8be6f01
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 5 deletions.
15 changes: 12 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ emis:
mock: true
host: https://vaausvrsapp81.aac.va.gov
veteran_status_url: /VIERSService/eMIS/v1/VeteranStatusService
payment_url: /VIERSService/eMIS/v1/PaymentService
payment_url:
v1: /VIERSService/eMIS/v1/PaymentService
v2: /VIERSService/eMIS/v2/PaymentService
military_information_url: /VIERSService/eMIS/v1/MilitaryInformationService
client_cert_path: /fake/client/cert/path
client_key_path: /fake/client/key/path
Expand All @@ -255,8 +257,15 @@ emis:
soap_namespaces:
xmlns:v11: http://viers.va.gov/cdi/eMIS/RequestResponse/MilitaryInfo/v1
payment:
soap_namespaces:
xmlns:v11: http://viers.va.gov/cdi/eMIS/RequestResponse/Payment/v1
v1:
soap_namespaces:
xmlns:v11: http://viers.va.gov/cdi/eMIS/RequestResponse/Payment/v1
v2:
soap_namespaces:
xmlns:v1: http://viers.va.gov/cdi/CDI/commonService/v2
xmlns:v12: http://viers.va.gov/cdi/eMIS/RequestResponse/v2
xmlns:v13: http://viers.va.gov/cdi/eMIS/commonService/v2
xmlns:v11: http://viers.va.gov/cdi/eMIS/RequestResponse/Payment/v2
veteran_status:
soap_namespaces:
xmlns:v11: http://viers.va.gov/cdi/eMIS/RequestResponse/VetStatus/v1
Expand Down
18 changes: 18 additions & 0 deletions lib/emis/models/pay_grade_history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module EMIS
module Models
class PayGradeHistory
include Virtus.model

attribute :personnel_organization_code, String
attribute :personnel_category_type_code, String
attribute :personnel_segment_identifier, String
attribute :pay_plan_code, String
attribute :pay_grade_code, String
attribute :service_rank_name_code, String
attribute :service_rank_name_txt, String
attribute :pay_grade_date, Date
end
end
end
2 changes: 1 addition & 1 deletion lib/emis/payment_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PaymentConfiguration < Configuration
# Payment Service URL
# @return [String] Payment Service URL
def base_path
URI.join(Settings.emis.host, Settings.emis.payment_url).to_s
URI.join(Settings.emis.host, Settings.emis.payment_url.v1).to_s
end

# :nocov:
Expand Down
24 changes: 24 additions & 0 deletions lib/emis/payment_configuration_v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'common/client/configuration/soap'

module EMIS
# Configuration for {EMIS::PaymentService}
# includes API URL and breakers service name.
class PaymentConfigurationV2 < Configuration
# Payment Service URL
# @return [String] Payment Service URL
def base_path
URI.join(Settings.emis.host, Settings.emis.payment_url.v2).to_s
end

# :nocov:

# Payment Service breakers name
# @return [String] Payment Service breakers name
def service_name
'EmisPaymentV2'
end
# :nocov:
end
end
2 changes: 1 addition & 1 deletion lib/emis/payment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PaymentService < Service
# Custom namespaces used in EMIS SOAP request message
# @return [Config::Options] Custom namespaces object
def custom_namespaces
Settings.emis.payment.soap_namespaces
Settings.emis.payment.v1.soap_namespaces
end
end
end
22 changes: 22 additions & 0 deletions lib/emis/payment_service_v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module EMIS
# HTTP Client for EMIS Payment Service requests.
class PaymentServiceV2 < Service
configuration EMIS::PaymentConfigurationV2

create_endpoints(
%i[
get_pay_grade_history
]
)

protected

# Custom namespaces used in EMIS SOAP request message
# @return [Config::Options] Custom namespaces object
def custom_namespaces
Settings.emis.payment.v2.soap_namespaces
end
end
end
35 changes: 35 additions & 0 deletions lib/emis/responses/get_pay_grade_history_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'emis/models/pay_grade_history'
require 'emis/responses/response'

module EMIS
module Responses
# EMIS v2 pay grade history response
class GetPayGradeHistoryResponse < EMIS::Responses::Response
# @return [String] XML Tag that contains response data
def item_tag_name
'payGradeHistory'
end

# @return [Hash] Schema for translating XML data into model data
def item_schema
{
'personnelOrganizationCode' => {},
'personnelCategoryTypeCode' => {},
'personnelSegmentIdentifier' => {},
'payPlanCode' => {},
'PayGradeCode' => {},
'serviceRankNameCode' => {},
'serviceRankNameTxt' => {},
'payGradeDate' => {}
}
end

# @return [Class] Model class to put response data
def model_class
EMIS::Models::PayGradeHistory
end
end
end
end
37 changes: 37 additions & 0 deletions spec/lib/emis/payment_service_v2_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'rails_helper'
require 'emis/payment_service'

describe EMIS::PaymentServiceV2 do
describe 'get_pay_grade_history' do
let(:edipi) { '1007697216' }

context 'with a valid request' do
it 'calls the get_pay_grade_history endpoint with a proper emis message' do
header_matcher = lambda do |r1, r2|
[r1, r2].each { |r| r.headers.delete('Date') }
expect(r1.headers).to eq(r2.headers)
end

allow(SecureRandom).to receive(:uuid).and_return('abc123')

VCR.use_cassette('emis/get_pay_grade_history/success',
match_requests_on: [:method, :uri, header_matcher, :body]) do
response = subject.get_pay_grade_history(edipi: edipi)

expect(response).to be_ok

first_item = response.items.first
expect(first_item.pay_plan_code).to eq('ME')
expect(first_item.personnel_segment_identifier).to eq('1')
expect(first_item.pay_plan_code).to eq('ME')
expect(first_item.pay_grade_code).to eq('04')
expect(first_item.service_rank_name_code).to eq('SRA')
expect(first_item.service_rank_name_txt).to eq('Senior Airman')
expect(first_item.pay_grade_date).to eq(Date.parse('2009-04-12'))
end
end
end
end
end
61 changes: 61 additions & 0 deletions spec/lib/emis/responses/get_pay_grade_history_response_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

require 'rails_helper'
require 'emis/responses/get_pay_grade_history_response'

describe EMIS::Responses::GetPayGradeHistoryResponse do
let(:faraday_response) { instance_double('Faraday::Response') }
let(:body) { Ox.parse(File.read('spec/support/emis/getPayGradeHistoryResponse.xml')) }
let(:response) { EMIS::Responses::GetPayGradeHistoryResponse.new(faraday_response) }
let(:first_item) { response.items.first }

before do
allow(faraday_response).to receive(:body) { body }
end

describe 'checking status' do
it 'returns true for ok?' do
expect(response).to be_ok
end
end

describe 'getting data' do
context 'with a successful response' do
it 'gives multiple items' do
expect(response.items.count).to eq(2)
end

it 'has the proper personnel organization code' do
expect(first_item.personnel_organization_code).to eq('42')
end

it 'has the proper personnel category type code' do
expect(first_item.personnel_category_type_code).to eq('V')
end

it 'has the proper personnel segment identifier' do
expect(first_item.personnel_segment_identifier).to eq('1')
end

it 'has the proper pay plan code' do
expect(first_item.pay_plan_code).to eq('ME')
end

it 'has the proper pay grade code' do
expect(first_item.pay_grade_code).to eq('04')
end

it 'has the proper service rank name code' do
expect(first_item.service_rank_name_code).to eq('SRA')
end

it 'has the proper service rank name text' do
expect(first_item.service_rank_name_txt).to eq('Senior Airman')
end

it 'has the proper pay grade date' do
expect(first_item.pay_grade_date).to eq(Date.parse('2009-04-12'))
end
end
end
end
45 changes: 45 additions & 0 deletions spec/support/emis/getPayGradeHistoryResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<NS1:Envelope xmlns:NS1="http://www.w3.org/2003/05/soap-envelope">
<NS1:Header>
<NS2:essResponseCode xmlns:NS2="http://va.gov/ess/message/v1">Success</NS2:essResponseCode>
<NS3:inputHeaderInfo xmlns:NS3="http://viers.va.gov/cdi/CDI/commonService/v2">
<NS3:userId>vets.gov</NS3:userId>
<NS3:sourceSystemName>vets.gov</NS3:sourceSystemName>
<NS3:transactionId>acf5c70e-1efb-41f0-97ba-732c9b362b70</NS3:transactionId>
</NS3:inputHeaderInfo>
</NS1:Header>
<NS1:Body>
<NS4:eMISpayGradeHistoryResponse xmlns:NS4="http://viers.va.gov/cdi/eMIS/RequestResponse/Payment/v2">
<NS5:payGradeHistory xmlns:NS5="http://viers.va.gov/cdi/eMIS/RequestResponse/v2">
<NS6:edipi xmlns:NS6="http://viers.va.gov/cdi/eMIS/commonService/v2">1007697216</NS6:edipi>
<NS7:keyData xmlns:NS7="http://viers.va.gov/cdi/eMIS/commonService/v2">
<NS7:personnelOrganizationCode>42</NS7:personnelOrganizationCode>
<NS7:personnelCategoryTypeCode>V</NS7:personnelCategoryTypeCode>
<NS7:personnelSegmentIdentifier>1</NS7:personnelSegmentIdentifier>
</NS7:keyData>
<NS8:payGradeHistoryData xmlns:NS8="http://viers.va.gov/cdi/eMIS/commonService/v2">
<NS8:payPlanCode>ME</NS8:payPlanCode>
<NS8:PayGradeCode>04</NS8:PayGradeCode>
<NS8:serviceRankNameCode>SRA</NS8:serviceRankNameCode>
<NS8:serviceRankNameTxt>Senior Airman</NS8:serviceRankNameTxt>
<NS8:payGradeDate>2009-04-12</NS8:payGradeDate>
</NS8:payGradeHistoryData>
</NS5:payGradeHistory>
<NS9:payGradeHistory xmlns:NS9="http://viers.va.gov/cdi/eMIS/RequestResponse/v2">
<NS10:edipi xmlns:NS10="http://viers.va.gov/cdi/eMIS/commonService/v2">1007697216</NS10:edipi>
<NS11:keyData xmlns:NS11="http://viers.va.gov/cdi/eMIS/commonService/v2">
<NS11:personnelOrganizationCode>12</NS11:personnelOrganizationCode>
<NS11:personnelCategoryTypeCode>A</NS11:personnelCategoryTypeCode>
<NS11:personnelSegmentIdentifier>1</NS11:personnelSegmentIdentifier>
</NS11:keyData>
<NS12:payGradeHistoryData xmlns:NS12="http://viers.va.gov/cdi/eMIS/commonService/v2">
<NS12:payPlanCode>ME</NS12:payPlanCode>
<NS12:PayGradeCode>04</NS12:PayGradeCode>
<NS12:serviceRankNameCode>SRA</NS12:serviceRankNameCode>
<NS12:serviceRankNameTxt>Senior Airman</NS12:serviceRankNameTxt>
<NS12:payGradeDate>2007-10-12</NS12:payGradeDate>
</NS12:payGradeHistoryData>
</NS9:payGradeHistory>
</NS4:eMISpayGradeHistoryResponse>
</NS1:Body>
</NS1:Envelope>

0 comments on commit 8be6f01

Please sign in to comment.