Class: Sendly::ConversationList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ConversationList

Returns a new instance of ConversationList.



645
646
647
648
649
650
651
652
# File 'lib/sendly/types.rb', line 645

def initialize(response)
  @data = (response["data"] || []).map { |c| Conversation.new(c) }
  pagination = response["pagination"] || {}
  @total = pagination["total"] || @data.length
  @limit = pagination["limit"] || 20
  @offset = pagination["offset"] || 0
  @has_more = pagination["hasMore"] || pagination["has_more"] || false
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



643
644
645
# File 'lib/sendly/types.rb', line 643

def data
  @data
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



643
644
645
# File 'lib/sendly/types.rb', line 643

def has_more
  @has_more
end

#limitObject (readonly)

Returns the value of attribute limit.



643
644
645
# File 'lib/sendly/types.rb', line 643

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



643
644
645
# File 'lib/sendly/types.rb', line 643

def offset
  @offset
end

#totalObject (readonly)

Returns the value of attribute total.



643
644
645
# File 'lib/sendly/types.rb', line 643

def total
  @total
end

Instance Method Details

#countObject Also known as: size, length



658
659
660
# File 'lib/sendly/types.rb', line 658

def count
  data.length
end

#each(&block) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


665
666
667
# File 'lib/sendly/types.rb', line 665

def empty?
  data.empty?
end

#firstObject



669
670
671
# File 'lib/sendly/types.rb', line 669

def first
  data.first
end

#lastObject



673
674
675
# File 'lib/sendly/types.rb', line 673

def last
  data.last
end