Class: Printavo::Page

Inherits:
Struct
  • Object
show all
Defined in:
lib/printavo/page.rb

Overview

Wraps a single page of API results with cursor metadata.

Examples:

Iterating pages manually

page = client.customers.fetch_page(first: 10)
page.records.each { |c| puts c.full_name }
puts page.has_next_page   # => true
puts page.end_cursor      # => "cursor_abc123"

Using each_page

client.customers.each_page(first: 10) do |records|
  records.each { |c| puts c.full_name }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_cursorObject

Returns the value of attribute end_cursor

Returns:

  • (Object)

    the current value of end_cursor



17
18
19
# File 'lib/printavo/page.rb', line 17

def end_cursor
  @end_cursor
end

#errorsObject

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



17
18
19
# File 'lib/printavo/page.rb', line 17

def errors
  @errors
end

#has_next_pageObject

Returns the value of attribute has_next_page

Returns:

  • (Object)

    the current value of has_next_page



17
18
19
# File 'lib/printavo/page.rb', line 17

def has_next_page
  @has_next_page
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



17
18
19
# File 'lib/printavo/page.rb', line 17

def 
  @metadata
end

#recordsObject

Returns the value of attribute records

Returns:

  • (Object)

    the current value of records



17
18
19
# File 'lib/printavo/page.rb', line 17

def records
  @records
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


20
# File 'lib/printavo/page.rb', line 20

def empty?  = records.empty?

#partial?Boolean

Returns:

  • (Boolean)


22
# File 'lib/printavo/page.rb', line 22

def partial? = records.any? && !success?

#sizeObject



19
# File 'lib/printavo/page.rb', line 19

def size    = records.size

#success?Boolean

Returns:

  • (Boolean)


21
# File 'lib/printavo/page.rb', line 21

def success? = Array(errors).empty?

#to_aObject



18
# File 'lib/printavo/page.rb', line 18

def to_a    = records