diff --git a/src/main/java/me/figo/FigoSession.java b/src/main/java/me/figo/FigoSession.java index 6473244..c47fddc 100644 --- a/src/main/java/me/figo/FigoSession.java +++ b/src/main/java/me/figo/FigoSession.java @@ -43,6 +43,10 @@ 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; import me.figo.models.PaymentContainer; @@ -182,6 +186,17 @@ public ServiceLoginSettings getLoginSettingsForService(String countryCode, Strin return this.queryApi("/rest/catalog/services/" + countryCode + "/" + serviceName, null, "GET", ServiceLoginSettings.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..fe9354a --- /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 getBankName() { + return bank_name; + } + + public String getBankCode() { + 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 getAdditionalIcons() { + 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..3f8c987 --- /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 getAvailableLanguages() { + return available_languages; + } + public String getCurrentLanguage() { + return current_language; + } +}