Skip to content
Closed
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>7.2.0</version>
<version>7.3.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:7.2.0'
implementation 'com.gocardless:gocardless-pro:7.3.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 = '7.2.0'
version = '7.3.0'

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

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/7.2.0 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/7.3.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", "7.2.0");
builder.put("GoCardless-Client-Version", "7.3.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
99 changes: 98 additions & 1 deletion src/main/java/com/gocardless/http/ListResponse.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gocardless.http;

import com.gocardless.resources.*;
import java.util.List;

/**
Expand All @@ -10,10 +11,12 @@
public class ListResponse<T> {
private final List<T> items;
private final Meta meta;
private final Linked linked;

ListResponse(List<T> items, Meta meta) {
ListResponse(List<T> items, Meta meta, Linked linked) {
this.items = items;
this.meta = meta;
this.linked = linked;
}

/**
Expand Down Expand Up @@ -81,4 +84,98 @@ private String getAfter() {
}
}
}

static class Linked {
private final List<BillingRequest> billingRequests;

public List<BillingRequest> getBillingRequests() {
return billingRequests;
}

private final List<Creditor> creditors;

public List<Creditor> getCreditors() {
return creditors;
}

private final List<Customer> customers;

public List<Customer> getCustomers() {
return customers;
}

private final List<InstalmentSchedule> instalmentSchedules;

public List<InstalmentSchedule> getInstalmentSchedules() {
return instalmentSchedules;
}

private final List<Mandate> mandates;

public List<Mandate> getMandates() {
return mandates;
}

private final List<OutboundPayment> outboundPayments;

public List<OutboundPayment> getOutboundPayments() {
return outboundPayments;
}

private final List<PayerAuthorisation> payerAuthorisations;

public List<PayerAuthorisation> getPayerAuthorisations() {
return payerAuthorisations;
}

private final List<Payment> payments;

public List<Payment> getPayments() {
return payments;
}

private final List<Payout> payouts;

public List<Payout> getPayouts() {
return payouts;
}

private final List<Refund> refunds;

public List<Refund> getRefunds() {
return refunds;
}

private final List<SchemeIdentifier> schemeIdentifiers;

public List<SchemeIdentifier> getSchemeIdentifiers() {
return schemeIdentifiers;
}

private final List<Subscription> subscriptions;

public List<Subscription> getSubscriptions() {
return subscriptions;
}

Linked(List<InstalmentSchedule> instalmentSchedules, List<Refund> refunds,
List<Payout> payouts, List<Mandate> mandates, List<Subscription> subscriptions,
List<SchemeIdentifier> schemeIdentifiers, List<BillingRequest> billingRequests,
List<Customer> customers, List<Creditor> creditors,
List<OutboundPayment> outboundPayments,
List<PayerAuthorisation> payerAuthorisations, List<Payment> payments) {
this.billingRequests = billingRequests;
this.creditors = creditors;
this.customers = customers;
this.instalmentSchedules = instalmentSchedules;
this.mandates = mandates;
this.outboundPayments = outboundPayments;
this.payerAuthorisations = payerAuthorisations;
this.payments = payments;
this.payouts = payouts;
this.refunds = refunds;
this.schemeIdentifiers = schemeIdentifiers;
this.subscriptions = subscriptions;
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/gocardless/http/ResponseParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<Li
List<T> items = parseMultiple(json, envelope, clazz);
JsonObject metaJson = json.getAsJsonObject("meta");
ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class);
return new ListResponse<>(ImmutableList.copyOf(items), meta);
JsonObject linkedJson = json.getAsJsonObject("linked");
ListResponse.Linked linked = gson.fromJson(linkedJson, ListResponse.Linked.class);
return new ListResponse<>(ImmutableList.copyOf(items), meta, linked);
}

GoCardlessApiException parseError(String responseBody) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/gocardless/resources/BillingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public enum PurposeCode {
GOVERNMENT, @SerializedName("pension")
PENSION, @SerializedName("tax")
TAX, @SerializedName("other")
OTHER, @SerializedName("unknown")
OTHER, @SerializedName("Epayment")
EPAYMENT, @SerializedName("Commercial")
COMMERCIAL, @SerializedName("OtherPayment")
OTHERPAYMENT, @SerializedName("Trade")
TRADE, @SerializedName("unknown")
UNKNOWN
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ public enum PurposeCode {
GOVERNMENT, @SerializedName("pension")
PENSION, @SerializedName("tax")
TAX, @SerializedName("other")
OTHER, @SerializedName("unknown")
OTHER, @SerializedName("Epayment")
EPAYMENT, @SerializedName("Commercial")
COMMERCIAL, @SerializedName("OtherPayment")
OTHERPAYMENT, @SerializedName("Trade")
TRADE, @SerializedName("unknown")
UNKNOWN
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.gocardless.resources;

import java.util.List;

/**
* Represents a creditor bank account validate resource returned from the API.
*
* Creditor Bank Accounts hold the bank details of a [creditor](#core-endpoints-creditors). These
* are the bank accounts which your [payouts](#core-endpoints-payouts) will be sent to.
*
* When all locale details and Iban are supplied validates creditor bank details without creating a
* creditor bank account and also provdes bank details such as name and icon url. When partial
* details are are provided the endpoint will only provide bank details such as name and icon url
* but will not be able to determine if the provided details are valid.
*
* <p class="restricted-notice">
* <strong>Restricted</strong>: This API is not available for partner integrations.
* </p>
*/
public class CreditorBankAccountValidate {
private CreditorBankAccountValidate() {
// blank to prevent instantiation
}

private String bankName;
private String iconUrl;
private List<InvalidReason> invalidReasons;
private Boolean isValid;

/**
* Name of bank, taken from the bank details.
*/
public String getBankName() {
return bankName;
}

/**
* URL of the bank's icon.
*/
public String getIconUrl() {
return iconUrl;
}

/**
* The reason why the bank details are invalid, if applicable.
*/
public List<InvalidReason> getInvalidReasons() {
return invalidReasons;
}

/**
* Whether the bank account details are valid.
*/
public Boolean getIsValid() {
return isValid;
}

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

private String field;
private String message;

/**
* The name of the field with the error
*/
public String getField() {
return field;
}

/**
* The error message
*/
public String getMessage() {
return message;
}
}
}
72 changes: 28 additions & 44 deletions src/main/java/com/gocardless/resources/Mandate.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.gocardless.resources;

