Class: LedgerSync::Adaptors::QuickBooksOnline::Searcher

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

Instance Attribute Summary

Attributes inherited from Searcher

#adaptor, #pagination, #query, #request

Instance Method Summary collapse

Methods included from Mixins::OffsetAndLimitPaginationSearcherMixin

#next_searcher, #previous_searcher

Methods inherited from Searcher

#initialize, #ledger_deserializer_class, #next_searcher, #previous_searcher

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

#query_stringObject



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

def query_string
  ''
end

#resourcesObject



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

def resources
  resource_class = self.class.inferred_resource_class

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

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

#searchObject



38
39
40
41
42
43
# File 'lib/ledger_sync/adaptors/quickbooks_online/searcher.rb', line 38

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