Skip to content

Commit

Permalink
Updated Retrievers (#16350)
Browse files Browse the repository at this point in the history
- Updated `Inquiries::Retriever`
- Updated `Correspondences::Retriever`

Co-authored-by: khoa-v-nguyen <[email protected]>
  • Loading branch information
Khoa-V-Nguyen and Khoa-V-Nguyen authored Apr 15, 2024
1 parent 4e7c4d2 commit 6f268f6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def fetch_data
data = JSON.parse(data, symbolize_names: true)[:Data]
filter_data(data)
else
endpoint = "inquiries/#{inquiry_id}/replies"
endpoint = "inquiry/#{inquiry_id}/replies"

response = Crm::Service.new(icn: nil).call(endpoint:)
handle_response_data(response)
Expand Down
3 changes: 2 additions & 1 deletion modules/ask_va_api/app/lib/ask_va_api/inquiries/retriever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def fetch_data(id = nil)
filter_data(data, id)
else
endpoint = 'inquiries'
payload = id ? { id: } : { icn: }
id ||= icn
payload = { id: }

response = Crm::Service.new(icn:).call(endpoint:, payload:)
handle_response_data(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,54 @@
end

context 'when successful' do
let(:user_mock_data) { true }
context 'with user_mock_data' do
let(:user_mock_data) { true }

it 'returns an array object with correct data' do
expect(retriever.call.first).to be_a(AskVAApi::Correspondences::Entity)
it 'returns an array object with correct data' do
expect(retriever.call.first).to be_a(AskVAApi::Correspondences::Entity)
end
end

context 'with Crm::Service' do
let(:crm_response) do
{
Data: [
{
Id: 'a5247de6-62c4-ee11-907a-001dd804eab2',
ModifiedOn: '2/5/2024 8:14:48 PM',
StatusReason: 'PendingSend',
Description: 'Dear aminul, Thank you for submitting ' \
'your Inquiry with the U.S.',
MessageType: 'Notification',
EnableReply: true,
AttachmentNames: nil
},
{
Id: 'f4b12ee3-93bb-ed11-9886-001dd806a6a7',
ModifiedOn: '3/5/2023 8:25:49 PM',
StatusReason: 'Sent',
Description: 'Dear aminul, Thank you for submitting your ' \
'Inquiry with the U.S. Department of Veteran Affairs.',
MessageType: 'Notification',
EnableReply: true,
AttachmentNames: nil
}
],
Message: nil,
ExceptionOccurred: false,
ExceptionMessage: nil,
MessageId: '086594d9-188b-46b0-9ce2-b8b36329506b'
}
end

before do
allow_any_instance_of(Crm::CrmToken).to receive(:call).and_return('Token')
allow(service).to receive(:call).and_return(crm_response)
end

it 'returns an array object with correct data' do
expect(retriever.call.first).to be_a(AskVAApi::Correspondences::Entity)
end
end
end
end
Expand Down

0 comments on commit 6f268f6

Please sign in to comment.