class SalesforceChunker::Client

Public Class Methods

new(**options) click to toggle source
# File lib/salesforce_chunker.rb, line 13
def initialize(**options)
  @log = options[:logger] || Logger.new(options[:log_output])
  @log.progname = "salesforce_chunker"

  @connection = SalesforceChunker::Connection.new(**options, logger: @log)
end

Public Instance Methods

manual_chunking_query(**options) click to toggle source
# File lib/salesforce_chunker.rb, line 55
def manual_chunking_query(**options)
  query(**options.merge(job_type: "manual_chunking"))
end
primary_key_chunking_query(**options) click to toggle source
# File lib/salesforce_chunker.rb, line 51
def primary_key_chunking_query(**options)
  query(**options.merge(job_type: "primary_key_chunking"))
end
query(query:, object:, **options) { |result| ... } click to toggle source
# File lib/salesforce_chunker.rb, line 20
def query(query:, object:, **options)
  return to_enum(:query, query: query, object: object, **options) unless block_given?

  case options[:job_type]
  when "single_batch"
    job_class = SalesforceChunker::SingleBatchJob
  when "manual_chunking"
    job_class = SalesforceChunker::ManualChunkingQuery
  when "primary_key_chunking", nil # for backwards compatibility
    job_class = SalesforceChunker::PrimaryKeyChunkingQuery
  end

  operation = options[:include_deleted] ? "queryAll" : "query"

  job_params = {
    connection: @connection,
    object: object,
    operation: operation,
    query: query,
    **options.slice(:batch_size, :logger, :log_output)
  }
  job_params[:logger] = @log if job_params[:logger].nil? && job_params[:log_output].nil?

  job = job_class.new(**job_params)
  job.download_results(**options.slice(:timeout_seconds, :retry_seconds)) { |result| yield(result) }
end
single_batch_query(**options) click to toggle source
# File lib/salesforce_chunker.rb, line 47
def single_batch_query(**options)
  query(**options.merge(job_type: "single_batch"))
end