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.



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_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



629
630
631
# File 'lib/sendly/types.rb', line 629

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



632
633
634
# File 'lib/sendly/types.rb', line 632

def model
  @model
end

#suggestionsArray<SuggestedReply> (readonly)

Returns AI-generated reply suggestions.

Returns:



626
627
628
# File 'lib/sendly/types.rb', line 626

def suggestions
  @suggestions
end

Instance Method Details

#countObject 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

Returns:

  • (Boolean)


651
652
653
# File 'lib/sendly/types.rb', line 651

def empty?
  suggestions.empty?
end

#firstObject



655
656
657
# File 'lib/sendly/types.rb', line 655

def first
  suggestions.first
end

#to_hObject



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: based_on_message_id,
    model: model
  }.compact
end