Skip to content

Commit bb860a7

Browse files
authored
Merge pull request #31 from trolley/dev
2 parents feb7b48 + 2210431 commit bb860a7

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

src/main/java/com/trolley/trolley/InvoiceGateway.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public Invoice fetch(final String invoiceId) throws Exception {
125125
* These options correspond to our documentation.
126126
* @param searchBy Enum of type Invoice.SearchBy denoting which field you want to search by
127127
* @param paramsList {@code List<String>} Required if 'searchBy' is either of these: 'invoiceId'
128-
* 'recipientId', 'invoiceNumber', 'tags'. Set to 'null' otherwise.
129-
* @param param String Required if 'searchBy' is either 'invoiceDate' or 'externalId'. Set to null otherwise.
128+
* 'recipientId', 'invoiceNumber', 'tags', or 'externalId'. Set to 'null' otherwise.
129+
* @param param String Required if 'searchBy' is 'invoiceDate'. Set to null otherwise.
130130
* @return {@code List<Invoice>}
131131
* @throws Exception
132132
*/
@@ -141,23 +141,23 @@ public List<Invoice> search(final SearchBy searchBy,
141141
case INVOICE_ID:
142142
case RECIPIENT_ID:
143143
case INVOICE_NUMBER:
144+
case EXTERNAL_ID:
144145
case TAGS:
145146
if(null == paramsList){
146147
throw new InvalidFieldException("variable paramsList can not be null for the provided searchBy parameter. Refer to method's Javadoc for more details.");
147148
}
148-
body = "{\""+searchBy.name()+"\":"
149+
body = "{\""+searchBy.getKey()+"\":"
149150
+new ObjectMapper()
150151
.setSerializationInclusion(Include.NON_EMPTY)
151152
.writeValueAsString(paramsList)
152153
+"}";
153154
break;
154155

155156
case INVOICE_DATE:
156-
case EXTERNAL_ID:
157157
if(null == param){
158158
throw new InvalidFieldException("variable param can not be null for the provided searchBy parameter. Refer to method's Javadoc for more details.");
159159
}
160-
body = "{\""+searchBy.name()+"\":\""+param+"\"}";
160+
body = "{\""+searchBy.getKey()+"\":\""+param+"\"}";
161161
break;
162162
}
163163
final String endPoint = "/v1/invoices/search/";
@@ -176,8 +176,8 @@ public List<Invoice> search(final SearchBy searchBy,
176176
* These options correspond to our documentation.
177177
* @param searchBy Enum of type Invoice.SearchBy denoting which field you want to search by
178178
* @param paramsList {@code List<String>} Required if 'searchBy' is either of these: 'invoiceId'
179-
* 'recipientId', 'invoiceNumber', 'tags'. Set to 'null' otherwise.
180-
* @param param String Required if 'searchBy' is either 'invoiceDate' or 'externalId'. Set to null otherwise.
179+
* 'recipientId', 'invoiceNumber', 'tags', or 'externalId'. Set to 'null' otherwise.
180+
* @param param String Required if 'searchBy' is 'invoiceDate'. Set to null otherwise.
181181
* @return Invoices object that contains {@code List<Invoice>} that you can traverse through, and a Meta object with pagination information
182182
* @throws Exception
183183
*/
@@ -198,7 +198,7 @@ public Invoices search(final SearchBy searchBy,
198198
if(null == paramsList){
199199
throw new InvalidFieldException("variable paramsList can not be null for the provided searchBy parameter. Refer to method's Javadoc for more details.");
200200
}
201-
body = "{\""+searchBy.name()+"\":"
201+
body = "{\""+searchBy.getKey()+"\":"
202202
+new ObjectMapper()
203203
.setSerializationInclusion(Include.NON_EMPTY)
204204
.writeValueAsString(paramsList)
@@ -212,7 +212,7 @@ public Invoices search(final SearchBy searchBy,
212212
if(null == param){
213213
throw new InvalidFieldException("variable param can not be null for the provided searchBy parameter. Refer to method's Javadoc for more details.");
214214
}
215-
body = "{\""+searchBy.name()+"\":\""+param+"\"}";
215+
body = "{\""+searchBy.getKey()+"\":\""+param+"\"}";
216216
break;
217217
}
218218
final String endPoint = "/v1/invoices/search/";

src/main/java/com/trolley/trolley/InvoiceLine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.trolley.trolley;
22

3-
import java.io.IOException;
43
import java.util.List;
54
import java.util.Locale;
65

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import com.fasterxml.jackson.annotation.JsonCreator;
77
import com.fasterxml.jackson.annotation.JsonInclude;
88
import com.fasterxml.jackson.annotation.JsonValue;
9-
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers.Default;
10-
import com.trolley.trolley.Invoice.SearchBy;
119

1210
@JsonInclude(JsonInclude.Include.NON_NULL)
1311
public class Recipient

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public void testInvoices() throws Exception {
4848
}
4949
};
5050

51-
// Create a new invoice - request body
51+
// Create a new invoice - prepare request body
5252
Invoice invoice = new Invoice();
5353
invoice.setRecipientId(recipient.getId());
5454
invoice.setInvoiceNumber("invoice-123");
5555
invoice.setDescription("test-invoice-create-java-sdk");
5656
invoice.setExternalId("ext-id-"+System.currentTimeMillis());
5757
invoice.setLines(invoiceLines);
5858

59-
// Create a new invoice - receiving response
59+
// Create a new invoice - send request and receive response
6060
invoice = client.invoice.create(invoice);
6161
assertEquals(invoice.getRecipientId(), recipient.getId());
6262

@@ -84,7 +84,7 @@ public void testInvoices() throws Exception {
8484
Invoices invoices = client.invoice.search(Invoice.SearchBy.RECIPIENT_ID, recipientIds, null,1,2);
8585
List<Invoice> invoiceList = invoices.getInvoices();
8686
assertEquals(invoiceList.get(0).getRecipientId(),invoice.getRecipientId());
87-
assertTrue(invoices.getMeta().getPages()>1);
87+
assertTrue(invoices.getMeta().getPages() >= 1);
8888

8989
//Cleanup - Delete Recipient
9090
boolean recDelResult = testHelper.deleteRecipient(recipient);

0 commit comments

Comments
 (0)