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 void
addMessageAction(MessageAction messageAction)
Adds a message action to the list of actionsvoid
addMessageItem(MessageItem messageItem)
Adds a message item to the list of itemsint
compareTo(Message o)
Message
copy()
boolean
equals(java.lang.Object o)
java.lang.String
getAvatarUrl()
The url for the user's avatar image.Coordinates
getCoordinates()
Returns Coordinatesjava.util.Date
getDate()
The date and time the message was sent.DisplaySettings
getDisplaySettings()
Returns DisplaySettings for carousel messagesMessageDto
getEntity()
java.io.File
getFile()
The file of the message.java.lang.String
getId()
The ID of the message.android.graphics.Bitmap
getImage()
The image of the message.long
getMediaSize()
The media size of the message.java.lang.String
getMediaType()
The media type of the message.java.lang.String
getMediaUrl()
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.String
getName()
The display name of the user.java.lang.String
getPayload()
The message payload from an actionjava.lang.String
getText()
The text content of the message.java.lang.String
getTextFallback()
Text to display for unsupported message typesjava.lang.String
getType()
The message typeMessageUploadStatus
getUploadStatus()
The upload status of the message.java.lang.String
getUserId()
The id for the user.java.lang.String
getUserRole()
The Role for the user.int
hashCode()
boolean
hasLocationRequest()
Returnstrue
if the message has a location requestboolean
hasReplies()
Returnstrue
if the message has reply actionsboolean
hasValidCoordinates()
Returnstrue
if the message has valid coordinatesboolean
isCarousel()
boolean
isFromCurrentUser()
Returns true if the message originated from the user, or false if the message comes from another participant.boolean
isRead()
Return true if the message has been readvoid
removeMessageAction(MessageAction messageAction)
Removes a message action from the list of actionsvoid
removeMessageItem(MessageItem messageItem)
Removes a message item from the list of itemsvoid
setAvatarUrl(java.lang.String avatarUrl)
Sets the url for the user's avatar image.void
setCoordinates(Coordinates coordinates)
Sets the coordinates for the messagevoid
setDisplaySettings(DisplaySettings displaySettings)
Sets the display settings for the messagevoid
setFile(java.io.File file)
Sets the file for the message.void
setImage(android.graphics.Bitmap bitmap)
Sets the image for the message.void
setMediaSize(long mediaSize)
Sets the media size for the messagevoid
setMediaType(java.lang.String mediaType)
Sets the media type for the messagevoid
setMediaUrl(java.lang.String mediaUrl)
Sets the media URL for the messagevoid
setMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
Sets the metadata for the messagevoid
setName(java.lang.String displayName)
Sets the user's displayName for the message.void
setPayload(java.lang.String payload)
Sets the payload for the messagevoid
setText(java.lang.String text)
Sets the text for the message.void
setTextFallback(java.lang.String textFallback)
Sets the text to display for unsupported message typesvoid
setType(java.lang.String type)
Sets the type of the messagevoid
setUploadStatus(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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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()
Returnstrue
if the message has reply actions- Returns:
true
if the message has reply actions,false
otherwise
-
hasLocationRequest
public boolean hasLocationRequest()
Returnstrue
if the message has a location request- Returns:
true
if the message has a location request,false
otherwise
-
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()
Returnstrue
if the message has valid coordinates- Returns:
true
if the message has valid coordinates,false
otherwise
-
-