searchAvailablePhoneNumbers method
Searches for phone numbers that can be ordered. For US numbers, provide at
least one of the following search filters: AreaCode,
City, State, or TollFreePrefix. If
you provide City, you must also provide State.
Numbers outside the US only support the PhoneNumberType
filter, which you must use.
May throw AccessDeniedException.
May throw BadRequestException.
May throw ForbiddenException.
May throw ServiceFailureException.
May throw ServiceUnavailableException.
May throw ThrottledClientException.
May throw UnauthorizedClientException.
Parameter areaCode :
The area code used to filter results. Only applies to the US.
Parameter city :
The city used to filter results. Only applies to the US.
Parameter country :
The country used to filter results. Defaults to the US Format: ISO 3166-1
alpha-2.
Parameter maxResults :
The maximum number of results to return in a single call.
Parameter nextToken :
The token used to retrieve the next page of results.
Parameter phoneNumberType :
The phone number type used to filter results. Required for non-US numbers.
Parameter state :
The state used to filter results. Required only if you provide
City. Only applies to the US.
Parameter tollFreePrefix :
The toll-free prefix that you use to filter results. Only applies to the
US.
Implementation
Future<SearchAvailablePhoneNumbersResponse> searchAvailablePhoneNumbers({
String? areaCode,
String? city,
String? country,
int? maxResults,
String? nextToken,
PhoneNumberType? phoneNumberType,
String? state,
String? tollFreePrefix,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
500,
);
final $query = <String, List<String>>{
if (areaCode != null) 'area-code': [areaCode],
if (city != null) 'city': [city],
if (country != null) 'country': [country],
if (maxResults != null) 'max-results': [maxResults.toString()],
if (nextToken != null) 'next-token': [nextToken],
if (phoneNumberType != null) 'phone-number-type': [phoneNumberType.value],
if (state != null) 'state': [state],
if (tollFreePrefix != null) 'toll-free-prefix': [tollFreePrefix],
};
final response = await _protocol.send(
payload: null,
method: 'GET',
requestUri: '/search?type=phone-numbers',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return SearchAvailablePhoneNumbersResponse.fromJson(response);
}