Sha256: fb6ada2e944631d5c791545f565351635896a19aa0311ebb80b40a05087ebf4c

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

class QboRails
  module ErrorHandler

    def handle_error_name_entity_already_exists(exception)
      if exception.message =~ /Duplicate Name Exists Error.*Another (customer|vendor|employee)/m
        display_name = Nokogiri::XML(exception.request_xml).at('DisplayName').content
        result = @base.find_by_display_name(display_name)
        if result.entries.size == 1
          @record.update_column(foreign_key, result.entries.first.id)
          @only_run_once = true
          @record.reload
          create_or_update(@record, @qb_record)
          true
        else
          false
        end
      else
        false
      end
    end

    def handle_error_no_line_items(exception)
      if exception.message =~ /Forbidden/
        @only_run_once = true
        create(@qb_record)
        true
      else
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qbo_rails-1.0.2 spec/dummy/app/services/qbo_rails/error_handler.rb
qbo_rails-1.0.1 spec/dummy/app/services/qbo_rails/error_handler.rb
qbo_rails-1.0.0 spec/dummy/app/services/qbo_rails/error_handler.rb