Skip to content
Merged
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
10 changes: 2 additions & 8 deletions src/main/java/com/easypost/model/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.easypost.exception.EasyPostException;
import com.easypost.net.EasyPostResource;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -119,16 +118,11 @@ public static boolean createList(final Map<String, Object> params) throws EasyPo
public static boolean createList(final Map<String, Object> params, final String apiKey) throws EasyPostException {
String createListUrl = String.format("%s/create_list", classURL(Tracker.class));

int count = 0;
Map<String, Object> newParams = new HashMap<String, Object>();
Map<String, Object> trackers = new HashMap<String, Object>();
for (Object tracker : (ArrayList) params.get("trackers")) {
trackers.put(String.valueOf(count), tracker);
count++;
}
newParams.put("trackers", trackers);
newParams.put("trackers", params);

request(RequestMethod.POST, createListUrl, newParams, Object.class, apiKey);
// This endpoint does not return a response so we return true here
return true;
}

Expand Down
23 changes: 8 additions & 15 deletions src/test/java/com/easypost/EasyPostTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,25 +354,18 @@ public void testTrackerCreateAndRetrieve() throws EasyPostException, ParseExcept

@Test
public void testBatchTrackerCreate() throws EasyPostException {
List<String> trackingCodes = new ArrayList<String>();
trackingCodes.add("EZ1000000001");
trackingCodes.add("EZ2000000002");
trackingCodes.add("EZ3000000003");

List<HashMap<String, Object>> trackingCodeParams = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> code;
String[] trackingCodes = new String[]{"EZ1000000001", "EZ1000000002", "EZ1000000003"};
HashMap<String, Object> trackingCodeParams = new HashMap<String, Object>();

for (int i = 0; i < trackingCodes.size(); i++) {
code = new HashMap<String, Object>();
code.put("tracking_code", trackingCodes.get(i));
for (int i = 0; i < trackingCodes.length; i++) {
HashMap<String, Object> code = new HashMap<String, Object>();
code.put("tracking_code", trackingCodes[i]);
code.put("carrier", "USPS");
trackingCodeParams.add(code);
trackingCodeParams.put(String.valueOf(i), code);
}

Map createListParams = new HashMap<String, Object>();
createListParams.put("trackers", trackingCodeParams);

Tracker.createList(createListParams);
Tracker.createList(trackingCodeParams);
}

@Test
Expand Down Expand Up @@ -1098,7 +1091,7 @@ public void testShipmentReportDates() throws EasyPostException {
assertEquals("Incorrect ShipmentReport start_date", "Sun Oct 01 00:00:00 PDT 2017", shipmentReport2.getStartDate().toString());
assertEquals("Incorrect ShipmentReport end_date", "Mon Oct 30 00:00:00 PDT 2017", shipmentReport2.getEndDate().toString());
}*/


/*
// This test requires a FedExSameDayCity account
Expand Down