diff --git a/config/settings.yml b/config/settings.yml index 0dffea35957..2a95c9620f6 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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 @@ -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 diff --git a/lib/emis/models/pay_grade_history.rb b/lib/emis/models/pay_grade_history.rb new file mode 100644 index 00000000000..deda4a33894 --- /dev/null +++ b/lib/emis/models/pay_grade_history.rb @@ -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 diff --git a/lib/emis/payment_configuration.rb b/lib/emis/payment_configuration.rb index 1518ad77cd0..2a25804c68c 100644 --- a/lib/emis/payment_configuration.rb +++ b/lib/emis/payment_configuration.rb @@ -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: diff --git a/lib/emis/payment_configuration_v2.rb b/lib/emis/payment_configuration_v2.rb new file mode 100644 index 00000000000..77223257a2e --- /dev/null +++ b/lib/emis/payment_configuration_v2.rb @@ -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 diff --git a/lib/emis/payment_service.rb b/lib/emis/payment_service.rb index 5ed7f1ffb9e..3bc6a1861f2 100644 --- a/lib/emis/payment_service.rb +++ b/lib/emis/payment_service.rb @@ -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 diff --git a/lib/emis/payment_service_v2.rb b/lib/emis/payment_service_v2.rb new file mode 100644 index 00000000000..2bea0837ad7 --- /dev/null +++ b/lib/emis/payment_service_v2.rb @@ -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 diff --git a/lib/emis/responses/get_pay_grade_history_response.rb b/lib/emis/responses/get_pay_grade_history_response.rb new file mode 100644 index 00000000000..131de59bb8d --- /dev/null +++ b/lib/emis/responses/get_pay_grade_history_response.rb @@ -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 diff --git a/spec/lib/emis/payment_service_v2_spec.rb b/spec/lib/emis/payment_service_v2_spec.rb new file mode 100644 index 00000000000..19e2d09e76a --- /dev/null +++ b/spec/lib/emis/payment_service_v2_spec.rb @@ -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 diff --git a/spec/lib/emis/responses/get_pay_grade_history_response_spec.rb b/spec/lib/emis/responses/get_pay_grade_history_response_spec.rb new file mode 100644 index 00000000000..d3df1e70906 --- /dev/null +++ b/spec/lib/emis/responses/get_pay_grade_history_response_spec.rb @@ -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 diff --git a/spec/support/emis/getPayGradeHistoryResponse.xml b/spec/support/emis/getPayGradeHistoryResponse.xml new file mode 100644 index 00000000000..86fafa63f7e --- /dev/null +++ b/spec/support/emis/getPayGradeHistoryResponse.xml @@ -0,0 +1,45 @@ + + + + Success + + vets.gov + vets.gov + acf5c70e-1efb-41f0-97ba-732c9b362b70 + + + + + + 1007697216 + + 42 + V + 1 + + + ME + 04 + SRA + Senior Airman + 2009-04-12 + + + + 1007697216 + + 12 + A + 1 + + + ME + 04 + SRA + Senior Airman + 2007-10-12 + + + + + \ No newline at end of file