Package ru.loolzaaa.youkassa.client
Class ApiClient
java.lang.Object
ru.loolzaaa.youkassa.client.ApiClient
Http client for YooKassa API server.
This client use Java 11 HttpClient for communication
and Jackson library for request/response body
serialization/deserialization respectively.
All requests used authentication routine supplied
by authHeaderSupplier with application/json
content-type header.
Success status code only 200.
Usually, instance of this class created by ApiClientBuilder.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TsendRequest(String method, String path, Map<String, String> headers, RequestBody body, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) Invoke execute method and deserialize response for entities collection.<T> TsendRequest(String method, String path, Map<String, String> headers, RequestBody body, Class<T> responseClass) Invoke execute method and deserialize response for single entity.
-
Constructor Details
-
ApiClient
CreatedApiClientinstance.Api endpoint and authentication header supplier must not be null.
- Parameters:
endpoint- YooKassa API server endpointauthHeaderSupplier- authentication header value supplier
-
-
Method Details
-
sendRequest
public <T> T sendRequest(String method, String path, Map<String, String> headers, RequestBody body, Class<T> responseClass) Invoke execute method and deserialize response for single entity.- Type Parameters:
T- type of returned entity- Parameters:
method- http methodpath- request path with query paramsheaders- additional headersbody- request bodyresponseClass- response type class- Returns:
- requested deserialized entity
-
sendRequest
public <T> T sendRequest(String method, String path, Map<String, String> headers, RequestBody body, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) Invoke execute method and deserialize response for entities collection.- Type Parameters:
T- type of returned entity- Parameters:
method- http methodpath- request path with query paramsheaders- additional headersbody- request bodytypeReference- jackson type reference for response- Returns:
- requested deserialized entities collection
-