Skip to content
Open
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 pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.trolley</groupId>
<artifactId>java-sdk</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<description>Java SDK for Trolley API</description>
<packaging>jar</packaging>
<name>Trolley Java SDK</name>
Expand Down Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.2</version>
<version>2.18.6</version>
</dependency>

<dependency>
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/trolley/BalancesGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public BalancesGateway(final Configuration config) {
* @throws Exception
*/
public List<Balances> getPaypalAccountBalances() throws Exception{
return fetchBalances("paypal");
final String endPoint = "/v1/balances/paypal";
final String response = this.client.get(endPoint);
return balancesListFactory(response);
}

/**
Expand All @@ -32,7 +34,9 @@ public List<Balances> getPaypalAccountBalances() throws Exception{
* @throws Exception
*/
public List<Balances> getTrolleyAccountBalances() throws Exception{
return fetchBalances("paymentrails");
final String endPoint = "/v1/balances/paymentrails";
final String response = this.client.get(endPoint);
return balancesListFactory(response);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/trolley/BatchGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Batch find(final String batchId) throws Exception {
if (batchId == null || batchId.isEmpty()) {
throw new InvalidFieldException("Batch id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId;
final String endPoint = "/v1/batches/{batchId}".replace("{batchId}", batchId);
final String response = this.client.get(endPoint);
return this.batchFactory(response);
}
Expand All @@ -39,7 +39,7 @@ public boolean update(final String batchId, final Batch batch) throws Exception
throw new InvalidFieldException("Batch object cannot be null or empty.");
}
final String jsonBatch = new ObjectMapper().writeValueAsString((Object)batch);
final String endPoint = "/v1/batches/" + batchId;
final String endPoint = "/v1/batches/{batchId}".replace("{batchId}", batchId);
this.client.patch(endPoint, jsonBatch);
return true;
}
Expand All @@ -48,7 +48,7 @@ public boolean delete(final String batchId) throws Exception {
if (batchId == null || batchId.isEmpty()) {
throw new InvalidFieldException("Batch id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId;
final String endPoint = "/v1/batches/{batchId}".replace("{batchId}", batchId);
this.client.delete(endPoint);
return true;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public String generateQuote(final String batchId) throws Exception {
if (batchId == null || batchId.isEmpty()) {
throw new InvalidFieldException("Batch id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId + "/generate-quote";
final String endPoint = "/v1/batches/{batchId}/generate-quote".replace("{batchId}", batchId);
final String response = this.client.post(endPoint);
return response;
}
Expand All @@ -105,7 +105,7 @@ public String processBatch(final String batchId) throws Exception {
if (batchId == null || batchId.isEmpty()) {
throw new InvalidFieldException("Batch id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId + "/start-processing";
final String endPoint = "/v1/batches/{batchId}/start-processing".replace("{batchId}", batchId);
final String response = this.client.post(endPoint);
return response;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public BatchSummary summary(final String batchId) throws Exception {
if (batchId == null || batchId.isEmpty()) {
throw new InvalidFieldException("Batch id cannot be null os empty");
}
final String endPoint = "/v1/batches/" + batchId + "/summary";
final String endPoint = "/v1/batches/{batchId}/summary".replace("{batchId}", batchId);
final String response = this.client.get(endPoint);
final ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/trolley/Gateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Gateway
public InvoiceGateway invoice;
public InvoiceLineGateway invoiceLine;
public InvoicePaymentGateway invoicePayment;
public VerificationGateway verification;
public VerificationGateway trust;

public Gateway(final Configuration config) {
this.config = config;
Expand All @@ -26,5 +28,7 @@ public Gateway(final Configuration config) {
this.invoice = new InvoiceGateway(config);
this.invoiceLine = new InvoiceLineGateway(config);
this.invoicePayment = new InvoicePaymentGateway(config);
this.verification = new VerificationGateway(config);
this.trust = this.verification;
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/trolley/OfflinePaymentGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public OfflinePayment create(final String recipientId, final OfflinePayment offl
String jsonRequest = new ObjectMapper()
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)offlinePayment);
final String endPoint = "/v1/recipients/" + recipientId + "/offlinePayments/";
final String endPoint = "/v1/recipients/{recipientId}/offlinePayments".replace("{recipientId}", recipientId);
final String response = this.client.post(endPoint, jsonRequest);
return this.offlinePaymentFactory(response);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean update(final String recipientId, final String offlinePaymentId, f
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)offlinePayment);

final String endPoint = "/v1/recipients/" + recipientId + "/offlinePayments/" + offlinePaymentId;
final String endPoint = "/v1/recipients/{recipientId}/offlinePayments/{offlinePaymentId}".replace("{recipientId}", recipientId).replace("{offlinePaymentId}", offlinePaymentId);
this.client.patch(endPoint, jsonRequest);
return true;
}
Expand All @@ -86,7 +86,7 @@ public boolean delete(final String recipientId,final String offlinePaymentId) th
throw new InvalidFieldException("offlinePaymentId cannot be null or empty.");
}

final String endPoint = "/v1/recipients/" + recipientId + "/offlinePayments/" + offlinePaymentId;
final String endPoint = "/v1/recipients/{recipientId}/offlinePayments/{offlinePaymentId}".replace("{recipientId}", recipientId).replace("{offlinePaymentId}", offlinePaymentId);
this.client.delete(endPoint);
return true;
}
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/com/trolley/PaymentGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ public Payment find(final String paymentId, final String batchId) throws Excepti
if (paymentId == null || paymentId.isEmpty()) {
throw new InvalidFieldException("Payment id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId + "/payments/" + paymentId;
final String endPoint = "/v1/batches/{batchId}/payments/{paymentId}".replace("{batchId}", batchId).replace("{paymentId}", paymentId);
final String response = this.client.get(endPoint);
return this.paymentFactory(response);
}

public Payment find(final String paymentId) throws Exception {
if (paymentId == null || paymentId.isEmpty()) {
throw new InvalidFieldException("Payment id cannot be null or empty.");
}
final String endPoint = "/v1/payments/{paymentId}".replace("{paymentId}", paymentId);
final String response = this.client.get(endPoint);
return this.paymentFactory(response);
}
Expand All @@ -45,7 +54,7 @@ public Payment create(final Payment payment, final String batchId) throws Except
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)payment);

final String endPoint = "/v1/batches/" + batchId + "/payments";
final String endPoint = "/v1/batches/{batchId}/payments".replace("{batchId}", batchId);
final String response = this.client.post(endPoint, jsonPayment);
return this.paymentFactory(response);
}
Expand All @@ -64,7 +73,7 @@ public boolean update(final String paymentId, final Payment payment, final Strin
final String jsonPayment = new ObjectMapper()
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)payment);
final String endPoint = "/v1/batches/" + batchId + "/payments/" + paymentId;
final String endPoint = "/v1/batches/{batchId}/payments/{paymentId}".replace("{batchId}", batchId).replace("{paymentId}", paymentId);
this.client.patch(endPoint, jsonPayment);
return true;
}
Expand All @@ -76,7 +85,7 @@ public boolean delete(final String paymentId, final String batchId) throws Excep
if (paymentId == null || paymentId.isEmpty()) {
throw new InvalidFieldException("Payment id cannot be null or empty.");
}
final String endPoint = "/v1/batches/" + batchId + "/payments/" + paymentId;
final String endPoint = "/v1/batches/{batchId}/payments/{paymentId}".replace("{batchId}", batchId).replace("{paymentId}", paymentId);
this.client.delete(endPoint);
return true;
}
Expand Down Expand Up @@ -121,7 +130,7 @@ public Payments search(final String batchId, final int page, final int pageSize,
if (searchTerm == null) {
throw new InvalidFieldException("searchTerm cannot be null. If you don't wish to provide a searchTerm, pass a blank String.");
}
final String endPoint = "/v1/batches/" + batchId + "/payments?search=" + searchTerm + "&page=" + page + "&pageSize=" + pageSize;
final String endPoint = "/v1/batches/{batchId}/payments".replace("{batchId}", batchId) + "?search=" + searchTerm + "&page=" + page + "&pageSize=" + pageSize;
final String response = this.client.get(endPoint);

return this.paymentListFactory(response);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/trolley/RecipientAccountGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public List<RecipientAccount> findAll(final String recipientId) throws Exception
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId + "/accounts";
final String endPoint = "/v1/recipients/{recipientId}/accounts".replace("{recipientId}", recipientId);
final String response = this.client.get(endPoint);
return this.recipientAccountListFactory(response);
}
Expand All @@ -33,7 +33,7 @@ public RecipientAccount find(final String recipientId, final String recipientAcc
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId + "/accounts/" + recipientAccountId;
final String endPoint = "/v1/recipients/{recipientId}/accounts/{recipientAccountId}".replace("{recipientId}", recipientId).replace("{recipientAccountId}", recipientAccountId);
final String response = this.client.get(endPoint);
return this.recipientAccountFactory(response);
}
Expand All @@ -48,7 +48,7 @@ public RecipientAccount create(final String recipientId, final RecipientAccount
final String jsonAccount = new ObjectMapper()
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)account);
final String endPoint = "/v1/recipients/" + recipientId + "/accounts";
final String endPoint = "/v1/recipients/{recipientId}/accounts".replace("{recipientId}", recipientId);
final String response = this.client.post(endPoint, jsonAccount);
return this.recipientAccountFactory(response);
}
Expand All @@ -63,7 +63,7 @@ public RecipientAccount update(final String recipientId, final String recipientA
final String jsonAccount = new ObjectMapper()
.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT)
.writeValueAsString((Object)account);
final String endPoint = "/v1/recipients/" + recipientId + "/accounts/" + recipientAccountId;
final String endPoint = "/v1/recipients/{recipientId}/accounts/{recipientAccountId}".replace("{recipientId}", recipientId).replace("{recipientAccountId}", recipientAccountId);
final String response = this.client.patch(endPoint, jsonAccount);
return this.recipientAccountFactory(response);
}
Expand All @@ -72,7 +72,7 @@ public boolean delete(final String recipientId, final String recipientAccountId)
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId + "/accounts/" + recipientAccountId;
final String endPoint = "/v1/recipients/{recipientId}/accounts/{recipientAccountId}".replace("{recipientId}", recipientId).replace("{recipientAccountId}", recipientAccountId);
this.client.delete(endPoint);
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/trolley/RecipientGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Recipient find(final String recipientId) throws Exception {
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId;
final String endPoint = "/v1/recipients/{recipientId}".replace("{recipientId}", recipientId);
final String response = this.client.get(endPoint);
return this.recipientFactory(response);
}
Expand All @@ -57,7 +57,7 @@ public Logs getAllLogs(final String recipientId, final int page, final int pageS
throw new InvalidFieldException("recipientId cannot be null.");
}

