lib/Stub/CallEvents.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 51
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 51
rs 10
wmc 4
mnd 0
bc 4
fnc 4
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A CallEvents.js ➔ factory 0 18 1
1
var CallEvents = {}
2
3
function factory (name, defaults) {
4
  defaults = defaults || {}
5
  var fullName = 'Call.' + name
6
  var event = function (data) {
7
    var self = this
8
    data = data || {}
9
    Object.defineProperty(this, 'name', {value: fullName, writable: false})
10
    Object.keys(defaults).forEach(function (key) {
11
      self[key] = defaults[key]
12
    })
13
    Object.keys(data).forEach(function (key) {
14
      self[key] = data[key]
15
    })
16
  }
17
  event.name = fullName
18
  event._properties = Object.keys(defaults)
19
  CallEvents[name] = event
20
}
21
22
factory('AudioStarted', {call: {}, headers: {}})
23
factory('Connected', {call: {}, customData: ''})
24
factory('Disconnected', {call: {}, cost: 0, duration: 0, headers: {}})
25
factory('Failed', {call: {}, code: 486, headers: {}, reason: {}})
26
factory('FirstVideoPacket', {call: {}, url: {}})
27
factory('InfoReceived', {body: '', call: {}, headers: {}, mimeType: 'application/json'})
28
factory('MessageReceived', {call: {}, headers: {}, text: ''})
29
factory('MicStatusChange', {active: false, call: {}})
30
factory('OffHold', {call: {}})
31
factory('OnHold', {call: {}})
32
factory('PlaybackFinished', {call: {}, error: null})
33
factory('ReInviteAccepted', {body: '', call: {}, headers: {}, mimeType: 'application/json'})
34
factory('ReInviteReceived', {body: '', call: {}, headers: {}, mimeType: 'application/json'})
35
factory('ReInviteRejected', {call: {}, headers: {}})
36
factory('RecordStarted', {call: {}, url: ''})
37
factory('RecordStopped', {call: {}, url: ''})
38
factory('Ringing', {call: {}, headers: {}})
39
factory('Statistics', {call: {}})
40
factory('ToneDetected', {ProgressTone: true, VoicemailTone: false, call: {}})
41
factory('ToneReceived', {call: {}, tone: ''})
42
factory('TransferComplete', {call: {}})
43
factory('VideoTrackCreated', {call: {}, url: ''})
44
factory('VoicemailPromptDetected', {call: {}, pattern: ''})
45
factory('VoicemailPromptNotDetected', {call: {}, pattern: ''})
46
factory('VoicemailToneDetected', {call: {}, frequency: 0})
47
factory('VoicemailToneNotDetected', {call: {}})
48
49
module.exports = {
50
  CallEvents: CallEvents
51
}
52