From bd4e62109269142267b63a6c9c4a38641f098c9c Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 12 Dec 2018 22:26:41 +0100 Subject: [PATCH 1/2] introduced new CatalogBanks object to support /catalog/banks rest call --- src/main/java/me/figo/FigoSession.java | 12 ++ src/main/java/me/figo/models/CatalogBank.java | 104 ++++++++++++++++++ src/main/java/me/figo/models/Language.java | 28 +++++ 3 files changed, 144 insertions(+) create mode 100644 src/main/java/me/figo/models/CatalogBank.java create mode 100644 src/main/java/me/figo/models/Language.java diff --git a/src/main/java/me/figo/FigoSession.java b/src/main/java/me/figo/FigoSession.java index 7c1c03f..0bd8ebe 100644 --- a/src/main/java/me/figo/FigoSession.java +++ b/src/main/java/me/figo/FigoSession.java @@ -43,6 +43,7 @@ import me.figo.models.Account; import me.figo.models.AccountBalance; import me.figo.models.Bank; +import me.figo.models.CatalogBank.CatalogBanksResponse; import me.figo.models.LoginSettings; import me.figo.models.Notification; import me.figo.models.Payment; @@ -184,6 +185,17 @@ public LoginSettings getLoginSettings(String countryCode, String bankCode) throw return this.queryApi("/rest/catalog/banks/" + countryCode + "/" + bankCode, null, "GET", LoginSettings.class); } + /** + * Returns banks catalog by country + * @param countryCode ISO 3166-1 + * @return CatalogBanksResponse containing a list of banks for that country + * @throws FigoException + * @throws IOException + */ + public CatalogBanksResponse getCatalogBanks(String countryCode) throws FigoException, IOException { + return this.queryApi("/rest/catalog/banks/" + countryCode, null, "GET", CatalogBanksResponse.class); + } + @Deprecated /** * Returns a TaskToken for a new account creation task diff --git a/src/main/java/me/figo/models/CatalogBank.java b/src/main/java/me/figo/models/CatalogBank.java new file mode 100644 index 0000000..aeece9c --- /dev/null +++ b/src/main/java/me/figo/models/CatalogBank.java @@ -0,0 +1,104 @@ +/** + * + */ +package me.figo.models; + +import java.util.List; +import java.util.Map; + +import com.google.gson.annotations.Expose; +import com.google.gson.internal.LinkedTreeMap; + +/** + * object representing the response of a /catalog/banks/{country_code} request + * + * @author Daniel + * + */ +public class CatalogBank { + + @Expose + private String bank_name; + + @Expose + private List icon; + + @Expose + private Language language; + + @Expose + private String bank_code; + + @Expose + private String bic; + + @Expose + private List credentials; + + @Expose + private String advice; + + public String getBic() { + return bic; + } + + public Language getLanguage() { + return language; + } + + public List getCredentials() { + return credentials; + } + + public String getAdvice() { + return advice; + } + + public String getBank_name() { + return bank_name; + } + + public String getBank_code() { + return bank_code; + } + + /** + * wrapper class holding the list of banks as returned by figo api + * + * @author Daniel + * + */ + public static class CatalogBanksResponse { + /** + * List of banks asked for + */ + @Expose + private List banks; + + public List getBanks() { + return banks; + } + + } + + /** + * @return bank icon URL + */ + public String getIconUrl() { + if(icon!=null&&icon.size()>0){ + return (String) icon.get(0); + } + return ""; + } + + /** + * @return the bank icon in other resolutions + */ + @SuppressWarnings("unchecked") + public Map getAddtionalIcons() { + if(icon!=null&&icon.size()>1){ + return (LinkedTreeMap) icon.get(1); + } + return null; + } +} diff --git a/src/main/java/me/figo/models/Language.java b/src/main/java/me/figo/models/Language.java new file mode 100644 index 0000000..c0a96cd --- /dev/null +++ b/src/main/java/me/figo/models/Language.java @@ -0,0 +1,28 @@ +/** + * + */ +package me.figo.models; + +import java.util.List; + +import com.google.gson.annotations.Expose; + +/** + * @author Daniel + * + */ +public class Language { + + @Expose + private List available_languages; + + @Expose + private String current_language; + + public List getAvailable_languages() { + return available_languages; + } + public String getCurrent_language() { + return current_language; + } +} From d5bb8d6bd8408874f4586d617ca6414d6b75732d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 18 Dec 2018 14:34:47 +0100 Subject: [PATCH 2/2] fixed methodNames (one typo and camel case) --- src/main/java/me/figo/models/CatalogBank.java | 6 +++--- src/main/java/me/figo/models/Language.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/figo/models/CatalogBank.java b/src/main/java/me/figo/models/CatalogBank.java index aeece9c..fe9354a 100644 --- a/src/main/java/me/figo/models/CatalogBank.java +++ b/src/main/java/me/figo/models/CatalogBank.java @@ -54,11 +54,11 @@ public String getAdvice() { return advice; } - public String getBank_name() { + public String getBankName() { return bank_name; } - public String getBank_code() { + public String getBankCode() { return bank_code; } @@ -95,7 +95,7 @@ public String getIconUrl() { * @return the bank icon in other resolutions */ @SuppressWarnings("unchecked") - public Map getAddtionalIcons() { + public Map getAdditionalIcons() { if(icon!=null&&icon.size()>1){ return (LinkedTreeMap) icon.get(1); } diff --git a/src/main/java/me/figo/models/Language.java b/src/main/java/me/figo/models/Language.java index c0a96cd..3f8c987 100644 --- a/src/main/java/me/figo/models/Language.java +++ b/src/main/java/me/figo/models/Language.java @@ -19,10 +19,10 @@ public class Language { @Expose private String current_language; - public List getAvailable_languages() { + public List getAvailableLanguages() { return available_languages; } - public String getCurrent_language() { + public String getCurrentLanguage() { return current_language; } }