Class Resource
java.lang.Object
esendex.sdk.java.service.resource.base.Resource
- Direct Known Subclasses:
AccessCheckResource
,BaseSurveysResource
,DeleteContactResource
,DeleteInboxMessageResource
,SurveySendResource
,UpdateMessageStatusResource
,XmlRequesterResource
,XmlRequesterResponderResource
,XmlResponderResource
A generalised Resource for connecting to the URL resource configured by.
EsendexProperties
Optional fields for Esendex account and id may be
set for subclasses to utilise.- Author:
- Mike Whittaker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Makes and completes the connection to the resource.protected String
Gets any account that is setCreate the endpoint URL that this service will submit a request to.protected abstract String
Gets the child portion of the url required to access the resource.protected String
getId()
Gets any resource id that is setprotected String
Retrieves the request data if any in raw String form.protected abstract HttpRequestMethod
Gets the HttpRequestMethod that this service stipulates eg GET, POST, PUT, DELETE.Gets the response.boolean
Is the Http response status code in the 200-299 range?.
-
Constructor Details
-
Resource
public Resource(Authenticator auth, String id, HttpQuery query, String version, String domain, boolean secure) -
Resource
-
Resource
Create a Resource service with optional account, id and/or query.- Parameters:
auth
- a ResourceAuthenticator that is appropriate for this Resourceaccount
- the Esendex account to access, may be nullid
- the unique identifier for a particular resource eg a message or contact ID. May be nullquery
- the query, may be null
-
-
Method Details
-
getEndpoint
Create the endpoint URL that this service will submit a request to.- Returns:
- the URL that is the endpoint
-
getEndpointChild
Gets the child portion of the url required to access the resource. The child part is appended to the base url and must not start with a '/' The base url is of the form 'http://api.esendex.com/{version}/' where version maybe similar to 'v1.0'- Returns:
- the child portion of the url required to access this resource
-
getRequestMethod
Gets the HttpRequestMethod that this service stipulates eg GET, POST, PUT, DELETE.- Returns:
- the required HttpRequestMethod
-
getAccount
Gets any account that is set- Returns:
- the account or null if not set
-
getId
Gets any resource id that is set- Returns:
- the id or null if not set
-
getResponse
Gets the response.- Returns:
- the response
-
getRequestData
Retrieves the request data if any in raw String form. By default returns null- Returns:
- the request data in raw form
-
execute
Makes and completes the connection to the resource.- Throws:
EsendexException
- If there is a problem during the connection or the HTTP response is outside the 200-299 range.
-
isHttpOkay
public boolean isHttpOkay()Is the Http response status code in the 200-299 range?.- Returns:
- true if there is a response yet and that !HttpResponse#isHttpOkay() returns true, else false
-