getExampleShortNumberForCost method
Gets a valid short number for the specified cost category.
regionCode
the region for which an example short number is needed
cost
the cost category of number that is needed
returns a valid short number for the specified region and cost category.
Returns an empty string when the metadata does not contain such information,
or the cost is ShortNumberCost.unknownCost.
Implementation
@visibleForTesting
String getExampleShortNumberForCost(String regionCode, ShortNumberCost cost) {
PhoneMetadata? phoneMetadata = _getShortNumberMetadataForRegion(regionCode);
if (phoneMetadata == null) {
return "";
}
PhoneNumberDesc? desc;
switch (cost) {
case ShortNumberCost.tollFree:
desc = phoneMetadata.tollFree;
break;
case ShortNumberCost.standardRate:
desc = phoneMetadata.standardRate;
break;
case ShortNumberCost.premiumRate:
desc = phoneMetadata.premiumRate;
break;
default:
// UNKNOWN_COST numbers are computed by the process of elimination from the other cost
// categories.
}
if (desc != null && desc.hasExampleNumber()) {
return desc.exampleNumber;
}
return "";
}