Class: LedgerSync::QuickBooksOnline::Searcher

Inherits:
Ledgers::Searcher
  • Object
show all
Includes:
Ledgers::Mixins::OffsetAndLimitPaginationSearcherMixin
Defined in:
lib/ledger_sync/quickbooks_online/searcher.rb

Instance Method Summary collapse

Instance Method Details

#query_stringObject



8
9
10
# File 'lib/ledger_sync/quickbooks_online/searcher.rb', line 8

def query_string
  ''
end

#resourcesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ledger_sync/quickbooks_online/searcher.rb', line 12

def resources
  resource_class = self.class.inferred_resource_class

  response = client.query(
    limit: limit,
    offset: offset,
    query: query_string,
    resource_class: resource_class
  )
  return [] if response.body.blank?

  (response.body.dig(
    'QueryResponse',
    client.class.ledger_resource_type_for(
      resource_class: resource_class
    ).classify
  ) || []).map do |c|
    self.class.inferred_deserializer_class.new.deserialize(
      hash: c,
      resource: resource_class.new
    )
  end
end

#searchObject



36
37
38
39
40
41
# File 'lib/ledger_sync/quickbooks_online/searcher.rb', line 36

def search
  super
rescue OAuth2::Error => e
  @response = e # TODO: Better catch/raise errors as LedgerSync::Error
  failure
end