Package com.aerisweather.aeris.model
Class AerisResponse
- java.lang.Object
-
- com.aerisweather.aeris.model.AerisResponse
-
- Direct Known Subclasses:
DroughtsMonitorResponse
,FiresOutlookResponse
,TropicalCyclonesResponse
public class AerisResponse extends Object
The basic response from the Aeris API. Generally all responses from Aeris will have a success boolean, than error string or an object attached to it.
-
-
Field Summary
Fields Modifier and Type Field Description AerisError
error
AerisError
returned from the response.The error property will always be null if the request was successful, results were returned and there were no errors or warnings.List<AerisDataJSON>
responses
List of AerisData returned from the responseboolean
success
Success status of the request.
-
Constructor Summary
Constructors Constructor Description AerisResponse()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AerisResponse
createObjectWithError(String code, String description)
Creates a JSON String for an AerisResponse with a specific Error code and description.static String
createWithError(String code, String description)
Creates a JSON String for an AerisResponse with a specific Error code and description.static AerisResponse
fromJSON(org.json.JSONObject jsonObject)
Static construction of an AerisResponse from a JSON object.AerisError
getError()
Gets the error from the response, if there is one.AerisDataJSON
getFirstResponse()
Gets the first index in the list of the AerisDataJSON responses.List<AerisDataJSON>
getListOfResponse()
Gets the list of data responsesint
getNumberOfResponses()
Returns the number of responses for this AerisResponse.AerisDataJSON
getResponse(int index)
Gets the data for the given index.boolean
isSuccessful()
Gets the success of the response.boolean
isSuccessfulWithResponses()
Gets the success of the response along with checking that there was no warning, and that the list of responses is not null.
-
-
-
Field Detail
-
success
public boolean success
Success status of the request.
-
error
public AerisError error
AerisError
returned from the response.The error property will always be null if the request was successful, results were returned and there were no errors or warnings.
-
responses
public List<AerisDataJSON> responses
List of AerisData returned from the response
-
-
Method Detail
-
fromJSON
public static AerisResponse fromJSON(org.json.JSONObject jsonObject)
Static construction of an AerisResponse from a JSON object. This constructor is needed to properly pull the JSON as the JSON response field can be an array or just a single object, so this- Parameters:
jsonObject
- Json object to use to construct the AerisResponse- Returns:
- AerisResponse made from the JSON object, or null if it fails to build it.
-
createWithError
public static String createWithError(String code, String description)
Creates a JSON String for an AerisResponse with a specific Error code and description.- Parameters:
code
- Code of the errordescription
- description of the error- Returns:
- String JSON object of an AerisResponse with the code and description
-
createObjectWithError
public static AerisResponse createObjectWithError(String code, String description)
Creates a JSON String for an AerisResponse with a specific Error code and description.- Parameters:
code
- Code of the errordescription
- description of the error- Returns:
- String JSON object of an AerisResponse with the code and description
-
getNumberOfResponses
public int getNumberOfResponses()
Returns the number of responses for this AerisResponse.- Returns:
- Number of responses
-
getResponse
public AerisDataJSON getResponse(int index)
Gets the data for the given index. Pass into aAerisFriendlyResponse
- Parameters:
index
- index to get the response at.- Returns:
- AerisData at that index.
-
getFirstResponse
public AerisDataJSON getFirstResponse()
Gets the first index in the list of the AerisDataJSON responses.- Returns:
- data for the first response.
-
getListOfResponse
public List<AerisDataJSON> getListOfResponse()
Gets the list of data responses- Returns:
- The list of data responses.
-
isSuccessfulWithResponses
public boolean isSuccessfulWithResponses()
Gets the success of the response along with checking that there was no warning, and that the list of responses is not null.- Returns:
- true if the response was successful with responses
-
isSuccessful
public boolean isSuccessful()
Gets the success of the response. Returns true if the response was sucessful or had a warning.- Returns:
- true if the response was successful.
-
getError
public AerisError getError()
Gets the error from the response, if there is one.- Returns:
- the error
-
-