Class AerisRequest
- java.lang.Object
-
- com.aerisweather.aeris.communication.UrlBuilder
-
- com.aerisweather.aeris.communication.AerisRequest
-
- Direct Known Subclasses:
AerisBatchRequest
,AerisPermissionsRequest
public class AerisRequest extends UrlBuilder
Builds request for various endpoints, actions, and parameters.Some code examples:
Construct a request for the observation for zip code 55403
AerisRequest request = new AerisRequest(TestConstants.CLIENT_ID, TestConstants.CLIENT_SECRET, new Endpoint( EndpointType.OBSERVATIONS), "55403"):
Construct a request for 5 observations within 50 miles of zip code 55403 (Minneapolis). Results will be sorted by distance (ascending) from zip code 55403
AerisRequest request = new AerisRequest(TestConstants.CLIENT_ID, TestConstants.CLIENT_SECRET, new Endpoint( EndpointType.OBSERVATIONS), Action.CLOSEST, new PlaceParameter("55403"), new LimitParameter(5), new RadiusParameter(50, RadiusUnitParameter.MILES) ;
-
-
Field Summary
Fields Modifier and Type Field Description protected Action
action
protected boolean
debug
protected Endpoint
endpoint
protected String
id
protected Double
lat
protected Double
longitude
protected Parameter[]
parameters
protected boolean
secureAccess
-
Fields inherited from class com.aerisweather.aeris.communication.UrlBuilder
clientId, clientSecret, packageName
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AerisRequest()
AerisRequest(Endpoint endpoint, Action action, Parameter... params)
Builds the request with a specified endpoint, action, params.AerisRequest(Endpoint endpoint, String id, Parameter... params)
Builds the request with a specified endpoint, action, params.AerisRequest(String clientId, String clientSecret, String packageName, Endpoint endpoint, Action action, Parameter... params)
Builds the request with a specified endpoint, action, params.AerisRequest(String clientId, String clientSecret, String packageName, Endpoint endpoint, String id, Parameter... params)
Builds the request with a specified endpoint, action, params.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
build()
Builds the request for from the given parametersdouble
getLat()
double
getLongitude()
protected String
getParameters()
Gets the parameters in the correct format.boolean
isDebug()
Returns if debug has been enabled which allows for the request and response to be logged in logcatboolean
isSecureAccess()
Returns whether secure access has been enabled.AerisRequest
withDebugOutput(boolean debug)
Constructs the request with the debug set to a value.AerisRequest
withSecureAccess(boolean secureAccess)
Sets the secure access.-
Methods inherited from class com.aerisweather.aeris.communication.UrlBuilder
getLimit, getOAuth, getPositionString
-
-
-
-
Constructor Detail
-
AerisRequest
protected AerisRequest()
-
AerisRequest
public AerisRequest(Endpoint endpoint, Action action, Parameter... params)
Builds the request with a specified endpoint, action, params. Grabs the secret id and client id from theAerisEngine
.- Parameters:
endpoint
- Endpoint we are requesting data fromaction
- Action to take on the endpointparams
- Optional parameters
-
AerisRequest
public AerisRequest(Endpoint endpoint, String id, Parameter... params)
Builds the request with a specified endpoint, action, params. Grabs the secret id and client id from theAerisEngine
.- Parameters:
endpoint
- Endpoint we are requesting data fromid
- Stringparams
- optional
-
AerisRequest
public AerisRequest(String clientId, String clientSecret, String packageName, Endpoint endpoint, String id, Parameter... params)
Builds the request with a specified endpoint, action, params.- Parameters:
clientId
- Aeris account idclientSecret
- Aeris account secretpackageName
- The package name of the service requesting dataendpoint
- Endpoint was are requestingid
- Stringparams
- optional
-
AerisRequest
public AerisRequest(String clientId, String clientSecret, String packageName, Endpoint endpoint, Action action, Parameter... params)
Builds the request with a specified endpoint, action, params.- Parameters:
clientId
- Aeris account idclientSecret
- Aeris account secretpackageName
- The package name of the service requesting dataendpoint
- Endpoint was are requestingaction
- Action to take on the endpointparams
- optional
-
-
Method Detail
-
withDebugOutput
public AerisRequest withDebugOutput(boolean debug)
Constructs the request with the debug set to a value. Default value is false- Parameters:
debug
- debug boolean to set as. True will log the request and response from Aeris.- Returns:
- The AerisRequest
-
isDebug
public boolean isDebug()
Returns if debug has been enabled which allows for the request and response to be logged in logcat- Returns:
- true if debug is enabled, false otherwise
-
isSecureAccess
public boolean isSecureAccess()
Returns whether secure access has been enabled. Secure access points the API to use HTTPS versus HTTP.- Returns:
- true if secure access is enabled.
-
withSecureAccess
public AerisRequest withSecureAccess(boolean secureAccess)
Sets the secure access. Secure access points the API to use HTTPS versus HTTP. Default is false.- Parameters:
secureAccess
- What to set the secure access to.- Returns:
- AerisRequest obj
-
build
public String build()
Builds the request for from the given parameters- Specified by:
build
in classUrlBuilder
- Returns:
- the String url for the request.
-
getParameters
protected String getParameters()
Gets the parameters in the correct format.- Returns:
- Parameters in a Url friendly format. 04april2016sshie - removed the appID (AMP update)
-
getLat
public double getLat() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
getLongitude
public double getLongitude() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
-