Class: Aws::Lex::Conversation::Type::Checkpoint

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/aws/lex/conversation/type/checkpoint.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

included

Class Method Details

.build(opts = {}) ⇒ Object



24
25
26
# File 'lib/aws/lex/conversation/type/checkpoint.rb', line 24

def build(opts = {})
  new(normalize_parameters(opts))
end

Instance Method Details

#restore(conversation, opts = {}) ⇒ Object

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/aws/lex/conversation/type/checkpoint.rb', line 52

def restore(conversation, opts = {})
  case dialog_action_type.raw
  when 'Close'
    conversation.close(
      intent: intent,
      fulfillment_state: opts.fetch(:fulfillment_state) { fulfillment_state },
      messages: opts.fetch(:messages)
    )
  when 'ConfirmIntent'
    conversation.confirm_intent(
      intent: intent,
      messages: opts.fetch(:messages)
    )
  when 'Delegate'
    conversation.delegate(
      intent: intent
    )
  when 'ElicitIntent'
    conversation.elicit_intent(
      intent: intent,
      messages: opts.fetch(:messages)
    )
  when 'ElicitSlot'
    conversation.elicit_slot(
      intent: intent,
      messages: opts.fetch(:messages),
      slot_to_elicit: slot_to_elicit
    )
  else
    raise ArgumentError, "invalid DialogActionType: `#{dialog_action_type.raw}`"
  end
end

#restore!(conversation, opts = {}) ⇒ Object

restore the checkpoint AND remove it from session



46
47
48
49
# File 'lib/aws/lex/conversation/type/checkpoint.rb', line 46

def restore!(conversation, opts = {})
  conversation.checkpoints.delete_if { |c| c.label == label }
  restore(conversation, opts)
end