-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Conversation
File.write('test/tmp/bsb_db.json', File.read('test/fixtures/bsb_db.json')) | ||
end | ||
|
||
let(:auspaynet_bsb_client_response) 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.
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
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 |
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.
I barely use minitest. Open to feedback if theres better ways to run this setup / stubbing
cb7aa32
to
928d5c3
Compare
end | ||
|
||
response = conn.post('/bsbquery/manual/paths/invoke') do |req| | ||
req.body = { outputparam: ' ' * OUTPUT_PARAM_WIDTH }.to_json |
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.
API guides to have at least 30 chars here
928d5c3
to
d9b44dc
Compare
- Fri, 06 Sep 2024 12:30:08 GMT | ||
body: | ||
encoding: UTF-8 | ||
string: '{"outputparam":"Query results returned "}[{"BSBCode":"012-002","BSBName":"ANZ |
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.
Manually amended this, the response is huge and felt overkill tracking the whole thing so cut off ~15k lines
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?