From 47d345085bb6d6472c7d17683de85f011f356725 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 26 Nov 2019 11:33:25 +0100 Subject: [PATCH 1/2] added scope param to start provider sync --- src/main/java/me/figo/FigoSession.java | 17 +++++++++++++++-- .../internal/StartProviderSyncRequest.java | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/figo/FigoSession.java b/src/main/java/me/figo/FigoSession.java index 782451a..a9e9afa 100644 --- a/src/main/java/me/figo/FigoSession.java +++ b/src/main/java/me/figo/FigoSession.java @@ -321,6 +321,7 @@ public ChallengeV4 solveSyncChallenge(String accessId, String syncId, String cha /** * Retrieve the details of a specific provider access identified by its ID. * country + * @param scope * * @return List of Accesses * @@ -331,15 +332,27 @@ public ChallengeV4 solveSyncChallenge(String accessId, String syncId, String cha */ public SyncStatusResponse startProviderSync(String accessId, String state, String redirect_uri, boolean disable_notifications, - boolean save_credentials, Map credentials) throws FigoException, IOException { + boolean save_credentials, Map credentials, List scope) throws FigoException, IOException { StartProviderSyncRequest request = new StartProviderSyncRequest(state, redirect_uri, disable_notifications, - save_credentials, credentials); + save_credentials, credentials, scope); SyncStatusResponse response = this.queryApi("/rest/accesses/" + accessId + "/syncs", request, "POST", SyncStatusResponse.class); return response; } + public SyncStatusResponse startProviderSync(String accessId, String state, String redirect_uri, + boolean disable_notifications, + boolean save_credentials, Map credentials) throws FigoException, IOException { + + List scope = Collections.singletonList("TRANSACTIONS"); + StartProviderSyncRequest request = new StartProviderSyncRequest(state, redirect_uri, disable_notifications, + save_credentials, credentials, scope); + SyncStatusResponse response = this.queryApi("/rest/accesses/" + accessId + "/syncs", request, "POST", + SyncStatusResponse.class); + return response; + } + /** * Returns a list of all supported credit cards and payment services for a country * @param countryCode diff --git a/src/main/java/me/figo/internal/StartProviderSyncRequest.java b/src/main/java/me/figo/internal/StartProviderSyncRequest.java index b403ad7..c37ad91 100644 --- a/src/main/java/me/figo/internal/StartProviderSyncRequest.java +++ b/src/main/java/me/figo/internal/StartProviderSyncRequest.java @@ -1,5 +1,6 @@ package me.figo.internal; +import java.util.List; import java.util.Map; import com.google.gson.annotations.Expose; @@ -10,13 +11,14 @@ public class StartProviderSyncRequest { public StartProviderSyncRequest(String state, String redirect_uri, boolean disable_notifications, - boolean save_secrets, Map credentials) { + boolean save_secrets, Map credentials, List scope) { super(); this.state = state; this.redirect_uri = redirect_uri; this.disable_notifications = disable_notifications; this.save_secrets = save_secrets; this.credentials = credentials; + this.scope = scope; } /** @@ -25,6 +27,12 @@ public StartProviderSyncRequest(String state, String redirect_uri, boolean disab @Expose public String state; + /** + * Defines the scope of the synchronization. + */ + @Expose + public List scope; + /** * URL to redirect to when the synchronization finished */ @@ -98,4 +106,12 @@ public boolean isSaveSecrets() { public void setSaveSecrets(boolean save_secrets) { this.save_secrets = save_secrets; } + + public List getScope() { + return scope; + } + + public void setScope(List scope) { + this.scope = scope; + } } From 36ac4da2e1990014b81ba91f69121b1fac7e697e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 26 Nov 2019 14:57:17 +0100 Subject: [PATCH 2/2] introduced enum for syncscope, --- src/main/java/me/figo/FigoSession.java | 5 ++-- .../internal/StartProviderSyncRequest.java | 24 ++++--------------- src/main/java/me/figo/internal/SyncScope.java | 15 ++++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 src/main/java/me/figo/internal/SyncScope.java diff --git a/src/main/java/me/figo/FigoSession.java b/src/main/java/me/figo/FigoSession.java index a9e9afa..e43c915 100644 --- a/src/main/java/me/figo/FigoSession.java +++ b/src/main/java/me/figo/FigoSession.java @@ -40,6 +40,7 @@ import me.figo.internal.StartProviderSyncRequest; import me.figo.internal.SubmitPaymentRequest; import me.figo.internal.SyncChallengeRequest; +import me.figo.internal.SyncScope; import me.figo.internal.SyncStatusResponse; import me.figo.internal.SyncTokenRequest; import me.figo.internal.TaskResponseType; @@ -332,7 +333,7 @@ public ChallengeV4 solveSyncChallenge(String accessId, String syncId, String cha */ public SyncStatusResponse startProviderSync(String accessId, String state, String redirect_uri, boolean disable_notifications, - boolean save_credentials, Map credentials, List scope) throws FigoException, IOException { + boolean save_credentials, Map credentials, List scope) throws FigoException, IOException { StartProviderSyncRequest request = new StartProviderSyncRequest(state, redirect_uri, disable_notifications, save_credentials, credentials, scope); @@ -345,7 +346,7 @@ public SyncStatusResponse startProviderSync(String accessId, String state, Strin boolean disable_notifications, boolean save_credentials, Map credentials) throws FigoException, IOException { - List scope = Collections.singletonList("TRANSACTIONS"); + List scope = Collections.singletonList(SyncScope.TRANSACTIONS); StartProviderSyncRequest request = new StartProviderSyncRequest(state, redirect_uri, disable_notifications, save_credentials, credentials, scope); SyncStatusResponse response = this.queryApi("/rest/accesses/" + accessId + "/syncs", request, "POST", diff --git a/src/main/java/me/figo/internal/StartProviderSyncRequest.java b/src/main/java/me/figo/internal/StartProviderSyncRequest.java index c37ad91..60be8aa 100644 --- a/src/main/java/me/figo/internal/StartProviderSyncRequest.java +++ b/src/main/java/me/figo/internal/StartProviderSyncRequest.java @@ -11,7 +11,7 @@ public class StartProviderSyncRequest { public StartProviderSyncRequest(String state, String redirect_uri, boolean disable_notifications, - boolean save_secrets, Map credentials, List scope) { + boolean save_secrets, Map credentials, List scope) { super(); this.state = state; this.redirect_uri = redirect_uri; @@ -31,7 +31,7 @@ public StartProviderSyncRequest(String state, String redirect_uri, boolean disab * Defines the scope of the synchronization. */ @Expose - public List scope; + public List scope; /** * URL to redirect to when the synchronization finished @@ -51,22 +51,6 @@ public StartProviderSyncRequest(String state, String redirect_uri, boolean disab @Expose public Map credentials; - public String getRedirect_uri() { - return redirect_uri; - } - - public void setRedirect_uri(String redirect_uri) { - this.redirect_uri = redirect_uri; - } - - public boolean isDisable_notifications() { - return disable_notifications; - } - - public void setDisable_notifications(boolean disable_notifications) { - this.disable_notifications = disable_notifications; - } - public Map getCredentials() { return credentials; } @@ -107,11 +91,11 @@ public void setSaveSecrets(boolean save_secrets) { this.save_secrets = save_secrets; } - public List getScope() { + public List getScope() { return scope; } - public void setScope(List scope) { + public void setScope(List scope) { this.scope = scope; } } diff --git a/src/main/java/me/figo/internal/SyncScope.java b/src/main/java/me/figo/internal/SyncScope.java new file mode 100644 index 0000000..f2ef06f --- /dev/null +++ b/src/main/java/me/figo/internal/SyncScope.java @@ -0,0 +1,15 @@ +/** + * + */ +package me.figo.internal; + +/** + * Defines the scope of the synchronization.
+ * "ACCOUNTS": Only fetch basic account data (e.g. holder name, IBAN etc.). Add new provider accounts to previously synced accesses.
+ * "TRANSACTIONS": Fetch transaction and account data. + * @author Daniel + * + */ +public enum SyncScope { + ACCOUNTS,TRANSACTIONS +}