salesforce_bulk2 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,7 @@ module SalesforceBulk2
|
|
60
60
|
|
61
61
|
@data = data
|
62
62
|
body = data
|
63
|
-
|
63
|
+
|
64
64
|
if data.is_a?(Array)
|
65
65
|
raise ArgumentError, "Batch data set exceeds #{@@batch_size} record limit by #{data.length - @@batch_size}" if data.length > @@batch_size
|
66
66
|
raise ArgumentError, "Batch data set is empty" if data.length < 1
|
@@ -87,7 +87,7 @@ module SalesforceBulk2
|
|
87
87
|
|
88
88
|
def get_result
|
89
89
|
response = @client.http_get("job/#{@job_id}/batch/#{@id}/result")
|
90
|
-
|
90
|
+
|
91
91
|
#Query Result
|
92
92
|
if response.body =~ /<.*?>/m
|
93
93
|
result = XmlSimple.xml_in(response.body)
|
@@ -185,22 +185,21 @@ module SalesforceBulk2
|
|
185
185
|
@jobs.map(&:abort)
|
186
186
|
end
|
187
187
|
|
188
|
-
|
189
188
|
## Operations
|
190
189
|
def delete(sobject, data, batch_size = nil)
|
191
|
-
perform_operation(:delete, sobject, data, :batch_size =>
|
190
|
+
perform_operation(:delete, sobject, data, :batch_size => batch_size)
|
192
191
|
end
|
193
192
|
|
194
193
|
def insert(sobject, data, batch_size = nil)
|
195
|
-
perform_operation(:insert, sobject, data, :batch_size =>
|
194
|
+
perform_operation(:insert, sobject, data, :batch_size => batch_size)
|
196
195
|
end
|
197
196
|
|
198
|
-
def query(sobject,
|
199
|
-
perform_operation(:query, sobject,
|
197
|
+
def query(sobject, query, batch_size = nil)
|
198
|
+
perform_operation(:query, sobject, query, :batch_size => batch_size)
|
200
199
|
end
|
201
200
|
|
202
201
|
def update(sobject, data, batch_size = nil)
|
203
|
-
perform_operation(:update, sobject, data, :batch_size =>
|
202
|
+
perform_operation(:update, sobject, data, :batch_size => batch_size)
|
204
203
|
end
|
205
204
|
|
206
205
|
def upsert(sobject, data, external_id, batch_size = nil)
|
@@ -210,7 +209,12 @@ module SalesforceBulk2
|
|
210
209
|
def perform_operation(operation, sobject, data, options = {})
|
211
210
|
job = new_job(operation: operation, object: sobject, :external_id => options[:external_id])
|
212
211
|
|
213
|
-
|
212
|
+
if data.is_a?(Array)
|
213
|
+
job.add_data(data, options[:batch_size])
|
214
|
+
else
|
215
|
+
job.new_batch(data)
|
216
|
+
end
|
217
|
+
|
214
218
|
job.close
|
215
219
|
|
216
220
|
until job.finished?
|
data/lib/salesforce_bulk2/job.rb
CHANGED
@@ -144,17 +144,13 @@ module SalesforceBulk2
|
|
144
144
|
|
145
145
|
def get_results
|
146
146
|
results = BatchResultCollection.new
|
147
|
-
|
148
147
|
get_batches.each { |batch| results << batch.get_result }
|
149
|
-
|
150
148
|
results.flatten
|
151
149
|
end
|
152
150
|
|
153
151
|
# def get_requests
|
154
152
|
# results = BatchResultCollection.new
|
155
|
-
|
156
153
|
# get_batches.each { |batch| results << batch.get_request }
|
157
|
-
|
158
154
|
# results.flatten
|
159
155
|
# end
|
160
156
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_bulk2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-08-
|
14
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|