Class: ONEAccess::Request::InvestorsRequestHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/oneaccess/request/investors_request_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, limit: PAGE_SIZE) ⇒ InvestorsRequestHandler

Returns a new instance of InvestorsRequestHandler.



8
9
10
11
# File 'lib/oneaccess/request/investors_request_handler.rb', line 8

def initialize(url:, limit: PAGE_SIZE)
  @url = url
  @limit = limit
end

Instance Method Details

#eachObject



13
14
15
16
17
18
19
20
21
22
23
24
# 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