class Restforce::Bulk::Job

Constants

JOB_CONTENT_TYPE_MAPPING

Attributes

content_type[RW]
created_by_id[RW]
created_date[RW]
id[RW]
object[RW]
operation[RW]
state[RW]
system_modstamp[RW]

Public Class Methods

create(operation, object_name, content_type=:xml) click to toggle source
# File lib/restforce/bulk/job.rb, line 14
def create(operation, object_name, content_type=:xml)
  builder  = Restforce::Bulk::Builder::Xml.new(operation)
  data     = builder.job(object_name, JOB_CONTENT_TYPE_MAPPING[content_type.to_sym])

  response = Restforce::Bulk.client.perform_request(:post, 'job', data)

  new(response.body.jobInfo)
end
find(id) click to toggle source
# File lib/restforce/bulk/job.rb, line 23
def find(id)
  response = Restforce::Bulk.client.perform_request(:get, "job/#{id}")

  new(response.body.jobInfo)
end
new(attributes={}) click to toggle source
# File lib/restforce/bulk/job.rb, line 33
def initialize(attributes={})
  assign_attributes(attributes)

  @batches = []
end

Public Instance Methods

abort() click to toggle source
# File lib/restforce/bulk/job.rb, line 70
def abort
  builder = Restforce::Bulk::Builder::Xml.new(operation)

  response = Restforce::Bulk.client.perform_request(:post, "job/#{id}", builder.abort)

  assign_attributes(response.body.jobInfo)
end
add_batch(data) click to toggle source
# File lib/restforce/bulk/job.rb, line 56
def add_batch(data)
  Restforce::Bulk::Batch.create(id, data, operation, content_type).tap do |batch|
    batches << batch
  end
end
batches() click to toggle source
# File lib/restforce/bulk/job.rb, line 43
def batches
  @batches
end
close() click to toggle source
# File lib/restforce/bulk/job.rb, line 62
def close
  builder = Restforce::Bulk::Builder::Xml.new(operation)

  response = Restforce::Bulk.client.perform_request(:post, "job/#{id}", builder.close)

  assign_attributes(response.body.jobInfo)
end
content_type=(value) click to toggle source
# File lib/restforce/bulk/job.rb, line 39
def content_type=(value)
  @content_type = JOB_CONTENT_TYPE_MAPPING.invert[value] || value
end
reload_batches() click to toggle source
# File lib/restforce/bulk/job.rb, line 47
def reload_batches
  response = Restforce::Bulk.client.perform_request(:get, "job/#{id}/batch")
  parser   = Restforce::Bulk::Parser::Xml.new

  @batches = parser.batches(response.body).map do |batch_info|
    Restforce::Bulk::Batch.new(batch_info)
  end
end