Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Thomson committed Jul 3, 2015
2 parents e63c805 + de1f9c1 commit 98a5323
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 145 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>0.3.0</version>
<version>0.4.0</version>
</dependency>
```

With Gradle:

```
compile 'com.gocardless:gocardless-pro:0.3.0'
compile 'com.gocardless:gocardless-pro:0.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 @@ -4,7 +4,7 @@ apply plugin: 'signing'

sourceCompatibility = 1.7
group = ' com.gocardless'
version = '0.3.0'
version = '0.4.0'

repositories {
mavenCentral()
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/gocardless/GoCardlessClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
public class GoCardlessClient {
private final HttpClient httpClient;
private final BankDetailsLookupService bankDetailsLookups;
private final CreditorService creditors;
private final CreditorBankAccountService creditorBankAccounts;
private final CustomerService customers;
Expand All @@ -18,7 +19,6 @@ public class GoCardlessClient {
private final HelperService helpers;
private final MandateService mandates;
private final MandatePdfService mandatePdfs;
private final ModulusCheckService modulusChecks;
private final PaymentService payments;
private final PayoutService payouts;
private final RedirectFlowService redirectFlows;
Expand All @@ -27,6 +27,7 @@ public class GoCardlessClient {

private GoCardlessClient(HttpClient httpClient) {
this.httpClient = httpClient;
this.bankDetailsLookups = new BankDetailsLookupService(httpClient);
this.creditors = new CreditorService(httpClient);
this.creditorBankAccounts = new CreditorBankAccountService(httpClient);
this.customers = new CustomerService(httpClient);
Expand All @@ -35,14 +36,20 @@ private GoCardlessClient(HttpClient httpClient) {
this.helpers = new HelperService(httpClient);
this.mandates = new MandateService(httpClient);
this.mandatePdfs = new MandatePdfService(httpClient);
this.modulusChecks = new ModulusCheckService(httpClient);
this.payments = new PaymentService(httpClient);
this.payouts = new PayoutService(httpClient);
this.redirectFlows = new RedirectFlowService(httpClient);
this.refunds = new RefundService(httpClient);
this.subscriptions = new SubscriptionService(httpClient);
}

/**
* A service class for working with bank details lookup resources.
*/
public BankDetailsLookupService bankDetailsLookups() {
return bankDetailsLookups;
}

/**
* A service class for working with creditor resources.
*/
Expand Down Expand Up @@ -99,13 +106,6 @@ public MandatePdfService mandatePdfs() {
return mandatePdfs;
}

/**
* A service class for working with modulus check resources.
*/
public ModulusCheckService modulusChecks() {
return modulusChecks;
}

/**
* A service class for working with payment resources.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gocardless/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.0 %s/%s %s/%s",
private static final String USER_AGENT = String.format("gocardless-pro/0.4.0 %s/%s %s/%s",
replaceSpaces(System.getProperty("os.name")),
replaceSpaces(System.getProperty("os.version")),
replaceSpaces(System.getProperty("java.vm.name")),
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/gocardless/resources/BankDetailsLookup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.gocardless.resources;

import java.util.List;

import com.google.gson.annotations.SerializedName;

/**
* Represents a bank details lookup resource returned from the API.
*
* Look up the name and reachability of a bank.
*/
public class BankDetailsLookup {
private BankDetailsLookup() {
// blank to prevent instantiation
}

private List<AvailableScheme> availableSchemes;
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<AvailableScheme> getAvailableSchemes() {
return availableSchemes;
}

/**
* The name of the bank with which the account is held (if available).
*/
public String getBankName() {
return bankName;
}

public enum AvailableScheme {
@SerializedName("bacs")
BACS, @SerializedName("sepa_core")
SEPA_CORE,
}
}
9 changes: 4 additions & 5 deletions src/main/java/com/gocardless/resources/MandatePdf.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/**
* Represents a mandate pdf resource returned from the API.
*
* Construct a mandate PDF for a given set of bank details or an already-existing mandate.
* Mandate PDFs allow you to easily display [scheme-rules compliant](#ui-compliance-requirements)
* Direct Debit mandates to your customers.
*/
public class MandatePdf {
private MandatePdf() {
Expand All @@ -14,17 +15,15 @@ private MandatePdf() {
private String url;

/**
* The date and time at which `url` will cease to be accessible (30 minutes after the original
* request).
* The date and time at which the `url` will expire (10 minutes after the original request).
*/
public String getExpiresAt() {
return expiresAt;
}

/**
* The URL at which this mandate PDF can be viewed until it expires at the date and time specified by
* `expires_at`. *You should not store this URL as it will only work for a short period of time. The
* structure of these URLs may change at any time.*
* `expires_at`. You should not store this URL or rely on its structure remaining the same.
*/
public String getUrl() {
return url;
Expand Down
78 changes: 0 additions & 78 deletions src/main/java/com/gocardless/resources/ModulusCheck.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
package com.gocardless.services;

import com.gocardless.http.*;
import com.gocardless.resources.ModulusCheck;
import com.gocardless.resources.BankDetailsLookup;

/**
* Service class for working with modulus check resources.
* Service class for working with bank details lookup resources.
*
* Check whether an account number and bank / branch code combination are compatible.
* Look up the name and reachability of a bank.
*/
public class ModulusCheckService {
public class BankDetailsLookupService {
private HttpClient httpClient;

/**
* Constructor. Users of this library should have no need to call this - an instance
* of this class can be obtained by calling
{@link com.gocardless.GoCardlessClient#modulusChecks() }.
{@link com.gocardless.GoCardlessClient#bankDetailsLookups() }.
*/
public ModulusCheckService(HttpClient httpClient) {
public BankDetailsLookupService(HttpClient httpClient) {
this.httpClient = httpClient;
}

/**
* Performs a modulus check.
* Performs a bank details lookup.
*
* Bank account details may be supplied using [local
* details](#ui-local-bank-details) or an IBAN.
*/
public ModulusCheckCreateRequest create() {
return new ModulusCheckCreateRequest(httpClient);
public BankDetailsLookupCreateRequest create() {
return new BankDetailsLookupCreateRequest(httpClient);
}

/**
* Request class for {@link ModulusCheckService#create }.
* Request class for {@link BankDetailsLookupService#create }.
*
* Performs a modulus check.
* Performs a bank details lookup.
*
* Bank account details may be supplied using [local
* details](#ui-local-bank-details) or an IBAN.
*/
public static final class ModulusCheckCreateRequest extends PostRequest<ModulusCheck> {
public static final class BankDetailsLookupCreateRequest extends PostRequest<BankDetailsLookup> {
private String accountNumber;
private String bankCode;
private String branchCode;
Expand All @@ -50,7 +50,7 @@ public static final class ModulusCheckCreateRequest extends PostRequest<ModulusC
* details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details) for more
* information. Alternatively you can provide an `iban`.
*/
public ModulusCheckCreateRequest withAccountNumber(String accountNumber) {
public BankDetailsLookupCreateRequest withAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
return this;
}
Expand All @@ -60,7 +60,7 @@ public ModulusCheckCreateRequest withAccountNumber(String accountNumber) {
* details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details) for more
* information. Alternatively you can provide an `iban`.
*/
public ModulusCheckCreateRequest withBankCode(String bankCode) {
public BankDetailsLookupCreateRequest withBankCode(String bankCode) {
this.bankCode = bankCode;
return this;
}
Expand All @@ -70,7 +70,7 @@ public ModulusCheckCreateRequest withBankCode(String bankCode) {
* details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details) for more
* information. Alternatively you can provide an `iban`.
*/
public ModulusCheckCreateRequest withBranchCode(String branchCode) {
public BankDetailsLookupCreateRequest withBranchCode(String branchCode) {
this.branchCode = branchCode;
return this;
}
Expand All @@ -79,7 +79,7 @@ public ModulusCheckCreateRequest withBranchCode(String branchCode) {
* [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
* alpha-2 code. Must be provided if specifying local details.
*/
public ModulusCheckCreateRequest withCountryCode(String countryCode) {
public BankDetailsLookupCreateRequest withCountryCode(String countryCode) {
this.countryCode = countryCode;
return this;
}
Expand All @@ -88,28 +88,28 @@ public ModulusCheckCreateRequest withCountryCode(String countryCode) {
* International Bank Account Number. Alternatively you can provide [local
* details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details).
*/
public ModulusCheckCreateRequest withIban(String iban) {
public BankDetailsLookupCreateRequest withIban(String iban) {
this.iban = iban;
return this;
}

private ModulusCheckCreateRequest(HttpClient httpClient) {
private BankDetailsLookupCreateRequest(HttpClient httpClient) {
super(httpClient);
}

@Override
protected String getPathTemplate() {
return "/modulus_checks";
return "/bank_details_lookups";
}

@Override
protected String getEnvelope() {
return "modulus_checks";
return "bank_details_lookups";
}

@Override
protected Class<ModulusCheck> getResponseClass() {
return ModulusCheck.class;
protected Class<BankDetailsLookup> getResponseClass() {
return BankDetailsLookup.class;
}

@Override
Expand Down
Loading

0 comments on commit 98a5323

Please sign in to comment.