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 classSimpleEasyDonateClient.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 StringaccessKeystatic StringAPI_ENDPOINTprotected HeadersdefaultHeadersprotected HttpClienthttpClientprotected JsonSerializationServicejsonSerializationprotected PluginManagerpluginManager
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleEasyDonateClient(@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 PendingPaymentBuildercreatePayment()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 PendingPaymentcreatePayment(@NotNull PendingPaymentBuilder paymentBuilder)Get the pending payment data using your credentials from pending payment builder.
This method also will be used byPendingPaymentBuilder.create().EasyHttpRequest.BuildercreateRequest(HttpClient.Method method)Get a new HTTP request builder using the API client provided HTTP client.protected <T> TexecutePluginRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull Headers headers, @Nullable QueryParams queryParams)protected <T> TexecuteShopRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull String apiPath, @Nullable Object... pathArgs)protected <T> TexecuteShopRequest(@NotNull Class<? extends ApiResponse<T>> responseType, @NotNull String apiPath, @Nullable QueryParams queryParams, @Nullable Object... pathArgs)@NotNull StringgetAccessKey()Get a used access key of any shop.@NotNull CouponsListgetCouponsList()Get the list of all coupons.@NotNull CouponsListgetCouponsList(@NotNull ActivityFlag activityFlag)Get the list of all coupons with the activity filter.@NotNull MassSalesListgetMassSalesList()Get the list of all mass sales.@NotNull MassSalesListgetMassSalesList(@NotNull ActivityFlag activityFlag)Get the list of all mass sales with the activity filter.@NotNull PaymentgetPayment(int paymentId)Get the payment by the #ID.@NotNull PaymentsListgetPaymentsList()Get the list of all finished payments.@NotNull ProductgetProduct(int productId)Get the shop product by the #ID.@NotNull ProductsListgetProductsList()Get the list of all shop products.@NotNull ServergetServer(int serverId)Get the shop connected server by the #ID.@NotNull ServersListgetServersList()Get the list of all shop connected servers.@NotNull ShopgetShop()Get the shop related data.<T> Trequest(@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:EasyDonateClientGet a used access key of any shop.- Specified by:
getAccessKeyin interfaceEasyDonateClient- Returns:
- The shop access key.
- See Also:
Shop.Extra.getAccessKey()
-
getShop
@NotNull public @NotNull Shop getShop() throws HttpRequestException, HttpResponseException
Description copied from interface:EasyDonateClientGet the shop related data.- Specified by:
getShopin 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:EasyDonateClientGet the shop product by the #ID.- Specified by:
getProductin 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:EasyDonateClientGet the list of all shop products.- Specified by:
getProductsListin 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:EasyDonateClientGet the shop connected server by the #ID.- Specified by:
getServerin 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:EasyDonateClientGet the list of all shop connected servers.- Specified by:
getServersListin 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:EasyDonateClientGet the list of all mass sales.- Specified by:
getMassSalesListin 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:EasyDonateClientGet the list of all mass sales with the activity filter.- Specified by:
getMassSalesListin 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:EasyDonateClientGet the list of all coupons.- Specified by:
getCouponsListin 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:EasyDonateClientGet the list of all coupons with the activity filter.- Specified by:
getCouponsListin 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:EasyDonateClientGet the payment by the #ID.- Specified by:
getPaymentin 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:EasyDonateClientGet the list of all finished payments.- Specified by:
getPaymentsListin 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:EasyDonateClientCreate 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:
createPaymentin 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:EasyDonateClientGet the pending payment data using your credentials from pending payment builder.
This method also will be used byPendingPaymentBuilder.create().- Specified by:
createPaymentin 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, HttpResponseExceptionDescription copied from interface:EasyDonateClientExecute a raw HTTP request and deserialize a response as an object with specified type.- Specified by:
requestin 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:EasyDonateClientSame thatEasyDonateClient.request(Class, EasyHttpRequest)but asynchronous.
Attention! A returned CompletableFuture instance may be completed exceptionally!- Specified by:
requestAsyncin 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:EasyDonateClientGet a new HTTP request builder using the API client provided HTTP client.- Specified by:
createRequestin interfaceEasyDonateClient- Parameters:
method- the HTTP method of a new request.- Returns:
- The new HTTP request builder instance.
-
-