lib/quickbooks/base.rb
# Generates a request by sending *args to Qbxml::Request.new, sends the request over the current connection,
# and interprets the response using Qbxml::ResponseSet.
# The response is then instantiated into an object or an array of objects.
# 
# This method is used mostly internally, but it is the yoke of this library - use it to perform custom requests.
Generates a request by sending *args to Qbxml::Request.new, sends the request over the current connection,
and interprets the response using Qbxml::ResponseSet.
The response is then instantiated into an object or an array of objects.

This method is used mostly internally, but it is the yoke of this library - use it to perform custom requests.
Generates a request by sending * args to Qbxml :: Request . new sends the request over the current connection and interprets the response using Qbxml :: ResponseSet . The response is then instantiated into an object or an array of objects . This method is used mostly internally but it is the yoke of this library - use it to perform custom requests .
def query(obj_or_args,*args)
        reinstantiate = if obj_or_args.is_a?(Quickbooks::Base)
          obj_or_args
        elsif obj_or_args.is_a?(Class)
          nil
        else
          args.unshift(obj_or_args)
          nil
        end
        objects = [] 
        self.request(reinstantiate || self, *args).each { |response| objects.concat(response.instantiate(reinstantiate)) } 
        if args[-1].is_a?(Hash) && !(time_filters = args[-1].stringify_keys.only('created_before', 'created_after', 'updated_before', 'updated_after', 'deleted_before', 'deleted_after')).empty?
          objects.reject! do |object|
            passes = true if object 
            time_filters.each do |filter,time|
              break unless passes 
              case filter
              when 'created_before'
                passes = Time.parse(object.time_created)  <  Time.parse(time.to_s)
              when 'created_after'
                passes = Time.parse(object.time_created)  >= Time.parse(time.to_s)
              when 'updated_before'
                passes = Time.parse(object.time_modified) <  Time.parse(time.to_s)
              when 'updated_after'
                passes = Time.parse(object.time_modified) >= Time.parse(time.to_s)
              when 'deleted_before'
                passes = Time.parse(object.time_deleted)  <  Time.parse(time.to_s)
              when 'deleted_after'
                passes = Time.parse(object.time_deleted)  >= Time.parse(time.to_s)
              end
            end
            !passes
          end
        end
        objects.length == 1 ? objects[0] : objects 
      end
def query ( obj_or_args , * args ) reinstantiate = if obj_or_args . is_a? ( Quickbooks :: Base ) obj_or_args elsif obj_or_args . is_a? ( Class ) nil else args . unshift ( obj_or_args ) nil end objects = [ ] self . request ( reinstantiate || self , * args ) . each { | response | objects . concat ( response . instantiate ( reinstantiate ) ) } if args [ - 1 ] . is_a? ( Hash ) && ! ( time_filters = args [ - 1 ] . stringify_keys . only ( 'created_before' , 'created_after' , 'updated_before' , 'updated_after' , 'deleted_before' , 'deleted_after' ) ) . empty? objects . reject! do | object | passes = true if object time_filters . each do | filter , time | break unless passes case filter when 'created_before' passes = Time . parse ( object . time_created ) < Time . parse ( time . to_s ) when 'created_after' passes = Time . parse ( object . time_created ) >= Time . parse ( time . to_s ) when 'updated_before' passes = Time . parse ( object . time_modified ) < Time . parse ( time . to_s ) when 'updated_after' passes = Time . parse ( object . time_modified ) >= Time . parse ( time . to_s ) when 'deleted_before' passes = Time . parse ( object . time_deleted ) < Time . parse ( time . to_s ) when 'deleted_after' passes = Time . parse ( object . time_deleted ) >= Time . parse ( time . to_s ) end end ! passes end end objects . length == 1 ? objects [ 0 ] : objects end
Generates a request by sending *args to Qbxml::Request.new, sends the request over the current connection,
and interprets the response using Qbxml::ResponseSet.
Generates a request by sending * args to Qbxml :: Request . new sends the request over the current connection and interprets the response using Qbxml :: ResponseSet .
# If an object is sent, we need to reinstantiate the response into that object # This will hold and return the instantiated objects from the quickbooks response # The following line is subject to unexpected results: IF the response contains more than one object, it will re-instantiate only the last one. # Does not instantiate if it's an error, but simply records response into response_log # Since Quickbooks only honors the Date in queries, we can filter the list further here to honor the Time requested. # filters we're triggered on: created_before, created_after, updated_before, updated_after, deleted_before, deleted_after # When there are no results, we actually get [nil] # Skip the rest of the tests if it fails one # **** # Here, we may rather always return an array, then methods such as .first can return just the first element
obj_or_args
<not_specific>
args
<not_specific>