lib/ecoportal/api/v1/people.rb in ecoportal-api-0.5.3 vs lib/ecoportal/api/v1/people.rb in ecoportal-api-0.5.5
- old
+ new
@@ -20,27 +20,27 @@
@client = client
end
# Iterates all the people of the organization.
# @note
- # - it ignores the key `results_from:` of `params:`.
+ # - it ignores the key `cursor_id:` of `params:`.
# - `each` is called by `to_a`
# @param params [Hash]
# @option params [String] :per_page the number of people you get per request.
# @option params [String] :q some text to search. Omit this parameter to target all the people.
# @yield [person] does some stuff with the person.
# @yieldparam person [Person]
def each(params: {}, &block)
return to_enum(:each) unless block
- results_from = nil
+ cursor_id = nil
loop do
- params.update(results_from: results_from) if results_from
+ params.update(cursor_id: cursor_id) if cursor_id
response = client.get("/people", params: params)
raise "Request failed." unless response.success?
response.body["results"].each do |person|
yield person_class.new(person)
end
- break unless (results_from = response.body["next_results_from"])
+ break unless (cursor_id = response.body["cursor_id"])
end
self
end
# Gets all the people via api requests.