Sha256: 9d7b004a56cf7fb9fd62d0cc82172e442c72a963d0379148fb3e8240b148fb7e

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

module Pipedrive
  module Operations
    module Read
      extend ActiveSupport::Concern
      include ::Enumerable
      include ::Pipedrive::Utils

      # This method smells of :reek:TooManyStatements but ignores them
      def each(params = {})
        return to_enum(:each, params) unless block_given?
        follow_pagination(:chunk, [], params) { |item| yield item }
      end

      def all(params = {})
        each(params).to_a
      end

      def chunk(params = {})
        res = make_api_call(:get, params)
        return [] unless res.success?
        res
      end

      def find_by_id(id)
        make_api_call(:get, id)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pipedrive.rb-0.2.0 lib/pipedrive/operations/read.rb
pipedrive.rb-0.1.0 lib/pipedrive/operations/read.rb