Package tech.checkhim
Class CheckHim
java.lang.Object
tech.checkhim.CheckHim
Main client class for interacting with the CheckHim phone number verification API.
This class provides a simple interface for verifying phone numbers using the
CheckHim service. It handles authentication, request formatting, and error handling.
Example usage:
CheckHim client = new CheckHim("ch_test_your_api_key");
VerificationResponse result = client.verify(
VerificationRequest.builder()
.number("+5511984339000")
.build()
);
System.out.println("Valid: " + result.isValid());
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the HTTP client and releases any resources.Gets the API key being used by this client.Gets the base URL being used by this client.Convenience method to verify a phone number using just the number string.verify(VerificationRequest request) Verifies a phone number using the CheckHim API.
-
Constructor Details
-
CheckHim
Creates a new CheckHim client with the specified API key.- Parameters:
apiKey- Your CheckHim API key (e.g., "ch_test_your_api_key")- Throws:
IllegalArgumentException- if apiKey is null or empty
-
CheckHim
Creates a new CheckHim client with the specified API key and custom base URL.- Parameters:
apiKey- Your CheckHim API keybaseUrl- Custom base URL for the API (useful for testing or enterprise environments)- Throws:
IllegalArgumentException- if apiKey is null or empty
-
-
Method Details
-
verify
Verifies a phone number using the CheckHim API.- Parameters:
request- The verification request containing the phone number to verify- Returns:
- VerificationResponse containing validation results and carrier information
- Throws:
CheckHimException- if the API request fails or returns an errorIllegalArgumentException- if request is null
-
verify
Convenience method to verify a phone number using just the number string.- Parameters:
phoneNumber- The phone number to verify in international format (e.g., "+5511984339000")- Returns:
- VerificationResponse containing validation results and carrier information
- Throws:
CheckHimException- if the API request fails or returns an errorIllegalArgumentException- if phoneNumber is null or empty
-
getApiKey
Gets the API key being used by this client.- Returns:
- The API key (masked for security)
-
getBaseUrl
Gets the base URL being used by this client.- Returns:
- The base URL
-
close
public void close()Closes the HTTP client and releases any resources. Call this method when you're done using the client to ensure proper cleanup.
-