diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d8ee534..5c8ccfd 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,6 +1,13 @@ # Salt Edge SDK library changelog -## [3.0.2] - 2019-08-06 +## [3.0.3] - 2019-08-06 +### Added +- Added Revoke Partner Consent feature + +### Changed +- Fixed Saltbridge object parse error + +## [3.0.2] - 2019-08-05 ### Added - Added documented sources to maven repository diff --git a/README.MD b/README.MD index 70d5d6b..ec0e4cf 100644 --- a/README.MD +++ b/README.MD @@ -64,7 +64,7 @@ repositories { ### Add SDK dependency to application `build.gradle` ```groovy -implementation ('com.saltedge.sdk:saltedge-library:3.0.2@aar') { +implementation ('com.saltedge.sdk:saltedge-library:3.0.3@aar') { transitive = true } ``` diff --git a/SDK_GUIDE.MD b/SDK_GUIDE.MD index 7ded2ec..6a07e40 100644 --- a/SDK_GUIDE.MD +++ b/SDK_GUIDE.MD @@ -23,8 +23,9 @@ * [Remove transactions](#remove-transactions) * [Consent](#consent) * [Show Consents](#show-consents) - * [Show Partners Consents](#show-partners-consents) * [Revoke Consent](#revoke-consent) + * [Show Partners Consents](#show-partners-consents) + * [Revoke Partner Consent](#revoke-partner-consent) * [Models](#models) * [Utilities](#utilities) --- @@ -798,6 +799,38 @@ SERequestManager.getInstance().fetchConsents( ); ``` +### [Revoke Consent](https://docs.saltedge.com/account_information/v5/#consents-revoke) +**Note: `Revoke Consent` feature is not available for Partners API.** + +Consent revoke is an option that allows you to revoke a consent for a connection of customer. + +#### Params: + +* `customerSecret` - unique customer secret. Not required for Partners API; +* `connectionSecret` - secret of connection which data should be fetched. +* `consentId` - unique ID of Consent which should be revoked + +#### Example: + +```java +SERequestManager.getInstance().revokeConsent( + customerSecret, + connectionSecret, + consentId, + new DeleteEntryResult() { + @Override + public void onSuccess(Boolean entryIsRemoved, String entryId) { + //show changes + } + + @Override + public void onFailure(String errorResponse) { + //handle error + } + } +); +``` + ### [Show Partners Consents](https://docs.saltedge.com/partners/v1/#partner_consents) **Note: `Get Partners Consent` feature is available only for Partners API.** @@ -826,26 +859,25 @@ SERequestManager.getInstance().fetchPartnerConsents( ); ``` -### [Revoke Consent](https://docs.saltedge.com/account_information/v5/#consents-revoke) -**Note: `Revoke Consent` feature is not available for Partners API.** +### [Revoke Partner Consent](https://docs.saltedge.com/partners/v1/#partner_consents-revoke) +**Note: `Revoke Partner Consent` feature is available only for Partners API.** -Consent revoke is an option that allows you to revoke a consent for a connection of customer. +Partner Consent revoke is an option that allows you to revoke a consent for a connection of customer (connection). #### Params: -* `customerSecret` - unique customer secret. Not required for Partners API; -* `connectionSecret` - secret of connection which data should be fetched. +* `connectionId` - unique ID of connection +* `consentId` - unique ID of Consent which should be revoked #### Example: ```java -SERequestManager.getInstance().revokeConsent( - customerSecret, - connectionSecret, +SERequestManager.getInstance().revokePartnerConsent( + connectionId, consentId, new DeleteEntryResult() { @Override - public void onSuccess(Boolean isRemoved) { + public void onSuccess(Boolean entryIsRemoved, String entryId) { //show changes } diff --git a/app/build.gradle b/app/build.gradle index fd0268e..52b4a02 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,7 @@ repositories { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation ('com.saltedge.sdk:saltedge-library:3.0.2@aar') { + implementation ('com.saltedge.sdk:saltedge-library:3.0.3@aar') { transitive = true } diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar new file mode 100644 index 0000000..a2043fe Binary files /dev/null and b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar differ diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.md5 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.md5 new file mode 100644 index 0000000..a5b8f6c --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.md5 @@ -0,0 +1 @@ +a1d08bb255884123b889297e40092a88 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.sha1 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.sha1 new file mode 100644 index 0000000..9345347 --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3-sources.jar.sha1 @@ -0,0 +1 @@ +bb8800ba8cd84f1a3ee7fd4afe000ce529eb5134 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar new file mode 100644 index 0000000..48d532d Binary files /dev/null and b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar differ diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.md5 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.md5 new file mode 100644 index 0000000..f14f931 --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.md5 @@ -0,0 +1 @@ +dc8648ecfb00bdb3016fb34b6aa23eee \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.sha1 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.sha1 new file mode 100644 index 0000000..ea26a8f --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.aar.sha1 @@ -0,0 +1 @@ +77e01e0c8043918cc7541b7bd7a85a4e99d0cdb4 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom new file mode 100644 index 0000000..8ad830b --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom @@ -0,0 +1,41 @@ + + + 4.0.0 + com.saltedge.sdk + saltedge-library + 3.0.3 + aar + + + com.google.android.gms + play-services-safetynet + 17.0.0 + compile + + + com.squareup.retrofit2 + retrofit + 2.5.0 + compile + + + com.squareup.retrofit2 + converter-gson + 2.5.0 + compile + + + com.squareup.okhttp3 + logging-interceptor + 3.12.2 + compile + + + org.jetbrains + annotations-java5 + 16.0.3 + compile + + + diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.md5 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.md5 new file mode 100644 index 0000000..f693320 --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.md5 @@ -0,0 +1 @@ +ed6e6aa00cf68467943cd6c4fa722d45 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.sha1 b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.sha1 new file mode 100644 index 0000000..29acf8a --- /dev/null +++ b/repo/com/saltedge/sdk/saltedge-library/3.0.3/saltedge-library-3.0.3.pom.sha1 @@ -0,0 +1 @@ +21ce481ec14b3579a8bbe87f606960193fcba394 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml index e67c30f..c05c183 100644 --- a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml +++ b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml @@ -3,7 +3,7 @@ com.saltedge.sdk saltedge-library - 3.0.2 + 3.0.3 1.3.1 1.3.2 @@ -21,7 +21,8 @@ 3.0.0 3.0.1 3.0.2 + 3.0.3 - 20190806135442 + 20190806155028 diff --git a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.md5 b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.md5 index da269a5..9d21e92 100644 --- a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.md5 +++ b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.md5 @@ -1 +1 @@ -35dadab2c16515ec18eb4dab93e3cf23 \ No newline at end of file +5f010124ee305fef7947523a72b28887 \ No newline at end of file diff --git a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.sha1 b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.sha1 index ae2ed29..c76435b 100644 --- a/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.sha1 +++ b/repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml.sha1 @@ -1 +1 @@ -1fac2fad449962c3eec2be614d1a5e81dcf9f046 \ No newline at end of file +b0e4b9055002711f8a5cfc76f065a07e5f339b9f \ No newline at end of file diff --git a/saltedge-library/build.gradle b/saltedge-library/build.gradle index 5510adb..d766b40 100644 --- a/saltedge-library/build.gradle +++ b/saltedge-library/build.gradle @@ -2,8 +2,8 @@ apply plugin: 'com.android.library' apply plugin: 'maven' -def appVersionCode = 17 -def appVersionName = "3.0.2" +def appVersionCode = 18 +def appVersionName = "3.0.3" android { compileSdkVersion 28 diff --git a/saltedge-library/src/main/java/com/saltedge/sdk/connector/ConsentRevokeConnector.java b/saltedge-library/src/main/java/com/saltedge/sdk/connector/ConsentRevokeConnector.java index 3ae277c..392ecce 100644 --- a/saltedge-library/src/main/java/com/saltedge/sdk/connector/ConsentRevokeConnector.java +++ b/saltedge-library/src/main/java/com/saltedge/sdk/connector/ConsentRevokeConnector.java @@ -64,8 +64,7 @@ public void onResponse(Call call, Response res ConsentResponse responseBody = response.body(); if (response.isSuccessful() && responseBody != null && responseBody.getData() != null) { callback.onSuccess(responseBody.getData().getRevokedAt() != null, consentId); - } - else onFailure(SEJsonTools.getErrorMessage(response.errorBody())); + } else onFailure(SEJsonTools.getErrorMessage(response.errorBody())); } @Override diff --git a/saltedge-library/src/main/java/com/saltedge/sdk/connector/PartnerConsentRevokeConnector.java b/saltedge-library/src/main/java/com/saltedge/sdk/connector/PartnerConsentRevokeConnector.java new file mode 100644 index 0000000..fba8ce9 --- /dev/null +++ b/saltedge-library/src/main/java/com/saltedge/sdk/connector/PartnerConsentRevokeConnector.java @@ -0,0 +1,72 @@ +/* +Copyright © 2019 Salt Edge. https://saltedge.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package com.saltedge.sdk.connector; + +import com.saltedge.sdk.interfaces.DeleteEntryResult; +import com.saltedge.sdk.model.response.ConsentResponse; +import com.saltedge.sdk.network.SERestClient; +import com.saltedge.sdk.utils.SEErrorTools; +import com.saltedge.sdk.utils.SEJsonTools; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class PartnerConsentRevokeConnector extends BasePinnedConnector implements Callback { + + private final DeleteEntryResult callback; + private String connectionId; + private String consentId; + + public PartnerConsentRevokeConnector(DeleteEntryResult callback) { + this.callback = callback; + } + + public void revokePartnerConsent(String connectionId, String consentId) { + this.connectionId = connectionId; + this.consentId = consentId; + checkAndLoadPinsOrDoRequest(); + } + + @Override + void enqueueCall() { + SERestClient.getInstance().service.revokePartnerConsent(connectionId, consentId).enqueue(this); + } + + @Override + void onFailure(String errorMessage) { + if (callback != null) callback.onFailure(errorMessage); + } + + @Override + public void onResponse(Call call, Response response) { + ConsentResponse responseBody = response.body(); + if (response.isSuccessful() && responseBody != null && responseBody.getData() != null) { + callback.onSuccess(responseBody.getData().getRevokedAt() != null, consentId); + } else onFailure(SEJsonTools.getErrorMessage(response.errorBody())); + } + + @Override + public void onFailure(Call call, Throwable t) { + onFailure(SEErrorTools.processConnectionError(t)); + } +} diff --git a/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiConstants.java b/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiConstants.java index ac99630..f3b1b0f 100644 --- a/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiConstants.java +++ b/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiConstants.java @@ -70,6 +70,7 @@ public class SEApiConstants { static final String API_CONSENTS_PATH = "consents"; static final String API_CONSENT_REVOKE_PATH = API_CONSENTS_PATH + "/{" + SEConstants.KEY_CONSENT_ID + "}/revoke"; static final String API_PARTNER_CONSENTS_PATH = "partner_consents"; + static final String API_PARTNER_CONSENT_REVOKE_PATH = API_PARTNER_CONSENTS_PATH + "/{" + SEConstants.KEY_CONSENT_ID + "}/revoke"; //Partners API URLs static final String PARTNERS_API_PATH = "api/partners/v1/"; diff --git a/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiInterface.java b/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiInterface.java index 27e0a28..3447435 100644 --- a/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiInterface.java +++ b/saltedge-library/src/main/java/com/saltedge/sdk/network/SEApiInterface.java @@ -203,4 +203,10 @@ Call revokeConsent( @Header(SEApiConstants.KEY_HEADER_CONNECTION_SECRET) String connectionSecret, @Path(value = SEConstants.KEY_CONSENT_ID, encoded = true) String consentId ); + + @PUT(SEApiConstants.API_PARTNER_CONSENT_REVOKE_PATH) + Call revokePartnerConsent( + @Query(value = SEConstants.KEY_CONNECTION_ID) String connectionId, + @Path(value = SEConstants.KEY_CONSENT_ID, encoded = true) String consentId + ); } diff --git a/saltedge-library/src/main/java/com/saltedge/sdk/network/SERequestManager.java b/saltedge-library/src/main/java/com/saltedge/sdk/network/SERequestManager.java index fd099ae..d49c5c6 100644 --- a/saltedge-library/src/main/java/com/saltedge/sdk/network/SERequestManager.java +++ b/saltedge-library/src/main/java/com/saltedge/sdk/network/SERequestManager.java @@ -31,6 +31,7 @@ of this software and associated documentation files (the "Software"), to deal import com.saltedge.sdk.connector.CustomerConnector; import com.saltedge.sdk.connector.DuplicatedTransactionsFetchConnector; import com.saltedge.sdk.connector.LeadSessionConnector; +import com.saltedge.sdk.connector.PartnerConsentRevokeConnector; import com.saltedge.sdk.connector.PartnerConsentsConnector; import com.saltedge.sdk.connector.PendingTransactionsFetchConnector; import com.saltedge.sdk.connector.ProvidersConnector; @@ -759,8 +760,8 @@ public void fetchConsents( * Feature is not available for Partner Application. * * @param customerSecret current Customer secret code - * @param connectionSecret secret code of the Connection which should be deleted if exist - * @param consentId id of Consent which should be revoked + * @param connectionSecret secret code of the Connection containing the consents + * @param consentId unique ID of Consent which should be revoked * @param callback callback for request result */ public void revokeConsent( @@ -778,7 +779,7 @@ public void revokeConsent( * The consents are sorted in ascending order of their ID, so the newest consent will come last. * Result is returned through callback. * - * Feature is not available for Partner Application. + * Feature is available only for Partner Application. * * @param connectionSecret secret code of the Connection * @param callback callback for request result @@ -791,6 +792,25 @@ public void fetchPartnerConsents( new PartnerConsentsConnector(callback).fetchPartnerConsents(connectionSecret); } + /** + * Partner consent revoke is an action that allows you to revoke a partner consent given by a specific customer. + * Result is returned through callback. + * + * Feature is available only for Partner Application. + * + * @param connectionId unique ID of the Connection containing the consents + * @param consentId unique ID of Consent which should be revoked + * @param callback callback for request result + */ + public void revokePartnerConsent( + @NotNull String connectionId, + @NotNull String consentId, + DeleteEntryResult callback + ) { + featureIsAvailableForPartnerOnly(); + new PartnerConsentRevokeConnector(callback).revokePartnerConsent(connectionId, consentId); + } + private void featureIsAvailableForPartnerOnly() { if (SaltEdgeSDK.isNotPartner()) throw new SDKFeatureException(); }