From 0bb7e067658c1b38ff7cde1f3297ec2077dfe1a9 Mon Sep 17 00:00:00 2001 From: Watson Zuo Date: Mon, 21 Jul 2025 16:36:45 +0800 Subject: [PATCH 1/3] support 2025-07 version --- README.md | 4 +- .../AfterShipTracking.csproj | 2 +- .../AfterShipTracking/AftershipClient.cs | 8 +- .../Models/CreateTrackingResponse.cs | 2 +- .../Models/DeleteTrackingByIdResponse.cs | 2 +- .../Models/GetTrackingByIdResponse.cs | 2 +- .../MarkTrackingCompletedByIdResponse.cs | 2 +- .../Models/RetrackTrackingByIdResponse.cs | 2 +- .../AfterShipTracking/Models/Tracking.cs | 2 +- .../Models/UpdateTrackingByIdResponse.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Public/AfterShipConfiguration.cs | 2 +- .../RestAPI/Courier/CourierService.cs | 4 +- .../CourierConnectionOption.cs | 60 +++++++-------- .../CourierConnectionService.cs | 38 +++++----- .../EstimatedDeliveryDateService.cs | 4 +- .../RestAPI/Tracking/TrackingOption.cs | 74 +++++++++---------- .../RestAPI/Tracking/TrackingService.cs | 38 +++++----- 18 files changed, 125 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index eaf0ddb..e0e0279 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ If you need support using AfterShip products, please contact support@aftership.c - [Endpoints](#endpoints) - [/trackings](#trackings) - [/couriers](#couriers) - - [/courier-connections](#courier-connections) - [/estimated-delivery-date](#estimated-delivery-date) - [Help](#help) - [License](#license) @@ -42,6 +41,7 @@ Each SDK version is designed to work with a specific API version. Please refer t | SDK Version | Supported API Version | Branch | | ----------- | --------------------- | ---------------------------------------------------------- | +| 12.x.x | 2025-07 | https://github.com/AfterShip/tracking-sdk-net/tree/2025-07 | | 11.x.x | 2025-04 | https://github.com/AfterShip/tracking-sdk-net/tree/2025-04 | | 10.x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-net/tree/2025-01 | | 9.x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-net/tree/2024-10 | @@ -132,7 +132,7 @@ class Program ## Rate Limiter -See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-04/quickstart/rate-limit) to understand the AfterShip rate limit policy. +See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-07/quickstart/rate-limit) to understand the AfterShip rate limit policy. ## Error Handling diff --git a/src/AfterShipTracking/AfterShipTracking/AfterShipTracking.csproj b/src/AfterShipTracking/AfterShipTracking/AfterShipTracking.csproj index d766969..bb8062d 100644 --- a/src/AfterShipTracking/AfterShipTracking/AfterShipTracking.csproj +++ b/src/AfterShipTracking/AfterShipTracking/AfterShipTracking.csproj @@ -10,7 +10,7 @@ Copyright © AfterShip AfterShipTracking en-US - 11.0.0 + 12.0.0 AfterShip diff --git a/src/AfterShipTracking/AfterShipTracking/AftershipClient.cs b/src/AfterShipTracking/AfterShipTracking/AftershipClient.cs index 7d5e696..8b994ac 100644 --- a/src/AfterShipTracking/AfterShipTracking/AftershipClient.cs +++ b/src/AfterShipTracking/AfterShipTracking/AftershipClient.cs @@ -64,10 +64,10 @@ public class AfterShipClient public IHttpClient HttpClient { get; } + public CourierConnectionService CourierConnection { get; set; } public TrackingService Tracking { get; set; } - public CourierService Courier { get; set; } public EstimatedDeliveryDateService EstimatedDeliveryDate { get; set; } - public CourierConnectionService CourierConnection { get; set; } + public CourierService Courier { get; set; } public AfterShipClient( string domain = null, string apiKey = null, @@ -96,10 +96,10 @@ public AfterShipClient( HttpClient = httpClient ?? new SystemNetHttpClient(this.ApiBase, authenticator, this.MaxRetry, this.Timeout, this.UserAgent,this.Proxy); + CourierConnection = new CourierConnectionService(HttpClient); Tracking = new TrackingService(HttpClient); - Courier = new CourierService(HttpClient); EstimatedDeliveryDate = new EstimatedDeliveryDateService(HttpClient); - CourierConnection = new CourierConnectionService(HttpClient); + Courier = new CourierService(HttpClient); } private void CheckConfig() diff --git a/src/AfterShipTracking/AfterShipTracking/Models/CreateTrackingResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/CreateTrackingResponse.cs index 343efe0..7c5ecb4 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/CreateTrackingResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/CreateTrackingResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryCreateTrackingResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/DeleteTrackingByIdResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/DeleteTrackingByIdResponse.cs index 9734b72..0a073fb 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/DeleteTrackingByIdResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/DeleteTrackingByIdResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryDeleteTrackingByIdResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/GetTrackingByIdResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/GetTrackingByIdResponse.cs index 493da6f..c588cfb 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/GetTrackingByIdResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/GetTrackingByIdResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryGetTrackingByIdResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/MarkTrackingCompletedByIdResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/MarkTrackingCompletedByIdResponse.cs index 5198c2a..d7cec5b 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/MarkTrackingCompletedByIdResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/MarkTrackingCompletedByIdResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryMarkTrackingCompletedByIdResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/RetrackTrackingByIdResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/RetrackTrackingByIdResponse.cs index eb392e1..d6fb4f1 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/RetrackTrackingByIdResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/RetrackTrackingByIdResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryRetrackTrackingByIdResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/Tracking.cs b/src/AfterShipTracking/AfterShipTracking/Models/Tracking.cs index 22ff7ff..3fecdc4 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/Tracking.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/Tracking.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryTracking [JsonProperty("datetime_max",NullValueHandling = NullValueHandling.Ignore)] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason",NullValueHandling = NullValueHandling.Ignore)] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Models/UpdateTrackingByIdResponse.cs b/src/AfterShipTracking/AfterShipTracking/Models/UpdateTrackingByIdResponse.cs index c03a143..3655d8d 100644 --- a/src/AfterShipTracking/AfterShipTracking/Models/UpdateTrackingByIdResponse.cs +++ b/src/AfterShipTracking/AfterShipTracking/Models/UpdateTrackingByIdResponse.cs @@ -564,7 +564,7 @@ public class LatestEstimatedDeliveryUpdateTrackingByIdResponse [JsonProperty("datetime_max")] public string? DatetimeMax { get; set; } /// - /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to this document. + /// ReviseReason Explains the reason for a change to the latest_estimated_delivery. This string will only have a value if:1. The source for the latest EDD is AfterShip EDD. 2. The reason for the change is known.For a comprehensive list of reasons, please refer to . /// [JsonProperty("revise_reason")] public string? ReviseReason { get; set; } diff --git a/src/AfterShipTracking/AfterShipTracking/Properties/AssemblyInfo.cs b/src/AfterShipTracking/AfterShipTracking/Properties/AssemblyInfo.cs index b423bc0..3ee93d2 100644 --- a/src/AfterShipTracking/AfterShipTracking/Properties/AssemblyInfo.cs +++ b/src/AfterShipTracking/AfterShipTracking/Properties/AssemblyInfo.cs @@ -12,5 +12,5 @@ internal class AssemblyInformation { - public const string AssemblyInformationalVersion = "11.0.0"; + public const string AssemblyInformationalVersion = "12.0.0"; } diff --git a/src/AfterShipTracking/AfterShipTracking/Public/AfterShipConfiguration.cs b/src/AfterShipTracking/AfterShipTracking/Public/AfterShipConfiguration.cs index a03d448..6b87e39 100644 --- a/src/AfterShipTracking/AfterShipTracking/Public/AfterShipConfiguration.cs +++ b/src/AfterShipTracking/AfterShipTracking/Public/AfterShipConfiguration.cs @@ -15,7 +15,7 @@ public static class AfterShipConfiguration public const string SDK_PREFIX = "AFTERSHIP_TRACKING_SDK"; public const int DEFAULT_MAX_RETRY = 2; public const int DEFAULT_TIMEOUT = 10000; - public const string DEFAULT_USER_AGENT = "tracking-sdk-net/11.0.0 (https://www.aftership.com) System.Net.Http.HttpClient/0.0.0"; + public const string DEFAULT_USER_AGENT = "tracking-sdk-net/12.0.0 (https://www.aftership.com) System.Net.Http.HttpClient/0.0.0"; public const string DEFAULT_DOMAIN = "https://api.aftership.com"; private static string domain; diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/Courier/CourierService.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/Courier/CourierService.cs index e8e52de..fc68c62 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/Courier/CourierService.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/Courier/CourierService.cs @@ -18,7 +18,7 @@ public CourierService(IHttpClient httpClient) public GetCouriersResponse GetCouriers( GetCouriersOptions? options = null) { - string path = $"/tracking/2025-04/couriers"; + string path = $"/tracking/2025-07/couriers"; Request request = new Request( HttpMethod.Get, path, @@ -30,7 +30,7 @@ public GetCouriersResponse GetCouriers( GetCouriersOptions? options = null) } public DetectCourierResponse DetectCourier( DetectCourierOptions? options = null) { - string path = $"/tracking/2025-04/couriers/detect"; + string path = $"/tracking/2025-07/couriers/detect"; Request request = new Request( HttpMethod.Post, path, diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionOption.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionOption.cs index 3927b17..7cf5261 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionOption.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionOption.cs @@ -10,25 +10,36 @@ namespace AfterShipTracking /// /// Description /// - public class PutCourierConnectionsByIdOptions : BaseOptions + public class PostCourierConnectionsOptions : BaseOptions { - public PutCourierConnectionsByIdOptions() + public PostCourierConnectionsOptions() { } - public PutCourierConnectionsByIdRequest PutCourierConnectionsByIdRequest { get; set; } + public PostCourierConnectionsRequest PostCourierConnectionsRequest { get; set; } override public string GetBody() { string body = null; - if ( PutCourierConnectionsByIdRequest != null) + if ( PostCourierConnectionsRequest != null) { - body = BaseResourceService.ToJson(PutCourierConnectionsByIdRequest); + body = BaseResourceService.ToJson(PostCourierConnectionsRequest); } return body; } + } + /// + /// Description + /// + public class DeleteCourierConnectionsByIdOptions : BaseOptions + { + public DeleteCourierConnectionsByIdOptions() + { + } + + } /// /// Description @@ -55,29 +66,6 @@ override public List> GetQueryParams() /// /// Description /// - public class PostCourierConnectionsOptions : BaseOptions - { - public PostCourierConnectionsOptions() - { - } - - - public PostCourierConnectionsRequest PostCourierConnectionsRequest { get; set; } - - override public string GetBody() - { - string body = null; - - if ( PostCourierConnectionsRequest != null) - { - body = BaseResourceService.ToJson(PostCourierConnectionsRequest); - } - return body; - } - } - /// - /// Description - /// public class GetCourierConnectionsByIdOptions : BaseOptions { public GetCourierConnectionsByIdOptions() @@ -89,12 +77,24 @@ public GetCourierConnectionsByIdOptions() /// /// Description /// - public class DeleteCourierConnectionsByIdOptions : BaseOptions + public class PutCourierConnectionsByIdOptions : BaseOptions { - public DeleteCourierConnectionsByIdOptions() + public PutCourierConnectionsByIdOptions() { } + public PutCourierConnectionsByIdRequest PutCourierConnectionsByIdRequest { get; set; } + + override public string GetBody() + { + string body = null; + + if ( PutCourierConnectionsByIdRequest != null) + { + body = BaseResourceService.ToJson(PutCourierConnectionsByIdRequest); + } + return body; + } } } diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionService.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionService.cs index 302a3c2..339f2ea 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionService.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/CourierConnection/CourierConnectionService.cs @@ -16,15 +16,11 @@ public CourierConnectionService(IHttpClient httpClient) this.HttpClient = httpClient; } - public CourierConnection PutCourierConnectionsById(string id, PutCourierConnectionsByIdOptions? options = null) + public CourierConnection PostCourierConnections( PostCourierConnectionsOptions? options = null) { - string path = $"/tracking/2025-04/courier-connections/{id}"; - if (string.IsNullOrEmpty(id)) - { - throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); - } + string path = $"/tracking/2025-07/courier-connections"; Request request = new Request( - HttpMethod.Patch, + HttpMethod.Post, path, options ); @@ -32,33 +28,37 @@ public CourierConnection PutCourierConnectionsById(string id, PutCourierConnect var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public GetCourierConnectionsResponseCourierConnectionListData GetCourierConnections( GetCourierConnectionsOptions? options = null) + public CourierConnection DeleteCourierConnectionsById(string id, DeleteCourierConnectionsByIdOptions? options = null) { - string path = $"/tracking/2025-04/courier-connections"; + string path = $"/tracking/2025-07/courier-connections/{id}"; + if (string.IsNullOrEmpty(id)) + { + throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); + } Request request = new Request( - HttpMethod.Get, + HttpMethod.Delete, path, options ); var response = this.HttpClient.MakeRequest(request); - return ProcessData(response); + return ProcessData(response); } - public CourierConnection PostCourierConnections( PostCourierConnectionsOptions? options = null) + public GetCourierConnectionsResponseCourierConnectionListData GetCourierConnections( GetCourierConnectionsOptions? options = null) { - string path = $"/tracking/2025-04/courier-connections"; + string path = $"/tracking/2025-07/courier-connections"; Request request = new Request( - HttpMethod.Post, + HttpMethod.Get, path, options ); var response = this.HttpClient.MakeRequest(request); - return ProcessData(response); + return ProcessData(response); } public CourierConnection GetCourierConnectionsById(string id, GetCourierConnectionsByIdOptions? options = null) { - string path = $"/tracking/2025-04/courier-connections/{id}"; + string path = $"/tracking/2025-07/courier-connections/{id}"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); @@ -72,15 +72,15 @@ public CourierConnection GetCourierConnectionsById(string id, GetCourierConnect var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public CourierConnection DeleteCourierConnectionsById(string id, DeleteCourierConnectionsByIdOptions? options = null) + public CourierConnection PutCourierConnectionsById(string id, PutCourierConnectionsByIdOptions? options = null) { - string path = $"/tracking/2025-04/courier-connections/{id}"; + string path = $"/tracking/2025-07/courier-connections/{id}"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); } Request request = new Request( - HttpMethod.Delete, + HttpMethod.Patch, path, options ); diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/EstimatedDeliveryDate/EstimatedDeliveryDateService.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/EstimatedDeliveryDate/EstimatedDeliveryDateService.cs index ebd0eb6..1ad9ae4 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/EstimatedDeliveryDate/EstimatedDeliveryDateService.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/EstimatedDeliveryDate/EstimatedDeliveryDateService.cs @@ -18,7 +18,7 @@ public EstimatedDeliveryDateService(IHttpClient httpClient) public PredictBatchResponse PredictBatch( PredictBatchOptions? options = null) { - string path = $"/tracking/2025-04/estimated-delivery-date/predict-batch"; + string path = $"/tracking/2025-07/estimated-delivery-date/predict-batch"; Request request = new Request( HttpMethod.Post, path, @@ -30,7 +30,7 @@ public PredictBatchResponse PredictBatch( PredictBatchOptions? options = null) } public EstimatedDeliveryDateResponse Predict( PredictOptions? options = null) { - string path = $"/tracking/2025-04/estimated-delivery-date/predict"; + string path = $"/tracking/2025-07/estimated-delivery-date/predict"; Request request = new Request( HttpMethod.Post, path, diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingOption.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingOption.cs index 9d6e67e..8db51ca 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingOption.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingOption.cs @@ -30,36 +30,36 @@ override public List> GetQueryParams() /// /// Description /// - public class UpdateTrackingByIdOptions : BaseOptions + public class DeleteTrackingByIdOptions : BaseOptions { - public UpdateTrackingByIdOptions() + public DeleteTrackingByIdOptions() { } - public UpdateTrackingByIdRequest UpdateTrackingByIdRequest { get; set; } - - override public string GetBody() - { - string body = null; - - if ( UpdateTrackingByIdRequest != null) - { - body = BaseResourceService.ToJson(UpdateTrackingByIdRequest); - } - return body; - } } /// /// Description /// - public class DeleteTrackingByIdOptions : BaseOptions + public class MarkTrackingCompletedByIdOptions : BaseOptions { - public DeleteTrackingByIdOptions() + public MarkTrackingCompletedByIdOptions() { } + public MarkTrackingCompletedByIdRequest MarkTrackingCompletedByIdRequest { get; set; } + + override public string GetBody() + { + string body = null; + + if ( MarkTrackingCompletedByIdRequest != null) + { + body = BaseResourceService.ToJson(MarkTrackingCompletedByIdRequest); + } + return body; + } } /// /// Description @@ -116,33 +116,22 @@ override public List> GetQueryParams() /// /// Description /// - public class RetrackTrackingByIdOptions : BaseOptions - { - public RetrackTrackingByIdOptions() - { - } - - - } - /// - /// Description - /// - public class MarkTrackingCompletedByIdOptions : BaseOptions + public class CreateTrackingOptions : BaseOptions { - public MarkTrackingCompletedByIdOptions() + public CreateTrackingOptions() { } - public MarkTrackingCompletedByIdRequest MarkTrackingCompletedByIdRequest { get; set; } + public CreateTrackingRequest CreateTrackingRequest { get; set; } override public string GetBody() { string body = null; - if ( MarkTrackingCompletedByIdRequest != null) + if ( CreateTrackingRequest != null) { - body = BaseResourceService.ToJson(MarkTrackingCompletedByIdRequest); + body = BaseResourceService.ToJson(CreateTrackingRequest); } return body; } @@ -150,24 +139,35 @@ override public string GetBody() /// /// Description /// - public class CreateTrackingOptions : BaseOptions + public class UpdateTrackingByIdOptions : BaseOptions { - public CreateTrackingOptions() + public UpdateTrackingByIdOptions() { } - public CreateTrackingRequest CreateTrackingRequest { get; set; } + public UpdateTrackingByIdRequest UpdateTrackingByIdRequest { get; set; } override public string GetBody() { string body = null; - if ( CreateTrackingRequest != null) + if ( UpdateTrackingByIdRequest != null) { - body = BaseResourceService.ToJson(CreateTrackingRequest); + body = BaseResourceService.ToJson(UpdateTrackingByIdRequest); } return body; } } + /// + /// Description + /// + public class RetrackTrackingByIdOptions : BaseOptions + { + public RetrackTrackingByIdOptions() + { + } + + + } } diff --git a/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingService.cs b/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingService.cs index e6b273b..4fc3cc5 100644 --- a/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingService.cs +++ b/src/AfterShipTracking/AfterShipTracking/RestAPI/Tracking/TrackingService.cs @@ -18,7 +18,7 @@ public TrackingService(IHttpClient httpClient) public Tracking GetTrackingById(string id, GetTrackingByIdOptions? options = null) { - string path = $"/tracking/2025-04/trackings/{id}"; + string path = $"/tracking/2025-07/trackings/{id}"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); @@ -32,15 +32,15 @@ public Tracking GetTrackingById(string id, GetTrackingByIdOptions? options = nu var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public Tracking UpdateTrackingById(string id, UpdateTrackingByIdOptions? options = null) + public Tracking DeleteTrackingById(string id, DeleteTrackingByIdOptions? options = null) { - string path = $"/tracking/2025-04/trackings/{id}"; + string path = $"/tracking/2025-07/trackings/{id}"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); } Request request = new Request( - HttpMethod.Put, + HttpMethod.Delete, path, options ); @@ -48,15 +48,15 @@ public Tracking UpdateTrackingById(string id, UpdateTrackingByIdOptions? option var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public Tracking DeleteTrackingById(string id, DeleteTrackingByIdOptions? options = null) + public Tracking MarkTrackingCompletedById(string id, MarkTrackingCompletedByIdOptions? options = null) { - string path = $"/tracking/2025-04/trackings/{id}"; + string path = $"/tracking/2025-07/trackings/{id}/mark-as-completed"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); } Request request = new Request( - HttpMethod.Delete, + HttpMethod.Post, path, options ); @@ -66,7 +66,7 @@ public Tracking DeleteTrackingById(string id, DeleteTrackingByIdOptions? option } public GetTrackingsResponseTrackingListData GetTrackings( GetTrackingsOptions? options = null) { - string path = $"/tracking/2025-04/trackings"; + string path = $"/tracking/2025-07/trackings"; Request request = new Request( HttpMethod.Get, path, @@ -76,13 +76,9 @@ public GetTrackingsResponseTrackingListData GetTrackings( GetTrackingsOptions? o var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public Tracking RetrackTrackingById(string id, RetrackTrackingByIdOptions? options = null) + public Tracking CreateTracking( CreateTrackingOptions? options = null) { - string path = $"/tracking/2025-04/trackings/{id}/retrack"; - if (string.IsNullOrEmpty(id)) - { - throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); - } + string path = $"/tracking/2025-07/trackings"; Request request = new Request( HttpMethod.Post, path, @@ -92,15 +88,15 @@ public Tracking RetrackTrackingById(string id, RetrackTrackingByIdOptions? opti var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public Tracking MarkTrackingCompletedById(string id, MarkTrackingCompletedByIdOptions? options = null) + public Tracking UpdateTrackingById(string id, UpdateTrackingByIdOptions? options = null) { - string path = $"/tracking/2025-04/trackings/{id}/mark-as-completed"; + string path = $"/tracking/2025-07/trackings/{id}"; if (string.IsNullOrEmpty(id)) { throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); } Request request = new Request( - HttpMethod.Post, + HttpMethod.Put, path, options ); @@ -108,9 +104,13 @@ public Tracking MarkTrackingCompletedById(string id, MarkTrackingCompletedByIdO var response = this.HttpClient.MakeRequest(request); return ProcessData(response); } - public Tracking CreateTracking( CreateTrackingOptions? options = null) + public Tracking RetrackTrackingById(string id, RetrackTrackingByIdOptions? options = null) { - string path = $"/tracking/2025-04/trackings"; + string path = $"/tracking/2025-07/trackings/{id}/retrack"; + if (string.IsNullOrEmpty(id)) + { + throw ErrorCode.GenSDKError(ErrorCode.REQUEST_ERROR,"request error"+": `id` is invalid"); + } Request request = new Request( HttpMethod.Post, path, From aac901de2bb138d940623bbd2dce0c4c3c99af6d Mon Sep 17 00:00:00 2001 From: Watson Zuo Date: Mon, 21 Jul 2025 17:23:45 +0800 Subject: [PATCH 2/3] update readme --- README.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/README.md b/README.md index e0e0279..71a7f12 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ If you need support using AfterShip products, please contact support@aftership.c - [Endpoints](#endpoints) - [/trackings](#trackings) - [/couriers](#couriers) + - [/courier-connections](#courier-connections) - [/estimated-delivery-date](#estimated-delivery-date) - [Help](#help) - [License](#license) @@ -293,6 +294,73 @@ DetectCourierResponse resp = client.Courier.DetectCourier(options); Console.WriteLine(resp.Total); ``` +### /courier-connections + +**POST** /courier-connections +```csharp +PostCourierConnectionsOptions postCourierConnectionsOptions = new PostCourierConnectionsOptions(); +postCourierConnectionsOptions.PostCourierConnectionsRequest = new PostCourierConnectionsRequest(); +PostCourierConnectionsRequest req = new PostCourierConnectionsRequest(); +req.CourierSlug = "dhl-api"; +Dictionary credentails = new Dictionary(); +credentails.Add("api_key", ""); +req.Credentials = credentails; +postCourierConnectionsOptions.PostCourierConnectionsRequest = req; +CourierConnection createdCourierConnection = client.CourierConnection.PostCourierConnections(postCourierConnectionsOptions); +if (createdCourierConnection != null) +{ + Console.WriteLine(createdCourierConnection.Id); +} +``` + +**GET** /courier-connections +```csharp +GetCourierConnectionsResponseCourierConnectionListData listCourierConnectionData = client.CourierConnection.GetCourierConnections(); +if (listCourierConnectionData != null) +{ + for (int i = 0; i < listCourierConnectionData.CourierConnections.Length; i++) + { + Console.WriteLine(listCourierConnectionData.CourierConnections[i].Id); + } +} +``` + +**GET** /courier-connections/:id +```csharp +CourierConnection courierConnection = client.CourierConnection.GetCourierConnectionsById(""); +if (courierConnection != null) +{ + Console.WriteLine(courierConnection.Id); +} +``` + +**DELETE** /courier-connections/:id +```csharp +CourierConnection courierConnection = client.CourierConnection.DeleteCourierConnectionsById(""); +if (courierConnection != null) +{ + Console.WriteLine(courierConnection.Id); +} +``` + +**PATCH** /courier-connections/:id +```csharp +PutCourierConnectionsByIdOptions putCourierConnectionsOptions = new PutCourierConnectionsByIdOptions(); +putCourierConnectionsOptions.PutCourierConnectionsByIdRequest = new PutCourierConnectionsByIdRequest(); +PutCourierConnectionsByIdRequest req = new PutCourierConnectionsByIdRequest(); + +Dictionary credentails = new Dictionary(); +credentails.Add("api_key", ""); +req.Credentials = credentails; +putCourierConnectionsOptions.PutCourierConnectionsByIdRequest = req; +CourierConnection courierConnection = client.CourierConnection.PutCourierConnectionsById("a5e8781ad3d249888a98e827760c3ad2", putCourierConnectionsOptions); +if (courierConnection != null) +{ + Console.WriteLine(courierConnection.Id); +} +``` + + ### /estimated-delivery-date **POST** /estimated-delivery-date/predict-batch @@ -326,6 +394,33 @@ PredictBatchResponse resp = client.EstimatedDeliveryDate.PredictBatch(options); Console.WriteLine(resp.EstimatedDeliveryDates[0].PickupTime); ``` +**POST** /estimated-delivery-date/predict + +```csharp +PredictOptions options = new PredictOptions(); +PredictRequest request = new PredictRequest(); + +EstimatedDeliveryDateRequest estimatedDeliveryDateRequest = new EstimatedDeliveryDateRequest(); + +DestinationAddressEstimatedDeliveryDateRequest dest = new DestinationAddressEstimatedDeliveryDateRequest(); +dest.CountryRegion = ""; +dest.State = ""; +estimatedDeliveryDateRequest.DestinationAddress = dest; + +OriginAddressEstimatedDeliveryDateRequest origin = new OriginAddressEstimatedDeliveryDateRequest(); +origin.CountryRegion = ""; +origin.State = ""; +estimatedDeliveryDateRequest.OriginAddress = origin; + +estimatedDeliveryDateRequest.Slug = ""; +estimatedDeliveryDateRequest.PickupTime = "2024-08-01 06:42:30"; + +options.PredictRequest = request; + +EstimatedDeliveryDateResponse resp = client.EstimatedDeliveryDate.Predict(options); +Console.WriteLine(resp.PickupTime); +``` + ## Help If you get stuck, we're here to help: From ebd8f69058f103e456de2543acf8a938187fa7ed Mon Sep 17 00:00:00 2001 From: Watson Zuo Date: Mon, 21 Jul 2025 17:37:24 +0800 Subject: [PATCH 3/3] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71a7f12..cc5c46a 100644 --- a/README.md +++ b/README.md @@ -353,7 +353,7 @@ Dictionary credentails = new Dictionary(); credentails.Add("api_key", ""); req.Credentials = credentails; putCourierConnectionsOptions.PutCourierConnectionsByIdRequest = req; -CourierConnection courierConnection = client.CourierConnection.PutCourierConnectionsById("a5e8781ad3d249888a98e827760c3ad2", putCourierConnectionsOptions); +CourierConnection courierConnection = client.CourierConnection.PutCourierConnectionsById("", putCourierConnectionsOptions); if (courierConnection != null) { Console.WriteLine(courierConnection.Id);