# Class: Calls

## Constructor

#### new Calls(callManager, callService)

  Provides call functionality to the client application. For call module namespace, see Call.

  This class provides the APIs to create new calls, get the information about the user's existing calls and receive incoming calls.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callManager` | AvayaClientServices.Services.Call.CallManager |
  `callService` | AvayaClientServices.Services.Call.CallService |

## Methods

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

  Adds onRingbackToneURLsChanged callback

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onRingbackToneURLsChangedCallback |

  ##### Returns:

  { void }

#### createCall(callCreationInfo) → {AvayaClientServices.Services.Call.Call}

  Creates a new outgoing call.

  Call creation is always successful and a newly created call instance is returned synchronously.
  In order to understand whether the call can be successfully set up, the client application should call Call.start().

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callCreationInfo` | AvayaClientServices.Services.Call.CallCreationInfo | Desired settings for the call to be created.

  ##### Returns:

  { AvayaClientServices.Services.Call.Call }

  Object for the new outgoing call.

#### createDefaultCall() → {AvayaClientServices.Services.Call.Call}

  Creates a new outgoing call in MPaaS environment.

  ##### Throws:

  AvayaClientServices.Services.Call.CallException

  ##### Returns:

  { AvayaClientServices.Services.Call.Call }

  Object for the new outgoing call.

#### getActiveCall() → {AvayaClientServices.Services.Call.Call}

  Returns current locally established active call. An active call is local and in the established state.
  The active call is undefined if there are no local calls or all local calls are in the held state.

  ##### Returns:

  { AvayaClientServices.Services.Call.Call }

#### getCallCount() → {number}

  Returns the number of the calls currently in progress including both local and remote.

  ##### Returns:

  { number }

#### getCalls() → {Array.<AvayaClientServices.Services.Call.Call>}

  Gets the calls currently in progress including both local and remote.

  ##### Returns:

  { Array.<AvayaClientServices.Services.Call.Call> }

#### getCredentialProvider() → {CredentialProvider|undefined}

  Returns calls credential provider. The returned type will be MPCCredentialTokenProvider when using a mediaServicesContext.

  ##### Returns:

  { CredentialProvider | undefined }

#### getIgnoredCalls() → {Array.<AvayaClientServices.Services.Call.Call>}

  Returns the calls that are currently in the ignored state.

  ##### Returns:

  { Array.<AvayaClientServices.Services.Call.Call> }

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

  Deprecated:
    - Returns an indication as to whether the removal of theEvents Subscriptions are enabled. It depends if the server connection was established and the presence of the events URL. This method is for internal use only and will be removed without further notice.

  ##### Returns:

  { AvayaClientServices.Base.Capability }

  Object describing whether Events Subscriptions are enabled.

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

  Deprecated:
    - Returns an indication as to whether the creation of Events Subscriptions are enabled. It depends if the server connection was established and the presence of the events URL. This method is for internal use only and will be removed without further notice.

  ##### Returns:

  { AvayaClientServices.Base.Capability }

  Object describing whether Events Subscriptions are enabled.

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

  Returns video capability based on license, user configuration and available network.

  ##### Returns:

  { AvayaClientServices.Base.Capability }

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

  Returns an indication as to whether VoIP calls are available. It depends on the user configuration, network availability and WebRTC technology support by the browser.

  ##### Returns:

  { AvayaClientServices.Base.Capability }

  Object describing whether VoIP calling is allowed.

#### hasHeldCall() → {boolean}

  Returns a boolean value indicating whether there is at least one call in the held state.

  ##### Returns:

  { boolean }

  True if there is at least one call in the held state, or false otherwise.

#### hasInitiatingCall() → {boolean}

  Returns a flag indicating whether there is at least one call being initiated.

  ##### Returns:

  { boolean }

  True if there is at least one call initiated but not yet established, or false otherwise.

#### isAvailable() → {boolean}

  Returns true if Calls service is available; otherwise, false.

  ##### Returns:

  { boolean }

#### removeOnNetworkEvents() → {AvayaClientServices.Base.Promise}

  Deprecated:
    - Unsusbcribe to network events. This method is for internal use only and will be removed without further notice.

  ##### Returns:

  { AvayaClientServices.Base.Promise }

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

  Removes onRingbackToneURLsChanged callback

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onRingbackToneURLsChangedCallback |

  ##### Returns:

  { void }

#### setOnNetworkEvents(acceptedEvents, onNetworkEventCallback) → {AvayaClientServices.Base.Promise}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `acceptedEvents` | Object |
  `onNetworkEventCallback` | AvayaClientServices.Services.Call.Calls#onNetworkEventCallback |

  Deprecated:
    - Susbcribe to network events. This method is for internal use only and will be removed without further notice.

  ##### Returns:

  { AvayaClientServices.Base.Promise }

### Callbacks

#### addOnCallCreatedCallback(callback)

  Adds new onCallCreatedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallCreatedCallback |

#### addOnCallRemovedCallback(callback)

  Adds new onCallRemovedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallRemovedCallback |

#### addOnCallsServiceAvailableCallback(callback)

  Adds new onCallsServiceAvailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallsServiceAvailableCallback |

#### addOnCallsServiceUnavailableCallback(callback)

  Adds new onCallsServiceUnavailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallsServiceUnavailableCallback |

#### addOnIncomingCallCallback(callback)

  Adds new onIncomingCallCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onIncomingCallCallback |

#### addOnMakeCallRequestedCallback(callback)

  Adds new onMakeCallRequestedCallback

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onMakeCallRequestedCallback |

#### addOnUndeliveredCallCallback(callback)

  Adds new onUndeliveredCallCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onUndeliveredCallCallback |

#### removeOnCallCreatedCallback(callback)

  Removes existing onCallCreatedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallCreatedCallback |

#### removeOnCallRemovedCallback(callback)

  Removes existing onCallRemovedCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallRemovedCallback |

#### removeOnCallsServiceAvailableCallback(callback)

  Removes existing onCallsServiceAvailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallsServiceAvailableCallback |

#### removeOnCallsServiceUnavailableCallback(callback)

  Removes existing onCallsServiceUnavailableCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onCallsServiceUnavailableCallback |

#### removeOnIncomingCallCallback(callback)

  Removes existing onIncomingCallCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onIncomingCallCallback |

#### removeOnMakeCallRequestedCallback(callback)

  Removes existing onMakeCallRequestedCallback

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onMakeCallRequestedCallback |

#### removeOnUndeliveredCallCallback(callback)

  Removes existing onUndeliveredCallCallback.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | AvayaClientServices.Services.Call.Calls#onUndeliveredCallCallback |

## Type Definitions

#### onCallCreatedCallback(call)

  Interface for the callback function to be invoked when a new call is created.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `call` | AvayaClientServices.Services.Call.Call | The new call.

#### onCallRemovedCallback(call)

  Interface for the callback function to be invoked when the existing call is removed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `call` | AvayaClientServices.Services.Call.Call | The removed call.

#### onCallsServiceAvailableCallback(calls)

  Interface for the callback function to be invoked when the call service is available.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `calls` | AvayaClientServices.Services.Call.Calls | Calls module instance.

#### onCallsServiceUnavailableCallback(calls)

  Interface for the callback function to be invoked when the call service is unavailable.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `calls` | AvayaClientServices.Services.Call.Calls | Calls module instance.

#### onIncomingCallCallback(call)

  Interface for the callback function to be invoked when an incoming call is received.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `call` | AvayaClientServices.Services.Call.Call | The incoming call.

#### onMakeCallRequestedCallback(call)

  Interface for the callback function to be invoked when remote expects a response to a make call request

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `call` | AvayaClientServices.Services.Call.Call | The make call expecting a confirmation

#### onNetworkEventCallback(events)

  The callback function to be invoked when a new network event is received.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `events` | Object | The new event received.

#### onRingbackToneURLsChangedCallback(ringbackToneURLs) → {void}

  Interface for the callback function to be invoked when ringback tone URLs were changed.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `ringbackToneURLs` | AvayaClientServices.Services.Call.RingbackToneURLs |

  ##### Returns:

  { void }

#### onUndeliveredCallCallback(calls, call)

  Interface for the callback function to be invoked when the call service is informed of the incoming call that was not delivered to the local application due to an active server feature, such as call forwarding or send all calls. If required, the application can use the information in this call object to update its call history records. Since the call is already ended, no further events will be sent for it.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `calls` | AvayaClientServices.Services.Call.Calls | Calls module instance.
  `call` | AvayaClientServices.Services.Call.Call | The undelivered call.