Skip to content

Commit

Permalink
Merge pull request #59 from ConstantinKV/doc
Browse files Browse the repository at this point in the history
3.0.3: Partner Consent Revoke feature
  • Loading branch information
ConstantinKV authored Aug 6, 2019
2 parents 1cca533 + fa7b82f commit 46f133e
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 24 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
Expand Down
52 changes: 42 additions & 10 deletions SDK_GUIDE.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---
Expand Down Expand Up @@ -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.**

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1d08bb255884123b889297e40092a88
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bb8800ba8cd84f1a3ee7fd4afe000ce529eb5134
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dc8648ecfb00bdb3016fb34b6aa23eee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
77e01e0c8043918cc7541b7bd7a85a4e99d0cdb4
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.saltedge.sdk</groupId>
<artifactId>saltedge-library</artifactId>
<version>3.0.3</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-safetynet</artifactId>
<version>17.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>3.12.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations-java5</artifactId>
<version>16.0.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ed6e6aa00cf68467943cd6c4fa722d45
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21ce481ec14b3579a8bbe87f606960193fcba394
5 changes: 3 additions & 2 deletions repo/com/saltedge/sdk/saltedge-library/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>com.saltedge.sdk</groupId>
<artifactId>saltedge-library</artifactId>
<versioning>
<release>3.0.2</release>
<release>3.0.3</release>
<versions>
<version>1.3.1</version>
<version>1.3.2</version>
Expand All @@ -21,7 +21,8 @@
<version>3.0.0</version>
<version>3.0.1</version>
<version>3.0.2</version>
<version>3.0.3</version>
</versions>
<lastUpdated>20190806135442</lastUpdated>
<lastUpdated>20190806155028</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
35dadab2c16515ec18eb4dab93e3cf23
5f010124ee305fef7947523a72b28887
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1fac2fad449962c3eec2be614d1a5e81dcf9f046
b0e4b9055002711f8a5cfc76f065a07e5f339b9f
4 changes: 2 additions & 2 deletions saltedge-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public void onResponse(Call<ConsentResponse> call, Response<ConsentResponse> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ConsentResponse> {

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<ConsentResponse> call, Response<ConsentResponse> 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<ConsentResponse> call, Throwable t) {
onFailure(SEErrorTools.processConnectionError(t));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,10 @@ Call<ConsentResponse> 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<ConsentResponse> revokePartnerConsent(
@Query(value = SEConstants.KEY_CONNECTION_ID) String connectionId,
@Path(value = SEConstants.KEY_CONSENT_ID, encoded = true) String consentId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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();
}
Expand Down

0 comments on commit 46f133e

Please sign in to comment.