Package tech.checkhim

Class CheckHim

java.lang.Object
tech.checkhim.CheckHim

public class CheckHim extends Object
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 Details

    • CheckHim

      public CheckHim(String apiKey)
      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

      public CheckHim(String apiKey, String baseUrl)
      Creates a new CheckHim client with the specified API key and custom base URL.
      Parameters:
      apiKey - Your CheckHim API key
      baseUrl - 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 error
      IllegalArgumentException - if request is null
    • verify

      public VerificationResponse verify(String phoneNumber) throws CheckHimException
      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 error
      IllegalArgumentException - if phoneNumber is null or empty
    • getApiKey

      public String getApiKey()
      Gets the API key being used by this client.
      Returns:
      The API key (masked for security)
    • getBaseUrl

      public String 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.