Sha256: dfc8ad8b9e61eed3c95916e336a71aca5420c6fd26b6f75e9bb34a06efd7215e

Contents?: true

Size: 946 Bytes

Versions: 5

Compression:

Stored size: 946 Bytes

Contents

module LedgerSync
  module Adaptors
    module Test
      module Customer
        class Searcher < LedgerSync::Adaptors::Searcher
          def next_searcher
            paginate(cursor: 'next_page')
          end

          def previous_searcher
            paginate(cursor: 'previous_page')
          end

          def resources
            @resources ||= begin
              adaptor
                .query(
                  resource: 'customer',
                  query: "name LIKE '#{query}%'"
                )
                .map do |c|
                  LedgerSync::Customer.new(
                    ledger_id: c.fetch('id'),
                    name: c.dig('name'),
                    # active: c.dig('active')
                  )
                end
            end
          end

          def search
            super
          rescue OAuth2::Error => e
            failure(e)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ledger_sync-1.3.2 lib/ledger_sync/adaptors/test/customer/searcher.rb
ledger_sync-1.3.1 lib/ledger_sync/adaptors/test/customer/searcher.rb
ledger_sync-1.1.3 lib/ledger_sync/adaptors/test/customer/searcher.rb
ledger_sync-1.1.2 lib/ledger_sync/adaptors/test/customer/searcher.rb
ledger_sync-1.1.1 lib/ledger_sync/adaptors/test/customer/searcher.rb