Class: LedgerSync::Adaptors::QuickBooksOnline::Searcher
- Defined in:
- lib/ledger_sync/adaptors/quickbooks_online/searcher.rb
Direct Known Subclasses
Account::Searcher, Bill::Searcher, Customer::Searcher, Department::Searcher, Deposit::Searcher, Expense::Searcher, JournalEntry::Searcher, LedgerClass::Searcher, Vendor::Searcher
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
Methods included from Mixins::InferResourceClassMixin
Constructor Details
This class inherits a constructor from LedgerSync::Adaptors::Searcher
Instance Method Details
#query_string ⇒ Object
9 10 11 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/searcher.rb', line 9 def query_string '' end |
#resources ⇒ Object
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 |
#search ⇒ Object
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 |