Class HttpClient

java.lang.Object
com.checkhim.http.HttpClient

public class HttpClient extends Object
HTTP client wrapper for making requests to the CheckHim API. This class handles authentication, request formatting, response parsing, and error handling for all API communications.
  • Constructor Details

    • HttpClient

      public HttpClient(String apiKey, String baseUrl)
      Creates a new HTTP client with the specified API key and base URL.
      Parameters:
      apiKey - The CheckHim API key
      baseUrl - The base URL for the API
  • Method Details

    • post

      public <T, R> R post(String endpoint, T requestBody, Class<R> responseType) throws CheckHimException
      Makes a POST request to the specified endpoint.
      Type Parameters:
      T - The type of the request body
      R - The type of the response
      Parameters:
      endpoint - The API endpoint (e.g., "/api/v1/verify")
      requestBody - The request body object
      responseType - The expected response type class
      Returns:
      The parsed response object
      Throws:
      CheckHimException - if the request fails or returns an error
    • close

      public void close()
      Closes the HTTP client and releases resources.