-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
10 changed files
with
256 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
61
spec/lib/emis/responses/get_pay_grade_history_response_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |