Skip to content

Commit 924cf12

Browse files
committed
Modify the format of the air waybill number
1 parent a1ac819 commit 924cf12

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public class Test
7474
{
7575
Console.WriteLine("Catch custom exceptions:" + ex.Message);
7676
}
77+
catch (TimeoutException ex)
78+
{
79+
Console.WriteLine("Timeout Exception: " + ex.Message);
80+
}
7781
catch (Exception ex)
7882
{
7983
Console.WriteLine("Catch other exceptions:" + ex.Message);

TrackingMoreAPI/TrackingMoreAPI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AssemblyName>TrackingMore-API</AssemblyName>
1010
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1111
<PackageId>TrackingMore</PackageId>
12-
<PackageVersion>0.1.0</PackageVersion>
12+
<PackageVersion>0.1.1</PackageVersion>
1313
<Authors>TrackingMore Team</Authors>
1414
<Copyright>Copyright 2014-2023</Copyright>
1515
<Owners>TrackingMore</Owners>

TrackingMoreAPI/src/AirWaybill.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Newtonsoft.Json;
2+
using System.Text.RegularExpressions;
23
using TrackingMoreAPI.Model;
34
using TrackingMoreAPI.Model.AirWaybills;
45

@@ -12,8 +13,8 @@ public ApiResponse<AirWaybills> CreateAnAirWayBill(AirWaybillParams airWaybillPa
1213
{
1314
throw new TrackingMoreException(Enums.ErrMissingAwbNumber);
1415
}
15-
if (airWaybillParams.awbNumber.Length != 12)
16-
{
16+
if (!Regex.IsMatch(airWaybillParams.awbNumber, @"^\d{3}[ -]?(\d{8})$"))
17+
{
1718
throw new TrackingMoreException(Enums.ErrInvalidAirWaybillFormat);
1819
}
1920
HttpMethod method = HttpMethod.Post;

TrackingMoreAPI/src/Enums.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ public class Enums
88
public const string ErrMissingAwbNumber = "Awb number cannot be empty";
99
public const string ErrMaxTrackingNumbersExceeded = "Max. 40 tracking numbers create in one call";
1010
public const string ErrEmptyId = "Id cannot be empty";
11-
public const string ErrInvalidAirWaybillFormat = "The air waybill number format is invalid and can only be 12 digits in length";
11+
public const string ErrInvalidAirWaybillFormat = "The air waybill number format is invalid";
1212
}

0 commit comments

Comments
 (0)