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 classAbstractRequest.Builder<T,BT extends AbstractRequest.Builder<T, ?>> Abstract builder class for requests. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRequest(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.HttpEntitygetBody()Get the request body.List<org.apache.hc.core5.http.NameValuePair> Get the body parameters for this request.org.apache.hc.core5.http.ContentTypeGet 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.voidInitialize 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:
executeAsyncin interfaceIRequest<T>- Returns:
- A
CompletableFuturefor 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:IRequestGet JSON response as string.- Specified by:
getJsonin 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:IRequestExecute POST request and get JSON response.- Specified by:
postJsonin 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:IRequestExecute PUT request and get JSON response.- Specified by:
putJsonin 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:IRequestExecute DELETE request and get JSON response.- Specified by:
deleteJsonin 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:IRequestGet the HTTP manager for this request.- Specified by:
getHttpManagerin interfaceIRequest<T>- Returns:
- The HTTP manager.
-
getUri
Description copied from interface:IRequestGet the URI for this request. -
getHeaders
Description copied from interface:IRequestGet the headers for this request.- Specified by:
getHeadersin interfaceIRequest<T>- Returns:
- List of headers.
-
getContentType
public org.apache.hc.core5.http.ContentType getContentType()Description copied from interface:IRequestGet the content type for this request.- Specified by:
getContentTypein interfaceIRequest<T>- Returns:
- The content type.
-
getBody
public org.apache.hc.core5.http.HttpEntity getBody()Description copied from interface:IRequestGet the request body. -
getBodyParameters
Description copied from interface:IRequestGet the body parameters for this request.- Specified by:
getBodyParametersin interfaceIRequest<T>- Returns:
- List of body parameters.
-