Sha256: b4d111a699af9231cb0f9f9fb207644aef948eff8191879b9ffea34ccba98382

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

module Pipedrive
  module Utils
    extend ActiveSupport::Concern

    def follow_pagination(method, args, params)
      start = params[:start] || 0
      loop do
        res = __send__(method, *args, params.merge(start: start))
        break if !res.try(:data) || !res.success?
        res.data.each do |item|
          yield item
        end
        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

2 entries across 2 versions & 1 rubygems

Version Path
pipedrive.rb-0.2.0 lib/pipedrive/utils.rb
pipedrive.rb-0.1.0 lib/pipedrive/utils.rb