Class: Sendly::ConversationWithMessages

Inherits:
Conversation show all
Defined in:
lib/sendly/types.rb

Constant Summary

Constants inherited from Conversation

Sendly::Conversation::STATUSES

Instance Attribute Summary collapse

Attributes inherited from Conversation

#contact_id, #created_at, #id, #last_message_at, #last_message_direction, #last_message_text, #message_count, #metadata, #phone_number, #status, #tags, #unread_count, #updated_at

Instance Method Summary collapse

Methods inherited from Conversation

#active?, #closed?, #to_h

Constructor Details

#initialize(data) ⇒ ConversationWithMessages

Returns a new instance of ConversationWithMessages.



733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/sendly/types.rb', line 733

def initialize(data)
  super(data)
  if data["messages"]
    msgs = data["messages"]
    @messages = {
      data: (msgs["data"] || []).map { |m| Message.new(m) },
      pagination: {
        total: msgs.dig("pagination", "total") || 0,
        limit: msgs.dig("pagination", "limit") || 20,
        offset: msgs.dig("pagination", "offset") || 0,
        has_more: msgs.dig("pagination", "hasMore") || msgs.dig("pagination", "has_more") || false
      }
    }
  end
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



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

def messages
  @messages
end