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

Add rake task to sync using AusPayNet API #61

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

astley92
Copy link

@astley92 astley92 commented Sep 6, 2024

Thanks for maintaining this gem!

I recently saw that Australian Payments Network have taken down the FTP server that was previously used to update the database and bank list and have released an API that can be used to update the bsb db content. So figured I'd make this PR and see if you were interested in merging.

Why

The current process to update the bsb database file is quite manual and can be made easier, especially given Australian Payments Network have introduced an API to fetch BSB data.

What

Adds a new rake task rake bsb:sync_bsb_db that uses the API to fetch latest BSB data and generate a new DB along with an outline of what changes have been made.

Splits the existing rake task into two. This is to ensure that the bank list task can still be run when required since it isn't updated in this PR and also to keep redundancy in case the API is down or something here breaks. There will still be a manual process to fall back to.

Updates README to reflect the above.

Discussion

This could be taken a step further again by using this rake task in a GHA that would create a PR if any changes are present. I'd be happy to put that together as well if it is something you'd be interested in?

File.write('test/tmp/bsb_db.json', File.read('test/fixtures/bsb_db.json'))
end

let(:auspaynet_bsb_client_response) do
Copy link
Author

Choose a reason for hiding this comment

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

This is pretty verbose, but can be nice having input and expected output next to eachother in a test that requires a bit of context to understand. Happy to move to a fixture if preferred

Comment on lines +118 to +121
BSB.stub_consts(DB_FILEPATH: 'test/tmp/bsb_db.json', CHANGES_FILEPATH: 'test/tmp/latest_update.json') do
BSB::AusPayNet::Client.stub(:fetch_all_bsbs, auspaynet_bsb_client_response) do
Rake::Task['bsb:sync_bsb_db'].invoke
end
Copy link
Author

Choose a reason for hiding this comment

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

I barely use minitest. Open to feedback if theres better ways to run this setup / stubbing

@astley92 astley92 marked this pull request as draft September 6, 2024 12:09
end

response = conn.post('/bsbquery/manual/paths/invoke') do |req|
req.body = { outputparam: ' ' * OUTPUT_PARAM_WIDTH }.to_json
Copy link
Author

Choose a reason for hiding this comment

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

API guides to have at least 30 chars here

- Fri, 06 Sep 2024 12:30:08 GMT
body:
encoding: UTF-8
string: '{"outputparam":"Query results returned "}[{"BSBCode":"012-002","BSBName":"ANZ
Copy link
Author

Choose a reason for hiding this comment

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

Manually amended this, the response is huge and felt overkill tracking the whole thing so cut off ~15k lines

@astley92 astley92 marked this pull request as ready for review September 6, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant