Package fr.sandro642.github.api
Class ApiClient
java.lang.Object
fr.sandro642.github.api.ApiFactory
fr.sandro642.github.api.ApiClient
ApiClient is a class that provides methods to interact with the ConnectLib API.
It extends ApiFactory and uses WebClient to make HTTP requests.
This class supports various HTTP methods including GET, POST, PUT, PATCH, and DELETE.
It handles the API responses and errors, logging them appropriately.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<ApiFactory>
callAPIDelete
(String routeName) Method to call the API with a DELETE request.reactor.core.publisher.Mono<ApiFactory>
callAPIGet
(String routeName) Method to call the API with a GET request.reactor.core.publisher.Mono<ApiFactory>
callAPIPatch
(String routeName, Map<String, Object> body) Method to call the API with a PATCH request.reactor.core.publisher.Mono<ApiFactory>
callAPIPost
(String routeName, Map<String, Object> body) Method to call the API with a POST request.reactor.core.publisher.Mono<ApiFactory>
callAPIPut
(String routeName, Map<String, Object> body) Method to call the API with a PUT request.Methods inherited from class fr.sandro642.github.api.ApiFactory
display, getData, getSpecData, parseFromRawJson
-
Constructor Details
-
ApiClient
public ApiClient()Constructor for ApiClient. It initializes the WebClient with the base URL from the ConnectLib configuration. If the base URL is not found, it throws a RuntimeException.
-
-
Method Details
-
callAPIGet
Method to call the API with a GET request.- Parameters:
routeName
- Name of the route to call.- Returns:
- a Mono that emits the ApiFactory response containing the parsed JSON data.
-
callAPIPost
public reactor.core.publisher.Mono<ApiFactory> callAPIPost(String routeName, Map<String, Object> body) Method to call the API with a POST request.- Parameters:
routeName
- Name of the route to call.body
- Body of the request (can be null for a request without body).- Returns:
- a Mono that emits the ApiFactory response containing the parsed JSON data.
-
callAPIPut
public reactor.core.publisher.Mono<ApiFactory> callAPIPut(String routeName, Map<String, Object> body) Method to call the API with a PUT request.- Parameters:
routeName
- Name of the route to call.body
- Body of the request (can be null for a request without body).- Returns:
- a Mono that emits the ApiFactory response containing the parsed JSON data.
-
callAPIPatch
public reactor.core.publisher.Mono<ApiFactory> callAPIPatch(String routeName, Map<String, Object> body) Method to call the API with a PATCH request.- Parameters:
routeName
- Name of the route to call.body
- Body of the request (can be null for a request without body).- Returns:
- a Mono that emits the ApiFactory response containing the parsed JSON data.
-
callAPIDelete
Method to call the API with a DELETE request.- Parameters:
routeName
- Name of the route to call.- Returns:
- a Mono that emits the ApiFactory response containing the parsed JSON data.
-