Class: TurnKit::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/turnkit/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, turn_id:, conversation_id:, payload: {}, created_at: Clock.now) ⇒ Event

Returns a new instance of Event.



7
8
9
10
11
12
13
# File 'lib/turnkit/event.rb', line 7

def initialize(type:, turn_id:, conversation_id:, payload: {}, created_at: Clock.now)
  @type = type.to_s
  @turn_id = turn_id
  @conversation_id = conversation_id
  @payload = payload || {}
  @created_at = created_at
end

Instance Attribute Details

#conversation_idObject (readonly)

Returns the value of attribute conversation_id.



5
6
7
# File 'lib/turnkit/event.rb', line 5

def conversation_id
  @conversation_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/turnkit/event.rb', line 5

def created_at
  @created_at
end

#payloadObject (readonly)

Returns the value of attribute payload.



5
6
7
# File 'lib/turnkit/event.rb', line 5

def payload
  @payload
end

#turn_idObject (readonly)

Returns the value of attribute turn_id.



5
6
7
# File 'lib/turnkit/event.rb', line 5

def turn_id
  @turn_id
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/turnkit/event.rb', line 5

def type
  @type
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
# File 'lib/turnkit/event.rb', line 15

def to_h
  {
    "type" => type,
    "turn_id" => turn_id,
    "conversation_id" => conversation_id,
    "payload" => payload,
    "created_at" => created_at
  }
end