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

API-42927-veteran-rep-service-standardization #19872

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ad123e1
Removes extra methods from definitions file.
stiehlrod Dec 12, 2024
e241095
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Dec 13, 2024
86534d9
Removes extra methods. Adds method to veteran_representative_service.…
stiehlrod Dec 13, 2024
2076350
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Dec 16, 2024
79f1c4b
Combines vet rep service methods to one file, removes extra service f…
stiehlrod Dec 17, 2024
03845cb
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Dec 19, 2024
28b3baf
Reverts change that will happen in another PR.
stiehlrod Dec 19, 2024
c52c416
Reverts change that will happen in another PR.
stiehlrod Dec 19, 2024
a84d15c
Reverts change that will happen in another PR.
stiehlrod Dec 19, 2024
4bc92fc
Corrects the namespace in the create_veteran_representative method. R…
stiehlrod Dec 20, 2024
5c9b445
Resolves merge conflict
stiehlrod Dec 20, 2024
7d6fb6c
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Dec 20, 2024
f2ba537
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Jan 2, 2025
e31632e
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Jan 6, 2025
620b0fb
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Jan 6, 2025
db364b4
Replaces nso with data.
stiehlrod Jan 6, 2025
9819bf9
Merge branch 'API-42927-veteran-rep-service-standardization' of githu…
stiehlrod Jan 6, 2025
59ae114
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Jan 6, 2025
653e370
Resolves merge conflict
stiehlrod Jan 8, 2025
2ee9eb6
Merge branch 'master' of github.com:department-of-veterans-affairs/ve…
stiehlrod Jan 8, 2025
e9896fb
Merge branch 'API-42927-veteran-rep-service-standardization' of githu…
stiehlrod Jan 8, 2025
24601c9
Resolves merge conflict
stiehlrod Jan 9, 2025
c6c845c
removes deprecated test file
stiehlrod Jan 9, 2025
82135c2
Merge branch 'master' into API-42927-veteran-rep-service-standardization
stiehlrod Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -287,30 +287,15 @@ module UpdatePoaRelationship
end
end

##
# VeteranRepresentativeService
##
module VeteranRepresentativeService
DEFINITION =
Service.new(
bean: Vdc::DEFINITION,
path: 'VeteranRepresentativeService'
)

module ReadAllVeteranRepresentatives
DEFINITION =
Action.new(
service: VeteranRepresentativeService::DEFINITION,
name: 'readAllVeteranRepresentatives',
key: 'VeteranRepresentativeReturnList'
)
end

module CreateVeteranRepresentative
DEFINITION =
Action.new(
service: VeteranRepresentativeService::DEFINITION,
name: 'createVeteranRepresentative',
key: 'VeteranRepresentativeReturn'
)
end
end

##
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
# frozen_string_literal: true

require_relative 'veteran_representative_service/create_veteran_representative_request'
require_relative 'veteran_representative_service/read_all_veteran_representatives'

module ClaimsApi
class VeteranRepresentativeService < ClaimsApi::LocalBGS
private
def bean_name
'VDC/VeteranRepresentativeService'
end

def create_veteran_representative(options)
# error VetRep cannot be null
injected = convert_nil_values(options)

