airtimeLookupNumber method
Look up a phone number
Describes a phone number and returns its carrier from a carrier lookup when the number is valid. Describes the number from numbering-plan data and, for a valid number, adds carrier information from a live carrier lookup. A number without the international shape gives 400 / 10001; a number its country does not assign returns 200 with isValid: false and carrier: null, without a carrier lookup. Returns 503 / 10007 when the carrier lookup is unavailable. The carrier is for display only and nothing is stored; use search to find a sellable operator.
Parameters:
- String phoneNumber (required): The number in international format, starting with + or 00; spaces, hyphens and parentheses are allowed.
Implementation
Future<NumberLookup?> airtimeLookupNumber(String phoneNumber, { Future<void>? abortTrigger, }) async {
final response = await airtimeLookupNumberWithHttpInfo(phoneNumber, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'NumberLookup',) as NumberLookup;
}
return null;
}