Class: Restforce::Bulk::Batch
- Inherits:
-
Object
- Object
- Restforce::Bulk::Batch
- Includes:
- Attributes
- Defined in:
- lib/restforce/bulk/batch.rb
Instance Attribute Summary collapse
-
#created_date ⇒ Object
Returns the value of attribute created_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#job_id ⇒ Object
Returns the value of attribute job_id.
-
#number_records_processed ⇒ Object
Returns the value of attribute number_records_processed.
-
#state ⇒ Object
Returns the value of attribute state.
-
#system_modstamp ⇒ Object
Returns the value of attribute system_modstamp.
Class Method Summary collapse
- .builder_class_for(content_type) ⇒ Object
- .create(job_id, data, operation, content_type = :xml) ⇒ Object
- .find(job_id, id) ⇒ Object
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #failed? ⇒ Boolean
- #in_progress? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Batch
constructor
A new instance of Batch.
- #not_processed? ⇒ Boolean
- #queued? ⇒ Boolean
- #refresh ⇒ Object
- #results ⇒ Object
Methods included from Attributes
Constructor Details
#initialize(attributes = {}) ⇒ Batch
Returns a new instance of Batch.
26 27 28 |
# File 'lib/restforce/bulk/batch.rb', line 26 def initialize(attributes={}) assign_attributes(attributes) end |
Instance Attribute Details
#created_date ⇒ Object
Returns the value of attribute created_date.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def created_date @created_date end |
#id ⇒ Object
Returns the value of attribute id.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def id @id end |
#job_id ⇒ Object
Returns the value of attribute job_id.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def job_id @job_id end |
#number_records_processed ⇒ Object
Returns the value of attribute number_records_processed.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def number_records_processed @number_records_processed end |
#state ⇒ Object
Returns the value of attribute state.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def state @state end |
#system_modstamp ⇒ Object
Returns the value of attribute system_modstamp.
24 25 26 |
# File 'lib/restforce/bulk/batch.rb', line 24 def system_modstamp @system_modstamp end |
Class Method Details
.builder_class_for(content_type) ⇒ Object
19 20 21 |
# File 'lib/restforce/bulk/batch.rb', line 19 def builder_class_for(content_type) Restforce::Bulk::Builder.const_get(content_type.to_s.camelize) end |
.create(job_id, data, operation, content_type = :xml) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/restforce/bulk/batch.rb', line 7 def create(job_id, data, operation, content_type=:xml) builder = builder_class_for(content_type).new(operation) response = Restforce::Bulk.client.perform_request(:post, "job/#{job_id}/batch", builder.transform(data, operation, content_type), content_type) new(response.body.batchInfo) end |
.find(job_id, id) ⇒ Object
15 16 17 |
# File 'lib/restforce/bulk/batch.rb', line 15 def find(job_id, id) new(job_id: job_id, id: id).tap(&:refresh) end |
Instance Method Details
#completed? ⇒ Boolean
38 39 40 |
# File 'lib/restforce/bulk/batch.rb', line 38 def completed? state == 'Completed' end |
#failed? ⇒ Boolean
42 43 44 |
# File 'lib/restforce/bulk/batch.rb', line 42 def failed? state == 'Failed' end |
#in_progress? ⇒ Boolean
34 35 36 |
# File 'lib/restforce/bulk/batch.rb', line 34 def in_progress? state == 'InProgress' end |
#not_processed? ⇒ Boolean
46 47 48 |
# File 'lib/restforce/bulk/batch.rb', line 46 def not_processed? state == 'Not Processed' end |
#queued? ⇒ Boolean
30 31 32 |
# File 'lib/restforce/bulk/batch.rb', line 30 def queued? state == 'Queued' end |
#refresh ⇒ Object
50 51 52 53 54 |
# File 'lib/restforce/bulk/batch.rb', line 50 def refresh response = Restforce::Bulk.client.perform_request(:get, "job/#{job_id}/batch/#{id}") assign_attributes(response.body.batchInfo) end |
#results ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/restforce/bulk/batch.rb', line 56 def results response = Restforce::Bulk.client.perform_request(:get, "job/#{job_id}/batch/#{id}/result") parser = results_parser_for(response.body).new parser.results_on(response.body).map do |result| Restforce::Bulk::Result.new({job_id: job_id, batch_id: id}.merge(result)) end end |