def make_request(namespace:, **args)
super(
endpoint: 'VDC/VeteranRepresentativeService',
namespaces: { namespace => '/data' },
transform_response: false,
**args
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<data:VetRepresentative>
#{injected}
</data:VetRepresentative>
EOXML

make_request(
endpoint: bean_name,
namespaces: { 'data' => '/data' },
action: 'createVeteranRepresentative',
body: body.to_s,
key: 'VeteranRepresentativeReturn',
transform_response: false
)
end

# type_code: form type (I.E. 21-22 vs 21-22A)
# ptcpnt_id: participant ID
def read_all_veteran_representatives(type_code:, ptcpnt_id:)
validate! type_code, ptcpnt_id

body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<ns0:CorpPtcpntIdFormTypeCode>
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't append an ns0 namespace to our outgoing request so this fails with the

<error><message>VetRep cannot be null</message></error>

Copy link
Contributor

Choose a reason for hiding this comment

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

this is still throwing this error. We don't have ns0, we'd need this to be data or the namespaces to include ns0.

<veteranCorpPtcpntId>#{ptcpnt_id}</veteranCorpPtcpntId>
<formTypeCode>#{type_code}</formTypeCode>
</ns0:CorpPtcpntIdFormTypeCode>
EOXML
ret = make_request(endpoint: bean_name, namespaces: { 'data' => '/data' },
action: 'readAllVeteranRepresentatives', body:,
key: 'VeteranRepresentativeReturnList',
transform_response: false) || []

[ret].flatten
end

private

def validate!(type_code, ptcpnt_id)
errors = []
errors << 'type_code is required' if type_code.nil?
errors << 'ptcpnt_id must be 1-15 digits and > 0' if ptcpnt_id.length > 15 || ptcpnt_id.to_i < 1

raise ArgumentError, "Errors: #{errors.join(', ')}" if errors.any?
end
end
end

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -2,9 +2,12 @@

require 'rails_helper'
require Rails.root / 'modules/claims_api/spec/rails_helper'
require 'bgs_service/veteran_representative_service'

RSpec.describe 'VeteranRepresentative versus POARequest comparison', :bgs do # rubocop:disable RSpec/DescribeClass
it 'concerns the same underlying data' do
skip 'refactor needed'

use_soap_cassette('results', use_spec_name_prefix: true) do
participant_ids = Set[]
comparisons =
@@ -47,10 +50,7 @@
page_number += 1
end

veteran_representative_action =
ClaimsApi::BGSClient::Definitions::
VeteranRepresentativeService::
ReadAllVeteranRepresentatives::DEFINITION.name
veteran_representative_action = 'readAllVeteranRepresentatives'

poa_request_action =
ClaimsApi::BGSClient::Definitions::
@@ -444,18 +444,12 @@ def get_poa_requests(participant_id)
end

def get_veteran_representatives(participant_id)
action =
ClaimsApi::BGSClient::Definitions::
VeteranRepresentativeService::
ReadAllVeteranRepresentatives::DEFINITION

result =
ClaimsApi::BGSClient.perform_request(action) do |xml, data_aliaz|
xml[data_aliaz].CorpPtcpntIdFormTypeCode do
xml.formTypeCode('21-22')
xml.veteranCorpPtcpntId(participant_id)
end
end
options = {}
options[:participant_id] = participant_id
result = ClaimsApi::VeteranRepresentativeService.new(
external_uid: participant_id,
external_key: participant_id
).read_all_veteran_representatives(options)

Array.wrap(result)
end
Original file line number Diff line number Diff line change
@@ -4,27 +4,13 @@
require 'bgs_service/veteran_representative_service'
require Rails.root.join('modules', 'claims_api', 'spec', 'support', 'bgs_client_spec_helpers.rb')

metadata = {
bgs: {
service: 'veteran_representative_service',
action: 'create_veteran_representative'
}
}

describe ClaimsApi::VeteranRepresentativeService, metadata do
describe ClaimsApi::VeteranRepresentativeService do
describe '#create_veteran_representative' do
subject do
service = described_class.new(**header_params)
service = described_class.new(external_uid: 'xUid', external_key: 'xKey')
service.create_veteran_representative(**params)
end

let(:header_params) do
{
external_uid: 'keyHere',
external_key: 'keyHere'
}
end

describe 'with valid request params' do
let(:params) do
{
@@ -100,7 +86,7 @@
end

it 'returns a response with expected body' do
use_bgs_cassette('valid_params') do
VCR.use_cassette('claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params') do
expect(subject).to eq(expected_response)
end
end
@@ -135,7 +121,7 @@
end

it 'raises Common::Exceptions::ServiceError' do
use_bgs_cassette('mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id') do
VCR.use_cassette('mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id') do
expect { subject }.to raise_error(
Common::Exceptions::ServiceError
)
Loading