[bisq-network/bisq] API POC: Use simple json file to create fiat payment accounts (#4752)
Stan
notifications at github.com
Thu Nov 5 17:41:26 CET 2020
This PR's purpose is to show how the API could create any exiting fiat `PaymentAccount` with a single CLI parameter, using reflection and json.
The idea is to use the CLI to create fiat accounts in four simple steps, as opposed to figuring out how to correctly pass a complicated set of parameters to a CLI `createpaymentacct` command. The steps are:
1. Get a list of payment account method IDs, e.g.,
`$ getpaymentmethods` -- returns list of payment method IDs and descriptions
2. Ask for a payment account (json) form, e.g.,
`$ getpaymentacctform japan_bank` (a paymentMethodId) -- returns a json file with fields specific to the payment method
3. Edit the returned json file, i.e., `japan_bank_form.json` with the user's file editor.
4. Submit the payment account json form via the CLI.
`$ createpaymentacct japan_bank_form.json`
The PR adds the new classes needed to generate a payment account json form for a given `paymentMethodId` (serialize only the necessary fields in a `PaymentAccount` subclass to json file), and de-serialize an edited json form into a `PaymentAccount` instance.
Changes include
- A new `isCountryBasedPaymentAccount` method in the abstract `PaymentAccount`, to help in serialization / de-serialization.
- A new `ReflectionUtils` class to :common util pkg.
- A new gson `PaymentAccountTypeAdapter` in core.api.model, for doing the `PaymentAccount` serialization and de-serialization
work.
- A new `PaymentAccountForm` class in core.api.model, to be used by the API's server, for creating new fiat accounts from json forms.
- A new `PaymentAccountFormTest` to prove this scheme works.
This new `PaymentAccount` serialization / de-serialization scheme is not exposed in the API yet, nor are de-serialized `PaymentAccount` instances persisted. The only change to existing code is the new `boolean isCountryBasedPaymentAccount()` method added to abstract `PaymentAccount`.
You can view, comment on, or merge this pull request online at:
https://github.com/bisq-network/bisq/pull/4752
-- Commit Summary --
* Add is instanceof CountryBasedPaymentAccount check to PaymentAccount
* Add ReflectionUtils to :common.util pkg
* Add gson type adapter for PaymentAccount serialization & de-serialization
* Add PaymentAccountForm for writing empty and submitting filled fiat acct json forms
* Test PaymentAccount / Json serialization and de-serialization
-- File Changes --
A common/src/main/java/bisq/common/util/ReflectionUtils.java (108)
A core/src/main/java/bisq/core/api/model/PaymentAccountForm.java (135)
A core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java (323)
M core/src/main/java/bisq/core/payment/PaymentAccount.java (4)
A core/src/test/java/bisq/core/api/model/PaymentAccountFormTest.java (411)
-- Patch Links --
https://github.com/bisq-network/bisq/pull/4752.patch
https://github.com/bisq-network/bisq/pull/4752.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4752
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201105/5950ece1/attachment-0001.html>
More information about the bisq-github
mailing list