Skip to content

Commit deacca9

Browse files
author
Aman Aalam
authored
Merge pull request #27 from trolley/dev
RC: Attributes update
2 parents 4abbec8 + 003bdb4 commit deacca9

File tree

7 files changed

+74
-11
lines changed

7 files changed

+74
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Add this dependency to your project's POM:
2020
<dependency>
2121
<groupId>com.trolley</groupId>
2222
<artifactId>java-sdk</artifactId>
23-
<version>1.1.1</version>
23+
<version>1.1.2</version>
2424
</dependency>
2525
```
2626

27-
The library's source is hosted at [https://github.com/paymentRails/java-sdk](https://github.com/trolley/java-sdk)
27+
The library's source is hosted at [https://github.com/Trolley/java-sdk](https://github.com/trolley/java-sdk)
2828

2929
The library can be found at: [https://central.sonatype.com/artifact/com.trolley/java-sdk/](https://central.sonatype.com/artifact/com.trolley/java-sdk/)
3030

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.trolley</groupId>
55
<artifactId>java-sdk</artifactId>
6-
<version>1.1.1</version>
6+
<version>1.1.2</version>
77
<description>Java SDK for Trolley API</description>
88
<packaging>jar</packaging>
99
<name>Trolley Java SDK</name>

src/main/java/com/trolley/trolley/Payment.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class Payment
3333
private Compliance compliance;
3434
private String payoutMethod;
3535
private String methodDisplay;
36-
Object batch;
36+
private Batch batch;
37+
private String checkNumber;
3738
String withholdingAmount;
3839
String withholdingCurrency;
3940
String equivalentWithholdingAmount;
@@ -287,6 +288,22 @@ public void setMethodDisplay(final String methodDisplay) {
287288
this.methodDisplay = methodDisplay;
288289
}
289290

291+
public Batch getBatch() {
292+
return batch;
293+
}
294+
295+
public void setBatch(Batch batch) {
296+
this.batch = batch;
297+
}
298+
299+
public String getCheckNumber() {
300+
return checkNumber;
301+
}
302+
303+
public void setCheckNumber(String checkNumber) {
304+
this.checkNumber = checkNumber;
305+
}
306+
290307
public static Payment find(final String payment_id, final String batch_id) throws Exception {
291308
return Configuration.gateway().payment.find(payment_id, batch_id);
292309
}

src/main/java/com/trolley/trolley/Recipient.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package com.trolley.trolley;
22

33
import java.util.List;
4+
import java.util.Locale;
5+
6+
import com.fasterxml.jackson.annotation.JsonCreator;
47
import com.fasterxml.jackson.annotation.JsonInclude;
8+
import com.fasterxml.jackson.annotation.JsonValue;
9+
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers.Default;
10+
import com.trolley.trolley.Invoice.SearchBy;
511

612
@JsonInclude(JsonInclude.Include.NON_NULL)
713
public class Recipient
@@ -19,7 +25,7 @@ public class Recipient
1925
String taxType;
2026
String status;
2127
String language;
22-
String complianceStatus;
28+
ComplianceStatus complianceStatus;
2329
String dob;
2430
String passport;
2531
String updatedAt;
@@ -42,6 +48,35 @@ public class Recipient
4248
String taxForm;
4349
String taxFormStatus;
4450
String taxWithholdingPercentage;
51+
52+
public static enum ComplianceStatus {
53+
REVIEW("review"),
54+
BLOCKED("blocked"),
55+
PENDING("pending"),
56+
VERIFIED("verified");
57+
58+
private String key;
59+
60+
ComplianceStatus(String key) {
61+
this.key = key;
62+
}
63+
64+
@JsonCreator
65+
public static ComplianceStatus fromString(String key) {
66+
return key == null
67+
? null
68+
: ComplianceStatus.valueOf(key.toUpperCase(Locale.US));
69+
}
70+
71+
@JsonValue
72+
public String getKey() {
73+
return key;
74+
}
75+
76+
public String toString(){
77+
return key.toLowerCase(Locale.US);
78+
}
79+
}
4580

4681
public Recipient() {
4782
this.taxWithholdingPercentage = "0.0";
@@ -223,11 +258,11 @@ public void setLanguage(final String language) {
223258
this.language = language;
224259
}
225260

226-
public String getComplianceStatus() {
261+
public ComplianceStatus getComplianceStatus() {
227262
return this.complianceStatus;
228263
}
229264

230-
public void setComplianceStatus(final String complianceStatus) {
265+
public void setComplianceStatus(final ComplianceStatus complianceStatus) {
231266
this.complianceStatus = complianceStatus;
232267
}
233268

src/main/java/com/trolley/trolley/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
public class Version {
77
public static int MAJOR = 1;
88
public static int MINOR = 1;
9-
public static int PATCH = 0;
9+
public static int PATCH = 2;
1010
}

src/test/java/com/trolley/sdk/integration/BatchTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import static org.junit.Assert.assertEquals;
55
import static org.junit.Assert.assertNotNull;
6+
import static org.junit.Assert.assertNull;
67
import static org.junit.Assert.assertTrue;
78

89
import java.util.ArrayList;
@@ -112,6 +113,9 @@ public void testCreateWithPayments() throws Exception {
112113

113114
assertEquals("15.00", batchPayments.get(0).getAmount());
114115
assertEquals("USD", batchPayments.get(0).getCurrency());
116+
assertEquals(batchPayments.get(0).getBatch().getId(), batch.getId());
117+
118+
assertNull(batchPayments.get(0).getCheckNumber());
115119

116120
//Cleanup
117121
boolean recDelResult = testHelper.deleteRecipient(recipientAlpha);

src/test/java/com/trolley/sdk/integration/RecipientTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public void testLifecycle() throws Exception {
5555
boolean response = client.recipient.update(recipient.getId(), body);
5656
assertNotNull(response);
5757

58+
// Test Compliance Status
59+
assertTrue(recipient.getComplianceStatus() == Recipient.ComplianceStatus.PENDING);
60+
5861
Recipient anotherRecipient = client.recipient.find(recipient.getId());
5962
assertEquals(anotherRecipient.getFirstName(), "Bob");
6063

@@ -105,9 +108,13 @@ public void testRecipientRouteMinimum() throws Exception {
105108
Gateway client = new Gateway(config);
106109
ArrayList<Recipient> recipients = (ArrayList<Recipient>)client.recipient.search(1,20,"");
107110
//Making sure routeMinimum is not null before asserting it's value
108-
assertNotNull(recipients.get(0).getRouteMinimum());
109-
//Making sure routeMinium is set to a non-null value
110-
assertTrue(Integer.parseInt(recipients.get(0).getRouteMinimum()) >= 0);
111+
for (Recipient recipient : recipients) {
112+
if(null != recipient.getRouteMinimum()){
113+
//Making sure routeMinium is set to a non-null value
114+
assertTrue(Integer.parseInt(recipient.getRouteMinimum()) >= 0);
115+
break;
116+
}
117+
}
111118
}
112119

113120
}

0 commit comments

Comments
 (0)