Skip to content

Commit 3c57f92

Browse files
committed
Modify the format of the air waybill number
1 parent 0eda187 commit 3c57f92

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

trackingmore-sdk/src/main/java/com/trackingmore/service/impl/AirWaybillImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@
1010
import com.trackingmore.utils.StrUtils;
1111

1212
import java.io.IOException;
13+
import java.util.regex.Matcher;
14+
import java.util.regex.Pattern;
1315

1416
public class AirWaybillImpl extends BaseTracking implements AirWaybills {
1517

1618
public TrackingMoreResponse CreateAnAirWayBill(AirWaybillParams airWaybillParams) throws TrackingMoreException,IOException{
1719
if(StrUtils.isEmpty(airWaybillParams.getAwbNumber())) {
1820
throw new TrackingMoreException(ErrorEnums.ErrMissingAwbNumber);
1921
}
20-
if(airWaybillParams.getAwbNumber().length() != 12) {
22+
23+
Pattern pattern = Pattern.compile("^\\d{3}[ -]?(\\d{8})$");
24+
Matcher matcher = pattern.matcher(airWaybillParams.getAwbNumber());
25+
if(!matcher.matches()) {
2126
throw new TrackingMoreException(ErrorEnums.ErrInvalidAirWaybillFormat);
2227
}
28+
2329
String apiPath = "/awb";
2430
String body = requestHelper.sendApiRequest(apiPath, "POST", null, airWaybillParams);
2531
TrackingMoreResponse response = objectMapper.readValue(body, new TypeReference<TrackingMoreResponse<AirWaybill>>() {});

0 commit comments

Comments
 (0)