Skip to content

Commit 72bceb2

Browse files
Merge pull request #8 from AfterShip-Team-Mocha/2025-01
feat: supporting 2025-01 version.
2 parents 9f17bf2 + 94b3943 commit 72bceb2

64 files changed

Lines changed: 9965 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea/
2+
.vs/
3+
src/AfterShipTracking/Test/
4+
src/AfterShipTracking/AfterShipTracking/bin/
5+
src/AfterShipTracking/AfterShipTracking/obj/
6+
Tracking.sln.DotSettings.user
7+
.DS_Store
8+
.config/

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 AfterShip
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 344 additions & 1 deletion
Large diffs are not rendered by default.

icon.png

1007 Bytes
Loading

src/.DS_Store

6 KB
Binary file not shown.

src/AfterShipTracking/.DS_Store

6 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 25.0.1706.9
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AfterShipTracking", "AfterShipTracking\AfterShipTracking.csproj", "{D3099A91-E005-4291-88AD-D7A3B85DDC1D}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D3099A91-E005-4291-88AD-D7A3B85DDC1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D3099A91-E005-4291-88AD-D7A3B85DDC1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D3099A91-E005-4291-88AD-D7A3B85DDC1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D3099A91-E005-4291-88AD-D7A3B85DDC1D}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{D2C22390-8325-4493-B940-F89BD8BA19EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{D2C22390-8325-4493-B940-F89BD8BA19EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{D2C22390-8325-4493-B940-F89BD8BA19EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{D2C22390-8325-4493-B940-F89BD8BA19EA}.Release|Any CPU.Build.0 = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
GlobalSection(ExtensibilityGlobals) = postSolution
27+
SolutionGuid = {5C216FDA-5980-4A44-A348-7C9B82282CE4}
28+
EndGlobalSection
29+
EndGlobal
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup Label="NuGet">
4+
<TargetFramework>net6.0</TargetFramework>
5+
<OutputPath>bin/Release</OutputPath>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>true</IsPackable>
8+
<PackageId>AfterShipTracking</PackageId>
9+
<Description>The official AfterShip Tracking .net API library</Description>
10+
<Copyright>Copyright © AfterShip</Copyright>
11+
<AssemblyTitle>AfterShipTracking</AssemblyTitle>
12+
<NeutralLanguage>en-US</NeutralLanguage>
13+
<VersionPrefix>10.0.0</VersionPrefix>
14+
<VersionSuffix>
15+
</VersionSuffix>
16+
<Authors>AfterShip</Authors>
17+
<NoWarn>CS1587;CS1591;CS1570;CS1573;CS1572;CS8618;CS8603;CS8625;CS8604;CS8765</NoWarn>
18+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
19+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20+
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
21+
<AssemblyName>AfterShipTracking</AssemblyName>
22+
<PackageTags>aftership;tracking;track;fedex;ups;usps;dhl;shipping;fulfillment;couriers;carriers</PackageTags>
23+
<PackageProjectUrl>https://www.aftership.com</PackageProjectUrl>
24+
<RepositoryUrl>https://github.com/aftership/tracking-sdk-net</RepositoryUrl>
25+
<RepositoryType>git</RepositoryType>
26+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
27+
<PackageReadmeFile>README.md</PackageReadmeFile>
28+
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
29+
<PackageIcon>icon.png</PackageIcon>
30+
</PropertyGroup>
31+
32+
<ItemGroup>
33+
<None Include="../../../README.md" Pack="true" PackagePath="\" />
34+
<None Include="../../../icon.png" Pack="true" PackagePath="\" />
35+
<None Include="../../../LICENSE.txt" Pack="true" PackagePath="\" />
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
40+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
41+
<PackageReference Include="NUnit" Version="4.1.0" />
42+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
43+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.0" />
44+
</ItemGroup>
45+
46+
<ItemGroup>
47+
<Folder Include="Adapter\" />
48+
<Folder Include="Adapter\" />
49+
<Folder Include="Exception\" />
50+
<Folder Include="Models\" />
51+
<Folder Include="Properties\" />
52+
<Folder Include="Public\" />
53+
<Folder Include="RestAPI\" />
54+
</ItemGroup>
55+
</Project>
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* This code was auto generated by AfterShip SDK Generator.
3+
* Do not edit the class manually.
4+
*/
5+
using System.Linq;
6+
7+
namespace AfterShipTracking
8+
{
9+
public class AfterShipClient
10+
{
11+
/// <summary>Gets the base URL for AfterShip's API.</summary>
12+
/// <value>The base URL for AfterShip's API.</value>
13+
public string ApiBase { get; set; }
14+
15+
/// <summary>
16+
/// Custom API domain.
17+
/// </summary>
18+
public string Domain;
19+
20+
/// <summary>
21+
/// Custom API domain.
22+
/// </summary>
23+
public int MaxRetry { get; set; }
24+
25+
/// <summary>
26+
/// Max request timeout in milliseconds.
27+
/// </summary>
28+
public int Timeout { get; set; }
29+
30+
/// <summary>
31+
/// Custom API domain.
32+
/// </summary>
33+
public string UserAgent { get; set; }
34+
35+
/// <summary>
36+
/// Custom API domain. Only http, socks4, socks4a, socks5 are allowed.
37+
/// </summary>
38+
public string Proxy { get; set; }
39+
40+
/// <summary>
41+
/// Custom API domain.
42+
/// </summary>
43+
public string ApiKey { get; set; }
44+
45+
/// <summary>
46+
/// AfterShip API secret for AES or RSA authentication method.
47+
/// </summary>
48+
public string ApiSecret { get; set; }
49+
50+
/// <summary>
51+
/// AfterShip API Authentication method. Allowed value: API_KEY , AES , RSA
52+
/// </summary>
53+
public string AuthenticationType { get; set; }
54+
55+
/// <summary>
56+
/// AfterShip API version.
57+
/// </summary>
58+
public string Version { get; set; }
59+
60+
/// <summary>
61+
/// AfterShip API Product
62+
/// </summary>
63+
public string Product { get; set; }
64+
65+
public IHttpClient HttpClient { get; }
66+
67+
public TrackingService Tracking { get; set; }
68+
public CourierService Courier { get; set; }
69+
public EstimatedDeliveryDateService EstimatedDeliveryDate { get; set; }
70+
public AfterShipClient(
71+
string domain = null,
72+
string apiKey = null,
73+
string apiSecret = null,
74+
string authenticationType = null,
75+
string userAgent = null,
76+
string proxy = null,
77+
int timeout = 0,
78+
int maxRetry = 0,
79+
IHttpClient httpClient = null
80+
)
81+
{
82+
Domain = domain ?? AfterShipConfiguration.Domain;
83+
ApiBase = Domain;
84+
MaxRetry = maxRetry == 0 ? AfterShipConfiguration.MaxRetry : maxRetry;
85+
Timeout = timeout == 0 ? AfterShipConfiguration.Timeout : timeout;
86+
UserAgent = userAgent ?? AfterShipConfiguration.UserAgent;
87+
Proxy = proxy ?? AfterShipConfiguration.Proxy;
88+
ApiKey = apiKey ?? AfterShipConfiguration.ApiKey;
89+
ApiSecret = apiSecret ?? AfterShipConfiguration.ApiSecret;
90+
AuthenticationType = authenticationType ?? AfterShipConfiguration.AuthenticationType;
91+
92+
CheckConfig();
93+
94+
Authenticator authenticator = new Authenticator(ApiKey, ApiSecret, AuthenticationType);
95+
96+
HttpClient = httpClient ?? new SystemNetHttpClient(this.ApiBase, authenticator, this.MaxRetry, this.Timeout, this.UserAgent, this.Proxy);
97+
98+
Tracking = new TrackingService(HttpClient);
99+
Courier = new CourierService(HttpClient);
100+
EstimatedDeliveryDate = new EstimatedDeliveryDateService(HttpClient);
101+
}
102+
103+
private void CheckConfig()
104+
{
105+
if (string.IsNullOrEmpty(ApiKey))
106+
{
107+
throw ErrorCode.GenSDKError(ErrorCode.INVALID_API_KEY, "apiKey cannot be empty");
108+
}
109+
110+
if (this.Timeout < 0 || this.Timeout > 30000)
111+
{
112+
throw ErrorCode.GenSDKError(ErrorCode.INVALID_OPTION, "timeout invalid, timeout must between 0 and 30000 (milliseconds)");
113+
}
114+
115+
if (this.MaxRetry < 0 || this.MaxRetry > 10)
116+
{
117+
throw ErrorCode.GenSDKError(ErrorCode.INVALID_OPTION, "max retry invalid, max retry must between 0 and 10");
118+
}
119+
120+
string[] array = {
121+
AfterShipConfiguration.AUTHENTICATION_TYPE_API_KEY,
122+
AfterShipConfiguration.AUTHENTICATION_TYPE_AES,
123+
AfterShipConfiguration.AUTHENTICATION_TYPE_RSA,
124+
};
125+
var authenticationType = AuthenticationType;
126+
if (!array.Contains(authenticationType))
127+
{
128+
throw ErrorCode.GenSDKError(ErrorCode.INVALID_OPTION, "Invalid option: authenticationType should be one of API_KEY, AES, RSA");
129+
}
130+
131+
if (authenticationType == AfterShipConfiguration.AUTHENTICATION_TYPE_AES || authenticationType == AfterShipConfiguration.AUTHENTICATION_TYPE_AES)
132+
{
133+
if (string.IsNullOrEmpty(ApiSecret))
134+
{
135+
throw ErrorCode.GenSDKError(ErrorCode.INVALID_API_KEY, "Invalid option: apiSecret cannot be empty");
136+
}
137+
}
138+
}
139+
}
140+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This code was auto generated by AfterShip SDK Generator.
3+
* Do not edit the class manually.
4+
*/
5+
using System;
6+
7+
namespace AfterShipTracking
8+
{
9+
public class AfterShipError : Exception
10+
{
11+
protected string errorCode;
12+
protected int? metaCode;
13+
protected int? statusCode;
14+
protected string message;
15+
protected object responseBody;
16+
protected object responseHeader;
17+
18+
public AfterShipError(string message, string errorCode, int? statusCode, int? metaCode, object responseBody = null, object responseHeader = null)
19+
: base(message)
20+
{
21+
this.metaCode = metaCode;
22+
this.message = message;
23+
this.errorCode = errorCode;
24+
this.statusCode = statusCode;
25+
this.responseBody = responseBody;
26+
this.responseHeader = responseHeader;
27+
}
28+
29+
public string ErrorCode
30+
{
31+
get { return errorCode; }
32+
}
33+
34+
public int? MetaCode
35+
{
36+
get { return metaCode; }
37+
}
38+
39+
public int? StatusCode
40+
{
41+
get { return statusCode; }
42+
}
43+
44+
public object ResponseBody
45+
{
46+
get { return responseBody; }
47+
}
48+
49+
public object ResponseHeader
50+
{
51+
get { return responseHeader; }
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)