-
- Type Parameters:
T
- the type of the response body data
public interface TerraApiResponse<T>
Interface for any response from Terra's API, containing the returned data from the query (if available) as well as the raw, unparsed body as aJsonNode
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @Nullable String
getMessage()
The value of themessage
key in the returned response body.@Nullable List<T>
getParsedData()
The data parsed from the response body as a list of Java objects.com.fasterxml.jackson.databind.JsonNode
getRawBody()
The raw, unparsed JSON body returned with the response.int
getResponseCode()
The HTTP response code that Terra returned from the request.@Nullable String
getType()
The value of thetype
key in the returned response body.@Nullable User
getUser()
The user that the request fetched data for.boolean
isSuccessful()
Whether the request to Terra returned a successful HTTP response code.
-
-
-
Method Detail
-
getResponseCode
int getResponseCode()
The HTTP response code that Terra returned from the request.- Returns:
- the response code
-
isSuccessful
boolean isSuccessful()
Whether the request to Terra returned a successful HTTP response code.- Returns:
- whether the response was successful
-
getType
@Nullable @Nullable String getType()
The value of thetype
key in the returned response body. This can be used to check whether this response contains parsed data, or if a special case occurred, such as the request being chunked due to being for more than 30 days of data.
This will only benull
if the request was unsuccessful, i.e. returned a non 2xx status code (accessible throughgetResponseCode()
orisSuccessful()
).- Returns:
- the type of the response payload
-
getMessage
@Nullable @Nullable String getMessage()
The value of themessage
key in the returned response body. This is a human-readable value denoting what occurred, however it may not always be provided.- Returns:
- the message sent with the response payload
-
getRawBody
com.fasterxml.jackson.databind.JsonNode getRawBody()
The raw, unparsed JSON body returned with the response.- Returns:
- the response body
-
getParsedData
@Nullable @Nullable List<T> getParsedData()
The data parsed from the response body as a list of Java objects.- Returns:
- the parsed data
-
-