import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -227,7 +226,9 @@ private ConsentParameters() {

private String endDate;
private Integer maxAmountPerPayment;
private List<Period> periods;
private Integer maxAmountPerPeriod;
private Integer maxPaymentsPerPeriod;
private Period period;
private String startDate;

/**
Expand All @@ -245,10 +246,24 @@ public Integer getMaxAmountPerPayment() {
}

/**
* Frequency configuration
* The maximum total amount that can be charged for all payments in this period
*/
public List<Period> getPeriods() {
return periods;
public Integer getMaxAmountPerPeriod() {
return maxAmountPerPeriod;
}

/**
* The maximum number of payments that can be collected in this period
*/
public Integer getMaxPaymentsPerPeriod() {
return maxPaymentsPerPeriod;
}

/**
* The repeating period for this mandate
*/
public Period getPeriod() {
return period;
}

/**
Expand All @@ -258,45 +273,14 @@ public String getStartDate() {
return startDate;
}

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

private Integer maxAmountPerPeriod;
private Integer maxPaymentsPerPeriod;
private PeriodPeriod period;

/**
* The maximum total amount that can be charged for all payments in this period
*/
public Integer getMaxAmountPerPeriod() {
return maxAmountPerPeriod;
}

/**
* The maximum number of payments that can be collected in this period
*/
public Integer getMaxPaymentsPerPeriod() {
return maxPaymentsPerPeriod;
}

/**
* The repeating period for this mandate
*/
public PeriodPeriod getPeriod() {
return period;
}

public enum PeriodPeriod {
@SerializedName("day")
DAY, @SerializedName("week")
WEEK, @SerializedName("month")
MONTH, @SerializedName("year")
YEAR, @SerializedName("flexible")
FLEXIBLE, @SerializedName("unknown")
UNKNOWN
}
public enum Period {
@SerializedName("day")
DAY, @SerializedName("week")
WEEK, @SerializedName("month")
MONTH, @SerializedName("year")
YEAR, @SerializedName("flexible")
FLEXIBLE, @SerializedName("unknown")
UNKNOWN
}
}

Expand Down
Loading