Sha256: 357b390e38231bb6860549b3a1f4c7e848a7d819b19da9a1b9633c6306c19fab

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Adaptors
    module NetSuite
      class Searcher < Adaptors::Searcher
        include Mixins::OffsetAndLimitPaginationSearcherMixin

        def resources
          resource_class = self.class.inferred_resource_class

          @resources ||= begin
            @request = adaptor
              .get(
                path: "/#{adaptor.class.ledger_resource_type_for(resource_class: resource_class)}?limit=#{limit}&offset=#{offset}"
              )

            request.body
              .fetch('items')
              .map do |c|
                ledger_deserializer_class.new(
                  resource: resource_class.new
                ).deserialize(hash: c)
              end
          end
        end

        private

        def default_offset
          0
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_sync-1.3.4 lib/ledger_sync/adaptors/netsuite/searcher.rb