Class Resource

java.lang.Object
esendex.sdk.java.service.resource.base.Resource
Direct Known Subclasses:
AccessCheckResource, BaseSurveysResource, DeleteContactResource, DeleteInboxMessageResource, SurveySendResource, UpdateMessageStatusResource, XmlRequesterResource, XmlRequesterResponderResource, XmlResponderResource

public abstract class Resource extends Object
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 Details

    • Resource

      public Resource(Authenticator auth, String id, HttpQuery query, String version, String domain, boolean secure)
    • Resource

      public Resource(Authenticator auth, String account, String id, HttpQuery query, String version)
    • Resource

      public Resource(Authenticator auth, String account, String id, HttpQuery query)
      Create a Resource service with optional account, id and/or query.
      Parameters:
      auth - a ResourceAuthenticator that is appropriate for this Resource
      account - the Esendex account to access, may be null
      id - the unique identifier for a particular resource eg a message or contact ID. May be null
      query - the query, may be null
  • Method Details

    • getEndpoint

      public URL getEndpoint()
      Create the endpoint URL that this service will submit a request to.
      Returns:
      the URL that is the endpoint
    • getEndpointChild

      protected abstract String 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

      protected abstract HttpRequestMethod getRequestMethod()
      Gets the HttpRequestMethod that this service stipulates eg GET, POST, PUT, DELETE.
      Returns:
      the required HttpRequestMethod
    • getAccount

      protected String getAccount()
      Gets any account that is set
      Returns:
      the account or null if not set
    • getId

      protected String getId()
      Gets any resource id that is set
      Returns:
      the id or null if not set
    • getResponse

      public HttpResponse getResponse()
      Gets the response.
      Returns:
      the response
    • getRequestData

      protected String getRequestData()
      Retrieves the request data if any in raw String form. By default returns null
      Returns:
      the request data in raw form
    • execute

      public void execute() throws EsendexException
      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