# Class: Message

## Constructor

#### new Message(messageService, conversation)

  Messages are pieces of information shared between Participants in Conversation.
  Apart from content (body), they can also contain Attachments.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messageService` | AvayaClientServices.Services.Messaging.MessageService |
  `conversation` | AvayaClientServices.Services.Messaging.Conversation |

## Methods

#### createAttachment(file) → {AvayaClientServices.Services.Messaging.Attachment}

  Creates an attachment from file for this Message.
  It will automatically attach the attachment to this Message.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `file` | File |

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#removeDraftAttachment

  ##### Returns:

  { AvayaClientServices.Services.Messaging.Attachment }

#### getAttachments() → {Array.<AvayaClientServices.Services.Messaging.Attachment>}

  Returns all Message Attachments.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#createAttachment

  ##### Returns:

  { Array.<AvayaClientServices.Services.Messaging.Attachment> }

#### getBody() → {String}

  Returns Message content.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setBodyAndReportTyping

  ##### Returns:

  { String }

#### getConversationId() → {String}

  Returns ID of conversation message belongs to.

  ##### Returns:

  { String }

#### getFromParticipant() → {AvayaClientServices.Services.Messaging.Participant}

  Returns the Participant, who sent message.

  ##### Returns:

  { AvayaClientServices.Services.Messaging.Participant }

#### getHtmlBody() → {String}

  Returns HTML content of this Message.

  ##### Returns:

  { String }

#### getId() → {String}

  Returns message unique id.

  ##### Returns:

  { String }

#### getImportance() → {AvayaClientServices.Services.Messaging.MessageImportance}

  Returns Message importance (e.g. high or normal).

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setImportance

  ##### Returns:

  { AvayaClientServices.Services.Messaging.MessageImportance }

#### getInReplyTo() → {String}

  If message is a reply to other message, returns other message id.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setInReplyTo

  ##### Returns:

  { String }

#### getLastModifiedDate() → {Date}

  Returns date and time that message was last modified.

  ##### Returns:

  { Date }

#### getReceivedDate() → {Date}

  Returns date and time that message was received.

  ##### Returns:

  { Date }

#### getSensitivity() → {AvayaClientServices.Services.Messaging.SensitivityLevel}

  Returns Message sensitivity. Message sensitivity is usually inherited from Conversation sensitivity.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setSensitivity

  ##### Returns:

  { AvayaClientServices.Services.Messaging.SensitivityLevel }

#### getSessionType() → {AvayaClientServices.Services.Messaging.SessionType}

  Returns session type if type of message is SESSION.

  ##### Returns:

  { AvayaClientServices.Services.Messaging.SessionType }

#### getStatus() → {AvayaClientServices.Services.Messaging.ResourceStatus}

  Returns Message status (e.g. draft or published).

  ##### Returns:

  { AvayaClientServices.Services.Messaging.ResourceStatus }

#### getType() → {AvayaClientServices.Services.Messaging.MessageType}

  Returns Message type (e.g. subject changed, participant joined etc.).

  ##### Returns:

  { AvayaClientServices.Services.Messaging.MessageType }

#### hasAttachment() → {Boolean}

  Determines whether Message has attachments.

  ##### Returns:

  { Boolean }

#### hasHtmlBody() → {Boolean}

  Determines wheter Message carry HTML body.

  ##### Returns:

  { Boolean }

#### hasUnreadAttachment() → {Boolean}

  Determines whether Message has unread attachments.

  ##### Returns:

  { Boolean }

#### isCoalesced() → {Boolean}

  Returns Message "coalesced" flag. Message is coalesced, when:

  - previous message is from the same user
  - specified message date and time is within 60 seconds of previous one
  - specified message and previous message does not contain any attachments
  - specified message is not an event
  - specified message and previous message has no error conditions
  - specified message sensitivity level matches that of the previous message

  ##### Returns:

  { Boolean }

#### isDoNotForward() → {Boolean}

  Returns Message 'Do Not Forward' flag.
  If this flag is set to true then participant can reply to this message.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setDoNotForward

  ##### Returns:

  { Boolean }

#### isFromMe() → {boolean}

  Returns true if message is created by selfParticipant.

  ##### Returns:

  { boolean }

#### isPrivate() → {Boolean}

  Determines whether Message is private.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#setSensitivity

  ##### Returns:

  { Boolean }

#### isRead() → {Boolean}

  Determines whether Message has been read.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#markAsRead

  ##### Returns:

  { Boolean }

#### markAsRead() → {AvayaClientServices.Base.Promise.<(Object|Object)>}

  Mark message as read.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#isRead

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(Object|Object)> }

#### removeDraftAttachment(attachment) → {void}

  Removes draft Attachment from the Message.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `attachment` | AvayaClientServices.Services.Messaging.Attachment | Instance of Attachment.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#createAttachment

  ##### Returns:

  { void }

#### reportTyping(isComposing) → {void}

  Reports typing notification.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `isComposing` | boolean | Value indicates whether user is composing or not.

  ##### Returns:

  { void }

#### send() → {AvayaClientServices.Base.Promise.<(AvayaClientServices.Services.Messaging.Message|AvayaClientServices.Services.Messaging.MessagingError)>}

  Sends Message.

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(AvayaClientServices.Services.Messaging.Message|AvayaClientServices.Services.Messaging.MessagingError)> }

#### setBodyAndReportTyping(body) → {AvayaClientServices.Base.Promise.<(Number|AvayaClientServices.Services.Messaging.MessagingError)>}

  Sets the Message content and report typing.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `body` | String | message body

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#getBody

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(Number|AvayaClientServices.Services.Messaging.MessagingError)> }

#### setDoNotForward(value) → {void}

  Sets the Message "do not forward" flag.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | Boolean | New value of doNotForward flag.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#isDoNotForward

  ##### Returns:

  { void }

#### setImportance(importance) → {boolean}

  Sets the Message importance.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `importance` | AvayaClientServices.Services.Messaging.MessageImportance | New value of message importance.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#getImportance

  ##### Returns:

  { boolean }

#### setInReplyTo(inReplyToMessage) → {void}

  Sets the Message to be a reply to other message.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `inReplyToMessage` | AvayaClientServices.Services.Messaging.Message | Instance of Message.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#getInReplyTo

  ##### Returns:

  { void }

#### setSensitivity(sensitivity) → {void}

  Sets the Message sensitivity.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `sensitivity` | AvayaClientServices.Services.Messaging.SensitivityLevel | New Sensitivity level value.

  ##### See:

    - AvayaClientServices.Services.Messaging.Message#getSensitivity

  ##### Returns:

  { void }

### Managing callbacks

#### addOnBodyChangedCallback(callback) → {void}

  Adds new onBodyChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onBodyChangedCallback |

  ##### Returns:

  { void }

#### addOnDoNotForwardStatusChangedCallback(callback) → {void}

  Adds new onDoNotForwardStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onDoNotForwardStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnHasAttachmentStatusChangedCallback(callback) → {void}

  Adds new onHasAttachmentStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onHasAttachmentStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnHasUnreadAttachmentStatusChangedCallback(callback) → {void}

  Adds new onHasUnreadAttachmentStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onHasUnreadAttachmentStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnImportanceChangedCallback(callback) → {void}

  Adds new onImportanceChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onImportanceChangedCallback |

  ##### Returns:

  { void }

#### addOnInReplyToChangedCallback(callback) → {void}

  Adds new onInReplyToChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onInReplyToChangedCallback |

  ##### Returns:

  { void }

#### addOnIsCoalescedStatusChangedCallback(callback) → {void}

  Adds new onIsCoalescedStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsCoalescedStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnIsPrivateStatusChangedCallback(callback) → {void}

  Adds new onIsPrivateStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsPrivateStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnIsReadStatusChangedCallback(callback) → {void}

  Adds new onIsReadStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsReadStatusChangedCallback |

  ##### Returns:

  { void }

#### addOnLastModifiedDateChangedCallback(callback) → {void}

  Adds new onLastModifiedDateChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onLastModifiedDateChangedCallback |

  ##### Returns:

  { void }

#### addOnSensitivityChangedCallback(callback) → {void}

  Adds new onSensitivityChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onSensitivityChangedCallback |

  ##### Returns:

  { void }

#### addOnStatusChangedCallback(callback) → {void}

  Adds new onStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnBodyChangedCallback(callback) → {void}

  Removes existing onBodyChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onBodyChangedCallback |

  ##### Returns:

  { void }

#### removeOnDoNotForwardStatusChangedCallback(callback) → {void}

  Delete existing onDoNotForwardStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onDoNotForwardStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnHasAttachmentStatusChangedCallback(callback) → {void}

  Removes existing onHasAttachmentStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onHasAttachmentStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnHasUnreadAttachmentStatusChangedCallback(callback) → {void}

  Removes existing onHasUnreadAttachmentStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onHasUnreadAttachmentStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnImportanceChangedCallback(callback) → {void}

  Removes existing onImportanceChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onImportanceChangedCallback |

  ##### Returns:

  { void }

#### removeOnInReplyToChangedCallback(callback) → {void}

  Removes existing onInReplyToChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onInReplyToChangedCallback |

  ##### Returns:

  { void }

#### removeOnIsCoalescedStatusChangedCallback(callback) → {void}

  Removes existing onIsCoalescedStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsCoalescedStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnIsPrivateStatusChangedCallback(callback) → {void}

  Delete existing onIsPrivateStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsPrivateStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnIsReadStatusChangedCallback(callback) → {void}

  Removes existing onIsReadStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onIsReadStatusChangedCallback |

  ##### Returns:

  { void }

#### removeOnLastModifiedDateChangedCallback(callback) → {void}

  Removes existing onLastModifiedDateChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onLastModifiedDateChangedCallback |

  ##### Returns:

  { void }

#### removeOnSensitivityChangedCallback(callback) → {void}

  Removes existing onSensitivityChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onSensitivityChangedCallback |

  ##### Returns:

  { void }

#### removeOnStatusChangedCallback(callback) → {void}

  Removes existing onStatusChangedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Messaging.Message#onStatusChangedCallback |

  ##### Returns:

  { void }

### Capabilities

#### getCreateAttachmentCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if attachment can be created.

           if (message is DRAFT_UNSENT)
               if (resource discovery provides size limits for attachments)
                   if (attachment's size is within the limits found in resource discovery)
                       allow
                   else
                       deny
               else
                   allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getMarkAsReadCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message can be marked as read.

           if (message is already read)
               deny
           if (service is not available)
               deny
           else
               allow

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getRemoveCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message can be removed.

           if (message is DRAFT_UNSENT)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getSendCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message can be sent.

           if (message is DRAFT_UNSENT && conversation is active && conversation is not closed)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getUpdateBodyCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if body can be updated.

           if (message is DRAFT_UNSENT)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getUpdateDoNotForwardCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message doNotForward property can be changed.

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getUpdateImportanceCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message importance property can be changed.

           if (message is DRAFT_UNSENT)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getUpdateInReplyToCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message inReplyTo property can be changed.

           if (message is DRAFT_UNSENT)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

#### getUpdateSensitivityCapability() → {AvayaClientServices.Base.Capability}

  Returns Capability object that indicates if message sensitivity property can be changed.

           if (message is DRAFT_UNSENT && conversation is DRAFT_UNSENT)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

## Type Definitions

#### onBodyChangedCallback(message, newBody) → {void}

  Interface for callback function to be invoked when message body has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `newBody` | string | New message body.

  ##### Returns:

  { void }

#### onDoNotForwardStatusChangedCallback(message, doNotForward) → {void}

  Interface for callback function to be invoked when message doNotForward flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `doNotForward` | boolean | New doNotForward value.

  ##### Returns:

  { void }

#### onHasAttachmentStatusChangedCallback(message, hasAttachment) → {void}

  Interface for callback function to be invoked when message hasAttachment flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `hasAttachment` | boolean | New hasAttachment value.

  ##### Returns:

  { void }

#### onHasUnreadAttachmentStatusChangedCallback(message, hasUnreadAttachment) → {void}

  Interface for callback function to be invoked when message hasUnreadAttachment flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `hasUnreadAttachment` | boolean | New hasUnreadAttachment value.

  ##### Returns:

  { void }

#### onImportanceChangedCallback(message, messageImportance) → {void}

  Interface for callback function to be invoked when message importance has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `messageImportance` | AvayaClientServices.Services.Messaging.MessageImportance | New message importance value.

  ##### Returns:

  { void }

#### onInReplyToChangedCallback(message, messageId) → {void}

  Interface for callback function to be invoked when message in reply to status has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `messageId` | String | Id of other message, that this message is a reply to.

  ##### Returns:

  { void }

#### onIsCoalescedStatusChangedCallback(message, isCoalesced) → {void}

  Interface for callback function to be invoked when message isCoalesced flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `isCoalesced` | boolean | New isCoalesced value.

  ##### Returns:

  { void }

#### onIsPrivateStatusChangedCallback(message, isPrivate) → {void}

  Interface for callback function to be invoked when message isPrivate flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `isPrivate` | boolean | New isPrivate value.

  ##### Returns:

  { void }

#### onIsReadStatusChangedCallback(message, isRead) → {void}

  Interface for callback function to be invoked when message isRead flag has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `isRead` | boolean | New isRead value.

  ##### Returns:

  { void }

#### onLastModifiedDateChangedCallback(message, newDate) → {void}

  Interface for callback function to be invoked when message last modified date has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `newDate` | Date | New last modified date.

  ##### Returns:

  { void }

#### onSensitivityChangedCallback(message, sensitivity) → {void}

  Interface for callback function to be invoked when message sensitivity level has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `sensitivity` | AvayaClientServices.Services.Messaging.SensitivityLevel | New sensitivity value.

  ##### Returns:

  { void }

#### onStatusChangedCallback(message, resourceStatus) → {void}

  Interface for callback function to be invoked when message resource status has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | AvayaClientServices.Services.Messaging.Message | Instance of message.
  `resourceStatus` | AvayaClientServices.Services.Messaging.ResourceStatus | New resource status value.

  ##### Returns:

  { void }