Sha256: e7b458d00d230080dd2c6fdd9f0866efb6b8e8147e622a8fd3f979b250525cd1
Contents?: true
Size: 1.44 KB
Versions: 13
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module LedgerSync module QuickBooksOnline class Searcher < Ledgers::Searcher include LedgerSync::Ledgers::Mixins::OffsetAndLimitPaginationSearcherMixin def query_string '' end 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 def search super rescue OAuth2::Error => e @response = e # TODO: Better catch/raise errors as LedgerSync::Error failure end private # Pagination uses notation of limit and offset # limit: number of results per page # # offset: position of first result in a list. # starts from 1, not 0 # # More here: # https://developer.intuit.com/app/developer/qbo/docs/develop/explore-the-quickbooks-online-api/data-queries#pagination def default_offset 1 end end end end
Version data entries
13 entries across 13 versions & 1 rubygems