Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from gocardless/gocardless-pro-java-template #126

Closed
wants to merge 2 commits into from
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: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ out/
##############################
## Visual Studio Code
##############################
.vscode/
.vscode/

tmp-push-files-checkout/
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.25.0</version>
<version>5.26.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:5.25.0'
implementation 'com.gocardless:gocardless-pro:5.26.0'
```

## Initializing the client
Expand Down
13 changes: 12 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
google()
maven {
url 'https://maven.google.com'
}
}

dependencies {
Expand All @@ -20,12 +25,18 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com.gocardless'
version = '5.25.0'
version = '5.26.0'

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

repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
google()
maven {
url 'https://maven.google.com'
}
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions gradlew
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
set -x

##############################################################################
##
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.25.0 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/5.26.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.25.0");
builder.put("GoCardless-Client-Version", "5.26.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/gocardless/resources/Subscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private Subscription() {
private Map<String, Object> metadata;
private Month month;
private String name;
private Boolean parentPlanPaused;
private String paymentReference;
private Boolean retryIfPossible;
private String startDate;
Expand Down Expand Up @@ -186,6 +187,13 @@ public String getName() {
return name;
}

/**
* Whether the parent plan of this subscription is paused.
*/
public Boolean getParentPlanPaused() {
return parentPlanPaused;
}

/**
* An optional payment reference. This will be set as the reference on each payment created and
* will appear on your customer's bank statement. See the documentation for the [create payment
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/gocardless/services/LogoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public LogoService(HttpClient httpClient) {
/**
* Creates a new logo associated with a creditor. If a creditor already has a logo, this will
* update the existing logo linked to the creditor.
*
* We support JPG and PNG formats. Your logo will be scaled to a maximum of 300px by 40px. For
* more guidance on how to upload logos that will look great across your customer payment page
* and notification emails see
* [here](https://developer.gocardless.com/gc-embed/setting-up-branding#tips_for_uploading_your_logo).
*/
public LogoCreateForCreditorRequest createForCreditor() {
return new LogoCreateForCreditorRequest(httpClient);
Expand All @@ -33,6 +38,11 @@ public LogoCreateForCreditorRequest createForCreditor() {
*
* Creates a new logo associated with a creditor. If a creditor already has a logo, this will
* update the existing logo linked to the creditor.
*
* We support JPG and PNG formats. Your logo will be scaled to a maximum of 300px by 40px. For
* more guidance on how to upload logos that will look great across your customer payment page
* and notification emails see
* [here](https://developer.gocardless.com/gc-embed/setting-up-branding#tips_for_uploading_your_logo).
*/
public static final class LogoCreateForCreditorRequest extends PostRequest<Logo> {
private String image;
Expand All @@ -52,7 +62,7 @@ public LogoCreateForCreditorRequest withLinks(Links links) {
}

/**
* ID of the creditor the payer theme belongs to
* ID of the creditor the logo belongs to
*/
public LogoCreateForCreditorRequest withLinksCreditor(String creditor) {
if (links == null) {
Expand Down Expand Up @@ -95,7 +105,7 @@ public static class Links {
private String creditor;

/**
* ID of the creditor the payer theme belongs to
* ID of the creditor the logo belongs to
*/
public Links withCreditor(String creditor) {
this.creditor = creditor;
Expand Down
105 changes: 105 additions & 0 deletions src/main/java/com/gocardless/services/MandateImportEntryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gocardless.http.*;
import com.gocardless.resources.MandateImportEntry;
import com.google.common.collect.ImmutableMap;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -171,6 +172,20 @@ public MandateImportEntryCreateRequest withBankAccountAccountNumber(String accou
return this;
}

/**
* Bank account type. Required for USD-denominated bank accounts. Must not be provided for
* bank accounts in other currencies. See [local details](#local-bank-details-united-states)
* for more information.
*/
public MandateImportEntryCreateRequest withBankAccountAccountType(
BankAccount.AccountType accountType) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withAccountType(accountType);
return this;
}

/**
* Bank code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
Expand Down Expand Up @@ -221,6 +236,19 @@ public MandateImportEntryCreateRequest withBankAccountIban(String iban) {
return this;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withBankAccountMetadata(
Map<String, String> metadata) {
if (bankAccount == null) {
bankAccount = new BankAccount();
}
bankAccount.withMetadata(metadata);
return this;
}

public MandateImportEntryCreateRequest withCustomer(Customer customer) {
this.customer = customer;
return this;
Expand Down Expand Up @@ -361,6 +389,18 @@ public MandateImportEntryCreateRequest withCustomerLanguage(String language) {
return this;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withCustomerMetadata(Map<String, String> metadata) {
if (customer == null) {
customer = new Customer();
}
customer.withMetadata(metadata);
return this;
}

/**
* [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including
* country code.
Expand Down Expand Up @@ -433,6 +473,18 @@ public MandateImportEntryCreateRequest withMandate(Mandate mandate) {
return this;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public MandateImportEntryCreateRequest withMandateMetadata(Map<String, String> metadata) {
if (mandate == null) {
mandate = new Mandate();
}
mandate.withMetadata(metadata);
return this;
}

/**
* Unique reference. Different schemes have different length and [character
* set](#appendix-character-sets) requirements. GoCardless will generate a unique reference
Expand Down Expand Up @@ -523,10 +575,12 @@ public Amendment withOriginalMandateReference(String originalMandateReference) {
public static class BankAccount {
private String accountHolderName;
private String accountNumber;
private AccountType accountType;
private String bankCode;
private String branchCode;
private String countryCode;
private String iban;
private Map<String, String> metadata;

/**
* Name of the account holder, as known by the bank. Usually this is the same as the
Expand All @@ -549,6 +603,16 @@ public BankAccount withAccountNumber(String accountNumber) {
return this;
}

/**
* Bank account type. Required for USD-denominated bank accounts. Must not be provided
* for bank accounts in other currencies. See [local
* details](#local-bank-details-united-states) for more information.
*/
public BankAccount withAccountType(AccountType accountType) {
this.accountType = accountType;
return this;
}

/**
* Bank code - see [local details](#appendix-local-bank-details) for more information.
* Alternatively you can provide an `iban`.
Expand Down Expand Up @@ -587,6 +651,27 @@ public BankAccount withIban(String iban) {
this.iban = iban;
return this;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public BankAccount withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

public enum AccountType {
@SerializedName("savings")
SAVINGS, @SerializedName("checking")
CHECKING, @SerializedName("unknown")
UNKNOWN;

@Override
public String toString() {
return name().toLowerCase();
}
}
}

public static class Customer {
Expand All @@ -601,6 +686,7 @@ public static class Customer {
private String familyName;
private String givenName;
private String language;
private Map<String, String> metadata;
private String phoneNumber;
private String postalCode;
private String region;
Expand Down Expand Up @@ -707,6 +793,15 @@ public Customer withLanguage(String language) {
return this;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public Customer withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

/**
* [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including
* country code.
Expand Down Expand Up @@ -761,8 +856,18 @@ public Links withMandateImport(String mandateImport) {
}

public static class Mandate {
private Map<String, String> metadata;
private String reference;

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public Mandate withMetadata(Map<String, String> metadata) {
this.metadata = metadata;
return this;
}

/**
* Unique reference. Different schemes have different length and [character
* set](#appendix-character-sets) requirements. GoCardless will generate a unique
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/gocardless/services/MandatePdfService.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public static final class MandatePdfCreateRequest extends PostRequest<MandatePdf
private String bic;
private String branchCode;
private String city;
private String companyName;
private String countryCode;
private String danishIdentityNumber;
private String familyName;
private String givenName;
private String iban;
private Links links;
private String mandateReference;
Expand Down Expand Up @@ -182,6 +185,15 @@ public MandatePdfCreateRequest withCity(String city) {
return this;
}

/**
* The customer's company name. Used to populate the "Customer Name or Company name" field
* on the PDF.
*/
public MandatePdfCreateRequest withCompanyName(String companyName) {
this.companyName = companyName;
return this;
}

/**
* [ISO
* 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
Expand All @@ -201,6 +213,24 @@ public MandatePdfCreateRequest withDanishIdentityNumber(String danishIdentityNum
return this;
}

/**
* The customer's family name (i.e. last name). Used to populate the "Customer Name or
* Company name" field on the PDF. Ignored if `company_name` is provided.
*/
public MandatePdfCreateRequest withFamilyName(String familyName) {
this.familyName = familyName;
return this;
}

/**
* The customer's given name (i.e. first name). Used to populate the "Customer Name or
* Company name" field on the PDF. Ignored if `company_name` is provided.
*/
public MandatePdfCreateRequest withGivenName(String givenName) {
this.givenName = givenName;
return this;
}

/**
* International Bank Account Number. Alternatively you can provide [local
* details](#appendix-local-bank-details). IBANs cannot be provided for Autogiro mandates.
Expand Down
1 change: 1 addition & 0 deletions tmp-push-files-checkout
Submodule tmp-push-files-checkout added at 1a06cf
Loading