getContactInfo method

Future<Contact?> getContactInfo(
  1. String phoneNumber
)

Gets contact information from a phone number.

phoneNumber is the phone number to look up. Returns a contact object if found.

Implementation

Future<Contact?> getContactInfo(String phoneNumber) async {
  _logger.info('Getting contact info for: $phoneNumber');

  try {
    if (!isValidPhoneNumber(phoneNumber)) {
      throw MessageException.invalidRecipient('Invalid phone number format');
    }

    // TODO: Use normalized phone number when API client integration is implemented
    // ignore: unused_local_variable
    final normalized = normalizePhoneNumber(phoneNumber);

    // The WhatsApp API currently doesn't provide a direct way to get contact info
    // This is a placeholder for future implementation.

    _logger.warning('WhatsApp API does not provide a direct way to get contact information');
    return null;
  } catch (e) {
    if (e is MessageException) rethrow;

    _logger.error('Failed to get contact info', e);
    throw MessageException(
      code: 'get_contact_info_error',
      message: 'Failed to get contact info: ${e.toString()}',
      originalException: e,
    );
  }
}