Class OAuth2Action<T>
java.lang.Object
com.jagrosh.jdautilities.oauth2.requests.OAuth2Action<T>
An adaptable lookalike of JDA's
RestAction.
OAuth2Actions can either be completed asynchronously using queue,
or synchronously using complete.
Note that OAuth2Action does not extend JDA's RestAction.
- Author:
- Kaidan Gustave
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final OAuth2ClientImplprotected static final Consumerprotected final net.dv8tion.jda.internal.requests.Methodprotected final String -
Constructor Summary
ConstructorsConstructorDescriptionOAuth2Action(OAuth2ClientImpl client, net.dv8tion.jda.internal.requests.Method method, String url) -
Method Summary
Modifier and TypeMethodDescriptionprotected okhttp3.Requestcomplete()Synchronously executes this OAuth2Action, returning the value constructed from the response if it was successful, or throwing theExceptionif it was not.protected okhttp3.RequestBodygetBody()Gets theclientresponsible for creating this OAuth2Action.protected okhttp3.Headersprotected net.dv8tion.jda.internal.requests.Methodprotected StringgetUrl()protected abstract Thandle(okhttp3.Response response) voidqueue()Asynchronously executes this OAuth2Action.voidAsynchronously executes this OAuth2Action, providing the value constructed from the response as the parameter given to the successConsumer.voidAsynchronously executes this OAuth2Action, providing the value constructed from the response as the parameter given to the successConsumerif the response is successful, or the exception to the failure Consumer if it's not.
-
Field Details
-
DEFAULT_SUCCESS
-
DEFAULT_FAILURE
-
client
-
method
protected final net.dv8tion.jda.internal.requests.Method method -
url
-
-
Constructor Details
-
OAuth2Action
public OAuth2Action(OAuth2ClientImpl client, net.dv8tion.jda.internal.requests.Method method, String url)
-
-
Method Details
-
getBody
protected okhttp3.RequestBody getBody() -
getHeaders
protected okhttp3.Headers getHeaders() -
buildRequest
protected okhttp3.Request buildRequest() -
getMethod
protected net.dv8tion.jda.internal.requests.Method getMethod() -
getUrl
-
queue
public void queue()Asynchronously executes this OAuth2Action. -
queue
Asynchronously executes this OAuth2Action, providing the value constructed from the response as the parameter given to the successConsumer.- Parameters:
success- The success consumer, executed when this OAuth2Action gets a successful response.
-
queue
Asynchronously executes this OAuth2Action, providing the value constructed from the response as the parameter given to the successConsumerif the response is successful, or the exception to the failure Consumer if it's not.- Parameters:
success- The success consumer, executed when this OAuth2Action gets a successful response.failure- The failure consumer, executed when this OAuth2Action gets a failed response.
-
complete
Synchronously executes this OAuth2Action, returning the value constructed from the response if it was successful, or throwing theExceptionif it was not.Bear in mind when using this, that this method blocks the thread it is called in.
- Returns:
- the value constructed from the response
- Throws:
IOException- on unsuccessful execution
-
getClient
Gets theclientresponsible for creating this OAuth2Action.- Returns:
- The OAuth2Client responsible for creating this.
-
handle
- Throws:
IOException
-