Package com.vonage.client.messages
Class MessageRequest.Builder<M extends MessageRequest,B extends MessageRequest.Builder<? extends M,? extends B>>
java.lang.Object
com.vonage.client.messages.MessageRequest.Builder<M,B>
- Type Parameters:
M- The type of MessageRequest that will be constructed when calling thebuild()method.B- The type of Builder that will be returned when chaining method calls. This is necessary to enable the methods to be called in any order and still return the most specific concrete subtype of builder, rather than this base class.
- Direct Known Subclasses:
MessengerRequest.Builder,MmsRequest.Builder,RcsRequest.Builder,SmsTextRequest.Builder,ViberRequest.Builder,WhatsappRequest.Builder
- Enclosing class:
MessageRequest
public abstract static class MessageRequest.Builder<M extends MessageRequest,B extends MessageRequest.Builder<? extends M,? extends B>>
extends Object
Mutable Builder class, designed to simulate named parameters to allow for convenient
construction of MessageRequests. Subclasses should add their own mutable parameters
and a method for setting them whilst returning the builder, to allow for chaining.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Protected constructor to prevent users from explicitly creating this object. -
Method Summary
Modifier and TypeMethodDescriptionabstract Mbuild()Builds the MessageRequest.protected B(OPTIONAL) Additional text to accompany the media.(OPTIONAL) Sets the client reference, which will be present in every message status.protected B(REQUIRED) Custom payload.(REQUIRED) Sets the sender number or ID.protected B(OPTIONAL) The media name.protected B(REQUIRED) Sets the text field.(REQUIRED) Sets the recipient number or ID.protected Bttl(int ttl) (OPTIONAL) The duration in milliseconds the delivery of a message will be attempted.protected B(REQUIRED) Sets the media URL.webhookUrl(String webhookUrl) (OPTIONAL) Specifies the URL to which Status Webhook messages will be sent for this particular message.webhookVersion(MessagesVersion webhookVersion) Specifies which version of the Messages API will be used to send Status Webhook messages for this particular message.
-
Constructor Details
-
Builder
protected Builder()Protected constructor to prevent users from explicitly creating this object. This should only be called by the staticbuilder()method in the non-abstract subclasses of this builder's parent (declaring) class.
-
-
Method Details
-
from
(REQUIRED) Sets the sender number or ID.- Parameters:
from- The number or ID to send the message from.- Returns:
- This builder.
-
custom
(REQUIRED) Custom payload. The schema of a custom object can vary widely according to the channel. Please consult the relevant documentation for details.- Parameters:
payload- The custom payload properties to send as a Map.- Returns:
- This builder.
-
to
(REQUIRED) Sets the recipient number or ID.- Parameters:
to- The number or ID to send the message to.- Returns:
- This builder.
-
clientRef
(OPTIONAL) Sets the client reference, which will be present in every message status.- Parameters:
clientRef- Client reference of up to 40 characters.- Returns:
- This builder.
-
webhookUrl
(OPTIONAL) Specifies the URL to which Status Webhook messages will be sent for this particular message. Overrides account-level and application-level Status Webhook url settings on a per-message basis.- Parameters:
webhookUrl- The status webhook URL as a string.- Returns:
- This builder.
- Since:
- 8.1.0
-
webhookVersion
Specifies which version of the Messages API will be used to send Status Webhook messages for this particular message. For example, if MessagesVersion.V0_1 is set, then the JSON body of Status Webhook messages for this message will be sent in Messages v0.1 format. Over-rides account-level and application-level API version settings on a per-message basis.- Parameters:
webhookVersion- The messages API version enum.- Returns:
- This builder.
- Since:
- 8.1.0
-
ttl
(OPTIONAL) The duration in milliseconds the delivery of a message will be attempted. By default, Vonage attempts delivery for 72 hours, however the maximum effective value depends on the operator and is typically 24 to 48 hours. We recommend this value should be kept at its default or at least 30 minutes.- Parameters:
ttl- The time-to-live for this message before abandoning delivery attempts, in milliseconds.- Returns:
- This builder.
-
text
(REQUIRED) Sets the text field.- Parameters:
text- The text string.- Returns:
- This builder.
-
url
(REQUIRED) Sets the media URL.- Parameters:
url- The URL as a string.- Returns:
- This builder.
-
caption
(OPTIONAL) Additional text to accompany the media. Must be between 1 and 2000 characters.- Parameters:
caption- The caption string.- Returns:
- This builder.
-
name
(OPTIONAL) The media name.- Parameters:
name- The name string.- Returns:
- This builder.
-
build
Builds the MessageRequest.- Returns:
- A MessageRequest, populated with all fields from this builder.
-