-
Notifications
You must be signed in to change notification settings - Fork 3
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
[CM-278] allow retrieve all sub merch #50
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,7 +163,7 @@ def bank_profiles(api_key:) | |
# | ||
# @param api_key [String] API key for the bank profiles endpoint. | ||
# | ||
# @return [Bambora::Bank::PaymentProfileResource] | ||
# @return [Bambora::Bank::BatchReportResource] | ||
def batch_reports(api_key:) | ||
@batch_reports = Bambora::Bank::BatchReportResource.new( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change here as you can see from the line 168 the expected return is |
||
client: xml_client, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,12 +6,15 @@ module Bambora | |||||
module Bank | ||||||
describe BatchReportResource do | ||||||
subject(:reports) { described_class.new(client: client, api_key: api_key) } | ||||||
subject(:reports_without_sub_merchant_id) do | ||||||
described_class.new(client: client_withot_sub_merchant_id, api_key: api_key) | ||||||
end | ||||||
|
||||||
let(:api_key) { 'fakekey' } | ||||||
let(:merchant_id) { 1 } | ||||||
let(:sub_merchant_id) { 2 } | ||||||
let(:base_url) { 'https://sandbox-web.na.bambora.com' } | ||||||
let(:headers) { { 'Authorization' => 'Passcode MTpmYWtla2V5', 'Sub-Merchant-ID' => sub_merchant_id } } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line as it is not used or needed. |
||||||
|
||||||
let(:response_body) do | ||||||
{ | ||||||
response: { | ||||||
|
@@ -96,6 +99,15 @@ module Bank | |||||
) | ||||||
end | ||||||
|
||||||
let(:client_withot_sub_merchant_id) do | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
instance_double( | ||||||
'Bambora::Rest::XMLClient', | ||||||
merchant_id: merchant_id, | ||||||
sub_merchant_id: nil, | ||||||
post: response_body, | ||||||
) | ||||||
end | ||||||
|
||||||
describe '#show' do | ||||||
let(:batch_id) { 1 } | ||||||
let(:from_date) { Time.now.to_s } | ||||||
|
@@ -112,6 +124,7 @@ module Bank | |||||
service_name: service_name, | ||||||
} | ||||||
end | ||||||
|
||||||
let(:posted_data) do | ||||||
{ | ||||||
body: { | ||||||
|
@@ -132,6 +145,34 @@ module Bank | |||||
} | ||||||
end | ||||||
|
||||||
let(:request_data_with_rpt_merchant_id) do | ||||||
{ | ||||||
service_name: service_name, | ||||||
rpt_filter_by_1: 'returned_date', | ||||||
rpt_operation_type_1: 'GT', | ||||||
rpt_filter_value_1: '2023-08-01', | ||||||
rpt_merchant_id: 'AllLive', | ||||||
} | ||||||
end | ||||||
|
||||||
let(:posted_data_with_rpt_merchant_id) do | ||||||
{ | ||||||
body: { | ||||||
merchant_id: 1, | ||||||
pass_code: 'fakekey', | ||||||
rpt_filter_by_1: 'returned_date', | ||||||
rpt_filter_value_1: '2023-08-01', | ||||||
rpt_format: 'JSON', | ||||||
rpt_operation_type_1: 'GT', | ||||||
rpt_version: '2.0', | ||||||
rpt_merchant_id: 'AllLive', | ||||||
service_name: service_name, | ||||||
session_source: 'external', | ||||||
}, | ||||||
path: '/scripts/reporting/report.aspx', | ||||||
} | ||||||
end | ||||||
|
||||||
context 'with no messageId' do | ||||||
it 'sends `post` to the client with the correct data' do | ||||||
reports.show(request_data) | ||||||
|
@@ -141,6 +182,15 @@ module Bank | |||||
it 'returns the expected response' do | ||||||
expect(reports.show(request_data)).to eq expected_response | ||||||
end | ||||||
|
||||||
it 'sends `post` to the client with the correct data where the sub merchant id comes from elements' do | ||||||
reports_without_sub_merchant_id.show(request_data_with_rpt_merchant_id) | ||||||
expect(client_withot_sub_merchant_id).to have_received(:post).with(posted_data_with_rpt_merchant_id) | ||||||
end | ||||||
|
||||||
it 'returns the expected response' do | ||||||
expect(reports_without_sub_merchant_id.show(request_data_with_rpt_merchant_id)).to eq expected_response | ||||||
end | ||||||
end | ||||||
|
||||||
context 'with messageIds' do | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but an alternative could be using
.compact
to removesub_merchant_id
if it'snil
.https://ruby-doc.org/core-2.4.2/Hash.html#method-i-compact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, does this new behaviour need to be documented in the Readme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggestion from @cristianoventura is really good here. It may remove the need for the conditional logic, as long as we change the merge order, and then call
#compact
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cristianoventura that's a good idea to update the README, although it needs some work in general. I'll note this for future work to update the README. Is that cool with you?