-
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
Conversation
@@ -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 comment
The 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 Bambora::Bank::BatchReportResource
not Bambora::Bank::PaymentProfileResource
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line as it is not used or needed.
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.
Looks good to me!
If we are planning to release this publicly right away I'd recommend bumping the patch or minor version as well as updating the changelog. If we do this, we probably need to make a release in ruby gems too, but if there are more related changes coming up, we can pack all of them together and release all at once.
|
||
params = DEFAULT_REQUEST_PARAMS.merge(additional_data).merge(request_data) | ||
|
||
client.sub_merchant_id.nil? ? params : params.merge(sub_merchant_id: client.sub_merchant_id) |
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 remove sub_merchant_id
if it's nil
.
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
.
additional_data = {
merchant_id: client.merchant_id,
pass_code: api_key,
sub_merchant_id: client.sub_merchant_id,
}
DEFAULT_REQUEST_PARAMS.merge(additional_data).merge(request_data).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?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
let(:client_withot_sub_merchant_id) do | |
let(:client_without_sub_merchant_id) do |
@cristianoventura good call on the gem versioning. Since this is a change we are still going to be exercising and evaluating, I suggest we leave the versioning out for now until it has been living in production for some time, and then we can cut a new release. Does that sound reasonable to you? |
@cristianoventura @jazziining that being said, I think we could update the CHANGELOG, with a new Unreleased heading, with a point about this new change. Do you mind doing that Jasmine? |
cf3d542
to
5eb1707
Compare
) | ||
).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.
Oh wow, we can even keep the previous implementation mostly intact with that suggestion 🙏🏻
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.
Small change, lots of testing, and a much more flexible API! Great work @jazziining!
Description:
This PR is to allow passing
sub merchant id
when calling the.show
where we use therpt_merchant_id
like all other query elements. This will enable retrieving the report not only for a specific sub merchant but also forall live
sub merchants.This update should not affect any current usage, as you should still be able to pass the
sub_merchant_id
when calling theBambora::Client.new
. In the mean time, you can also get rid of that and pass additional element when calling theclient.show
where you can specify the sub merchant id by using the keyrpt_merchant_id
Jira: CM-216
Test:
./bin/console
./bin/console