Sha256: 6323175b2609c062b7fb50d03f6892546c84181f28b850039363bd3c6144a5fe
Contents?: true
Size: 1.53 KB
Versions: 8
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module LedgerSync module Ledgers module QuickBooksOnline class Searcher < Ledgers::Searcher include 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 end
Version data entries
8 entries across 8 versions & 1 rubygems