# Class: User

## Constructor

#### new User(conf, mediaServicesFactory, sdkVersion)

  User provides configurations and access to all the modules - Call, Collaboration, Conference, Contacts, Messaging, Presence, VoiceMessaging.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `conf` | AvayaClientServices.Config.UserConfiguration |
  `mediaServicesFactory` | AvayaClientServices.Base.MediaServicesFactory |
  `sdkVersion` | string | SDK version.

## Methods

#### getCalls() → {AvayaClientServices.Services.Call.Calls}

  Gets an instance of the Calls module.

  ##### Returns:

  { AvayaClientServices.Services.Call.Calls }

#### getCollaboration() → {AvayaClientServices.Services.Collaboration.Collaboration}

  TODO: Remove when it becomes obsolete.
  Gets an instance of the Collaboration module.

  Deprecated:
    - Since implementation multi collaborations feature.

  ##### Returns:

  { AvayaClientServices.Services.Collaboration.Collaboration }

#### getCollaborations() → {AvayaClientServices.Services.Collaboration.Collaborations}

  Gets an instance of the Collaborations module.

  ##### Returns:

  { AvayaClientServices.Services.Collaboration.Collaborations }

#### getContacts() → {AvayaClientServices.Services.Contacts.Contacts}

  Gets an instance of the Contacts module.

  ##### Returns:

  { AvayaClientServices.Services.Contacts.Contacts }

#### getMessaging() → {AvayaClientServices.Services.Messaging.Messaging}

  Gets an instance of the Messaging module.

  ##### Returns:

  { AvayaClientServices.Services.Messaging.Messaging }

#### getPresenceService() → {AvayaClientServices.Services.Presence.PresenceService}

  Gets an instance of the PresenceService module.

  ##### Returns:

  { AvayaClientServices.Services.Presence.PresenceService }

#### getSelfContact() → {AvayaClientServices.Services.Contacts.Contact|undefined}

  Gets the contact information for the currently logged-in user.
  It is possible for no contact record to be found for the current user. In this case the application
  should fall back to other methods for retrieving or displaying contact information for the current user.

  Function returns undefined value until Contacts module successfully starts.
  Use onContactsServiceAvailableCallback to determine when to call this function.

  ##### See:

    - {AvayaClientServices.Services.Contacts.Contacts#onContactsServiceAvailableCallback}

  ##### Returns:

  { AvayaClientServices.Services.Contacts.Contact | undefined }

#### getVoiceMessaging() → {AvayaClientServices.Services.VoiceMessaging.VoiceMessaging}

  Gets an instance of the VoiceMessaging module.

  ##### Returns:

  { AvayaClientServices.Services.VoiceMessaging.VoiceMessaging }

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

  Starts all the configured services.

  ##### Returns:

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

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

  Stops all the running services.

  ##### Returns:

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

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

  Stops all the running services immediately. This function should only be called before window closes.
  It will cleanup active calls, but all other services will perform minimal cleanup.

  ##### Returns:

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

### Managing callbacks

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

  Adds new onUserRegistrationFailed callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserRegistrationFailed |

  ##### Returns:

  { void }

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

  Adds new onUserRegistrationSuccessful callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserRegistrationSuccessful |

  ##### Returns:

  { void }

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

  Adds new onUserUnregistrationFailed callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserUnregistrationFailed |

  ##### Returns:

  { void }

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

  Adds new onUserUnregistrationSuccessful callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserUnregistrationSuccessful |

  ##### Returns:

  { void }

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

  Removes existing onUserRegistrationFailed callback.
  For registered user, it will be returned upon receiving calls service activation failure response from AAWG.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserRegistrationFailed |

  ##### Returns:

  { void }

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

  Removes existing onUserRegistrationSuccessful callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserRegistrationSuccessful |

  ##### Returns:

  { void }

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

  Removes existing onUserUnregistrationFailed callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserUnregistrationFailed |

  ##### Returns:

  { void }

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

  Removes existing onUserUnregistrationSuccessful callback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.User#onUserUnregistrationSuccessful |

  ##### Returns:

  { void }

## Type Definitions

#### onUserRegistrationFailed(user) → {void}

  Interface for the callback function to be invoked when the user registration failed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `user` | AvayaClientServices.User | User session that the callback is associated with.

  ##### Returns:

  { void }

#### onUserRegistrationSuccessful(conferenceTokenHref) → {void}

  Interface for the callback function to be invoked when the user registration is completed successfully.
  For registered user, it will be returned upon receiving calls service activation success response from AAWG.
  For MPaaS, external gateway, and guest users it will be returned when call service is available.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `conferenceTokenHref` | string | Deprecated. Please use Portal for token retrieval.

  ##### Returns:

  { void }

#### onUserUnregistrationFailed(user) → {void}

  Interface for the callback function to be invoked when the user unregistration failed during User.stop() and User.stopImmediately().

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `user` | AvayaClientServices.User | User session that the callback is associated with.

  ##### Returns:

  { void }

#### onUserUnregistrationSuccessful(user) → {void}

  Interface for the callback function to be invoked when the user unregistration is completed successfully during User.stop() and User.stopImmediately().

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `user` | AvayaClientServices.User | User session that the callback is associated with.

  ##### Returns:

  { void }