Skip to content

Commit 963adda

Browse files
updated transferMethod query to fetch default currency code if exist. (#148)
* updated transferMethod query to fetch default currency code if exist. * Added mDefaultCurrencyCode to store the default currency code and initialize it inside the constructor.
1 parent 813709e commit 963adda

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

core/src/main/java/com/hyperwallet/android/model/graphql/keyed/Country.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class Country implements KeyedNode {
3838
private static final String CURRENCIES = "currencies";
3939

4040
private final Set<Currency> mCurrencies;
41+
42+
private final String mDefaultCurrencyCode;
4143
private final String mCode;
4244
private final MappedConnection<Currency> mCurrencyMappedConnection;
4345
private final String mName;
@@ -52,6 +54,7 @@ public Country(@NonNull final JSONObject country) throws JSONException, NoSuchMe
5254
mCode = country.optString(COUNTRY_CODE);
5355
mName = country.optString(COUNTRY_NAME);
5456
mCurrencies = new LinkedHashSet<>(1);
57+
mDefaultCurrencyCode = country.optString("defaultCurrencyCode");
5558
JSONObject currencies = country.optJSONObject(CURRENCIES);
5659
if (currencies != null && currencies.length() != 0) {
5760
mCurrencyMappedConnection = new MappedConnection<>(currencies, Currency.class);
@@ -78,6 +81,14 @@ public String getName() {
7881
return mName;
7982
}
8083

84+
/**
85+
* @return Currency code represented in ISO 4217 three-letter code format
86+
*/
87+
88+
public String getDefaultCurrency() {
89+
return mDefaultCurrencyCode;
90+
}
91+
8192
/**
8293
* @return set of {@code Currency} represented by this {@code Country} instance
8394
*/

core/src/main/java/com/hyperwallet/android/model/graphql/query/TransferMethodConfigurationKeysQuery.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class TransferMethodConfigurationKeysQuery implements GqlQuery {
3535
+ "\t\tnodes {\n"
3636
+ "\t\t\tcode\n"
3737
+ "\t\t\tname\n"
38+
+ "\t\t\tdefaultCurrencyCode\n"
3839
+ "\t\t\tcurrencies {\n"
3940
+ "\t\t\t\tnodes {\n"
4041
+ "\t\t\t\t\tcode\n"

core/src/test/java/com/hyperwallet/android/GqlTransactionBuilderTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void testBuild_withRequiredParametersOnly() {
5757
+ "\t\tnodes {\n"
5858
+ "\t\t\tcode\n"
5959
+ "\t\t\tname\n"
60+
+ "\t\t\tdefaultCurrencyCode\n"
6061
+ "\t\t\tcurrencies {\n"
6162
+ "\t\t\t\tnodes {\n"
6263
+ "\t\t\t\t\tcode\n"

core/src/test/java/com/hyperwallet/android/GqlTransactionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void testPerformRequest_usingHttpPost() throws IOException {
8282
+ "\t\tnodes {\n"
8383
+ "\t\t\tcode\n"
8484
+ "\t\t\tname\n"
85+
+ "\t\t\tdefaultCurrencyCode\n"
8586
+ "\t\t\tcurrencies {\n"
8687
+ "\t\t\t\tnodes {\n"
8788
+ "\t\t\t\t\tcode\n"

core/src/test/java/com/hyperwallet/android/model/graphql/query/TransferMethodConfigurationKeysQueryTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public void testToQuery_returnsQuery() {
1515
+ "\t\tnodes {\n"
1616
+ "\t\t\tcode\n"
1717
+ "\t\t\tname\n"
18+
+ "\t\t\tdefaultCurrencyCode\n"
1819
+ "\t\t\tcurrencies {\n"
1920
+ "\t\t\t\tnodes {\n"
2021
+ "\t\t\t\t\tcode\n"

0 commit comments

Comments
 (0)