Package io.smooch.core
Class Message
- java.lang.Object
-
- io.smooch.core.Message
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Message>
public final class Message extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Message>
Object representing a received or sent message- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Message(Coordinates coordinates, java.util.Map<java.lang.String,java.lang.Object> metadata)Create a message with the given coordinates.Message(java.lang.String text, java.lang.String payload, java.util.Map<java.lang.String,java.lang.Object> metadata)Create a message with the given text, payload, and metadata.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessageAction(MessageAction messageAction)Adds a message action to the list of actionsvoidaddMessageItem(MessageItem messageItem)Adds a message item to the list of itemsintcompareTo(Message o)Messagecopy()booleanequals(java.lang.Object o)java.lang.StringgetAvatarUrl()The url for the user's avatar image.CoordinatesgetCoordinates()Returns Coordinatesjava.util.DategetDate()The date and time the message was sent.DisplaySettingsgetDisplaySettings()Returns DisplaySettings for carousel messagesMessageDtogetEntity()java.io.FilegetFile()The file of the message.java.lang.StringgetId()The ID of the message.android.graphics.BitmapgetImage()The image of the message.longgetMediaSize()The media size of the message.java.lang.StringgetMediaType()The media type of the message.java.lang.StringgetMediaUrl()The media URL of the message.java.util.List<MessageAction>getMessageActions()The list of Message Action objects contained in the message.java.util.List<MessageItem>getMessageItems()The list of Message Item objects contained in the message.java.util.Map<java.lang.String,java.lang.Object>getMetadata()The metadata of the messagejava.lang.StringgetName()The display name of the user.java.lang.StringgetPayload()The message payload from an actionjava.lang.StringgetText()The text content of the message.java.lang.StringgetTextFallback()Text to display for unsupported message typesjava.lang.StringgetType()The message typeMessageUploadStatusgetUploadStatus()The upload status of the message.java.lang.StringgetUserId()The id for the user.java.lang.StringgetUserRole()The Role for the user.inthashCode()booleanhasLocationRequest()Returnstrueif the message has a location requestbooleanhasReplies()Returnstrueif the message has reply actionsbooleanhasValidCoordinates()Returnstrueif the message has valid coordinatesbooleanisCarousel()booleanisFromCurrentUser()Returns true if the message originated from the user, or false if the message comes from another participant.booleanisRead()Return true if the message has been readvoidremoveMessageAction(MessageAction messageAction)Removes a message action from the list of actionsvoidremoveMessageItem(MessageItem messageItem)Removes a message item from the list of itemsvoidsetAvatarUrl(java.lang.String avatarUrl)Sets the url for the user's avatar image.voidsetCoordinates(Coordinates coordinates)Sets the coordinates for the messagevoidsetDisplaySettings(DisplaySettings displaySettings)Sets the display settings for the messagevoidsetFile(java.io.File file)Sets the file for the message.voidsetImage(android.graphics.Bitmap bitmap)Sets the image for the message.voidsetMediaSize(long mediaSize)Sets the media size for the messagevoidsetMediaType(java.lang.String mediaType)Sets the media type for the messagevoidsetMediaUrl(java.lang.String mediaUrl)Sets the media URL for the messagevoidsetMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)Sets the metadata for the messagevoidsetName(java.lang.String displayName)Sets the user's displayName for the message.voidsetPayload(java.lang.String payload)Sets the payload for the messagevoidsetText(java.lang.String text)Sets the text for the message.voidsetTextFallback(java.lang.String textFallback)Sets the text to display for unsupported message typesvoidsetType(java.lang.String type)Sets the type of the messagevoidsetUploadStatus(MessageUploadStatus uploadStatus)
-
-
-
Constructor Detail
-
Message
public Message(java.lang.String text, java.lang.String payload, java.util.Map<java.lang.String,java.lang.Object> metadata)Create a message with the given text, payload, and metadata. The message will be owned by the current user.- Parameters:
text- The textpayload- The message payloadmetadata- The message metadata (JSON Object)
-
Message
public Message(Coordinates coordinates, java.util.Map<java.lang.String,java.lang.Object> metadata)
Create a message with the given coordinates.- Parameters:
coordinates- The coordinatesmetadata- The message metadata (JSON Object)
-
-
Method Detail
-
copy
public Message copy()
-
isCarousel
public boolean isCarousel()
-
getAvatarUrl
public java.lang.String getAvatarUrl()
The url for the user's avatar image.- Returns:
- The url
-
getUserId
public java.lang.String getUserId()
The id for the user.- Returns:
- The id
-
getUserRole
public java.lang.String getUserRole()
The Role for the user.- Returns:
- The Role
-
setAvatarUrl
public void setAvatarUrl(java.lang.String avatarUrl)
Sets the url for the user's avatar image.- Parameters:
avatarUrl- the url for the user's avatar image
-
getDate
public java.util.Date getDate()
The date and time the message was sent.- Returns:
- The date
-
isFromCurrentUser
public boolean isFromCurrentUser()
Returns true if the message originated from the user, or false if the message comes from another participant.- Returns:
- Is the message from the current user
-
getMessageActions
public java.util.List<MessageAction> getMessageActions()
The list of Message Action objects contained in the message.- Returns:
- The message actions
-
addMessageAction
public void addMessageAction(MessageAction messageAction)
Adds a message action to the list of actions
-
removeMessageAction
public void removeMessageAction(MessageAction messageAction)
Removes a message action from the list of actions
-
getMessageItems
public java.util.List<MessageItem> getMessageItems()
The list of Message Item objects contained in the message.- Returns:
- The message items
-
addMessageItem
public void addMessageItem(MessageItem messageItem)
Adds a message item to the list of items
-
removeMessageItem
public void removeMessageItem(MessageItem messageItem)
Removes a message item from the list of items
-
getName
public java.lang.String getName()
The display name of the user. This property may be null if no display name could be determined.- Returns:
- The displayName
-
setName
public void setName(java.lang.String displayName)
Sets the user's displayName for the message.
-
getText
public java.lang.String getText()
The text content of the message.- Returns:
- The text
-
setText
public void setText(java.lang.String text)
Sets the text for the message.
-
getUploadStatus
public MessageUploadStatus getUploadStatus()
The upload status of the message.- Returns:
- The status
-
setUploadStatus
public void setUploadStatus(MessageUploadStatus uploadStatus)
-
isRead
public boolean isRead()
Return true if the message has been read- Returns:
- Flag indicating that the message has been read
-
getMetadata
public java.util.Map<java.lang.String,java.lang.Object> getMetadata()
The metadata of the message- Returns:
- The metadata (JSON Object)
-
setMetadata
public void setMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
Sets the metadata for the message
-
getPayload
public java.lang.String getPayload()
The message payload from an action- Returns:
- The message payload
-
setPayload
public void setPayload(java.lang.String payload)
Sets the payload for the message
-
getMediaUrl
public java.lang.String getMediaUrl()
The media URL of the message.- Returns:
- The media URL
-
setMediaUrl
public void setMediaUrl(java.lang.String mediaUrl)
Sets the media URL for the message
-
getMediaType
public java.lang.String getMediaType()
The media type of the message.- Returns:
- The media type
-
setMediaType
public void setMediaType(java.lang.String mediaType)
Sets the media type for the message
-
getMediaSize
public long getMediaSize()
The media size of the message.- Returns:
- The media size
-
setMediaSize
public void setMediaSize(long mediaSize)
Sets the media size for the message
-
getId
public java.lang.String getId()
The ID of the message.- Returns:
- The ID
-
setImage
public void setImage(android.graphics.Bitmap bitmap)
Sets the image for the message.
-
setFile
public void setFile(java.io.File file)
Sets the file for the message.
-
getImage
public android.graphics.Bitmap getImage()
The image of the message.- Returns:
- The image
-
getFile
public java.io.File getFile()
The file of the message.- Returns:
- The file
-
getTextFallback
public java.lang.String getTextFallback()
Text to display for unsupported message types- Returns:
- The text to display
-
setTextFallback
public void setTextFallback(java.lang.String textFallback)
Sets the text to display for unsupported message types
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getEntity
public MessageDto getEntity()
-
getType
public java.lang.String getType()
The message type- Returns:
- The message type
- See Also:
MessageType
-
setType
public void setType(java.lang.String type)
Sets the type of the message
-
hasReplies
public boolean hasReplies()
Returnstrueif the message has reply actions- Returns:
trueif the message has reply actions,falseotherwise
-
hasLocationRequest
public boolean hasLocationRequest()
Returnstrueif the message has a location request- Returns:
trueif the message has a location request,falseotherwise
-
getCoordinates
public Coordinates getCoordinates()
Returns Coordinates- Returns:
- Coordinates
-
setCoordinates
public void setCoordinates(Coordinates coordinates)
Sets the coordinates for the message
-
getDisplaySettings
public DisplaySettings getDisplaySettings()
Returns DisplaySettings for carousel messages- Returns:
- DisplaySettings
-
setDisplaySettings
public void setDisplaySettings(DisplaySettings displaySettings)
Sets the display settings for the message
-
hasValidCoordinates
public boolean hasValidCoordinates()
Returnstrueif the message has valid coordinates- Returns:
trueif the message has valid coordinates,falseotherwise
-
-