Skip to content
Kward Search API index

Class: Kward::Transport::Host::PluginChatTurn

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/transport/host.rb

Overview

Handle for an asynchronously running plugin-chat turn.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, handle, actor) ⇒ PluginChatTurn

Returns a new instance of PluginChatTurn.



254
255
256
257
258
259
# File 'lib/kward/transport/host.rb', line 254

def initialize(host, handle, actor)
  @host = host
  @actor = actor
  @id = handle.id.to_s.freeze
  @chat_id = handle.chat_id.to_s.freeze
end

Instance Attribute Details

#chat_idObject (readonly)

Returns the value of attribute chat_id.



252
253
254
# File 'lib/kward/transport/host.rb', line 252

def chat_id
  @chat_id
end

#idObject (readonly)

Returns the value of attribute id.



252
253
254
# File 'lib/kward/transport/host.rb', line 252

def id
  @id
end

Instance Method Details

#cancelObject



275
276
277
278
# File 'lib/kward/transport/host.rb', line 275

def cancel
  @host.authorize!(:cancel_plugin_chat_turn, actor: @actor, chat_id: @chat_id, turn_id: @id)
  @host.plugin_chat_gateway.cancel_transport_plugin_chat_turn(turn_id: @id)
end

#events(after: nil) ⇒ Object



267
268
269
# File 'lib/kward/transport/host.rb', line 267

def events(after: nil)
  @host.plugin_chat_gateway.transport_plugin_chat_turn_events(turn_id: @id, after: after)
end

#statusObject



271
272
273
# File 'lib/kward/transport/host.rb', line 271

def status
  @host.plugin_chat_gateway.transport_plugin_chat_turn_status(turn_id: @id)
end

#subscribe(after: nil, &block) ⇒ Object

Raises:

  • (ArgumentError)


261
262
263
264
265
# File 'lib/kward/transport/host.rb', line 261

def subscribe(after: nil, &block)
  raise ArgumentError, "plugin chat turn subscription requires a block" unless block

  @host.plugin_chat_gateway.subscribe_transport_plugin_chat_turn(turn_id: @id, after: after, &block)
end