Sha256: 514d60b6af59cc6c10ab300dfe1d95c25665cfec18ea4c1b9792a83b6d9f62d1

Contents?: true

Size: 550 Bytes

Versions: 6

Compression:

Stored size: 550 Bytes

Contents

# frozen_string_literal: true

module Pipedrive
  module Utils
    extend ActiveSupport::Concern

    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
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
pipedrive_api_rb-1.0.5 lib/pipedrive/utils.rb
pipedrive_api_rb-1.0.4 lib/pipedrive/utils.rb
pipedrive_api_rb-1.0.2 lib/pipedrive/utils.rb
pipedrive_api_rb-1.0.1 lib/pipedrive/utils.rb
pipedrive_api_rb-1.0.0 lib/pipedrive/utils.rb
pipedrive.rb-0.3.0 lib/pipedrive/utils.rb