Package io.github.dawncord.api
Class ApiClient
java.lang.Object
io.github.dawncord.api.ApiClient
Utility class for making HTTP requests to an API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidSends a DELETE request to the specified URL.static com.fasterxml.jackson.databind.JsonNodeSends a GET request to the specified URL and retrieves the response as a JSON object.static com.fasterxml.jackson.databind.JsonNodegetJsonParams(String url, Map<String, String> params) Performs a GET request to the specified URL with the provided query parameters.static com.fasterxml.jackson.databind.JsonNodeSends a PATCH request to the specified URL with the provided JSON object as the request body.static com.fasterxml.jackson.databind.JsonNodepatchAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url) Sends a PATCH request with multipart form data to the specified URL.static com.fasterxml.jackson.databind.JsonNodeSends a POST request to the specified URL with the provided JSON object as the request body.static com.fasterxml.jackson.databind.JsonNodepostAttachments(okhttp3.MultipartBody.Builder multipartBuilder, String url) Sends a POST request with multipart form data to the specified URL.static voidSends a PUT request to the specified URL with the provided JSON object as the request body.
-
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
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
Sends a DELETE request to the specified URL.- Parameters:
url- The URL to which the request is sent.
-
getJson
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.
-