Class ApiClient

java.lang.Object
io.github.dawncord.api.ApiClient

public class ApiClient extends Object
Utility class for making HTTP requests to an API.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Sends a DELETE request to the specified URL.
    static com.fasterxml.jackson.databind.JsonNode
    Sends a GET request to the specified URL and retrieves the response as a JSON object.
    static com.fasterxml.jackson.databind.JsonNode
    Performs a GET request to the specified URL with the provided query parameters.
    static com.fasterxml.jackson.databind.JsonNode
    patch(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
    Sends a PATCH request to the specified URL with the provided JSON object as the request body.
    static com.fasterxml.jackson.databind.JsonNode
    patchAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url)
    Sends a PATCH request with multipart form data to the specified URL.
    static com.fasterxml.jackson.databind.JsonNode
    post(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
    Sends a POST request to the specified URL with the provided JSON object as the request body.
    static com.fasterxml.jackson.databind.JsonNode
    postAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url)
    Sends a POST request with multipart form data to the specified URL.
    static void
    put(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
    Sends a PUT request to the specified URL with the provided JSON object as the request body.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ApiClient

      public ApiClient()
  • Method Details

    • post

      public static com.fasterxml.jackson.databind.JsonNode post(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
      Sends a POST request to the specified URL with the provided JSON object as the request body.
      Parameters:
      jsonObject - The JSON object to be sent in the request body.
      url - The URL to which the request is sent.
      Returns:
      The JSON response from the server.
    • patch

      public static com.fasterxml.jackson.databind.JsonNode patch(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
      Sends a PATCH request to the specified URL with the provided JSON object as the request body.
      Parameters:
      jsonObject - The JSON object to be sent in the request body.
      url - The URL to which the request is sent.
      Returns:
      The JSON response from the server.
    • put

      public static void put(com.fasterxml.jackson.databind.JsonNode jsonObject, String url)
      Sends a PUT request to the specified URL with the provided JSON object as the request body.
      Parameters:
      jsonObject - The JSON object to be sent in the request body.
      url - The URL to which the request is sent.
    • delete

      public static void delete(String url)
      Sends a DELETE request to the specified URL.
      Parameters:
      url - The URL to which the request is sent.
    • getJson

      public static com.fasterxml.jackson.databind.JsonNode getJson(String url)
      Sends a GET request to the specified URL and retrieves the response as a JSON object.
      Parameters:
      url - The URL to send the GET request to.
      Returns:
      A JSON object containing the response data from the specified URL.
    • getJsonParams

      public static com.fasterxml.jackson.databind.JsonNode getJsonParams(String url, Map<String,String> params)
      Performs a GET request to the specified URL with the provided query parameters.
      Parameters:
      url - The URL to which the request is sent.
      params - The query parameters to be included in the request.
      Returns:
      The JSON response from the server.
    • postAttachments

      public static com.fasterxml.jackson.databind.JsonNode postAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url)
      Sends a POST request with multipart form data to the specified URL.
      Parameters:
      multipartBuilder - The builder for constructing the multipart request body.
      url - The URL to which the request is sent.
      Returns:
      The JSON response from the server.
    • patchAttachments

      public static com.fasterxml.jackson.databind.JsonNode patchAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url)
      Sends a PATCH request with multipart form data to the specified URL.
      Parameters:
      multipartBuilder - The builder for constructing the multipart request body.
      url - The URL to which the request is sent.
      Returns:
      The JSON response from the server.