Class AbstractClient

    • Constructor Detail

      • AbstractClient

        protected AbstractClient()

        Default constructor.

      • AbstractClient

        protected AbstractClient​(Locale locale)

        Overloaded constructor.

        Parameters:
        locale - the Locale for this client
    • Method Detail

      • setCommunicationProtocol

        public void setCommunicationProtocol​(CommunicationProtocol communicationProtocol)

        Sets the communication protocol for this client instance.

        Parameters:
        communicationProtocol - the CommunicationProtocol for this client instance
      • getLocale

        public Locale getLocale()

        Retrieves the Locale for this client instance.

        Returns:
        the Locale for this client instance
      • setLocale

        public void setLocale​(Locale locale)

        Sets the Locale for this client instance. Note that doing this after a call to setLocalizationLocale(Locale) overwrites the localization language with the input of this method.

        Parameters:
        locale - the Locale for this client
      • getLocalizationLocale

        public Locale getLocalizationLocale()

        Returns the Locale used for the localization.

        Returns:
        locale the Locale for the localization
      • setLocalizationLocale

        public void setLocalizationLocale​(Locale loc)

        Changes the Locale used for the localization. Useful if the client needs to be in a different language than the error messages.

        Parameters:
        loc - the Locale for the localization
      • getRootUrl

        protected URLEndpoint getRootUrl()

        Determines the URL for the API based on the current Locale and communication protocol.

        Returns:
        the URL representing the entry point for the API
      • doGetRequest

        protected String doGetRequest​(String url)

        Performs a GET request to the specified URL.

        Parameters:
        url - the URL which will be sent a GET request
        Returns:
        a string representation of the API's response
      • doPostRequest

        protected String doPostRequest​(String url,
                                       String query)

        Performs a POST request to the specified URL.

        Parameters:
        url - the URL which will be sent a POST request
        query - the query which the API will process
        Returns:
        a string representation of the API's response
      • getResponseModels

        protected List<ResponseModel> getResponseModels​(String table)

        Retrieves the response models for a given table.

        Parameters:
        table - the table
        Returns:
        a list of ResponseModel
      • getResponseModels

        protected List<ResponseModel> getResponseModels​(String table,
                                                        Map<String,​Collection<?>> mappings)

        Retrieves the response models for a given table which match the input constraints.

        Parameters:
        table - the table
        mappings - the mappings
        Returns:
        a list of ResponseModel
      • getUrl

        public abstract URLEndpoint getUrl()

        Returns the URL endpoint which this client represents.

        Returns:
        the URL endpoint for this client