From 67252642c7daa85d14a2b0cad6f2e5a967ba7f05 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Thu, 18 Mar 2021 16:14:28 -0300 Subject: [PATCH] Disambiguate payment acct json form's "country" field Make it clear the user needs to enter a two letter country code in json form's "country" field, not a country name. The json form's field name was not changed to "countryCode" in this change for the following reason: The API's payment account forms are dynamically generated using reflection, and PaymentAccount class hierarchy @Setter methods determine which form fields are included or excluded. Reflection and @Setter methods are also used when reading completed json forms, to set the field values on a new PaymentAccount instance before it is persisted. CountryBasedPaymentAccount subclasses have a country field and a @Setter, not a countryCode field, hence this shortcut to informing the user the country field value is a country-code. --- .../apitest/method/payment/AbstractPaymentAccountTest.java | 5 ++++- .../java/bisq/core/api/model/PaymentAccountTypeAdapter.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java index 034bc3aeb02..433898731e5 100644 --- a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java +++ b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java @@ -129,7 +129,10 @@ protected final void verifyEmptyForm(File jsonForm, String paymentMethodId, Stri assertEquals(paymentMethodId, emptyForm.get(PROPERTY_NAME_PAYMENT_METHOD_ID)); assertEquals("your accountname", emptyForm.get(PROPERTY_NAME_ACCOUNT_NAME)); for (String field : fields) { - assertEquals("your " + field.toLowerCase(), emptyForm.get(field)); + if (field.equals("country")) + assertEquals("your two letter country code", emptyForm.get(field)); + else + assertEquals("your " + field.toLowerCase(), emptyForm.get(field)); } } diff --git a/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java b/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java index b566ac10b0d..219c3db04c9 100644 --- a/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java @@ -147,7 +147,10 @@ private void writeInnerMutableFields(JsonWriter out, PaymentAccount account) { String fieldName = field.getName(); out.name(fieldName); - out.value("your " + fieldName.toLowerCase()); + if (fieldName.equals("country")) + out.value("your two letter country code"); + else + out.value("your " + fieldName.toLowerCase()); } } catch (Exception ex) { String errMsg = format("cannot create a new %s json form",