-
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 all 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_without_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_without_sub_merchant_id) do | ||
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_without_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.
Oh wow, we can even keep the previous implementation mostly intact with that suggestion 🙏🏻