Class: SignalWire::Relay::CallStateEvent

Inherits:
RelayEvent
  • Object
show all
Defined in:
lib/signalwire/relay/relay_event.rb

Overview

calling.call.state

Instance Attribute Summary collapse

Attributes inherited from RelayEvent

#call_id, #event_type, #params, #timestamp

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call_state: '', end_reason: '', direction: '', device: {}, **base) ⇒ CallStateEvent

Returns a new instance of CallStateEvent.



46
47
48
49
50
51
52
# File 'lib/signalwire/relay/relay_event.rb', line 46

def initialize(call_state: '', end_reason: '', direction: '', device: {}, **base)
  super(**base)
  @call_state = call_state
  @end_reason = end_reason
  @direction  = direction
  @device     = device
end

Instance Attribute Details

#call_stateObject (readonly)

Returns the value of attribute call_state.



31
32
33
# File 'lib/signalwire/relay/relay_event.rb', line 31

def call_state
  @call_state
end

#deviceObject (readonly)

Returns the value of attribute device.



31
32
33
# File 'lib/signalwire/relay/relay_event.rb', line 31

def device
  @device
end

#directionObject (readonly)

Returns the value of attribute direction.



31
32
33
# File 'lib/signalwire/relay/relay_event.rb', line 31

def direction
  @direction
end

#end_reasonObject (readonly)

Returns the value of attribute end_reason.



31
32
33
# File 'lib/signalwire/relay/relay_event.rb', line 31

def end_reason
  @end_reason
end

Class Method Details

.from_payload(payload) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/signalwire/relay/relay_event.rb', line 33

def self.from_payload(payload)
  base = RelayEvent.from_payload(payload)
  p = base.params
  new(
    event_type: base.event_type, params: base.params,
    call_id: base.call_id, timestamp: base.timestamp,
    call_state: p['call_state'] || '',
    end_reason: p['end_reason'] || '',
    direction:  p['direction'] || '',
    device:     p['device'] || {}
  )
end