Class SimpleEasyDonateClient
- java.lang.Object
-
- ru.easydonate.easydonate4j.api.v3.client.SimpleEasyDonateClient
-
- All Implemented Interfaces:
EasyDonateClient
public class SimpleEasyDonateClient extends Object implements EasyDonateClient
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleEasyDonateClient.SimplePluginManager
-
Nested classes/interfaces inherited from interface ru.easydonate.easydonate4j.api.v3.client.EasyDonateClient
EasyDonateClient.Builder
-
-
Field Summary
Fields Modifier and Type Field Description protected String
accessKey
static String
API_ENDPOINT
protected Headers
defaultHeaders
protected HttpClient
httpClient
protected JsonSerializationService
jsonSerialization
protected PluginManager
pluginManager
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleEasyDonateClient(@NotNull String accessKey, @NotNull String userAgent, long connectTimeout, long responseTimeout, long readTimeout, long writeTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull PendingPaymentBuilder
createPayment()
Create a new payment to use the EasyDonate platform only for money receiving.
You can generate a new payment and send the link to needed players in your plugin.@NotNull PendingPayment
createPayment(@NotNull PendingPaymentBuilder paymentBuilder)
Get the pending payment data using your credentials from pending payment builder.
This method also will be used byPendingPaymentBuilder.create()
.EasyHttpRequest.Builder
createRequest(HttpClient.Method method)
Get a new HTTP request builder using the API client provided HTTP client.protected <T> T
executePluginRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull Headers headers, @Nullable QueryParams queryParams)
protected <T> T
executeShopRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull String apiPath, @Nullable Object... pathArgs)
protected <T> T
executeShopRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull String apiPath, @Nullable QueryParams queryParams, @Nullable Object... pathArgs)
@NotNull String
getAccessKey()
Get a used access key of any shop.@NotNull CouponsList
getCouponsList()
Get the list of all coupons.@NotNull CouponsList
getCouponsList(@NotNull ActivityFlag activityFlag)
Get the list of all coupons with the activity filter.@NotNull MassSalesList
getMassSalesList()
Get the list of all mass sales.@NotNull MassSalesList
getMassSalesList(@NotNull ActivityFlag activityFlag)
Get the list of all mass sales with the activity filter.@NotNull Payment
getPayment(int paymentId)
Get the payment by the #ID.@NotNull PaymentsList
getPaymentsList()
Get the list of all finished payments.@NotNull Product
getProduct(int productId)
Get the shop product by the #ID.@NotNull ProductsList
getProductsList()
Get the list of all shop products.@NotNull Server
getServer(int serverId)
Get the shop connected server by the #ID.@NotNull ServersList
getServersList()
Get the list of all shop connected servers.@NotNull Shop
getShop()
Get the shop related data.<T> T
request(@NotNull Class<? extends ApiResponse<T>> responseObjectType, @NotNull EasyHttpRequest httpRequest)
Execute a raw HTTP request and deserialize a response as an object with specified type.<T> @NotNull CompletableFuture<T>
requestAsync(@NotNull Class<? extends ApiResponse<T>> responseObjectType, @NotNull EasyHttpRequest httpRequest)
Same thatEasyDonateClient.request(Class, EasyHttpRequest)
but asynchronous.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ru.easydonate.easydonate4j.api.v3.client.EasyDonateClient
getHttpClient, getJsonSerialization, getPluginManager
-
-
-
-
Field Detail
-
API_ENDPOINT
public static final String API_ENDPOINT
- See Also:
- Constant Field Values
-
accessKey
protected final String accessKey
-
pluginManager
protected final PluginManager pluginManager
-
defaultHeaders
protected final Headers defaultHeaders
-
httpClient
protected final HttpClient httpClient
-
jsonSerialization
protected final JsonSerializationService jsonSerialization
-
-
Method Detail
-
getAccessKey
@NotNull public @NotNull String getAccessKey()
Description copied from interface:EasyDonateClient
Get a used access key of any shop.- Specified by:
getAccessKey
in interfaceEasyDonateClient
- Returns:
- The shop access key.
- See Also:
Shop.Extra.getAccessKey()
-
getShop
@NotNull public @NotNull Shop getShop() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the shop related data.- Specified by:
getShop
in interfaceEasyDonateClient
- Returns:
- The shop describing object.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Shop
-
getProduct
@NotNull public @NotNull Product getProduct(int productId) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the shop product by the #ID.- Specified by:
getProduct
in interfaceEasyDonateClient
- Parameters:
productId
- the ID of requested product.- Returns:
- The product describing object.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Product
-
getProductsList
@NotNull public @NotNull ProductsList getProductsList() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all shop products.- Specified by:
getProductsList
in interfaceEasyDonateClient
- Returns:
- The list of products.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Product
-
getServer
@NotNull public @NotNull Server getServer(int serverId) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the shop connected server by the #ID.- Specified by:
getServer
in interfaceEasyDonateClient
- Parameters:
serverId
- the ID of requested connected server.- Returns:
- The connected server describing object.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Server
-
getServersList
@NotNull public @NotNull ServersList getServersList() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all shop connected servers.- Specified by:
getServersList
in interfaceEasyDonateClient
- Returns:
- The list of connected servers.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Server
-
getMassSalesList
@NotNull public @NotNull MassSalesList getMassSalesList() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all mass sales.- Specified by:
getMassSalesList
in interfaceEasyDonateClient
- Returns:
- The list of mass sales.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
MassSale
-
getMassSalesList
@NotNull public @NotNull MassSalesList getMassSalesList(@NotNull @NotNull ActivityFlag activityFlag) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all mass sales with the activity filter.- Specified by:
getMassSalesList
in interfaceEasyDonateClient
- Parameters:
activityFlag
- the activity flag to filter the list of stored mass sales.- Returns:
- The filtered list of mass sales.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
MassSale
,ActivityFlag
-
getCouponsList
@NotNull public @NotNull CouponsList getCouponsList() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all coupons.- Specified by:
getCouponsList
in interfaceEasyDonateClient
- Returns:
- The list of coupons.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Coupon
-
getCouponsList
@NotNull public @NotNull CouponsList getCouponsList(@NotNull @NotNull ActivityFlag activityFlag) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all coupons with the activity filter.- Specified by:
getCouponsList
in interfaceEasyDonateClient
- Parameters:
activityFlag
- the activity flag to filter the list of stored coupons.- Returns:
- The filtered list of coupons.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Coupon
,ActivityFlag
-
getPayment
@NotNull public @NotNull Payment getPayment(int paymentId) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the payment by the #ID.- Specified by:
getPayment
in interfaceEasyDonateClient
- Parameters:
paymentId
- the ID of requested payment.- Returns:
- The payment describing object.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Payment
,PaymentStatus
-
getPaymentsList
@NotNull public @NotNull PaymentsList getPaymentsList() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the list of all finished payments.- Specified by:
getPaymentsList
in interfaceEasyDonateClient
- Returns:
- The list of finished payments.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
Payment
,PaymentStatus.SUCCESS
-
createPayment
@NotNull public @NotNull PendingPaymentBuilder createPayment()
Description copied from interface:EasyDonateClient
Create a new payment to use the EasyDonate platform only for money receiving.
You can generate a new payment and send the link to needed players in your plugin.- Specified by:
createPayment
in interfaceEasyDonateClient
- Returns:
- The pending payment builder instance.
- See Also:
PendingPaymentBuilder
-
createPayment
@NotNull public @NotNull PendingPayment createPayment(@NotNull @NotNull PendingPaymentBuilder paymentBuilder) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Get the pending payment data using your credentials from pending payment builder.
This method also will be used byPendingPaymentBuilder.create()
.- Specified by:
createPayment
in interfaceEasyDonateClient
- Parameters:
paymentBuilder
- the further pending payment describing builder instance.- Returns:
- The pending payment describing object.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
PendingPayment
,PendingPaymentBuilder
,EasyDonateClient.createPayment()
-
executeShopRequest
@NotNull protected <T> T executeShopRequest(@NotNull @NotNull Class<? extends ApiResponse<T>> responseType, @NotNull @NotNull String apiPath, @Nullable @Nullable Object... pathArgs) throws HttpRequestException, HttpResponseException
-
executeShopRequest
@NotNull protected <T> T executeShopRequest(@NotNull @NotNull Class<? extends ApiResponse<T>> responseType, @NotNull @NotNull String apiPath, @Nullable @Nullable QueryParams queryParams, @Nullable @Nullable Object... pathArgs) throws HttpRequestException, HttpResponseException
-
executePluginRequest
@NotNull protected <T> T executePluginRequest(@NotNull @NotNull Class<? extends ApiResponse<T>> responseType, @NotNull @NotNull Headers headers, @Nullable @Nullable QueryParams queryParams) throws HttpRequestException, HttpResponseException
-
request
@NotNull public <T> T request(@NotNull @NotNull Class<? extends ApiResponse<T>> responseObjectType, @NotNull @NotNull EasyHttpRequest httpRequest) throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClient
Execute a raw HTTP request and deserialize a response as an object with specified type.- Specified by:
request
in interfaceEasyDonateClient
- Type Parameters:
T
- the generic type that represents a response object type.- Parameters:
responseObjectType
- the type of object to deserialize from.httpRequest
- the built HTTP request instance to execute.- Returns:
- The deserialized instance from response for your request.
- Throws:
HttpRequestException
- when any errors with request sending has occured.HttpResponseException
- when any errors with response handling has occured.- See Also:
EasyDonateClient.requestAsync(Class, EasyHttpRequest)
-
requestAsync
@NotNull public <T> @NotNull CompletableFuture<T> requestAsync(@NotNull @NotNull Class<? extends ApiResponse<T>> responseObjectType, @NotNull @NotNull EasyHttpRequest httpRequest)
Description copied from interface:EasyDonateClient
Same thatEasyDonateClient.request(Class, EasyHttpRequest)
but asynchronous.
Attention! A returned CompletableFuture instance may be completed exceptionally!- Specified by:
requestAsync
in interfaceEasyDonateClient
- Type Parameters:
T
- the generic type that represents a response object type.- Parameters:
responseObjectType
- the type of object to deserialize from.httpRequest
- the built HTTP request instance to execute.- Returns:
- The future-wrapped deserialized instance from response for your request.
- See Also:
EasyDonateClient.request(Class, EasyHttpRequest)
-
createRequest
@NotNull public EasyHttpRequest.Builder createRequest(@NotNull HttpClient.Method method)
Description copied from interface:EasyDonateClient
Get a new HTTP request builder using the API client provided HTTP client.- Specified by:
createRequest
in interfaceEasyDonateClient
- Parameters:
method
- the HTTP method of a new request.- Returns:
- The new HTTP request builder instance.
-
-