# Class: Messaging

## Constructor

#### new Messaging(messagingService)

  Messaging module provides Instant Messaging functionality of the SDK.
  For Messaging module namespace, see AvayaClientServices.Services.Messaging.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messagingService` | AvayaClientServices.Services.Messaging.MessagingService |

## Methods

#### createConversation() → {AvayaClientServices.Services.Messaging.Conversation}

  Creates new conversation.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#removeConversation
    - AvayaClientServices.Services.Messaging.Messaging#getActiveConversations

  ##### Returns:

  { AvayaClientServices.Services.Messaging.Conversation }

  Conversation object

#### getActiveConversations() → {AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation>}

  Returns list of conversations that user is currently in.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#createConversation
    - AvayaClientServices.Services.Messaging.Messaging#removeConversation

  ##### Returns:

  { AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation> }

  DataRetrieval of AvayaClientServices.Services.Messaging.Conversation objects

#### getAllActiveConversationsForContact(contact) → {AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation>}

  Returns all conversations that given contact is a participant of.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `contact` | AvayaClientServices.Contact.Contact |

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#getActiveConversations

  ##### Returns:

  { AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation> }

  DataRetrieval of AvayaClientServices.Services.Messaging.Conversation objects

#### getDraftConversations() → {Array.<AvayaClientServices.Services.Messaging.Conversation>}

  Returns list of draft conversations. We consider a conversation draft, when it exists only locally.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#getActiveConversations

  ##### Returns:

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

  Array of AvayaClientServices.Services.Messaging.Conversation objects

#### getNumberOfConversationsWithUnreadContent() → {Number}

  Returns number of conversations with unread content.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#getNumberOfConversationsWithUnreadContentSinceLastAccess

  ##### Returns:

  { Number }

  Number of conversations with unread content.

#### getNumberOfConversationsWithUnreadContentSinceLastAccess() → {Number}

  Returns number of Conversations with unread content since last access.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#getNumberOfConversationsWithUnreadContent

  ##### Returns:

  { Number }

  Number of conversations with unread content since last access.

#### getRoutableDomains() → {Array.<String>}

  Returns routable domains obtained from resource discovery.
  List of routable domains consists of all domains that are allowed to take part in Conversation.

  ##### Returns:

  { Array.<String> }

  List of routable domains

#### getSelfAddress() → {String}

  Returns address of Participant that user is currently logged in as.

  ##### Returns:

  { String }

  Self address

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

  Leaves all conversations that user is a member of.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#leaveConversations

  ##### Returns:

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

#### leaveConversations(conversations) → {AvayaClientServices.Base.Promise.<(Boolean|AvayaClientServices.Services.Messaging.MessagingError)>}

  Leaves the conversations specified in conversations array.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `conversations` | Array.<AvayaClientServices.Services.Messaging.Conversation> | Array of conversations to leave

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#leaveAllConversations

  ##### Returns:

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

#### removeConversation(conversation) → {AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Base.BaseError)>}

  Removes received conversation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `conversation` | AvayaClientServices.Services.Messaging.Conversation | Conversation to be removed.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#createConversation

  ##### Returns:

  { AvayaClientServices.Base.Promise.<(undefined|AvayaClientServices.Base.BaseError)> }

#### searchConversations(messagingQuery) → {AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation>}

  Searches for conversations and returns only ones that match the conditions described in messagingQuery.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messagingQuery` | AvayaClientServices.Services.Messaging.MessagingQuery | A MessagingQuery object

  ##### Returns:

  { AvayaClientServices.Base.DataRetrieval.<AvayaClientServices.Services.Messaging.Conversation> }

  DataRetrieval of AvayaClientServices.Services.Messaging.Conversation objects

#### start(userConfiguration) → {AvayaClientServices.Base.Promise.<(undefined|undefined)>}

  Starts the Messaging service.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `userConfiguration` | AvayaClientServices.Config.UserConfiguration |

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#stop

  ##### Returns:

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

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

  Stops the Messaging service.

  ##### See:

    - AvayaClientServices.Services.Messaging.Messaging#start

  ##### Returns:

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

#### validateAddresses(addressesToValidate) → {AvayaClientServices.Base.Promise.<(Array|AvayaClientServices.Services.Messaging.MessagingError)>}

  Validates addresses of users.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `addressesToValidate` | Array.<String> | Array of addresses to be validated

  ##### Returns:

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

### Managing callbacks

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

  Adds a new onMessagingLimitsChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Adds new onMessagingServiceAvailableCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Adds new onMessagingServiceUnavailableCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Adds new onNumberOfConversationsWithUnreadContentChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Adds new onNumberOfConversationsWithUnreadContentSinceLastAccessChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Adds new onRoutableDomainsChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onMessagingLimitsChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onMessagingServiceAvailableCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onMessagingServiceUnavailableCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onNumberOfConversationsWithUnreadContentChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onNumberOfConversationsWithUnreadContentSinceLastAccessChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

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

  Removes existing onRoutableDomainsChangedCallback.

  ##### Parameters:

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

  ##### Returns:

  { void }

### Capabilities

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

  Returns Capability object that indicates if conversation can be created.

           if (service is available and an endpoint for conversations exists)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

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

           if (service is available and an endpoint for marking messages as read exists)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

  Returns Capability object that indicates if a list of conversations can be retrieved.

           if (service is available and an endpoint for conversations exists)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

  Returns Capability object that indicates if search conversations can be performed.

           if (service is available and an endpoint for conversations exists)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

  Returns Capability object that indicates if messaging service can be started.

           if (service has already started)
               deny
           else
               allow

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

  Returns Capability object that indicates if participant can be validated by addresses.

           if (service is available and endpoint for address validation exists)
               allow
           else
               deny

  ##### Returns:

  { AvayaClientServices.Base.Capability }

## Type Definitions

#### onMessagingLimitsChangedCallback(messaging, limits) → {void}

  Interface for callback function to be invoked when messaging limits has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.
  `limits` | Object | New limits object.

  ##### Returns:

  { void }

#### onMessagingServiceAvailableCallback(messaging) → {void}

  Interface for callback function to be invoked when messaging service becomes available.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.

  ##### Returns:

  { void }

#### onMessagingServiceUnavailableCallback(messaging) → {void}

  Interface for callback function to be invoked when messaging service becomes unavailable.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.

  ##### Returns:

  { void }

#### onNumberOfConversationsWithUnreadContentChangedCallback(messaging, numberOfConversationWithUnreadContent) → {void}

  Interface for callback function to be invoked when number of conversation with unread content has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.
  `numberOfConversationWithUnreadContent` | Number | New number of conversations with unread content.

  ##### Returns:

  { void }

#### onNumberOfConversationsWithUnreadContentSinceLastAccessChangedCallback(messaging, numberOfConversationWithUnviewedContentSinceLastAccess) → {void}

  Interface for callback function to be invoked when number of conversations with unviewed content since last access has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.
  `numberOfConversationWithUnviewedContentSinceLastAccess` | Number | New number of conversations with unviewed content since last access.

  ##### Returns:

  { void }

#### onRoutableDomainsChangedCallback(messaging, routableDomains) → {void}

  Interface for callback function to be invoked when routable domains has changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `messaging` | AvayaClientServices.Services.Messaging.Messaging | Instance of messaging module.
  `routableDomains` | Array.<String> | New array of routable domains.

  ##### Returns:

  { void }