Class: SignalWire::Relay::MessageStateEvent

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

Overview

messaging.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(message_id: '', context: '', direction: '', from_number: '', to_number: '', body: '', media: [], segments: 0, message_state: '', reason: '', tags: [], **base) ⇒ MessageStateEvent

Returns a new instance of MessageStateEvent.



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# File 'lib/signalwire/relay/relay_event.rb', line 618

def initialize(message_id: '', context: '', direction: '', from_number: '',
               to_number: '', body: '', media: [], segments: 0,
               message_state: '', reason: '', tags: [], **base)
  super(**base)
  @message_id    = message_id
  @context       = context
  @direction     = direction
  @from_number   = from_number
  @to_number     = to_number
  @body          = body
  @media         = media
  @segments      = segments
  @message_state = message_state
  @reason        = reason
  @tags          = tags
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def body
  @body
end

#contextObject (readonly)

Returns the value of attribute context.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def context
  @context
end

#directionObject (readonly)

Returns the value of attribute direction.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def direction
  @direction
end

#from_numberObject (readonly)

Returns the value of attribute from_number.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def from_number
  @from_number
end

#mediaObject (readonly)

Returns the value of attribute media.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def media
  @media
end

#message_idObject (readonly)

Returns the value of attribute message_id.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def message_id
  @message_id
end

#message_stateObject (readonly)

Returns the value of attribute message_state.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def message_state
  @message_state
end

#reasonObject (readonly)

Returns the value of attribute reason.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def reason
  @reason
end

#segmentsObject (readonly)

Returns the value of attribute segments.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def segments
  @segments
end

#tagsObject (readonly)

Returns the value of attribute tags.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def tags
  @tags
end

#to_numberObject (readonly)

Returns the value of attribute to_number.



595
596
597
# File 'lib/signalwire/relay/relay_event.rb', line 595

def to_number
  @to_number
end

Class Method Details

.from_payload(payload) ⇒ Object



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
# File 'lib/signalwire/relay/relay_event.rb', line 598

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,
    message_id:    p['message_id'] || '',
    context:       p['context'] || '',
    direction:     p['direction'] || '',
    from_number:   p['from_number'] || '',
    to_number:     p['to_number'] || '',
    body:          p['body'] || '',
    media:         p['media'] || [],
    segments:      p['segments'] || 0,
    message_state: p['message_state'] || '',
    reason:        p['reason'] || '',
    tags:          p['tags'] || []
  )
end