Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 committed Jul 12, 2024
1 parent 0ebf1fd commit bf57ffb
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.easypost.model;

import lombok.Getter;

@Getter
public class RecommendShipDateForShipmentResult {
private TimeInTransitDetailsForShipDateRecommendation easypostTimeInTransitData;
private Rate rate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.easypost.model;

import java.util.List;
import lombok.Getter;

@Getter
public class RecommendShipDateResponse {
private List<RecommendShipDateForShipmentResult> rates;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
public class ShipDateForZipPairRecommendation {
private String carrier;
private String service;
private TimeInTransitDetailsForDeliveryDate easypostTimeInTransitData;
private TimeInTransitDetailsForShipDate easypostTimeInTransitData;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

@Getter
public class TimeInTransitDetailsForDeliveryDate {
private Date shipOnDate;
private Float deliveryDateConfidence;
private int estimatedTransitDays;
private Date easypostEstimatedDeliveryDate;
private TimeInTransit daysInTransit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.easypost.model;

import java.util.Date;
import lombok.Getter;

@Getter
public class TimeInTransitDetailsForShipDate {
private Date shipOnDate;
private Float deliveryDateConfidence;
private int estimatedTransitDays;
private TimeInTransit daysInTransit;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.easypost.model;

import java.util.Date;
import lombok.Getter;

@Getter
public class TimeInTransitDetailsForShipDateRecommendation {
private Date desiredDeliveryDate;
private Float deliveryDateConfidence;
private String estimatedTransitDays;
private String shipOnDate;
private TimeInTransit daysInTransit;
}
8 changes: 5 additions & 3 deletions src/main/java/com/easypost/service/ShipmentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.easypost.model.EstimatedDeliveryDate;
import com.easypost.model.EstimatedDeliveryDateResponse;
import com.easypost.model.Rate;
import com.easypost.model.RecommendShipDateForShipmentResult;
import com.easypost.model.RecommendShipDateResponse;
import com.easypost.model.Shipment;
import com.easypost.model.SmartRate;
import com.easypost.model.SmartrateAccuracy;
Expand Down Expand Up @@ -471,14 +473,14 @@ public List<EstimatedDeliveryDate> retrieveEstimatedDeliveryDate(final String id
* @return EstimatedDeliveryDate object.
* @throws EasyPostException When the request fails.
*/
public List<EstimatedDeliveryDate> recommendShipDate(final String id, final String desiredDeliveryDate)
public List<RecommendShipDateForShipmentResult> recommendShipDate(final String id, final String desiredDeliveryDate)
throws EasyPostException {
HashMap<String, Object> params = new HashMap<>();
params.put("desired_delivery_date", desiredDeliveryDate);
String endpoint = "shipments/" + id + "/smartrate/precision_shipping";

EstimatedDeliveryDateResponse response = Requestor.request(RequestMethod.GET, endpoint, params,
EstimatedDeliveryDateResponse.class, client);
RecommendShipDateResponse response = Requestor.request(RequestMethod.GET, endpoint, params,
RecommendShipDateResponse.class, client);
return response.getRates();
}
}
5 changes: 3 additions & 2 deletions src/test/java/com/easypost/ShipmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.easypost.model.Form;
import com.easypost.model.Parcel;
import com.easypost.model.Rate;
import com.easypost.model.RecommendShipDateForShipmentResult;
import com.easypost.model.Shipment;
import com.easypost.model.ShipmentCollection;
import com.easypost.model.SmartRate;
Expand Down Expand Up @@ -730,9 +731,9 @@ public void testRetrieveRecommendDate() throws EasyPostException {

Shipment shipment = vcr.client.shipment.create(Fixtures.basicShipment());

List<EstimatedDeliveryDate> estimatedDeliveryDates = vcr.client.shipment
List<RecommendShipDateForShipmentResult> estimatedDeliveryDates = vcr.client.shipment
.recommendShipDate(shipment.getId(), Fixtures.desiredDeliveryDate());
for (EstimatedDeliveryDate estimatedDeliveryDate : estimatedDeliveryDates) {
for (RecommendShipDateForShipmentResult estimatedDeliveryDate : estimatedDeliveryDates) {
assertNotNull(estimatedDeliveryDate.getEasypostTimeInTransitData());
}
}
Expand Down

0 comments on commit bf57ffb

Please sign in to comment.