Skip to content

Commit

Permalink
Merge pull request #130 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Changes from gocardless/gocardless-pro-java-template
  • Loading branch information
KarmanLeung authored Aug 6, 2024
2 parents f6f7d34 + c906982 commit f8a92a2
Show file tree
Hide file tree
Showing 17 changed files with 356 additions and 83 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.26.1</version>
<version>5.27.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:5.26.1'
implementation 'com.gocardless:gocardless-pro:5.27.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 = '5.26.1'
version = '5.27.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 @@ -27,6 +27,7 @@ public class GoCardlessClient {
private final CustomerBankAccountService customerBankAccounts;
private final CustomerNotificationService customerNotifications;
private final EventService events;
private final ExportService exports;
private final InstalmentScheduleService instalmentSchedules;
private final InstitutionService institutions;
private final LogoService logos;
Expand Down Expand Up @@ -183,6 +184,7 @@ private GoCardlessClient(HttpClient httpClient) {
this.customerBankAccounts = new CustomerBankAccountService(httpClient);
this.customerNotifications = new CustomerNotificationService(httpClient);
this.events = new EventService(httpClient);
this.exports = new ExportService(httpClient);
this.instalmentSchedules = new InstalmentScheduleService(httpClient);
this.institutions = new InstitutionService(httpClient);
this.logos = new LogoService(httpClient);
Expand Down Expand Up @@ -298,6 +300,13 @@ public EventService events() {
return events;
}

/**
* A service class for working with export resources.
*/
public ExportService exports() {
return exports;
}

/**
* A service class for working with instalment schedule 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.26.1 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/5.27.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", "5.26.1");
builder.put("GoCardless-Client-Version", "5.27.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
25 changes: 17 additions & 8 deletions src/main/java/com/gocardless/resources/BillingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ private PaymentRequest() {
private FundsSettlement fundsSettlement;
private Links links;
private Map<String, Object> metadata;
private String reference;
private String scheme;

/**
Expand All @@ -779,7 +780,7 @@ public Integer getAppFee() {
/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP` and
* `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your customers in
* Germany only.
* supported Eurozone countries only.
*/
public String getCurrency() {
return currency;
Expand Down Expand Up @@ -818,12 +819,21 @@ public Map<String, Object> getMetadata() {
return metadata;
}

/**
* A custom payment reference defined by the merchant. It is only available for payments
* using the Direct Funds settlement model on the Faster Payments scheme.
*
*/
public String getReference() {
return reference;
}

/**
* (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is
* supported in the UK (GBP) and `sepa_credit_transfer` and `sepa_instant_credit_transfer`
* are supported in Germany (EUR). In Germany, `sepa_credit_transfer` is used as the
* default. Please be aware that `sepa_instant_credit_transfer` may incur an additional fee
* for your customer.
* are supported in supported Eurozone countries (EUR). For Eurozone countries,
* `sepa_credit_transfer` is used as the default. Please be aware that
* `sepa_instant_credit_transfer` may incur an additional fee for your customer.
*/
public String getScheme() {
return scheme;
Expand Down Expand Up @@ -1002,10 +1012,9 @@ private CustomerBankAccount() {
private Map<String, Object> metadata;

/**
* Name of the account holder, as known by the bank. Usually this is the same as the
* name stored with the linked [creditor](#core-endpoints-creditors). This field will be
* transliterated, upcased and truncated to 18 characters. This field is required unless
* the request includes a [customer bank account
* Name of the account holder, as known by the bank. This field will be transliterated,
* upcased and truncated to 18 characters. This field is required unless the request
* includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
*/
public String getAccountHolderName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public Integer getPaymentRequestAmount() {

/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP` and `EUR`
* supported; `GBP` with your customers in the UK and for `EUR` with your customers in Germany
* only.
* supported; `GBP` with your customers in the UK and for `EUR` with your customers in supported
* Eurozone countries only.
*/
public String getPaymentRequestCurrency() {
return paymentRequestCurrency;
Expand All @@ -177,8 +177,9 @@ public Map<String, Object> getPaymentRequestMetadata() {
/**
* (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is supported
* in the UK (GBP) and `sepa_credit_transfer` and `sepa_instant_credit_transfer` are supported
* in Germany (EUR). In Germany, `sepa_credit_transfer` is used as the default. Please be aware
* that `sepa_instant_credit_transfer` may incur an additional fee for your customer.
* in supported Eurozone countries (EUR). For Eurozone countries, `sepa_credit_transfer` is used
* as the default. Please be aware that `sepa_instant_credit_transfer` may incur an additional
* fee for your customer.
*/
public String getPaymentRequestScheme() {
return paymentRequestScheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ private CustomerBankAccount() {
private Map<String, Object> metadata;

/**
* Name of the account holder, as known by the bank. Usually this is the same as the name stored
* with the linked [creditor](#core-endpoints-creditors). This field will be transliterated,
* upcased and truncated to 18 characters. This field is required unless the request includes a
* Name of the account holder, as known by the bank. This field will be transliterated, upcased
* and truncated to 18 characters. This field is required unless the request includes a
* [customer bank account token](#javascript-flow-customer-bank-account-tokens).
*/
public String getAccountHolderName() {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/gocardless/resources/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public Map<String, Object> getResourceMetadata() {
* <ul>
* <li>`billing_requests`</li>
* <li>`creditors`</li>
* <li>`exports`</li>
* <li>`instalment_schedules`</li>
* <li>`mandates`</li>
* <li>`payer_authorisations`</li>
Expand All @@ -111,7 +112,8 @@ public ResourceType getResourceType() {
public enum ResourceType {
@SerializedName("billing_requests")
BILLING_REQUESTS, @SerializedName("creditors")
CREDITORS, @SerializedName("instalment_schedules")
CREDITORS, @SerializedName("exports")
EXPORTS, @SerializedName("instalment_schedules")
INSTALMENT_SCHEDULES, @SerializedName("mandates")
MANDATES, @SerializedName("organisations")
ORGANISATIONS, @SerializedName("payer_authorisations")
Expand Down
82 changes: 82 additions & 0 deletions src/main/java/com/gocardless/resources/Export.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.gocardless.resources;

import com.google.gson.annotations.SerializedName;

/**
* Represents a export resource returned from the API.
*
* File-based exports of data
*/
public class Export {
private Export() {
// blank to prevent instantiation
}

private String createdAt;
private String currency;
private String downloadUrl;
private ExportType exportType;
private String id;

/**
* Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created.
*/
public String getCreatedAt() {
return createdAt;
}

/**
* The currency of the export (if applicable)
*/
public String getCurrency() {
return currency;
}

/**
* Download url for the export file. Subject to expiry.
*/
public String getDownloadUrl() {
return downloadUrl;
}

/**
* The type of the export
*/
public ExportType getExportType() {
return exportType;
}

/**
* Unique identifier, beginning with "EX".
*/
public String getId() {
return id;
}

public enum ExportType {
@SerializedName("payments_index")
PAYMENTS_INDEX, @SerializedName("events_index")
EVENTS_INDEX, @SerializedName("refunds_index")
REFUNDS_INDEX, @SerializedName("payouts_index")
PAYOUTS_INDEX, @SerializedName("customers_index")
CUSTOMERS_INDEX, @SerializedName("subscriptions_index")
SUBSCRIPTIONS_INDEX, @SerializedName("payment_events")
PAYMENT_EVENTS, @SerializedName("subscription_events")
SUBSCRIPTION_EVENTS, @SerializedName("payout_events")
PAYOUT_EVENTS, @SerializedName("refund_events")
REFUND_EVENTS, @SerializedName("mandate_events")
MANDATE_EVENTS, @SerializedName("payout_events_breakdown")
PAYOUT_EVENTS_BREAKDOWN, @SerializedName("payout_events_reconciliation")
PAYOUT_EVENTS_RECONCILIATION, @SerializedName("payout_transactions_breakdown")
PAYOUT_TRANSACTIONS_BREAKDOWN, @SerializedName("payout_transactions_reconciliation")
PAYOUT_TRANSACTIONS_RECONCILIATION, @SerializedName("authorisation_requests")
AUTHORISATION_REQUESTS, @SerializedName("customer_bank_accounts")
CUSTOMER_BANK_ACCOUNTS, @SerializedName("users")
USERS, @SerializedName("organisation_authorisations")
ORGANISATION_AUTHORISATIONS, @SerializedName("gc_invalid_authorisation_requests")
GC_INVALID_AUTHORISATION_REQUESTS, @SerializedName("partner_fees")
PARTNER_FEES, @SerializedName("payments_import_template")
PAYMENTS_IMPORT_TEMPLATE, @SerializedName("unknown")
UNKNOWN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,9 @@ private BankAccount() {
private Map<String, Object> metadata;

/**
* Name of the account holder, as known by the bank. Usually this is the same as the name
* stored with the linked [creditor](#core-endpoints-creditors). This field will be
* transliterated, upcased and truncated to 18 characters. This field is required unless the
* request includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
* Name of the account holder, as known by the bank. This field will be transliterated,
* upcased and truncated to 18 characters. This field is required unless the request
* includes a [customer bank account token](#javascript-flow-customer-bank-account-tokens).
*/
public String getAccountHolderName() {
return accountHolderName;
Expand Down
49 changes: 36 additions & 13 deletions src/main/java/com/gocardless/services/BillingRequestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public BillingRequestCreateRequest withPaymentRequestAppFee(Integer appFee) {
/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP` and
* `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your customers in
* Germany only.
* supported Eurozone countries only.
*/
public BillingRequestCreateRequest withPaymentRequestCurrency(String currency) {
if (paymentRequest == null) {
Expand Down Expand Up @@ -461,12 +461,25 @@ public BillingRequestCreateRequest withPaymentRequestMetadata(
return this;
}

/**
* A custom payment reference defined by the merchant. It is only available for payments
* using the Direct Funds settlement model on the Faster Payments scheme.
*
*/
public BillingRequestCreateRequest withPaymentRequestReference(String reference) {
if (paymentRequest == null) {
paymentRequest = new PaymentRequest();
}
paymentRequest.withReference(reference);
return this;
}

/**
* (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is
* supported in the UK (GBP) and `sepa_credit_transfer` and `sepa_instant_credit_transfer`
* are supported in Germany (EUR). In Germany, `sepa_credit_transfer` is used as the
* default. Please be aware that `sepa_instant_credit_transfer` may incur an additional fee
* for your customer.
* are supported in supported Eurozone countries (EUR). For Eurozone countries,
* `sepa_credit_transfer` is used as the default. Please be aware that
* `sepa_instant_credit_transfer` may incur an additional fee for your customer.
*/
public BillingRequestCreateRequest withPaymentRequestScheme(String scheme) {
if (paymentRequest == null) {
Expand Down Expand Up @@ -895,6 +908,7 @@ public static class PaymentRequest {
private String description;
private FundsSettlement fundsSettlement;
private Map<String, String> metadata;
private String reference;
private String scheme;

/**
Expand All @@ -918,7 +932,7 @@ public PaymentRequest withAppFee(Integer appFee) {
/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP`
* and `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your
* customers in Germany only.
* customers in supported Eurozone countries only.
*/
public PaymentRequest withCurrency(String currency) {
this.currency = currency;
Expand Down Expand Up @@ -957,12 +971,23 @@ public PaymentRequest withMetadata(Map<String, String> metadata) {
return this;
}

/**
* A custom payment reference defined by the merchant. It is only available for payments
* using the Direct Funds settlement model on the Faster Payments scheme.
*
*/
public PaymentRequest withReference(String reference) {
this.reference = reference;
return this;
}

/**
* (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is
* supported in the UK (GBP) and `sepa_credit_transfer` and
* `sepa_instant_credit_transfer` are supported in Germany (EUR). In Germany,
* `sepa_credit_transfer` is used as the default. Please be aware that
* `sepa_instant_credit_transfer` may incur an additional fee for your customer.
* `sepa_instant_credit_transfer` are supported in supported Eurozone countries (EUR).
* For Eurozone countries, `sepa_credit_transfer` is used as the default. Please be
* aware that `sepa_instant_credit_transfer` may incur an additional fee for your
* customer.
*/
public PaymentRequest withScheme(String scheme) {
this.scheme = scheme;
Expand Down Expand Up @@ -1505,11 +1530,9 @@ public static final class BillingRequestCollectBankAccountRequest
private String payId;

/**
* Name of the account holder, as known by the bank. Usually this is the same as the name
* stored with the linked [creditor](#core-endpoints-creditors). This field will be
* transliterated, upcased and truncated to 18 characters. This field is required unless the
* request includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
* Name of the account holder, as known by the bank. This field will be transliterated,
* upcased and truncated to 18 characters. This field is required unless the request
* includes a [customer bank account token](#javascript-flow-customer-bank-account-tokens).
*/
public BillingRequestCollectBankAccountRequest withAccountHolderName(
String accountHolderName) {
Expand Down
Loading

0 comments on commit f8a92a2

Please sign in to comment.