aws-lex-conversation 4.3.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69743533fc27787f0b8ac0f5d2a002496a118c92949c57b90ab1738439a7618d
4
- data.tar.gz: 98d688962a53a164c398436a9f9101cfedd50dc0238598a3c71e387e6f271f89
3
+ metadata.gz: 8722262608a479a7c20069ac72e1e15c70e417fe92ffcbc4eaaab6b54defc792
4
+ data.tar.gz: ee77736e7e9c313a3de59b6c651253d226cfb5c0def75e52f50082489e514cd0
5
5
  SHA512:
6
- metadata.gz: 336228d5bebb36f2f275a78decf3459ce34c48bdaf4c73d48b2f3c15634d414fbf4f3036bb1603b0996b8026cb49605b11d20ef1d5f0b30bc993638aaa549eb2
7
- data.tar.gz: 7d7147e2c8c65dfa93424f5bb366206b825d9c88c2831f3a140294002ebd6805da384ead59538e964c2934b33a11fb9c80b22c915ece0007382532ef0bb87691
6
+ metadata.gz: c0c8edafbb942dd0e692908db397887c5fea54e2fef7be71369ed72be2debd62054cb4c31593f0d38598d895758c9bd5b0ce678f3e3ec05ec807354a230b51a6
7
+ data.tar.gz: 360558203dbc323968b841e8caf1f37cd3ee14afa43f308fa254d5edfee471321916527fd7806382614f19386f50c3753f8f7f403866d052c592dcdeccaf34e1
@@ -5,39 +5,32 @@ module Aws
5
5
  class Conversation
6
6
  module Slot
7
7
  class Elicitation
8
- attr_accessor :name, :elicit, :message, :follow_up_message,
9
- :content_type, :fallback, :maximum_elicitations,
10
- :conversation
8
+ attr_accessor :name, :elicit, :messages, :follow_up_messages,
9
+ :fallback, :maximum_elicitations, :conversation
11
10
 
12
11
  def initialize(opts = {})
13
12
  self.name = opts.fetch(:name)
14
13
  self.elicit = opts.fetch(:elicit) { ->(_c) { true } }
15
- self.message = opts.fetch(:message)
16
- self.follow_up_message = opts.fetch(:follow_up_message) { opts.fetch(:message) }
17
- self.content_type = opts.fetch(:content_type) do
18
- Aws::Lex::Conversation::Type::Message::ContentType.new('PlainText')
19
- end
20
- self.fallback = opts.fetch(:fallback) { ->(_c) {} }
14
+ self.messages = opts.fetch(:messages)
15
+ self.follow_up_messages = opts.fetch(:follow_up_messages) { opts.fetch(:messages) }
16
+ self.fallback = opts[:fallback]
21
17
  self.maximum_elicitations = opts.fetch(:maximum_elicitations) { 0 }
22
18
  end
23
19
 
24
20
  def elicit!
21
+ return false unless elicit?
25
22
  return fallback.call(conversation) if maximum_elicitations?
26
23
 
27
24
  increment_slot_elicitations!
28
25
  conversation.elicit_slot(
29
26
  slot_to_elicit: name,
30
- messages: [
31
- elicitation_message
32
- ]
27
+ messages: elicitation_messages
33
28
  )
34
29
  end
35
30
 
36
- def message_content_type
37
- content_type.is_a?(Proc) ? content_type.call(conversation) : content_type
38
- end
39
-
40
31
  def elicit?
32
+ return false if maximum_elicitations? && fallback.nil?
33
+
41
34
  elicit.call(conversation) && !slot.filled?
42
35
  end
43
36
 
@@ -47,21 +40,12 @@ module Aws
47
40
  conversation.slots[name.to_sym]
48
41
  end
49
42
 
50
- def elicitation_message
51
- first_elicitation? ? compose_message(message) : compose_message(follow_up_message)
43
+ def elicitation_messages
44
+ first_elicitation? ? compose_messages(messages) : compose_messages(follow_up_messages)
52
45
  end
53
46
 
54
- def compose_message(msg)
55
- content = msg.is_a?(Proc) ? msg.call(conversation) : msg
56
-
57
- if content.is_a?(Aws::Lex::Conversation::Type::Message)
58
- content
59
- else
60
- {
61
- content: content,
62
- contentType: message_content_type
63
- }
64
- end
47
+ def compose_messages(msg)
48
+ msg.is_a?(Proc) ? msg.call(conversation) : msg
65
49
  end
66
50
 
67
51
  def increment_slot_elicitations!
@@ -3,7 +3,7 @@
3
3
  module Aws
4
4
  module Lex
5
5
  class Conversation
6
- VERSION = '4.3.0'
6
+ VERSION = '5.0.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-lex-conversation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
@@ -9,10 +9,10 @@ authors:
9
9
  - Darko Dosenovic
10
10
  - Zoie Carnegie
11
11
  - Carlos Mejia Castelo
12
- autorequire:
12
+ autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2021-08-26 00:00:00.000000000 Z
15
+ date: 2021-08-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: shrink_wrap
@@ -107,7 +107,7 @@ licenses:
107
107
  - MIT
108
108
  metadata:
109
109
  homepage_uri: https://github.com/amaabca/aws-lex-conversation
110
- post_install_message:
110
+ post_install_message:
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubygems_version: 3.1.2
126
- signing_key:
126
+ signing_key:
127
127
  specification_version: 4
128
128
  summary: AWS Lex Conversation Dialog Management
129
129
  test_files: []