Module: NakoPay::Event
- Defined in:
- lib/nakopay/resources.rb
Class Method Summary collapse
- .auto_paging_each(limit: nil, type: nil) ⇒ Object
- .list(limit: nil, starting_after: nil, type: nil) ⇒ Object
Class Method Details
.auto_paging_each(limit: nil, type: nil) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/nakopay/resources.rb', line 118 def auto_paging_each(limit: nil, type: nil) return enum_for(:auto_paging_each, limit: limit, type: type) unless block_given? cursor = nil loop do page = list(limit: limit, starting_after: cursor, type: type) page["data"].each { |e| yield e } break unless page["has_more"] cursor = page["next_cursor"] || page["data"].last&.id break unless cursor end end |
.list(limit: nil, starting_after: nil, type: nil) ⇒ Object
112 113 114 115 116 |
# File 'lib/nakopay/resources.rb', line 112 def list(limit: nil, starting_after: nil, type: nil) page = NakoPay.client.request(:get, "/events-list", query: { limit: limit, starting_after: starting_after, type: type }) page["data"] = (page["data"] || []).map { |r| Resource.new(r) } page end |