diff --git a/CHANGELOG.md b/CHANGELOG.md index 0852055fb..215d992b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `ApiKey.Delete` - `ApiKey.Enable` - `ApiKey.Disable` +- Adds `Tracker.Delete` function ## v7.4.0 (2025-11-24) diff --git a/EasyPost.Tests/ServicesTests/TrackerServiceTest.cs b/EasyPost.Tests/ServicesTests/TrackerServiceTest.cs index 9bad4a2d3..2659a17ff 100644 --- a/EasyPost.Tests/ServicesTests/TrackerServiceTest.cs +++ b/EasyPost.Tests/ServicesTests/TrackerServiceTest.cs @@ -147,6 +147,21 @@ public async Task TestRetrieve() Assert.Equal(tracker.Id, retrievedTracker.Id); } + [Fact] + [CrudOperations.Delete] + [Testing.Function] + public async Task TestDelete() + { + UseVCR("delete"); + + Tracker tracker = await Client.Tracker.Create(Fixtures.Usps, "EZ1000000001"); + + await Client.Tracker.Delete(tracker.Id); + + // Deleting a Tracker does not return anything, so we can't test the response + Assert.True(true); + } + #endregion #endregion diff --git a/EasyPost.Tests/cassettes/net/tracker_service/delete.json b/EasyPost.Tests/cassettes/net/tracker_service/delete.json new file mode 100644 index 000000000..8163da99f --- /dev/null +++ b/EasyPost.Tests/cassettes/net/tracker_service/delete.json @@ -0,0 +1,98 @@ +[ + { + "Duration": 919, + "RecordedAt": "2026-02-03T11:53:53.34816-07:00", + "Request": { + "Body": "{\"tracker\":{\"carrier\":\"USPS\",\"tracking_code\":\"EZ1000000001\"}}", + "BodyContentType": "Json", + "ContentHeaders": { + "Content-Type": "application/json; charset=utf-8", + "Content-Length": "61" + }, + "Method": "POST", + "RequestHeaders": { + "Authorization": "", + "User-Agent": "" + }, + "Uri": "https://api.easypost.com/v2/trackers" + }, + "Response": { + "Body": "{\"id\":\"trk_b88311999eaa4429bd11ce27ea62d302\",\"object\":\"Tracker\",\"mode\":\"test\",\"tracking_code\":\"EZ1000000001\",\"status\":\"pre_transit\",\"status_detail\":\"status_update\",\"created_at\":\"2025-11-06T17:40:39Z\",\"updated_at\":\"2025-11-06T17:40:39Z\",\"signed_by\":null,\"weight\":null,\"est_delivery_date\":\"2025-11-06T17:40:39Z\",\"shipment_id\":null,\"carrier\":\"USPS\",\"tracking_details\":[{\"object\":\"TrackingDetail\",\"message\":\"Pre-Shipment Info Sent to USPS\",\"description\":\"\",\"status\":\"pre_transit\",\"status_detail\":\"status_update\",\"datetime\":\"2025-10-06T17:40:39Z\",\"source\":\"USPS\",\"carrier_code\":\"\",\"tracking_location\":{\"object\":\"TrackingLocation\",\"city\":null,\"state\":null,\"country\":null,\"zip\":null},\"est_delivery_date\":null},{\"object\":\"TrackingDetail\",\"message\":\"Shipping Label Created\",\"description\":\"\",\"status\":\"pre_transit\",\"status_detail\":\"status_update\",\"datetime\":\"2025-10-07T06:17:39Z\",\"source\":\"USPS\",\"carrier_code\":\"\",\"tracking_location\":{\"object\":\"TrackingLocation\",\"city\":\"HOUSTON\",\"state\":\"TX\",\"country\":null,\"zip\":\"77063\"},\"est_delivery_date\":null}],\"carrier_detail\":{\"object\":\"CarrierDetail\",\"service\":\"First-Class Package Service\",\"container_type\":null,\"est_delivery_date_local\":null,\"est_delivery_time_local\":null,\"origin_location\":\"HOUSTON TX, 77001\",\"origin_tracking_location\":{\"object\":\"TrackingLocation\",\"city\":\"HOUSTON\",\"state\":\"TX\",\"country\":null,\"zip\":\"77063\"},\"destination_location\":\"CHARLESTON SC, 29401\",\"destination_tracking_location\":null,\"guaranteed_delivery_date\":null,\"alternate_identifier\":null,\"initial_delivery_attempt\":null},\"delivery_evidence\":[],\"finalized\":true,\"is_return\":false,\"public_url\":\"https://track.easypost.com/djE6dHJrX2I4ODMxMTk5OWVhYTQ0MjliZDExY2UyN2VhNjJkMzAy\"}", + "BodyContentType": "Json", + "ContentHeaders": { + "Expires": "0", + "Content-Type": "application/json; charset=utf-8", + "Content-Length": "1691" + }, + "HttpVersion": "1.1", + "ResponseHeaders": { + "X-Frame-Options": "SAMEORIGIN", + "X-XSS-Protection": "1; mode=block", + "X-Content-Type-Options": "nosniff", + "x-download-options": "noopen", + "x-permitted-cross-domain-policies": "none", + "Referrer-Policy": "strict-origin-when-cross-origin", + "x-ep-request-uuid": "e05a3b9f69824440e7897aa8003aee64", + "Cache-Control": "no-store, no-cache, private", + "Pragma": "no-cache", + "Location": "/api/v2/trackers/trk_b88311999eaa4429bd11ce27ea62d302", + "x-runtime": "0.088088", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202602022215-5a5c93c546-master", + "x-backend": "easypost", + "x-proxied": "intlb4nuq 5f0235a1ab,extlb1nuq cbbd141214", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" + }, + "Status": { + "Code": 200, + "Message": "OK" + } + } + }, + { + "Duration": 208, + "RecordedAt": "2026-02-03T11:53:53.65716-07:00", + "Request": { + "Body": "", + "BodyContentType": "Text", + "ContentHeaders": {}, + "Method": "DELETE", + "RequestHeaders": { + "Authorization": "", + "User-Agent": "" + }, + "Uri": "https://api.easypost.com/v2/trackers/trk_b88311999eaa4429bd11ce27ea62d302" + }, + "Response": { + "Body": "{\"success\":true}", + "BodyContentType": "Json", + "ContentHeaders": { + "Expires": "0", + "Content-Type": "application/json; charset=utf-8", + "Content-Length": "16" + }, + "HttpVersion": "1.1", + "ResponseHeaders": { + "X-Frame-Options": "SAMEORIGIN", + "X-XSS-Protection": "1; mode=block", + "X-Content-Type-Options": "nosniff", + "x-download-options": "noopen", + "x-permitted-cross-domain-policies": "none", + "Referrer-Policy": "strict-origin-when-cross-origin", + "x-ep-request-uuid": "e05a3b9f69824441e7897aa8003aef96", + "Cache-Control": "no-store, no-cache, private", + "Pragma": "no-cache", + "x-runtime": "0.036036", + "x-node": "bigweb57nuq", + "x-version-label": "easypost-202602022215-5a5c93c546-master", + "x-backend": "easypost", + "x-proxied": "intlb4nuq 5f0235a1ab,extlb1nuq cbbd141214", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" + }, + "Status": { + "Code": 200, + "Message": "OK" + } + } + } +] diff --git a/EasyPost/Services/TrackerService.cs b/EasyPost/Services/TrackerService.cs index 64259d62b..fe9589afb 100644 --- a/EasyPost/Services/TrackerService.cs +++ b/EasyPost/Services/TrackerService.cs @@ -127,6 +127,16 @@ public async Task RetrieveBatch(Parameters.Tracker.Batch para return collection; } + /// + /// Delete a . + /// Related API documentation. + /// + /// The ID of the to delete. + /// to use for the HTTP request. + /// None. + [CrudOperations.Delete] + public async Task Delete(string id, CancellationToken cancellationToken = default) => await RequestAsync(Method.Delete, $"trackers/{id}", cancellationToken); + #endregion } }