final String endPoint = "/v1/recipients/" + recipientId + "/logs?page="+page+"&pageSize="+pageSize;
final String endPoint = "/v1/recipients/{recipientId}/logs".replace("{recipientId}", recipientId) + "?page=" + page + "&pageSize=" + pageSize;
final String response = this.client.get(endPoint);
return logListFactory(response);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public List<Payment> findPayments(final String recipientId) throws Exception {
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId + "/payments";
final String endPoint = "/v1/recipients/{recipientId}/payments".replace("{recipientId}", recipientId);
final String response = this.client.get(endPoint);
final ObjectMapper mapper = new ObjectMapper();
final JsonNode node = mapper.readTree(response);
Expand Down Expand Up @@ -123,7 +123,7 @@ public boolean update(final String recipientId, final Recipient recipient) throw
throw new InvalidFieldException("Recipient object cannot be null or empty");
}
final String jsonRecipient = new ObjectMapper().writeValueAsString((Object)recipient);
final String endPoint = "/v1/recipients/" + recipientId;
final String endPoint = "/v1/recipients/{recipientId}".replace("{recipientId}", recipientId);
this.client.patch(endPoint, jsonRecipient);
return true;
}
Expand All @@ -132,7 +132,7 @@ public boolean delete(final String recipientId) throws Exception {
if (recipientId == null || recipientId.isEmpty()) {
throw new InvalidFieldException("Recipient id cannot be null or empty.");
}
final String endPoint = "/v1/recipients/" + recipientId;
final String endPoint = "/v1/recipients/{recipientId}".replace("{recipientId}", recipientId);
this.client.delete(endPoint);
return true;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public OfflinePayments getAllOfflinePayments(final String recipientId, final int
throw new InvalidFieldException("searchTerm cannot be null. If you don't wish to provide a searchTerm, pass a blank String.");
}

final String endPoint = "/v1/recipients/" + recipientId + "/offlinePayments?search=" + searchTerm + "&page=" + page + "&pageSize=" + pageSize;
final String endPoint = "/v1/recipients/{recipientId}/offlinePayments".replace("{recipientId}", recipientId) + "?search=" + searchTerm + "&page=" + page + "&pageSize=" + pageSize;

final String response = this.client.get(endPoint);

Expand Down
55 changes: 55 additions & 0 deletions src/main/java/com/trolley/VerificationGateway.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.trolley;

import java.net.URLEncoder;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class VerificationGateway {
Client client;

public VerificationGateway(final Configuration config) {
this.client = new Client(config);
}

public String search(final Map<String, Object> filters) throws Exception {
String endpoint = "/v1/verifications";
if (filters != null && !filters.isEmpty()) {
endpoint += "?" + queryString(filters);
}
return this.client.get(endpoint);
}

public String all(final Map<String, Object> filters) throws Exception {
return search(filters);
}

public String expire(final Object body) throws Exception {
final String endpoint = "/v1/verifications/expire";
return this.client.patch(endpoint, new ObjectMapper().writeValueAsString(body));
}

public String trigger(final String verificationType, final Object body) throws Exception {
final String endpoint = "/v1/verifications/{verificationType}/trigger".replace("{verificationType}", verificationType);
return this.client.post(endpoint, new ObjectMapper().writeValueAsString(body));
}

public String triggerWatchlist(final Object body) throws Exception {
final String endpoint = "/v1/verifications/watchlist/trigger";
return this.client.post(endpoint, new ObjectMapper().writeValueAsString(body));
}

private String queryString(final Map<String, Object> filters) throws Exception {
StringBuilder builder = new StringBuilder();
for (Map.Entry<String, Object> entry : filters.entrySet()) {
if (builder.length() > 0) {
builder.append("&");
}
builder.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
builder.append("=");
builder.append(URLEncoder.encode(String.valueOf(entry.getValue()), "UTF-8"));
}
return builder.toString();
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/trolley/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class Version {
public static int MAJOR = 2;
public static int MINOR = 0;
public static int MINOR = 2;
public static int PATCH = 0;
}
3 changes: 3 additions & 0 deletions src/main/java/com/trolley/types/OfflinePayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class OfflinePayment
{
private String id;
private String recipientId;
private Recipient recipient;
private String amount;
private String currency;
Expand All @@ -24,6 +25,8 @@ public class OfflinePayment
private String updatedAt;
private String createdAt;
private String deletedAt;
private String activityCount;
private Boolean taxReportable;

public void setEquivalentWithholdingCurrency(final String equivalentWithholdingCurrency) {
this.equivalentWithholdingCurrency = equivalentWithholdingCurrency;
Expand Down
Loading