Class AbstractRequest<T>
java.lang.Object
se.michaelthelin.spotify.requests.AbstractRequest<T>
- Type Parameters:
T
- The response type.
- All Implemented Interfaces:
IRequest<T>
- Direct Known Subclasses:
AbstractAuthorizationRequest
,AbstractDataRequest
,AuthorizationCodePKCERefreshRequest
,AuthorizationCodePKCERequest
,AuthorizationCodeUriRequest
Abstract base class for all requests.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
AbstractRequest.Builder<T,
BT extends AbstractRequest.Builder<T, ?>> Abstract builder class for requests. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractRequest
(AbstractRequest.Builder<T, ?> builder) Protected constructor for requests. -
Method Summary
Modifier and TypeMethodDescriptionbodyParametersToJson
(List<org.apache.hc.core5.http.NameValuePair> bodyParameters) Convert body parameters to JSON string.Execute DELETE request and get JSON response.Get something asynchronously.org.apache.hc.core5.http.HttpEntity
getBody()
Get the request body.List
<org.apache.hc.core5.http.NameValuePair> Get the body parameters for this request.org.apache.hc.core5.http.ContentType
Get the content type for this request.List
<org.apache.hc.core5.http.Header> Get the headers for this request.Get the HTTP manager for this request.getJson()
Get JSON response as string.getUri()
Get the URI for this request.void
Initialize the request body based on content type.postJson()
Execute POST request and get JSON response.putJson()
Execute PUT request and get JSON response.
-
Constructor Details
-
AbstractRequest
Protected constructor for requests.- Parameters:
builder
- The builder instance.
-
-
Method Details
-
executeAsync
Get something asynchronously.- Specified by:
executeAsync
in interfaceIRequest<T>
- Returns:
- A
CompletableFuture
for a generic.
-
initializeBody
public void initializeBody()Initialize the request body based on content type. -
bodyParametersToJson
Convert body parameters to JSON string.- Parameters:
bodyParameters
- The body parameters to convert.- Returns:
- JSON string representation.
-
getJson
public String getJson() throws IOException, SpotifyWebApiException, org.apache.hc.core5.http.ParseExceptionDescription copied from interface:IRequest
Get JSON response as string.- Specified by:
getJson
in interfaceIRequest<T>
- Returns:
- JSON response string.
- Throws:
IOException
- If an I/O error occurs.SpotifyWebApiException
- If a Spotify Web API error occurs.org.apache.hc.core5.http.ParseException
- If a parsing error occurs.
-
postJson
public String postJson() throws IOException, SpotifyWebApiException, org.apache.hc.core5.http.ParseExceptionDescription copied from interface:IRequest
Execute POST request and get JSON response.- Specified by:
postJson
in interfaceIRequest<T>
- Returns:
- JSON response string.
- Throws:
IOException
- If an I/O error occurs.SpotifyWebApiException
- If a Spotify Web API error occurs.org.apache.hc.core5.http.ParseException
- If a parsing error occurs.
-
putJson
public String putJson() throws IOException, SpotifyWebApiException, org.apache.hc.core5.http.ParseExceptionDescription copied from interface:IRequest
Execute PUT request and get JSON response.- Specified by:
putJson
in interfaceIRequest<T>
- Returns:
- JSON response string.
- Throws:
IOException
- If an I/O error occurs.SpotifyWebApiException
- If a Spotify Web API error occurs.org.apache.hc.core5.http.ParseException
- If a parsing error occurs.
-
deleteJson
public String deleteJson() throws IOException, SpotifyWebApiException, org.apache.hc.core5.http.ParseExceptionDescription copied from interface:IRequest
Execute DELETE request and get JSON response.- Specified by:
deleteJson
in interfaceIRequest<T>
- Returns:
- JSON response string.
- Throws:
IOException
- If an I/O error occurs.SpotifyWebApiException
- If a Spotify Web API error occurs.org.apache.hc.core5.http.ParseException
- If a parsing error occurs.
-
getHttpManager
Description copied from interface:IRequest
Get the HTTP manager for this request.- Specified by:
getHttpManager
in interfaceIRequest<T>
- Returns:
- The HTTP manager.
-
getUri
Description copied from interface:IRequest
Get the URI for this request. -
getHeaders
Description copied from interface:IRequest
Get the headers for this request.- Specified by:
getHeaders
in interfaceIRequest<T>
- Returns:
- List of headers.
-
getContentType
public org.apache.hc.core5.http.ContentType getContentType()Description copied from interface:IRequest
Get the content type for this request.- Specified by:
getContentType
in interfaceIRequest<T>
- Returns:
- The content type.
-
getBody
public org.apache.hc.core5.http.HttpEntity getBody()Description copied from interface:IRequest
Get the request body. -
getBodyParameters
Description copied from interface:IRequest
Get the body parameters for this request.- Specified by:
getBodyParameters
in interfaceIRequest<T>
- Returns:
- List of body parameters.
-