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.



566
567
568
569
570
571
572
573
# File 'lib/sendly/types.rb', line 566

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.



564
565
566
# File 'lib/sendly/types.rb', line 564

def data
  @data
end

#has_moreObject (readonly)

Returns the value of attribute has_more.



564
565
566
# File 'lib/sendly/types.rb', line 564

def has_more
  @has_more
end

#limitObject (readonly)

Returns the value of attribute limit.



564
565
566
# File 'lib/sendly/types.rb', line 564

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



564
565
566
# File 'lib/sendly/types.rb', line 564

def offset
  @offset
end

#totalObject (readonly)

Returns the value of attribute total.



564
565
566
# File 'lib/sendly/types.rb', line 564

def total
  @total
end

Instance Method Details

#countObject Also known as: size, length



579
580
581
# File 'lib/sendly/types.rb', line 579

def count
  data.length
end

#each(&block) ⇒ Object



575
576
577
# File 'lib/sendly/types.rb', line 575

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

#empty?Boolean

Returns:

  • (Boolean)


586
587
588
# File 'lib/sendly/types.rb', line 586

def empty?
  data.empty?
end

#firstObject



590
591
592
# File 'lib/sendly/types.rb', line 590

def first
  data.first
end

#lastObject



594
595
596
# File 'lib/sendly/types.rb', line 594

def last
  data.last
end