Skip to content

Commit

Permalink
Delivery date (#452)
Browse files Browse the repository at this point in the history
- Add new models for smart rates with estimated delivery dates
- Add function to retrieve estimated delivery date using date parameter
- Add function to retrieve estimated delivery date using Parameters object
- Add new GetEstimatedDeliveryDate parameters object
- Add unit tests for getting estimated delivery date for a shipment
- Add cassettes, fixture data
- Change base class for TimeInTransit since it is ephemeral
  • Loading branch information
nwithan8 committed May 1, 2023
1 parent ec9d7d8 commit 6c0bf38
Show file tree
Hide file tree
Showing 11 changed files with 528 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,27 @@ public async Task TestRegenerateRatesWithCarbonOffset()
Assert.NotNull(newRateWithCarbon.CarbonOffset);
}

[Fact]
[Testing.Function]
public async Task TestRetrieveEstimatedDeliveryDates()
{
UseVCR("estimated_delivery_dates");

Shipment shipment = await Client.Shipment.Create(Fixtures.Parameters.Shipments.Create(Fixtures.BasicShipment));

BetaFeatures.Parameters.Shipments.RetrieveEstimatedDeliveryDate retrieveEstimatedDeliveryDatesParameters = new BetaFeatures.Parameters.Shipments.RetrieveEstimatedDeliveryDate
{
PlannedShipDate = Fixtures.PlannedShipDate,
};

List<RateWithEstimatedDeliveryDate> ratesWithEstimatedDeliveryDates = await Client.Shipment.RetrieveEstimatedDeliveryDate(shipment.Id, retrieveEstimatedDeliveryDatesParameters);

foreach (var rate in ratesWithEstimatedDeliveryDates)
{
Assert.NotNull(rate.EasyPostTimeInTransitData);
}
}

#endregion

#endregion
Expand Down
2 changes: 2 additions & 0 deletions EasyPost.Tests/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static byte[] EventBody

internal static string PickupService => GetFixtureStructure().ServiceNames.Usps.PickupService;

internal static string PlannedShipDate => "2023-05-02";

internal static Dictionary<string, object> ReferralCustomer => GetFixtureStructure().Users.Referral;

internal static string ReportDate => "2022-04-12";
Expand Down
16 changes: 16 additions & 0 deletions EasyPost.Tests/ServicesTests/ShipmentServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,22 @@ public async Task TestForms()
}
}

[Fact]
[Testing.Function]
public async Task TestRetrieveEstimatedDeliveryDates()
{
UseVCR("estimated_delivery_dates");

Shipment shipment = await Client.Shipment.Create(Fixtures.BasicShipment);

List<RateWithEstimatedDeliveryDate> ratesWithEstimatedDeliveryDates = await Client.Shipment.RetrieveEstimatedDeliveryDate(shipment.Id, Fixtures.PlannedShipDate);

foreach (var rate in ratesWithEstimatedDeliveryDates)
{
Assert.NotNull(rate.EasyPostTimeInTransitData);
}
}

#endregion

#endregion
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c0bf38

Please sign in to comment.