Class: Sendly::SuggestRepliesResponse
- Inherits:
-
Object
- Object
- Sendly::SuggestRepliesResponse
- Includes:
- Enumerable
- Defined in:
- lib/sendly/types.rb
Instance Attribute Summary collapse
-
#based_on_message_id ⇒ String?
readonly
ID of the inbound message the suggestions are based on.
-
#model ⇒ String?
readonly
Model that generated the suggestions.
-
#suggestions ⇒ Array<SuggestedReply>
readonly
AI-generated reply suggestions.
Instance Method Summary collapse
- #count ⇒ Object (also: #size, #length)
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(data) ⇒ SuggestRepliesResponse
constructor
A new instance of SuggestRepliesResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ SuggestRepliesResponse
Returns a new instance of SuggestRepliesResponse.
634 635 636 637 638 |
# File 'lib/sendly/types.rb', line 634 def initialize(data) @suggestions = (data["suggestions"] || []).map { |s| SuggestedReply.new(s) } @based_on_message_id = data["basedOnMessageId"] || data["based_on_message_id"] @model = data["model"] end |
Instance Attribute Details
#based_on_message_id ⇒ String? (readonly)
Returns ID of the inbound message the suggestions are based on.
629 630 631 |
# File 'lib/sendly/types.rb', line 629 def @based_on_message_id end |
#model ⇒ String? (readonly)
Returns Model that generated the suggestions.
632 633 634 |
# File 'lib/sendly/types.rb', line 632 def model @model end |
#suggestions ⇒ Array<SuggestedReply> (readonly)
Returns AI-generated reply suggestions.
626 627 628 |
# File 'lib/sendly/types.rb', line 626 def suggestions @suggestions end |
Instance Method Details
#count ⇒ Object Also known as: size, length
644 645 646 |
# File 'lib/sendly/types.rb', line 644 def count suggestions.length end |
#each(&block) ⇒ Object
640 641 642 |
# File 'lib/sendly/types.rb', line 640 def each(&block) suggestions.each(&block) end |
#empty? ⇒ Boolean
651 652 653 |
# File 'lib/sendly/types.rb', line 651 def empty? suggestions.empty? end |
#first ⇒ Object
655 656 657 |
# File 'lib/sendly/types.rb', line 655 def first suggestions.first end |
#to_h ⇒ Object
659 660 661 662 663 664 665 |
# File 'lib/sendly/types.rb', line 659 def to_h { suggestions: suggestions.map(&:to_h), based_on_message_id: , model: model }.compact end |