class ONEAccess::Request::InvestorsRequestHandler
Constants
- PAGE_SIZE
Attributes
limit[R]
url[R]
Public Class Methods
new(url:, limit: PAGE_SIZE)
click to toggle source
# File lib/oneaccess/request/investors_request_handler.rb, line 8 def initialize(url:, limit: PAGE_SIZE) @url = url @limit = limit end
Public Instance Methods
each() { |investor| ... }
click to toggle source
# File lib/oneaccess/request/investors_request_handler.rb, line 13 def each offset = 0 loop do http_response = Http::HttpClient.get(url, build_params(offset)) response = Response::InvestorsResponse.from_json(http_response.body) response&.data&.each do |investor| yield investor end break unless more_records?(response.meta) offset += 1 end end
Private Instance Methods
build_params(offset)
click to toggle source
# File lib/oneaccess/request/investors_request_handler.rb, line 33 def build_params(offset) { limit: limit, offset: offset, } end
more_records?(meta)
click to toggle source
# File lib/oneaccess/request/investors_request_handler.rb, line 40 def more_records?(meta) meta.offset < (meta.total / meta.limit).ceil - 1 end