Class: Sendly::SuggestRepliesResponse

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sendly/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SuggestRepliesResponse

Returns a new instance of SuggestRepliesResponse.



713
714
715
716
717
# File 'lib/sendly/types.rb', line 713

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_idString? (readonly)

Returns ID of the inbound message the suggestions are based on.

Returns:

  • (String, nil)

    ID of the inbound message the suggestions are based on



708
709
710
# File 'lib/sendly/types.rb', line 708

def based_on_message_id
  @based_on_message_id
end

#modelString? (readonly)

Returns Model that generated the suggestions.

Returns:

  • (String, nil)

    Model that generated the suggestions



711
712
713
# File 'lib/sendly/types.rb', line 711

def model
  @model
end

#suggestionsArray<SuggestedReply> (readonly)

Returns AI-generated reply suggestions.

Returns:



705
706
707
# File 'lib/sendly/types.rb', line 705

def suggestions
  @suggestions
end

Instance Method Details

#countObject Also known as: size, length



723
724
725
# File 'lib/sendly/types.rb', line 723

def count
  suggestions.length
end

#each(&block) ⇒ Object



719
720
721
# File 'lib/sendly/types.rb', line 719

def each(&block)
  suggestions.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


730
731
732
# File 'lib/sendly/types.rb', line 730

def empty?
  suggestions.empty?
end

#firstObject



734
735
736
# File 'lib/sendly/types.rb', line 734

def first
  suggestions.first
end

#to_hObject



738
739
740
741
742
743
744
# File 'lib/sendly/types.rb', line 738

def to_h
  {
    suggestions: suggestions.map(&:to_h),
    based_on_message_id: based_on_message_id,
    model: model
  }.compact
end