Class AbstractClient

java.lang.Object
ai.philterd.philter.AbstractClient
Direct Known Subclasses:
PhilterClient

public abstract class AbstractClient extends Object
  • Field Details

  • Constructor Details

    • AbstractClient

      public AbstractClient()
  • Method Details

    • execute

      protected <T> T execute(retrofit2.Call<T> call) throws IOException
      Executes a call and returns its response body, translating non-successful responses into the appropriate exception.
      Type Parameters:
      T - The response body type.
      Parameters:
      call - The Call to execute.
      Returns:
      The response body.
      Throws:
      IOException - Thrown if the request cannot be executed.
    • executeVoid

      protected void executeVoid(retrofit2.Call<?> call) throws IOException
      Executes a call that has no meaningful response body, translating non-successful responses into the appropriate exception.
      Parameters:
      call - The Call to execute.
      Throws:
      IOException - Thrown if the request cannot be executed.
    • toException

      protected RuntimeException toException(int code)
      Maps an HTTP status code to a client exception.
      Parameters:
      code - The HTTP status code.
      Returns:
      A RuntimeException describing the error.