Sha256: 2f17943be26b45f6962ae4760709541d9ff8e9b81da574ca856e347809c54f2a
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true module LedgerSync module Adaptors module NetSuite class Searcher < Adaptors::Searcher include Mixins::OffsetAndLimitPaginationSearcherMixin def query_attributes @query_attributes ||= searcher_ledger_deserializer_class.attributes.map(&:ledger_attribute) end def query_string "SELECT #{query_attributes.join(', ')} FROM #{query_table}" end def query_table @query_table ||= self.class.inferred_resource_class.resource_type end def resources resource_class = self.class.inferred_resource_class @resources ||= begin @request = adaptor .post( body: { q: query_string.to_s }, request_url: adaptor.api_base_url.gsub('/record/v1', '') + "/query/v1/suiteql?limit=#{limit}&offset=#{offset}" ) case request.status when 200 request.body .fetch('items') .map do |c| searcher_ledger_deserializer_class.new( resource: resource_class.new ).deserialize(hash: c) end when 404 [] end end end def searcher_ledger_deserializer_class @searcher_ledger_deserializer_class ||= self.class.inferred_searcher_ledger_deserializer_class end private def default_offset 0 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.3.5 | lib/ledger_sync/adaptors/netsuite/searcher.rb |