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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next Release

- Adds support for `UspsShipAccount`
- Adds `Tracker.RetrieveBatch` function
- Disposes of Luma service after use

## v7.2.0 (2025-06-18)
Expand Down
21 changes: 20 additions & 1 deletion EasyPost.Tests/ServicesTests/TrackerServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost.Exceptions.General;
Expand Down Expand Up @@ -148,6 +147,26 @@ public async Task TestRetrieve()
Assert.Equal(tracker.Id, retrievedTracker.Id);
}

[Fact]
[CrudOperations.Read]
[Testing.Function]
public async Task TestRetrieveBatch()
{
UseVCR("retrieve_batch");

Tracker tracker = await Client.Tracker.Create(Fixtures.Usps, "EZ1000000001");

List<string> trackingCodes = new() { tracker.TrackingCode };
TrackerCollection trackerCollection = await Client.Tracker.RetrieveBatch(new Dictionary<string, object> { { "tracking_codes", trackingCodes } });

List<Tracker> trackers = trackerCollection.Trackers;

foreach (Tracker singleTracker in trackers)
{
Assert.IsType<Tracker>(singleTracker);
}
}

#endregion

#endregion
Expand Down
101 changes: 101 additions & 0 deletions EasyPost.Tests/cassettes/net/tracker_service/retrieve_batch.json

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

13 changes: 13 additions & 0 deletions EasyPost/Services/TrackerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ public async Task<TrackerCollection> All(Parameters.Tracker.All parameters, Canc
[CrudOperations.Read]
public async Task<Tracker> Retrieve(string id, CancellationToken cancellationToken = default) => await RequestAsync<Tracker>(Method.Get, $"trackers/{id}", cancellationToken);

/// <summary>
/// Retrieves a batch of <see cref="Tracker"/>s.
/// </summary>
/// <param name="parameters">A dictionary of parameters to filter the list of <see cref="Tracker"/>s with.</param>
/// <param name="cancellationToken"><see cref="CancellationToken"/> to use for the HTTP request.</param>
/// <returns>A <see cref="TrackerCollection"/> instance.</returns>
[CrudOperations.Read]
public async Task<TrackerCollection> RetrieveBatch(Dictionary<string, object>? parameters = null, CancellationToken cancellationToken = default)
{
TrackerCollection collection = await RequestAsync<TrackerCollection>(Method.Post, "trackers/batch", cancellationToken, parameters);
return collection;
}

#endregion
}
}
Loading