Module: Pipedrive::Utils

Extended by:
ActiveSupport::Concern
Included in:
Operations::Read, Organization, Person
Defined in:
lib/pipedrive/utils.rb

Instance Method Summary collapse

Instance Method Details

#follow_pagination(method, args, params, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pipedrive/utils.rb', line 7

def follow_pagination(method, args, params, &block)
  start = params[:start] || 0
  loop do
    res = __send__(method, *args, params.merge(start: start))
    break if !res.try(:data) || !res.success?

    res.data.each(&block)
    break unless res.try(:additional_data).try(:pagination).try(:more_items_in_collection?)

    start = res.try(:additional_data).try(:pagination).try(:next_start)
  end
end