Skip to content

Commit c3771f3

Browse files
authored
Merge pull request #631 from EasyPost/SHPE-483_batch_trackers
feat: add RetrieveBatch tracker function
2 parents e86300d + 36f88e2 commit c3771f3

File tree

4 files changed

+135
-1
lines changed

4 files changed

+135
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Next Release
44

55
- Adds support for `UspsShipAccount`
6+
- Adds `Tracker.RetrieveBatch` function
67
- Disposes of Luma service after use
78

89
## v7.2.0 (2025-06-18)

EasyPost.Tests/ServicesTests/TrackerServiceTest.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Threading.Tasks;
43
using EasyPost.Exceptions.General;
@@ -148,6 +147,26 @@ public async Task TestRetrieve()
148147
Assert.Equal(tracker.Id, retrievedTracker.Id);
149148
}
150149

150+
[Fact]
151+
[CrudOperations.Read]
152+
[Testing.Function]
153+
public async Task TestRetrieveBatch()
154+
{
155+
UseVCR("retrieve_batch");
156+
157+
Tracker tracker = await Client.Tracker.Create(Fixtures.Usps, "EZ1000000001");
158+
159+
List<string> trackingCodes = new() { tracker.TrackingCode };
160+
TrackerCollection trackerCollection = await Client.Tracker.RetrieveBatch(new Dictionary<string, object> { { "tracking_codes", trackingCodes } });
161+
162+
List<Tracker> trackers = trackerCollection.Trackers;
163+
164+
foreach (Tracker singleTracker in trackers)
165+
{
166+
Assert.IsType<Tracker>(singleTracker);
167+
}
168+
}
169+
151170
#endregion
152171

153172
#endregion

EasyPost.Tests/cassettes/net/tracker_service/retrieve_batch.json

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EasyPost/Services/TrackerService.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ public async Task<TrackerCollection> All(Parameters.Tracker.All parameters, Canc
114114
[CrudOperations.Read]
115115
public async Task<Tracker> Retrieve(string id, CancellationToken cancellationToken = default) => await RequestAsync<Tracker>(Method.Get, $"trackers/{id}", cancellationToken);
116116

117+
/// <summary>
118+
/// Retrieves a batch of <see cref="Tracker"/>s.
119+
/// </summary>
120+
/// <param name="parameters">A dictionary of parameters to filter the list of <see cref="Tracker"/>s with.</param>
121+
/// <param name="cancellationToken"><see cref="CancellationToken"/> to use for the HTTP request.</param>
122+
/// <returns>A <see cref="TrackerCollection"/> instance.</returns>
123+
[CrudOperations.Read]
124+
public async Task<TrackerCollection> RetrieveBatch(Dictionary<string, object>? parameters = null, CancellationToken cancellationToken = default)
125+
{
126+
TrackerCollection collection = await RequestAsync<TrackerCollection>(Method.Post, "trackers/batch", cancellationToken, parameters);
127+
return collection;
128+
}
129+
117130
#endregion
118131
}
119132
}

0 commit comments

Comments
 (0)