diff --git a/README.md b/README.md index 10594e99..e4937e29 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 6.5.0 + 6.6.0 ``` With Gradle: ``` -implementation 'com.gocardless:gocardless-pro:6.5.0' +implementation 'com.gocardless:gocardless-pro:6.6.0' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index 97226c8f..5e0c7ae1 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/src/main/java/com/gocardless/GoCardlessClient.java b/src/main/java/com/gocardless/GoCardlessClient.java index 97d0b14e..3d322ead 100644 --- a/src/main/java/com/gocardless/GoCardlessClient.java +++ b/src/main/java/com/gocardless/GoCardlessClient.java @@ -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; @@ -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); @@ -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. */ diff --git a/src/main/java/com/gocardless/http/HttpClient.java b/src/main/java/com/gocardless/http/HttpClient.java index 7a4bcaf5..3d8fbb49 100644 --- a/src/main/java/com/gocardless/http/HttpClient.java +++ b/src/main/java/com/gocardless/http/HttpClient.java @@ -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")), @@ -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; diff --git a/src/main/java/com/gocardless/resources/BankAccountDetail.java b/src/main/java/com/gocardless/resources/BankAccountDetail.java new file mode 100644 index 00000000..c4ecd16c --- /dev/null +++ b/src/main/java/com/gocardless/resources/BankAccountDetail.java @@ -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; + } +} diff --git a/src/main/java/com/gocardless/services/BankAccountDetailService.java b/src/main/java/com/gocardless/services/BankAccountDetailService.java new file mode 100644 index 00000000..f4046d63 --- /dev/null +++ b/src/main/java/com/gocardless/services/BankAccountDetailService.java @@ -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 { + @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 getPathParams() { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("identity", identity); + return params.build(); + } + + @Override + protected Map getQueryParams() { + ImmutableMap.Builder 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 getResponseClass() { + return BankAccountDetail.class; + } + } +}