Class: SignalWire::Relay::RelayEvent

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

Overview

Base event wrapper for raw signalwire.event payloads. Subclasses provide typed accessors for specific event types.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_type:, params: {}, call_id: '', timestamp: 0.0) ⇒ RelayEvent

Returns a new instance of RelayEvent.



10
11
12
13
14
15
# File 'lib/signalwire/relay/relay_event.rb', line 10

def initialize(event_type:, params: {}, call_id: '', timestamp: 0.0)
  @event_type = event_type
  @params     = params
  @call_id    = call_id
  @timestamp  = timestamp
end

Instance Attribute Details

#call_idObject (readonly)

Returns the value of attribute call_id.



8
9
10
# File 'lib/signalwire/relay/relay_event.rb', line 8

def call_id
  @call_id
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



8
9
10
# File 'lib/signalwire/relay/relay_event.rb', line 8

def event_type
  @event_type
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/signalwire/relay/relay_event.rb', line 8

def params
  @params
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/signalwire/relay/relay_event.rb', line 8

def timestamp
  @timestamp
end

Class Method Details

.from_payload(payload) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/signalwire/relay/relay_event.rb', line 17

def self.from_payload(payload)
  et = payload['event_type'] || ''
  p  = payload['params'] || {}
  new(
    event_type: et,
    params:     p,
    call_id:    p['call_id'] || '',
    timestamp:  p['timestamp'] || 0.0
  )
end