Class MessageRequest

java.lang.Object
com.vonage.client.JsonableBaseObject
com.vonage.client.messages.MessageRequest
All Implemented Interfaces:
Jsonable
Direct Known Subclasses:
MessengerRequest, MmsRequest, RcsRequest, SmsTextRequest, ViberRequest, WhatsappRequest

public abstract class MessageRequest extends JsonableBaseObject
Abstract base class of all Messages sent via the Messages v1 API. All subclasses follow a builder pattern to enable easy construction. The design philosophy is "correct by construction": that is, validation occurs when calling the MessageRequest.Builder.build() method. It is still the responsibility of the user to ensure all required parameters are set. The Javadoc for each parameter in the builders indicates whether it is mandatory (REQUIRED) or not (OPTIONAL). Failure to specify mandatory parameters will result in NullPointerException being thrown. Parameters which are invalid (i.e. have malformed values, such as empty strings) will result in IllegalArgumentException being thrown. The documentation on each parameter should provide clarity on parameter restrictions.
  • Field Details

  • Constructor Details

    • MessageRequest

      protected MessageRequest(MessageRequest.Builder<?,?> builder, Channel channel, MessageType messageType)
      Constructor where all of this class's fields should be set. This is protected to prevent users form explicitly calling it; this should only be called from the MessageRequest.Builder.build() method. Subclasses should hide this constructor as well to avoid potentially confusing users on how to construct this object.
      Parameters:
      builder - The mutable builder object used to assign this MessageRequest's fields from.
      channel - The service to send the message through.
      messageType - The type of message to send.
  • Method Details