Class: Restforce::Bulk::Job
- Inherits:
-
Object
- Object
- Restforce::Bulk::Job
- Includes:
- Attributes
- Defined in:
- lib/restforce/bulk/job.rb
Constant Summary collapse
- JOB_CONTENT_TYPE_MAPPING =
{ csv: 'CSV', xml: 'XML', zip_csv: 'ZIP_CSV', zip_xml: 'ZIP_XML' }
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#created_by_id ⇒ Object
Returns the value of attribute created_by_id.
-
#created_date ⇒ Object
Returns the value of attribute created_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#object ⇒ Object
Returns the value of attribute object.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#state ⇒ Object
Returns the value of attribute state.
-
#system_modstamp ⇒ Object
Returns the value of attribute system_modstamp.
Class Method Summary collapse
Instance Method Summary collapse
- #abort ⇒ Object
- #add_batch(data) ⇒ Object
- #batches ⇒ Object
- #close ⇒ Object
-
#initialize(attributes = {}) ⇒ Job
constructor
A new instance of Job.
- #reload_batches ⇒ Object
Methods included from Attributes
Constructor Details
#initialize(attributes = {}) ⇒ Job
Returns a new instance of Job.
33 34 35 36 37 |
# File 'lib/restforce/bulk/job.rb', line 33 def initialize(attributes={}) assign_attributes(attributes) @batches = [] end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def content_type @content_type end |
#created_by_id ⇒ Object
Returns the value of attribute created_by_id.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def created_by_id @created_by_id end |
#created_date ⇒ Object
Returns the value of attribute created_date.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def created_date @created_date end |
#id ⇒ Object
Returns the value of attribute id.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def id @id end |
#object ⇒ Object
Returns the value of attribute object.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def object @object end |
#operation ⇒ Object
Returns the value of attribute operation.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def operation @operation end |
#state ⇒ Object
Returns the value of attribute state.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def state @state end |
#system_modstamp ⇒ Object
Returns the value of attribute system_modstamp.
30 31 32 |
# File 'lib/restforce/bulk/job.rb', line 30 def system_modstamp @system_modstamp end |
Class Method Details
.create(operation, object_name, content_type = :xml) ⇒ Object
14 15 16 17 18 19 20 21 |
# 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 |
Instance Method Details
#abort ⇒ Object
70 71 72 73 74 75 76 |
# 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) ⇒ Object
56 57 58 59 60 |
# 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 ⇒ Object
43 44 45 |
# File 'lib/restforce/bulk/job.rb', line 43 def batches @batches end |
#close ⇒ Object
62 63 64 65 66 67 68 |
# 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 |
#reload_batches ⇒ Object
47 48 49 50 51 52 53 54 |
# 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 |