Package ru.loolzaaa.youkassa.client
Class ApiClient
- java.lang.Object
-
- ru.loolzaaa.youkassa.client.ApiClient
-
public class ApiClient extends java.lang.Object
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
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
sendRequest(java.lang.String method, java.lang.String path, java.util.Map<java.lang.String,java.lang.String> headers, RequestBody body, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Invoke execute method and deserialize response for entities collection.<T> T
sendRequest(java.lang.String method, java.lang.String path, java.util.Map<java.lang.String,java.lang.String> headers, RequestBody body, java.lang.Class<T> responseClass)
Invoke execute method and deserialize response for single entity.
-
-
-
Constructor Detail
-
ApiClient
public ApiClient(java.lang.String endpoint, java.util.function.Supplier<java.lang.String> authHeaderSupplier)
CreatedApiClient
instance.Api endpoint and authentication header supplier must not be null.
- Parameters:
endpoint
- YooKassa API server endpointauthHeaderSupplier
- authentication header value supplier
-
-
Method Detail
-
sendRequest
public <T> T sendRequest(java.lang.String method, java.lang.String path, java.util.Map<java.lang.String,java.lang.String> headers, RequestBody body, java.lang.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(java.lang.String method, java.lang.String path, java.util.Map<java.lang.String,java.lang.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
-
-