searchAvailablePhoneNumbers method

Future<SearchAvailablePhoneNumbersResponse> searchAvailablePhoneNumbers({
  1. required PhoneNumberCountryCode phoneNumberCountryCode,
  2. required PhoneNumberType phoneNumberType,
  3. String? instanceId,
  4. int? maxResults,
  5. String? nextToken,
  6. String? phoneNumberPrefix,
  7. String? targetArn,
})

Searches for available phone numbers that you can claim to your Connect Customer instance or traffic distribution group. If the provided TargetArn is a traffic distribution group, you can call this API in both Amazon Web Services Regions associated with the traffic distribution group.

May throw AccessDeniedException. May throw InternalServiceException. May throw InvalidParameterException. May throw ThrottlingException.

Parameter phoneNumberCountryCode : The ISO country code.

Parameter phoneNumberType : The type of phone number.

Parameter instanceId : The identifier of the Connect Customer instance that phone numbers are claimed to. You can find the instance ID in the Amazon Resource Name (ARN) of the instance. You must enter InstanceId or TargetArn.

Parameter maxResults : The maximum number of results to return per page.

Parameter nextToken : The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

Parameter phoneNumberPrefix : The prefix of the phone number. If provided, it must contain + as part of the country code.

Parameter targetArn : The Amazon Resource Name (ARN) for Connect Customer instances or traffic distribution groups that phone number inbound traffic is routed through. You must enter InstanceId or TargetArn.

Implementation

Future<SearchAvailablePhoneNumbersResponse> searchAvailablePhoneNumbers({
  required PhoneNumberCountryCode phoneNumberCountryCode,
  required PhoneNumberType phoneNumberType,
  String? instanceId,
  int? maxResults,
  String? nextToken,
  String? phoneNumberPrefix,
  String? targetArn,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    10,
  );
  final $payload = <String, dynamic>{
    'PhoneNumberCountryCode': phoneNumberCountryCode.value,
    'PhoneNumberType': phoneNumberType.value,
    if (instanceId != null) 'InstanceId': instanceId,
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
    if (phoneNumberPrefix != null) 'PhoneNumberPrefix': phoneNumberPrefix,
    if (targetArn != null) 'TargetArn': targetArn,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/phone-number/search-available',
    exceptionFnMap: _exceptionFns,
  );
  return SearchAvailablePhoneNumbersResponse.fromJson(response);
}