Skip to content

Changes from gocardless/gocardless-pro-java-template #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ With Maven:
<dependency>
<groupId>com.gocardless</groupId>
<artifactId>gocardless-pro</artifactId>
<version>6.5.0</version>
<version>6.6.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:6.5.0'
implementation 'com.gocardless:gocardless-pro:6.6.0'
```

## Initializing the client
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com.gocardless'
version = '6.5.0'
version = '6.6.0'

apply plugin: 'ch.raffael.pegdown-doclet'

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/gocardless/GoCardlessClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class GoCardlessClient {
private final HttpClient httpClient;
private final BalanceService balances;
private final BankAccountDetailService bankAccountDetails;
private final BankAuthorisationService bankAuthorisations;
private final BankDetailsLookupService bankDetailsLookups;
private final BillingRequestService billingRequests;
Expand Down Expand Up @@ -173,6 +174,7 @@ public GoCardlessClient build() {
private GoCardlessClient(HttpClient httpClient) {
this.httpClient = httpClient;
this.balances = new BalanceService(httpClient);
this.bankAccountDetails = new BankAccountDetailService(httpClient);
this.bankAuthorisations = new BankAuthorisationService(httpClient);
this.bankDetailsLookups = new BankDetailsLookupService(httpClient);
this.billingRequests = new BillingRequestService(httpClient);
Expand Down Expand Up @@ -218,6 +220,13 @@ public BalanceService balances() {
return balances;
}

/**
* A service class for working with bank account detail resources.
*/
public BankAccountDetailService bankAccountDetails() {
return bankAccountDetails;
}

/**
* A service class for working with bank authorisation resources.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gocardless/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class HttpClient {
private static final String DISALLOWED_USER_AGENT_CHARACTERS =
"[^\\w!#$%&'\\*\\+\\-\\.\\^`\\|~]";
private static final String USER_AGENT =
String.format("gocardless-pro-java/6.5.0 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/6.6.0 java/%s %s/%s %s/%s",
cleanUserAgentToken(System.getProperty("java.vm.specification.version")),
cleanUserAgentToken(System.getProperty("java.vm.name")),
cleanUserAgentToken(System.getProperty("java.version")),
Expand All @@ -49,7 +49,7 @@ public class HttpClient {
builder.put("GoCardless-Version", "2015-07-06");
builder.put("Accept", "application/json");
builder.put("GoCardless-Client-Library", "gocardless-pro-java");
builder.put("GoCardless-Client-Version", "6.5.0");
builder.put("GoCardless-Client-Version", "6.6.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/com/gocardless/resources/BankAccountDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.gocardless.resources;

import com.google.gson.annotations.SerializedName;

/**
* Represents a bank account detail resource returned from the API.
*
* Retrieve bank account details in JWE encrypted format
*/
public class BankAccountDetail {
private BankAccountDetail() {
// blank to prevent instantiation
}

private String ciphertext;
private String encryptedKey;
private String iv;
@SerializedName("protected")
private String protectedValue;
private String tag;

/**
* Base64 URL encoded encrypted payload, in this case bank details.
*/
public String getCiphertext() {
return ciphertext;
}

/**
* Base64 URL encoded symmetric content encryption key, encrypted with the asymmetric key from
* your JWKS.
*/
public String getEncryptedKey() {
return encryptedKey;
}

/**
* Base64 URL encoded initialization vector, used during content encryption.
*/
public String getIv() {
return iv;
}

/**
* Base64 URL encoded JWE header values, containing the following keys:
*
* - `alg`: the asymmetric encryption type used to encrypt symmetric key, e.g: `RSA-OAEP`. -
* `enc`: the content encryption type, e.g: `A256GCM`. - `kid`: the ID of an RSA-2048 public
* key, from your JWKS, used to encrypt the AES key.
*/
public String getProtectedValue() {
return protectedValue;
}

/**
* Base64 URL encoded authentication tag, used to verify payload integrity during decryption.
*/
public String getTag() {
return tag;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.gocardless.services;

import com.gocardless.http.*;
import com.gocardless.resources.BankAccountDetail;
import com.google.common.collect.ImmutableMap;
import java.util.Map;

/**
* Service class for working with bank account detail resources.
*
* Retrieve bank account details in JWE encrypted format
*/
public class BankAccountDetailService {
private final HttpClient httpClient;

/**
* Constructor. Users of this library should have no need to call this - an instance of this
* class can be obtained by calling
* {@link com.gocardless.GoCardlessClient#bankAccountDetails() }.
*/
public BankAccountDetailService(HttpClient httpClient) {
this.httpClient = httpClient;
}

/**
* Returns bank account details in the flattened JSON Web Encryption format described in RFC
* 7516
*/
public BankAccountDetailGetRequest get(String identity) {
return new BankAccountDetailGetRequest(httpClient, identity);
}

/**
* Request class for {@link BankAccountDetailService#get }.
*
* Returns bank account details in the flattened JSON Web Encryption format described in RFC
* 7516
*/
public static final class BankAccountDetailGetRequest extends GetRequest<BankAccountDetail> {
@PathParam
private final String identity;

private BankAccountDetailGetRequest(HttpClient httpClient, String identity) {
super(httpClient);
this.identity = identity;
}

public BankAccountDetailGetRequest withHeader(String headerName, String headerValue) {
this.addHeader(headerName, headerValue);
return this;
}

@Override
protected Map<String, String> getPathParams() {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("identity", identity);
return params.build();
}

@Override
protected Map<String, Object> getQueryParams() {
ImmutableMap.Builder<String, Object> params = ImmutableMap.builder();
params.putAll(super.getQueryParams());
return params.build();
}

@Override
protected String getPathTemplate() {
return "bank_account_details/:identity";
}

@Override
protected String getEnvelope() {
return "bank_account_details";
}

@Override
protected Class<BankAccountDetail> getResponseClass() {
return BankAccountDetail.class;
}
}
}