Interface RestClient


public interface RestClient
A RestClient is a client for REST services. It can be used to query data from the service or send data to the service.
Author:
seed-master
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String path)
    Sends a GET request for the given path and returns the response as String.
    <T> T
    get(String path, Class<T> responseType, Map<String,Object> params)
    Sends a GET request for the given path with the given parameters and returns the response as an object of the given response type
    get(String path, Map<String,Object> params)
    Sends a GET request for the given path with the given parameters and returns the response as String.
    <T> T
    post(String path, Class<T> responseType, Object requestObject)
    Sends an object via a POST request for the given path and returns the response as an object of the given response type
    <T> T
    post(String path, Class<T> responseType, Object requestObject, Map<String,Object> params)
    Sends an object via a POST request for the given path with the given parameters and returns the response as an object of the given response type
  • Method Details

    • get

      String get(String path)
      Sends a GET request for the given path and returns the response as String.
      Parameters:
      path - the request path
      Returns:
      the response as String
    • get

      String get(String path, Map<String,Object> params)
      Sends a GET request for the given path with the given parameters and returns the response as String.
      Parameters:
      path - the request path
      params - a map of named parameters
      Returns:
      the response as String
    • get

      <T> T get(String path, Class<T> responseType, Map<String,Object> params)
      Sends a GET request for the given path with the given parameters and returns the response as an object of the given response type
      Type Parameters:
      T - the type of the response object
      Parameters:
      path - the request path
      responseType - the class of the response
      params - a map of named parameters
      Returns:
      the response as an object of the given response type
    • post

      <T> T post(String path, Class<T> responseType, @Nullable Object requestObject)
      Sends an object via a POST request for the given path and returns the response as an object of the given response type
      Type Parameters:
      T - the type of the response object
      Parameters:
      path - the request path
      responseType - the class of the response
      requestObject - the object to be POSTed (may be null)
      Returns:
      the response as an object of the given response type
    • post

      <T> T post(String path, Class<T> responseType, @Nullable Object requestObject, Map<String,Object> params)
      Sends an object via a POST request for the given path with the given parameters and returns the response as an object of the given response type
      Type Parameters:
      T - the type of the response object
      Parameters:
      path - the request path
      responseType -
      requestObject - the class of the response
      params -
      Returns:
      the response as an object of the given response type