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

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:7.2.0'
implementation 'com.gocardless:gocardless-pro:7.4.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.4.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.4.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.4.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<Payout> payouts, List<Customer> customers, List<Creditor> creditors,
List<InstalmentSchedule> instalmentSchedules,
List<OutboundPayment> outboundPayments, List<BillingRequest> billingRequests,
List<SchemeIdentifier> schemeIdentifiers, List<Payment> payments,
List<Subscription> subscriptions, List<Mandate> mandates,
List<PayerAuthorisation> payerAuthorisations, List<Refund> refunds) {
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
8 changes: 8 additions & 0 deletions src/main/java/com/gocardless/resources/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ private Links() {
private String customerBankAccount;
private String instalmentSchedule;
private String mandate;
private String mandateRequest;
private String mandateRequestMandate;
private String newCustomerBankAccount;
private String newMandate;
Expand Down Expand Up @@ -397,6 +398,13 @@ public String getMandate() {
return mandate;
}

/**
* This is the id of the mandate request associated to this event
*/
public String getMandateRequest() {
return mandateRequest;
}

/**
* If `resource_type` is `billing_requests`, this is the ID of the
* [mandate](#core-endpoints-mandates) which has been created.
Expand Down
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
19 changes: 14 additions & 5 deletions src/main/java/com/gocardless/resources/OutboundPayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private OutboundPayment() {
private Links links;
private Map<String, Object> metadata;
private String reference;
private String scheme;
private Scheme scheme;
private Status status;
private Verifications verifications;

Expand Down Expand Up @@ -103,7 +103,10 @@ public Map<String, Object> getMetadata() {
}

/**
* An auto-generated reference that will appear on your receiver's bank statement.
* An optional reference that will appear on your customer's bank statement. The character limit
* for this reference is dependent on the scheme.<br />
* <strong>Faster Payments</strong> - 18 characters, including:
* "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 &-./"<br />
*/
public String getReference() {
return reference;
Expand All @@ -113,7 +116,7 @@ public String getReference() {
* Bank payment scheme to process the outbound payment. Currently only "faster_payments" (GBP)
* is supported.
*/
public String getScheme() {
public Scheme getScheme() {
return scheme;
}

Expand Down Expand Up @@ -156,6 +159,12 @@ public enum Currency {
UNKNOWN
}

public enum Scheme {
@SerializedName("faster_payments")
FASTER_PAYMENTS, @SerializedName("unknown")
UNKNOWN
}

public enum Status {
@SerializedName("verifying")
VERIFYING, @SerializedName("pending_approval")
Expand Down Expand Up @@ -233,8 +242,8 @@ private RecipientBankAccountHolderVerification() {
private Type type;

/**
* -| The actual account name returned by the recipient's bank, populated only in the
* case of a partial match.
* The actual account name returned by the recipient's bank, populated only in the case
* of a partial match.
*/
public String getActualAccountName() {
return actualAccountName;
Expand Down
Loading