Class ApiEnvelope


  • public class ApiEnvelope
    extends java.lang.Object
    Envelope/wrapper for API responses. This class standardizes the JSON shape returned by the API by always including the apiVersion and optionally including either a successful payload (message/data) or an error description (error). It is typically created via one of the static wrap(...) factory methods. Use asJsonNode() to obtain a JsonNode representation of the envelope, or asJsValue() to obtain a Play JsValue. Note: An instance is intended to represent either a success response or an error response. If an ApiEnvelope.ErrorCode is present, the envelope is treated as an error regardless of any provided data.
    • Constructor Detail

      • ApiEnvelope

        public ApiEnvelope()
    • Method Detail

      • wrap

        public static ApiEnvelope wrap​(java.lang.Object obj)
      • wrap

        public static ApiEnvelope wrap​(com.fasterxml.jackson.databind.JsonNode data)
      • wrap

        public static ApiEnvelope wrap​(java.lang.String message)
      • wrap

        public static ApiEnvelope wrap​(java.lang.String message,
                                       com.fasterxml.jackson.databind.JsonNode data)
      • asJsonNode

        public com.fasterxml.jackson.databind.JsonNode asJsonNode()
      • asJsValue

        public play.api.libs.json.JsValue asJsValue()