Class: Nfe::ListPage

Inherits:
Data
  • Object
show all
Defined in:
lib/nfe/pagination.rb,
sig/nfe/pagination.rbs

Overview

Pagination metadata for a list response. NFE.io endpoints paginate in one of two shapes; each resource populates only the half relevant to it:

  • page-style — page_index / page_count (cursor fields nil)
  • cursor-style — starting_after / ending_before (+page_index+ nil)

total is optional and may be present in either shape.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_index: nil, page_count: nil, starting_after: nil, ending_before: nil, total: nil) ⇒ ListPage

Returns a new instance of ListPage.

Parameters:

  • page_index: (Object) (defaults to: nil)
  • page_count: (Object) (defaults to: nil)
  • starting_after: (Object) (defaults to: nil)
  • ending_before: (Object) (defaults to: nil)
  • total: (Object) (defaults to: nil)


24
25
26
27
# File 'lib/nfe/pagination.rb', line 24

def initialize(page_index: nil, page_count: nil, starting_after: nil,
               ending_before: nil, total: nil)
  super
end

Instance Attribute Details

#ending_beforeObject (readonly)

Returns the value of attribute ending_before.

Returns:

  • (Object)


6
7
8
# File 'sig/nfe/pagination.rbs', line 6

def ending_before
  @ending_before
end

#page_countObject (readonly)

Returns the value of attribute page_count.

Returns:

  • (Object)


4
5
6
# File 'sig/nfe/pagination.rbs', line 4

def page_count
  @page_count
end

#page_indexObject (readonly)

Returns the value of attribute page_index.

Returns:

  • (Object)


3
4
5
# File 'sig/nfe/pagination.rbs', line 3

def page_index
  @page_index
end

#starting_afterObject (readonly)

Returns the value of attribute starting_after.

Returns:

  • (Object)


5
6
7
# File 'sig/nfe/pagination.rbs', line 5

def starting_after
  @starting_after
end

#totalObject (readonly)

Returns the value of attribute total.

Returns:

  • (Object)


7
8
9
# File 'sig/nfe/pagination.rbs', line 7

def total
  @total
end

Class Method Details

.from_cursor(starting_after: nil, ending_before: nil, total: nil) ⇒ Nfe::ListPage

Returns a cursor-style page with +page_index+/+page_count+ nil.

Parameters:

  • starting_after: (Object) (defaults to: nil)
  • ending_before: (Object) (defaults to: nil)
  • total: (Object) (defaults to: nil)

Returns:

  • (Nfe::ListPage)

    a cursor-style page with +page_index+/+page_count+ nil.



19
20
21
22
# File 'lib/nfe/pagination.rb', line 19

def self.from_cursor(starting_after: nil, ending_before: nil, total: nil)
  new(page_index: nil, page_count: nil,
      starting_after: starting_after, ending_before: ending_before, total: total)
end

.from_page(page_index: nil, page_count: nil, total: nil) ⇒ Nfe::ListPage

Returns a page-style page with cursor fields left nil.

Parameters:

  • page_index: (Object) (defaults to: nil)
  • page_count: (Object) (defaults to: nil)
  • total: (Object) (defaults to: nil)

Returns:

  • (Nfe::ListPage)

    a page-style page with cursor fields left nil.



13
14
15
16
# File 'lib/nfe/pagination.rb', line 13

def self.from_page(page_index: nil, page_count: nil, total: nil)
  new(page_index: page_index, page_count: page_count,
      starting_after: nil, ending_before: nil, total: total)
end

.newinstance

Parameters:

  • page_index: (Object)
  • page_count: (Object)
  • starting_after: (Object)
  • ending_before: (Object)
  • total: (Object)

Returns:

  • (instance)


9
# File 'sig/nfe/pagination.rbs', line 9

def self.new: (?page_index: untyped, ?page_count: untyped, ?starting_after: untyped, ?ending_before: untyped, ?total: untyped) -> instance