Add an "is disposable?" field to CarrierData

This commit is contained in:
Jon Chambers
2026-02-18 12:14:29 -05:00
committed by Jon Chambers
parent a99635fbee
commit 6b9734f70f
5 changed files with 32 additions and 16 deletions

View File

@@ -9,19 +9,22 @@ import java.util.Optional;
/// Line type and home network information for a specific phone number.
///
/// @param carrierName the name of the network operator for the specified phone number
/// @param lineType the line type for the specified phone number
/// @param mcc the mobile country code (MCC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param mnc the mobile network code (MNC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param isPorted indicates whether the number has been ported from its original network to another network; may be
/// empty if not known
/// @param carrierName the name of the network operator for the specified phone number
/// @param lineType the line type for the specified phone number
/// @param mcc the mobile country code (MCC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param mnc the mobile network code (MNC) of the phone number's home network if known; may be empty if the
/// phone number is not a mobile number
/// @param isPorted indicates whether the number has been ported from its original network to another network; may
/// be empty if not known
/// @param isDisposable indicates whether the number is believed to be connected to a service that offers pooled,
/// "disposable" numbers; may be empty if not known
public record CarrierData(String carrierName,
LineType lineType,
Optional<String> mcc,
Optional<String> mnc,
Optional<Boolean> isPorted) {
Optional<Boolean> isPorted,
Optional<Boolean> isDisposable) {
public enum LineType {
MOBILE,

View File

@@ -148,7 +148,8 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
lineType(result.telephoneNumberType()),
mccFromMccMnc(networkDetails.mccmnc()),
mncFromMccMnc(networkDetails.mccmnc()),
isPorted(result.isPorted())));
isPorted(result.isPorted()),
isDisposableNumber(result.disposableNumber())));
}
private static Tag getCreditsSpentTag(final HlrLookupResult hlrLookupResult) {
@@ -205,6 +206,15 @@ public class HlrLookupCarrierDataProvider implements CarrierDataProvider {
};
}
@VisibleForTesting
static Optional<Boolean> isDisposableNumber(@Nullable final String disposableNumber) {
return switch (disposableNumber) {
case "YES" -> Optional.of(true);
case "NO" -> Optional.of(false);
case null, default -> Optional.empty();
};
}
@VisibleForTesting
static HlrLookupResponse parseResponse(final String responseJson) throws JsonProcessingException {
return OBJECT_MAPPER.readValue(responseJson, HlrLookupResponse.class);

View File

@@ -16,5 +16,6 @@ record HlrLookupResult(String error,
String currentNetwork,
NetworkDetails currentNetworkDetails,
String telephoneNumberType,
String isPorted) {
String isPorted,
String disposableNumber) {
}