diff --git a/README.md b/README.md index d03e6652..6f002716 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 0.4.0 + 0.5.0 ``` With Gradle: ``` -compile 'com.gocardless:gocardless-pro:0.4.0' +compile 'com.gocardless:gocardless-pro:0.5.0' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index 46be97f2..b83ec203 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'signing' sourceCompatibility = 1.7 group = ' com.gocardless' -version = '0.4.0' +version = '0.5.0' repositories { mavenCentral() diff --git a/src/main/java/com/gocardless/GoCardlessClient.java b/src/main/java/com/gocardless/GoCardlessClient.java index 105cad19..6c61543c 100644 --- a/src/main/java/com/gocardless/GoCardlessClient.java +++ b/src/main/java/com/gocardless/GoCardlessClient.java @@ -16,7 +16,6 @@ public class GoCardlessClient { private final CustomerService customers; private final CustomerBankAccountService customerBankAccounts; private final EventService events; - private final HelperService helpers; private final MandateService mandates; private final MandatePdfService mandatePdfs; private final PaymentService payments; @@ -33,7 +32,6 @@ private GoCardlessClient(HttpClient httpClient) { this.customers = new CustomerService(httpClient); this.customerBankAccounts = new CustomerBankAccountService(httpClient); this.events = new EventService(httpClient); - this.helpers = new HelperService(httpClient); this.mandates = new MandateService(httpClient); this.mandatePdfs = new MandatePdfService(httpClient); this.payments = new PaymentService(httpClient); @@ -85,13 +83,6 @@ public EventService events() { return events; } - /** - * A service class for working with helper resources. - */ - public HelperService helpers() { - return helpers; - } - /** * A service class for working with mandate resources. */ diff --git a/src/main/java/com/gocardless/http/HttpClient.java b/src/main/java/com/gocardless/http/HttpClient.java index 402e4097..07c22ced 100644 --- a/src/main/java/com/gocardless/http/HttpClient.java +++ b/src/main/java/com/gocardless/http/HttpClient.java @@ -19,7 +19,7 @@ * Users of this library should not need to access this class directly. */ public class HttpClient { - private static final String USER_AGENT = String.format("gocardless-pro/0.4.0 %s/%s %s/%s", + private static final String USER_AGENT = String.format("gocardless-pro/0.5.0 %s/%s %s/%s", replaceSpaces(System.getProperty("os.name")), replaceSpaces(System.getProperty("os.version")), replaceSpaces(System.getProperty("java.vm.name")), @@ -29,7 +29,7 @@ public class HttpClient { private static final Map HEADERS; static { ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put("GoCardless-Version", "2015-04-29"); + builder.put("GoCardless-Version", "2015-07-06"); HEADERS = builder.build(); } private final OkHttpClient rawClient; diff --git a/src/main/java/com/gocardless/resources/BankDetailsLookup.java b/src/main/java/com/gocardless/resources/BankDetailsLookup.java index f19a5dcb..9a764ce7 100644 --- a/src/main/java/com/gocardless/resources/BankDetailsLookup.java +++ b/src/main/java/com/gocardless/resources/BankDetailsLookup.java @@ -14,15 +14,15 @@ private BankDetailsLookup() { // blank to prevent instantiation } - private List availableSchemes; + private List availableDebitSchemes; private String bankName; /** * Array of [schemes](#mandates_scheme) supported for this bank account. This will be an empty array * if the bank account is not reachable by any schemes. */ - public List getAvailableSchemes() { - return availableSchemes; + public List getAvailableDebitSchemes() { + return availableDebitSchemes; } /** @@ -32,7 +32,7 @@ public String getBankName() { return bankName; } - public enum AvailableScheme { + public enum AvailableDebitScheme { @SerializedName("bacs") BACS, @SerializedName("sepa_core") SEPA_CORE, diff --git a/src/main/java/com/gocardless/resources/Helper.java b/src/main/java/com/gocardless/resources/Helper.java deleted file mode 100644 index 7c5cae91..00000000 --- a/src/main/java/com/gocardless/resources/Helper.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.gocardless.resources; - -public class Helper { - private Helper() { - // blank to prevent instantiation - } -} diff --git a/src/main/java/com/gocardless/resources/Subscription.java b/src/main/java/com/gocardless/resources/Subscription.java index abcdd944..522093e4 100644 --- a/src/main/java/com/gocardless/resources/Subscription.java +++ b/src/main/java/com/gocardless/resources/Subscription.java @@ -17,9 +17,9 @@ * - The first payment * must be charged within 1 year. * - When neither `month` nor `day_of_month` are present, the - * subscription will recur from the `start_at` based on the `interval_unit`. + * subscription will recur from the `start_date` based on the `interval_unit`. * - If `month` or - * `day_of_month` are present, the recurrence rules will be applied from the `start_at`, and the + * `day_of_month` are present, the recurrence rules will be applied from the `start_date`, and the * following validations apply: * * | interval_unit | month @@ -77,7 +77,7 @@ private Subscription() { private String createdAt; private String currency; private Integer dayOfMonth; - private String endAt; + private String endDate; private String id; private Integer interval; private IntervalUnit intervalUnit; @@ -86,7 +86,7 @@ private Subscription() { private Month month; private String name; private String paymentReference; - private String startAt; + private String startDate; private String status; private List upcomingPayments; @@ -98,8 +98,8 @@ public Integer getAmount() { } /** - * An alternative way to set `end_at`. The total number of payments that should be taken by this - * subscription. This will set `end_at` automatically. + * An alternative way to set `end_date`. The total number of payments that should be taken by this + * subscription. This will set `end_date` automatically. */ public Integer getCount() { return count; @@ -133,8 +133,8 @@ public Integer getDayOfMonth() { * not** be charged. If blank, the subscription will continue forever. Alternatively, `count` can be * set to achieve a specific number of payments. */ - public String getEndAt() { - return endAt; + public String getEndDate() { + return endDate; } /** @@ -200,8 +200,8 @@ public String getPaymentReference() { * or after the [mandate](#core-endpoints-mandates)'s `next_possible_charge_date`. When blank, this * will be set as the mandate's `next_possible_charge_date`. */ - public String getStartAt() { - return startAt; + public String getStartDate() { + return startDate; } /** diff --git a/src/main/java/com/gocardless/services/BankDetailsLookupService.java b/src/main/java/com/gocardless/services/BankDetailsLookupService.java index 7382d630..365e2982 100644 --- a/src/main/java/com/gocardless/services/BankDetailsLookupService.java +++ b/src/main/java/com/gocardless/services/BankDetailsLookupService.java @@ -24,7 +24,7 @@ public BankDetailsLookupService(HttpClient httpClient) { * Performs a bank details lookup. * * Bank account details may be supplied using [local - * details](#ui-local-bank-details) or an IBAN. + * details](#appendix-local-bank-details) or an IBAN. */ public BankDetailsLookupCreateRequest create() { return new BankDetailsLookupCreateRequest(httpClient); @@ -36,7 +36,7 @@ public BankDetailsLookupCreateRequest create() { * Performs a bank details lookup. * * Bank account details may be supplied using [local - * details](#ui-local-bank-details) or an IBAN. + * details](#appendix-local-bank-details) or an IBAN. */ public static final class BankDetailsLookupCreateRequest extends PostRequest { private String accountNumber; @@ -46,9 +46,8 @@ public static final class BankDetailsLookupCreateRequest extends PostRequest { - private String accountHolderName; - private String accountNumber; - private String bankCode; - private String bic; - private String branchCode; - private String countryCode; - private String iban; - private Map links; - private String mandateReference; - private String scheme; - private String signedAt; - - /** - * Name of the account holder, as known by the bank. Usually this matches the name of the - * [customer](#core-endpoints-customers). This field cannot exceed 18 characters. - */ - public HelperMandateRequest withAccountHolderName(String accountHolderName) { - this.accountHolderName = accountHolderName; - return this; - } - - /** - * Bank account number - see [local details](#ui-local-bank-details) for more information. - */ - public HelperMandateRequest withAccountNumber(String accountNumber) { - this.accountNumber = accountNumber; - return this; - } - - /** - * Bank code - see [local details](#ui-local-bank-details) for more information. - */ - public HelperMandateRequest withBankCode(String bankCode) { - this.bankCode = bankCode; - return this; - } - - /** - * SWIFT BIC. Optional (will be derived from the `iban` or local details if not provided). - */ - public HelperMandateRequest withBic(String bic) { - this.bic = bic; - return this; - } - - /** - * Branch code - see [local details](#ui-local-bank-details) for more information. - */ - public HelperMandateRequest withBranchCode(String branchCode) { - this.branchCode = branchCode; - return this; - } - - /** - * [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) - * alpha-2 code. Defaults to the country code of the `iban` if supplied, otherwise is required. - */ - public HelperMandateRequest withCountryCode(String countryCode) { - this.countryCode = countryCode; - return this; - } - - /** - * International Bank Account Number. Alternatively you can provide [local - * details](#ui-local-bank-details). - */ - public HelperMandateRequest withIban(String iban) { - this.iban = iban; - return this; - } - - public HelperMandateRequest withLinks(Map links) { - this.links = links; - return this; - } - - public HelperMandateRequest withLinks(String key, String value) { - if (links == null) { - links = new HashMap<>(); - } - links.put(key, value); - return this; - } - - /** - * Unique 6 to 18 character reference. This may be left blank at the point of signing. - */ - public HelperMandateRequest withMandateReference(String mandateReference) { - this.mandateReference = mandateReference; - return this; - } - - /** - * Direct Debit scheme. Can be supplied or automatically detected from the customer's bank account - * details (if provided). - */ - public HelperMandateRequest withScheme(String scheme) { - this.scheme = scheme; - return this; - } - - /** - * If provided, this endpoint will render a form with this date and no signature field. - */ - public HelperMandateRequest withSignedAt(String signedAt) { - this.signedAt = signedAt; - return this; - } - - private HelperMandateRequest(HttpClient httpClient) { - super(httpClient); - } - - @Override - protected String getPathTemplate() { - return "/helpers/mandate"; - } - - @Override - protected String getEnvelope() { - return "data"; - } - - @Override - protected Class getResponseClass() { - return Helper.class; - } - - @Override - protected boolean hasBody() { - return true; - } - - @Override - protected String getRequestEnvelope() { - return "data"; - } - } - - /** - * Request class for {@link HelperService#modulusCheck }. - * - * Check whether an account number and bank / branch code combination are compatible. - * - * Bank - * account details may either be supplied using the IBAN (international bank account number), or - * [local details](#ui-local-bank-details). For more information on the different fields required in - * each country, please see the [local bank details](#ui-local-bank-details) section. - */ - public static final class HelperModulusCheckRequest extends PostRequest { - private String accountNumber; - private String bankCode; - private String branchCode; - private String countryCode; - private String iban; - - /** - * Bank account number - see [local details](#ui-local-bank-details) for more information. - */ - public HelperModulusCheckRequest withAccountNumber(String accountNumber) { - this.accountNumber = accountNumber; - return this; - } - - /** - * Bank code - see [local details](#ui-local-bank-details) for more information. - */ - public HelperModulusCheckRequest withBankCode(String bankCode) { - this.bankCode = bankCode; - return this; - } - - /** - * Branch code - see [local details](#ui-local-bank-details) for more information. - */ - public HelperModulusCheckRequest withBranchCode(String branchCode) { - this.branchCode = branchCode; - return this; - } - - /** - * [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) - * alpha-2 code. Defaults to the country code of the `iban` if supplied, otherwise is required. - */ - public HelperModulusCheckRequest withCountryCode(String countryCode) { - this.countryCode = countryCode; - return this; - } - - /** - * International Bank Account Number. Alternatively you can provide [local - * details](#ui-local-bank-details). - */ - public HelperModulusCheckRequest withIban(String iban) { - this.iban = iban; - return this; - } - - private HelperModulusCheckRequest(HttpClient httpClient) { - super(httpClient); - } - - @Override - protected String getPathTemplate() { - return "/helpers/modulus_check"; - } - - @Override - protected String getEnvelope() { - return "data"; - } - - @Override - protected Class getResponseClass() { - return Helper.class; - } - - @Override - protected boolean hasBody() { - return true; - } - - @Override - protected String getRequestEnvelope() { - return "data"; - } - } -} diff --git a/src/main/java/com/gocardless/services/MandatePdfService.java b/src/main/java/com/gocardless/services/MandatePdfService.java index eda7d4d7..fc0dfe0a 100644 --- a/src/main/java/com/gocardless/services/MandatePdfService.java +++ b/src/main/java/com/gocardless/services/MandatePdfService.java @@ -111,7 +111,7 @@ public MandatePdfCreateRequest withBranchCode(String branchCode) { /** * [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) - * alpha-2 code. Defaults to the country code of the `iban` if supplied, otherwise is required. + * alpha-2 code. Required if providing local details. */ public MandatePdfCreateRequest withCountryCode(String countryCode) { this.countryCode = countryCode; @@ -134,7 +134,7 @@ public MandatePdfCreateRequest withLinks(Links links) { /** * ID of an existing [mandate](#core-endpoints-mandates) to build the PDF from. The customer's bank - * details will be censored in the generated PDF. + * details will be censored in the generated PDF. No other parameters may be provided alongside this. */ public MandatePdfCreateRequest withLinksMandate(String mandate) { if (links == null) { @@ -199,7 +199,7 @@ public static class Links { /** * ID of an existing [mandate](#core-endpoints-mandates) to build the PDF from. The customer's bank - * details will be censored in the generated PDF. + * details will be censored in the generated PDF. No other parameters may be provided alongside this. */ public Links withMandate(String mandate) { this.mandate = mandate; diff --git a/src/main/java/com/gocardless/services/MandateService.java b/src/main/java/com/gocardless/services/MandateService.java index 3a12399b..a174a8b8 100644 --- a/src/main/java/com/gocardless/services/MandateService.java +++ b/src/main/java/com/gocardless/services/MandateService.java @@ -54,15 +54,6 @@ public MandateListRequest> all() { /** * Retrieves the details of an existing mandate. - * - * If you specify `Accept: application/pdf` on a - * request to this endpoint it will return a PDF complying to the relevant scheme rules, which you - * can present to your customer. - * - * PDF mandates can be retrieved in Dutch, English, French, - * German, Italian, Portuguese and Spanish by specifying the [ISO - * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table) language code - * as an `Accept-Language` header. */ public MandateGetRequest get(String identity) { return new MandateGetRequest(httpClient, identity); @@ -379,15 +370,6 @@ public String toString() { * Request class for {@link MandateService#get }. * * Retrieves the details of an existing mandate. - * - * If you specify `Accept: application/pdf` on a - * request to this endpoint it will return a PDF complying to the relevant scheme rules, which you - * can present to your customer. - * - * PDF mandates can be retrieved in Dutch, English, French, - * German, Italian, Portuguese and Spanish by specifying the [ISO - * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table) language code - * as an `Accept-Language` header. */ public static final class MandateGetRequest extends GetRequest { @PathParam diff --git a/src/main/java/com/gocardless/services/SubscriptionService.java b/src/main/java/com/gocardless/services/SubscriptionService.java index f52d43fa..b48a3e5b 100644 --- a/src/main/java/com/gocardless/services/SubscriptionService.java +++ b/src/main/java/com/gocardless/services/SubscriptionService.java @@ -23,9 +23,9 @@ * - The first payment * must be charged within 1 year. * - When neither `month` nor `day_of_month` are present, the - * subscription will recur from the `start_at` based on the `interval_unit`. + * subscription will recur from the `start_date` based on the `interval_unit`. * - If `month` or - * `day_of_month` are present, the recurrence rules will be applied from the `start_at`, and the + * `day_of_month` are present, the recurrence rules will be applied from the `start_date`, and the * following validations apply: * * | interval_unit | month @@ -139,7 +139,7 @@ public static final class SubscriptionCreateRequest extends PostRequest