Class Response

java.lang.Object
com.loop54.model.response.Response
Direct Known Subclasses:
AutoCompleteResponse, ErrorResponse, GetBasketRecommendationsResponse, GetComplementaryEntitiesResponse, GetEntitiesByAttributeResponse, GetEntitiesResponse, GetPopularEntitiesResponse, GetRecentEntitiesResponse, GetRecommendedEntitiesResponse, GetRelatedEntitiesResponse, SearchResponse

public class Response extends Object
A response from the engine. Used for responses that don't return any standardized data parameters.
  • Field Details

    • customData

      public Map<String,Object> customData
      Any additional, non-standard, data. Contact support for information about how and when to use this.
  • Constructor Details

    • Response

      public Response()
  • Method Details

    • getCustomDataOrThrow

      public <T> T getCustomDataOrThrow(String key, Class<T> clazz) throws Loop54Exception
      Retrieve a named custom value from the response. If not found, or the value could not be deserialized or cast to T, it will throw an exception.
      Type Parameters:
      T - Expected type of the response data to retrieve.
      Parameters:
      key - Key of the custom data.
      clazz - Expected class of the response data to retrieve.
      Returns:
      Deserialized data as the specified type, if it exists.
      Throws:
      Loop54Exception - If not found, or the value could not be deserialized to the desired class.
    • getCustomDataOrDefault

      public <T> T getCustomDataOrDefault(String key, Class<T> clazz) throws Loop54Exception
      Retrieve a named custom value from the response. If not found it will return the default value. If the value could not be deserialized or cast to T it will throw an exception.
      Type Parameters:
      T - Expected type of the response data to retrieve.
      Parameters:
      key - Key of the custom data.
      clazz - Expected class of the response data to retrieve.
      Returns:
      Deserialized data as the specified type. If the data did not exist null is returned.
      Throws:
      Loop54Exception - if the value cannot be deserialized to the desired class.