Class: LedgerSync::Adaptors::Test::Customer::Searcher

Inherits:
Searcher
  • Object
show all
Defined in:
lib/ledger_sync/adaptors/test/customer/searcher.rb

Instance Attribute Summary

Attributes inherited from Searcher

#adaptor, #pagination, #query, #request

Instance Method Summary collapse

Methods inherited from Searcher

#initialize

Methods included from Mixins::InferLedgerSerializerMixin

included

Methods included from Mixins::InferResourceClassMixin

included

Constructor Details

This class inherits a constructor from LedgerSync::Adaptors::Searcher

Instance Method Details

#next_searcherObject



6
7
8
# File 'lib/ledger_sync/adaptors/test/customer/searcher.rb', line 6

def next_searcher
  paginate(cursor: 'next_page')
end

#previous_searcherObject



10
11
12
# File 'lib/ledger_sync/adaptors/test/customer/searcher.rb', line 10

def previous_searcher
  paginate(cursor: 'previous_page')
end

#resourcesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ledger_sync/adaptors/test/customer/searcher.rb', line 14

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

#searchObject



31
32
33
34
35
# File 'lib/ledger_sync/adaptors/test/customer/searcher.rb', line 31

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