Skip to content

Commit

Permalink
Merge pull request #116 from gocardless/template-changes
Browse files Browse the repository at this point in the history
[MENG-527] Template changes
  • Loading branch information
kevthanewversi authored Nov 27, 2023
2 parents 107c635 + c6e7edb commit 0e79691
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 5 deletions.
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>5.20.0</version>
<version>5.21.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:5.20.0'
implementation 'com.gocardless:gocardless-pro:5.21.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 @@ -20,7 +20,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com.gocardless'
version = '5.20.0'
version = '5.21.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 @@ -44,6 +44,7 @@ public class GoCardlessClient {
private final SchemeIdentifierService schemeIdentifiers;
private final SubscriptionService subscriptions;
private final TaxRateService taxRates;
private final TransferredMandateService transferredMandates;
private final VerificationDetailService verificationDetails;
private final WebhookService webhooks;

Expand Down Expand Up @@ -197,6 +198,7 @@ private GoCardlessClient(HttpClient httpClient) {
this.schemeIdentifiers = new SchemeIdentifierService(httpClient);
this.subscriptions = new SubscriptionService(httpClient);
this.taxRates = new TaxRateService(httpClient);
this.transferredMandates = new TransferredMandateService(httpClient);
this.verificationDetails = new VerificationDetailService(httpClient);
this.webhooks = new WebhookService(httpClient);
}
Expand Down Expand Up @@ -411,6 +413,13 @@ public TaxRateService taxRates() {
return taxRates;
}

/**
* A service class for working with transferred mandate resources.
*/
public TransferredMandateService transferredMandates() {
return transferredMandates;
}

/**
* A service class for working with verification detail 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/5.20.0 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/5.21.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 @@ -48,7 +48,7 @@ public class HttpClient {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("GoCardless-Version", "2015-07-06");
builder.put("GoCardless-Client-Library", "gocardless-pro-java");
builder.put("GoCardless-Client-Version", "5.20.0");
builder.put("GoCardless-Client-Version", "5.21.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/com/gocardless/resources/TransferredMandate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.gocardless.resources;

/**
* Represents a transferred mandate resource returned from the API.
*
* Mandates that have been transferred using Current Account Switch Service
*/
public class TransferredMandate {
private TransferredMandate() {
// blank to prevent instantiation
}

private String encryptedCustomerBankDetails;
private String encryptedDecryptionKey;
private Links links;
private String publicKeyId;

/**
* Encrypted customer bank account details, containing: `iban`, `account_holder_name`,
* `swift_bank_code`, `swift_branch_code`, `swift_account_number`
*/
public String getEncryptedCustomerBankDetails() {
return encryptedCustomerBankDetails;
}

/**
* Random AES-256 key used to encrypt bank account details, itself encrypted with your public
* key.
*/
public String getEncryptedDecryptionKey() {
return encryptedDecryptionKey;
}

public Links getLinks() {
return links;
}

/**
* The ID of an RSA-2048 public key, from your JWKS, used to encrypt the AES key.
*/
public String getPublicKeyId() {
return publicKeyId;
}

public static class Links {
private Links() {
// blank to prevent instantiation
}

private String customerBankAccount;
private String mandate;

/**
* The ID of the updated [customer_bank_account](#core-endpoints-customer-bank-accounts)
*/
public String getCustomerBankAccount() {
return customerBankAccount;
}

/**
* The ID of the transferred mandate
*/
public String getMandate() {
return mandate;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.gocardless.services;

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

/**
* Service class for working with transferred mandate resources.
*
* Mandates that have been transferred using Current Account Switch Service
*/
public class TransferredMandateService {
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#transferredMandates() }.
*/
public TransferredMandateService(HttpClient httpClient) {
this.httpClient = httpClient;
}

/**
* Returns new customer bank details for a mandate that's been recently transferred
*/
public TransferredMandateTransferredMandatesRequest transferredMandates(String identity) {
return new TransferredMandateTransferredMandatesRequest(httpClient, identity);
}

/**
* Request class for {@link TransferredMandateService#transferredMandates }.
*
* Returns new customer bank details for a mandate that's been recently transferred
*/
public static final class TransferredMandateTransferredMandatesRequest
extends GetRequest<TransferredMandate> {
@PathParam
private final String identity;

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

public TransferredMandateTransferredMandatesRequest 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 String getPathTemplate() {
return "transferred_mandates/:identity";
}

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

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

0 comments on commit 0e79691

Please sign in to comment.