salesforcebulk 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aceb2e1e1f4bf2d5dae8113b8131d2378194fb9d49b6be5692782d077e7b8129
4
- data.tar.gz: eea875e4951aabdad0f7be3f2346af0d716ea818dff2fcc171538daf39009669
3
+ metadata.gz: f820b68636330723af5423eac1fd9c0bbbc09cb22fe14651bf82f9b9a76108bf
4
+ data.tar.gz: af753d04858e10b980c5c140ab2e0bd251f33edd4e9382f96c0112d40a16f0e4
5
5
  SHA512:
6
- metadata.gz: df9d8c3b856594bf0ff565291d81f4162c54be74426be63a7eb15eec58054d6f02dfa30e11ae477c66c4a3c5a0ca182fcc5f568bd90ed335944c8700075194a9
7
- data.tar.gz: 1d15a68c54bc8e27d651ade36b2df3fc730cee2b52b9b9ad5e86293105bd6fa0556fe6200f1e1a9997625f74e6c89d734180db1317fc1beecf3fc0ec15aaef5a
6
+ metadata.gz: 880925281c6aded2a647d9ad59eed9d9f5d2459c8093e9616f8569ee675b7562e8504663e64421e7d4d8ba3e7c73db0be534de75fe41af082b15cfcd5f08fa3e
7
+ data.tar.gz: 7987781dfd889b6b27f0ae32bf13e49f83a3e1f8c1872c42ca47bb0c33605b13aeeb7d71002b8d02f9072a44d8f76b665b29254ffc8ae022832d4fa48a85aa88
data/README.md CHANGED
@@ -1,41 +1,34 @@
1
1
  # SalesforceBulk
2
2
 
3
- [![Version][rubygems_badge]][rubygems]
4
- [rubygems_badge]: http://img.shields.io/gem/v/salesforcebulk.svg
5
- [rubygems]: https://rubygems.org/gems/salesforcebulk
6
-
7
- [![Travis CI][travis_badge]][travis]
8
- [travis_badge]: http://img.shields.io/travis/javierjulio/salesforce_bulk/master.svg
9
- [travis]: https://travis-ci.org/javierjulio/salesforce_bulk
3
+ [![Gem Version](https://badge.fury.io/rb/salesforcebulk.svg)](https://badge.fury.io/rb/salesforcebulk)
4
+ [![Tests](https://github.com/javierjulio/salesforce_bulk/actions/workflows/ci.yml/badge.svg)](https://github.com/javierjulio/salesforce_bulk/actions/workflows/ci.yml)
10
5
 
11
6
  ## Overview
12
7
 
13
- SalesforceBulk is an easy to use Ruby gem for connecting to and using the [Salesforce Bulk API](http://www.salesforce.com/us/developer/docs/api_asynch/index.htm). This is a rewrite and separate release of Jorge Valdivia's salesforce_bulk gem (renamed `salesforcebulk`) with full unit tests and full API capability (e.g. adding multiple batches per job). This gem was built on Ruby 2.0.0, 2.1.6, and 2.2.2.
8
+ SalesforceBulk is an easy to use Ruby gem for connecting to and using the [Salesforce Bulk API](http://www.salesforce.com/us/developer/docs/api_asynch/index.htm). This is a rewrite and separate release of Jorge Valdivia's salesforce_bulk gem (renamed `salesforcebulk`) with full unit tests and full API capability (e.g. adding multiple batches per job).
14
9
 
15
10
  ## Installation
16
11
 
17
12
  Install SalesforceBulk from RubyGems:
18
13
 
19
- gem install salesforcebulk
14
+ ```
15
+ gem install salesforcebulk
16
+ ```
20
17
 
21
18
  Or include it in your project's `Gemfile` with Bundler:
22
19
 
23
- gem 'salesforcebulk'
20
+ ```ruby
21
+ gem 'salesforcebulk'
22
+ ```
24
23
 
25
24
  ## Contribute
26
25
 
27
- To contribute, fork this repo, create a topic branch, make changes, then send a pull request. Pull requests without accompanying tests will *not* be accepted. If you need help creating tests let me know and I'll help out. To setup the project and run tests in your fork, just do:
28
-
29
- bundle install
30
- rake
31
-
32
- To run the test suite on all gemfiles with your current ruby version, use:
33
-
34
- bundle exec rake wwtd:local
35
-
36
- To run the full test suite with different gemfiles and ruby versions, use:
26
+ To contribute, fork this repo, create a topic branch, add changes and tests, then send a pull request. To setup the project and run tests in your fork, just do:
37
27
 
38
- bundle exec rake wwtd
28
+ ```
29
+ bundle install
30
+ bundle exec rake
31
+ ```
39
32
 
40
33
  ## Configuration and Initialization
41
34
 
@@ -43,87 +36,84 @@ To run the full test suite with different gemfiles and ruby versions, use:
43
36
 
44
37
  When retrieving a password you will also be given a security token. Combine the two into a single value as the API treats this as your real password.
45
38
 
46
- require 'salesforce_bulk'
39
+ ```ruby
40
+ require 'salesforce_bulk'
47
41
 
48
- client = SalesforceBulk::Client.new(username: 'MyUsername', password: 'MyPasswordWithSecurtyToken')
49
- client.authenticate
42
+ client = SalesforceBulk::Client.new(username: 'MyUsername', password: 'MyPasswordWithSecurtyToken')
43
+ client.authenticate
44
+ ```
50
45
 
51
46
  Optional keys include `login_host` (default is 'login.salesforce.com') and `version` (default is '24.0').
52
47
 
53
- ### Configuring from a YAML file
54
-
55
- Create a YAML file with the content below. Only `username` and `password` is required.
56
-
57
- ---
58
- username: MyUsername
59
- password: MyPassword
60
- login_host: login.salesforce.com # default
61
- version: 24.0 # default
62
-
63
- Then in a Ruby script:
64
-
65
- require 'salesforce_bulk'
66
-
67
- client = SalesforceBulk::Client.new("config/salesforce_bulk.yml")
68
- client.authenticate
69
-
70
48
  ## Usage Examples
71
49
 
72
50
  An important note about the data in any of the examples below: each hash in a data set must have the same set of keys. If you need to have logic to not include certain values simply specify a nil value for a key rather than not including the key-value pair.
73
51
 
74
52
  ### Basic Overall Example
75
53
 
76
- data1 = [{:Name__c => 'Test 1'}, {:Name__c => 'Test 2'}]
77
- data2 = [{:Name__c => 'Test 3'}, {:Name__c => 'Test 4'}]
54
+ ```ruby
55
+ data1 = [{:Name__c => 'Test 1'}, {:Name__c => 'Test 2'}]
56
+ data2 = [{:Name__c => 'Test 3'}, {:Name__c => 'Test 4'}]
78
57
 
79
- job = client.add_job(:insert, :MyObject__c)
58
+ job = client.add_job(:insert, :MyObject__c)
80
59
 
81
- # easily add multiple batches to a job
82
- batch = client.add_batch(job.id, data1)
83
- batch = client.add_batch(job.id, data2)
60
+ # easily add multiple batches to a job
61
+ batch = client.add_batch(job.id, data1)
62
+ batch = client.add_batch(job.id, data2)
84
63
 
85
- job = client.close_job(job.id) # or use the abort_job(id) method
64
+ job = client.close_job(job.id) # or use the abort_job(id) method
65
+ ```
86
66
 
87
67
  ### Adding a Job
88
68
 
89
69
  When adding a job you can specify the following operations for the first argument:
90
- - :delete
91
- - :insert
92
- - :update
93
- - :upsert
94
- - :query
70
+ - `:delete`
71
+ - `:insert`
72
+ - `:update`
73
+ - `:upsert`
74
+ - `:query`
95
75
 
96
76
  When using the :upsert operation you must specify an external ID field name:
97
77
 
98
- job = client.add_job(:upsert, :MyObject__c, :external_id_field_name => :MyId__c)
78
+ ```ruby
79
+ job = client.add_job(:upsert, :MyObject__c, :external_id_field_name => :MyId__c)
80
+ ```
99
81
 
100
82
  For any operation you should be able to specify a concurrency mode. The default is `Parallel`. The only other choice is `Serial`.
101
83
 
102
- job = client.add_job(:upsert, :MyObject__c, :concurrency_mode => :Serial, :external_id_field_name => :MyId__c)
84
+ ```ruby
85
+ job = client.add_job(:upsert, :MyObject__c, :concurrency_mode => :Serial, :external_id_field_name => :MyId__c)
86
+ ```
103
87
 
104
88
  ### Retrieving Job Information (e.g. Status)
105
89
 
106
90
  The Job object has various properties such as status, created time, number of completed and failed batches and various other values.
107
91
 
108
- job = client.job_info(jobId) # returns a Job object
92
+ ```ruby
93
+ job = client.job_info(jobId) # returns a Job object
109
94
 
110
- puts "Job #{job.id} is closed." if job.closed? # other: open?, aborted?
95
+ puts "Job #{job.id} is closed." if job.closed? # other: open?, aborted?
96
+ ```
111
97
 
112
98
  ### Retrieving Info for a single Batch
113
99
 
114
100
  The Batch object has various properties such as status, created time, number of processed and failed records and various other values.
115
101
 
116
- batch = client.batch_info(jobId, batchId) # returns a Batch object
102
+ ```ruby
103
+ batch = client.batch_info(jobId, batchId) # returns a Batch object
117
104
 
118
- puts "Batch #{batch.id} is in progress." if batch.in_progress?
105
+ puts "Batch #{batch.id} is in progress." if batch.in_progress?
106
+ ```
119
107
 
120
108
  ### Retrieving Info for all Batches
121
109
 
122
- batches = client.batch_info_list(jobId) # returns an Array of Batch objects
110
+ ```ruby
111
+ batches = client.batch_info_list(jobId) # returns an Array of Batch objects
123
112
 
124
- batches.each do |batch|
125
- puts "Batch #{batch.id} completed." if batch.completed? # other: failed?, in_progress?, queued?
126
- end
113
+ batches.each do |batch|
114
+ puts "Batch #{batch.id} completed." if batch.completed? # other: failed?, in_progress?, queued?
115
+ end
116
+ ```
127
117
 
128
118
  ### Retrieving Batch Results (for Delete, Insert, Update and Upsert)
129
119
 
@@ -131,11 +121,13 @@ To verify that a batch completed successfully or failed call the `batch_info` or
131
121
 
132
122
  The object returned from the following example only applies to the operations: `delete`, `insert`, `update` and `upsert`. Query results are handled differently.
133
123
 
134
- results = client.batch_result(jobId, batchId) # returns an Array of BatchResult objects
124
+ ```ruby
125
+ results = client.batch_result(jobId, batchId) # returns an Array of BatchResult objects
135
126
 
136
- results.each do |result|
137
- puts "Item #{result.id} had an error of: #{result.error}" if result.error?
138
- end
127
+ results.each do |result|
128
+ puts "Item #{result.id} had an error of: #{result.error}" if result.error?
129
+ end
130
+ ```
139
131
 
140
132
  ### Retrieving Query based Batch Results
141
133
 
@@ -143,21 +135,23 @@ To verify that a batch completed successfully or failed call the `batch_info` or
143
135
 
144
136
  Query results are handled differently as its possible that a single batch could return multiple results if objects returned are large enough. Note: I haven't been able to replicate this behavior but in a fork by @WWJacob has [discovered that multiple results can be returned](https://github.com/WWJacob/salesforce_bulk/commit/8f9e68c390230e885823e45cd2616ac3159697ef).
145
137
 
146
- # returns a QueryResultCollection object (an Array)
147
- results = client.batch_result(jobId, batchId)
138
+ ```ruby
139
+ # returns a QueryResultCollection object (an Array)
140
+ results = client.batch_result(jobId, batchId)
148
141
 
149
- while results.any?
142
+ while results.any?
150
143
 
151
- # Assuming query was: SELECT Id, Name, CustomField__c FROM Account
152
- results.each do |result|
153
- puts result[:Id], result[:Name], result[:CustomField__c]
154
- end
144
+ # Assuming query was: SELECT Id, Name, CustomField__c FROM Account
145
+ results.each do |result|
146
+ puts result[:Id], result[:Name], result[:CustomField__c]
147
+ end
155
148
 
156
- puts "Another set is available." if results.next?
149
+ puts "Another set is available." if results.next?
157
150
 
158
- results.next
151
+ results.next
159
152
 
160
- end
153
+ end
154
+ ```
161
155
 
162
156
  Note: By reviewing the API docs and response format my understanding was that the API would return multiple results sets for a single batch if the query was to large but this does not seem to be the case in my live testing. It seems to be capped at 10000 records (as it when inserting data) but I haven't been able to verify through the documentation. If you know anything about that your input is appreciated. In the meantime the gem was built to support multiple result sets for a query batch but seems that will change which will simplify that method.
163
157
 
@@ -171,78 +165,14 @@ To release a new version, update the version number in `version.rb`, and then ru
171
165
  - Clean up/reorganize tests better
172
166
  - Rdocs
173
167
 
174
- ## Version History
175
-
176
- **3.0.0** (July 19, 2017)
177
-
178
- * Dropped old Ruby support, now requires Ruby 2.3 and up
179
- * Dropped Travis build for Rails 4.0
180
- * Added support for re-authenticating ([#20]((https://github.com/javierjulio/salesforce_bulk/pull/20))
181
- * Use the right tag name for total batches in job info ([#19]((https://github.com/javierjulio/salesforce_bulk/pull/19))
168
+ ### Releasing
182
169
 
183
- **2.0.2** (February 20, 2017)
184
-
185
- * Rails 5 support by relaxing ActiveSupport dependency ([#18](https://github.com/javierjulio/salesforce_bulk/pull/18))
186
-
187
- **2.0.1** (January 24, 2017)
188
-
189
- * Bug fix for response handling ([#17](https://github.com/javierjulio/salesforce_bulk/pull/17))
190
-
191
- **2.0.0** (April 25, 2015)
192
-
193
- * Dropped support for Ruby 1.8 and Ruby 1.9
194
- * Added support for Ruby 2.0, 2.1 and 2.2
195
- * Added support for Rails 4.0, 4.1 an 4.2
196
- * Changed test_helper to avoid requiring test_unit (removed in Ruby 2.2)
197
- * Replaced Test::Unit::TestCase with ActiveSupport::TestCase
198
- * Bumped shoulda and losen dependencies on minitest
199
- * All changes in PR's #13, #14, #15, #16 - thanks [@pschambacher](https://github.com/pschambacher)
200
-
201
- **1.4.0** (June 1, 2014)
202
-
203
- * Added state_message to Batch class (#11 - thanks [@bethesque](https://github.com/bethesque))
204
-
205
- **1.3.0** (April 28, 2014)
206
-
207
- * Added support for multiple subdomains (#10 - thanks [@lucianapazos](https://github.com/lucianapazos))
208
- * Added dependency version requirements to gemspec
209
-
210
- **1.2.0** (October 10, 2012)
211
-
212
- * Added Ruby 1.8.7 support (thanks [@dlee](https://github.com/dlee))
213
-
214
- **1.1.0** (August 20, 2012)
215
-
216
- * Added travis setup. Support for Ruby 1.9.2 and 1.9.3 specified.
217
- * Removed `token` property on Client object. Specify token in `password` field.
218
- * Accepted pull request for 1.9.3 improvements.
219
- * Description updates in README.
170
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
220
171
 
221
- **1.0.0** (August 17, 2012)
172
+ ## Contributing
222
173
 
223
- * Initial public release.
174
+ Bug reports and pull requests are welcome on GitHub at https://github.com/javierjulio/salesforce_bulk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
224
175
 
225
176
  ## License
226
177
 
227
- (The MIT license)
228
-
229
- Copyright (c) 2012 Javier Julio
230
-
231
- Permission is hereby granted, free of charge, to any person obtaining
232
- a copy of this software and associated documentation files (the
233
- "Software"), to deal in the Software without restriction, including
234
- without limitation the rights to use, copy, modify, merge, publish,
235
- distribute, sublicense, and/or sell copies of the Software, and to
236
- permit persons to whom the Software is furnished to do so, subject to
237
- the following conditions:
238
-
239
- The above copyright notice and this permission notice shall be
240
- included in all copies or substantial portions of the Software.
241
-
242
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
243
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
244
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
245
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
246
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
247
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
248
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
178
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,11 +1,7 @@
1
- require 'net/https'
1
+ require 'net/http'
2
2
  require 'xmlsimple'
3
3
  require 'csv'
4
- require 'active_support'
5
- require 'active_support/core_ext/object/blank'
6
- require 'active_support/core_ext/hash/keys'
7
4
  require 'salesforce_bulk/version'
8
- require 'salesforce_bulk/core_extensions/string'
9
5
  require 'salesforce_bulk/salesforce_error'
10
6
  require 'salesforce_bulk/client'
11
7
  require 'salesforce_bulk/job'
@@ -46,7 +46,7 @@ module SalesforceBulk
46
46
  end
47
47
 
48
48
  def state?(value)
49
- self.state.present? && self.state.casecmp(value) == 0
49
+ !self.state.nil? && self.state.casecmp(value) == 0
50
50
  end
51
51
  end
52
52
  end
@@ -1,37 +1,37 @@
1
1
  module SalesforceBulk
2
2
  class BatchResult
3
-
3
+
4
4
  # A boolean indicating if record was created. If updated value is false.
5
5
  attr_accessor :created
6
-
6
+
7
7
  # The error message.
8
8
  attr_accessor :error
9
-
9
+
10
10
  # The record's unique id.
11
11
  attr_accessor :id
12
-
13
- # If record was created successfully. If false then an error message is provided.
12
+
13
+ # If record was created successfully. If false then an error message is provided.
14
14
  attr_accessor :success
15
-
15
+
16
16
  def initialize(id, success, created, error)
17
17
  @id = id
18
18
  @success = success
19
19
  @created = created
20
20
  @error = error
21
21
  end
22
-
22
+
23
23
  def error?
24
- error.present?
24
+ !error.nil? && error.respond_to?(:empty?) && !error.empty?
25
25
  end
26
-
26
+
27
27
  def created?
28
28
  created
29
29
  end
30
-
30
+
31
31
  def successful?
32
32
  success
33
33
  end
34
-
34
+
35
35
  def updated?
36
36
  !created && success
37
37
  end
@@ -21,14 +21,9 @@ module SalesforceBulk
21
21
  attr_reader :session_id
22
22
 
23
23
  def initialize(options={})
24
- if options.is_a?(String)
25
- options = YAML.load_file(options)
26
- options.symbolize_keys!
27
- end
28
-
29
24
  options = {:login_host => 'login.salesforce.com', :version => 24.0}.merge(options)
30
25
 
31
- options.assert_valid_keys(:username, :password, :login_host, :version)
26
+ assert_valid_keys(options, :username, :password, :login_host, :version)
32
27
 
33
28
  self.username = options[:username]
34
29
  self.password = "#{options[:password]}"
@@ -106,7 +101,7 @@ module SalesforceBulk
106
101
 
107
102
  raise ArgumentError.new("Invalid operation: #{operation}") unless @valid_operations.include?(operation)
108
103
 
109
- options.assert_valid_keys(:external_id_field_name, :concurrency_mode)
104
+ assert_valid_keys(options, :external_id_field_name, :concurrency_mode)
110
105
 
111
106
  if options[:concurrency_mode]
112
107
  concurrency_mode = options[:concurrency_mode].capitalize
@@ -124,7 +119,7 @@ module SalesforceBulk
124
119
 
125
120
  response = http_post("job", xml)
126
121
  data = XmlSimple.xml_in(response.body, 'ForceArray' => false)
127
- job = Job.new_from_xml(data)
122
+ Job.new_from_xml(data)
128
123
  end
129
124
 
130
125
  def batch_info_list(jobId)
@@ -152,7 +147,7 @@ module SalesforceBulk
152
147
  if ['application/xml', 'text/xml'].include? response.content_type
153
148
  result = XmlSimple.xml_in(response.body)
154
149
 
155
- if result['result'].present?
150
+ if !result['result'].nil? && !result['result'].empty?
156
151
  results = query_result(jobId, batchId, result['result'].first)
157
152
 
158
153
  collection = QueryResultCollection.new(self, jobId, batchId, result['result'].first, result['result'])
@@ -162,7 +157,7 @@ module SalesforceBulk
162
157
  result = BatchResultCollection.new(jobId, batchId)
163
158
 
164
159
  CSV.parse(response.body, :headers => true) do |row|
165
- result << BatchResult.new(row[0], row[1].to_b, row[2].to_b, row[3])
160
+ result << BatchResult.new(row[0], to_boolean(row[1]), to_boolean(row[2]), row[3])
166
161
  end
167
162
 
168
163
  result
@@ -178,7 +173,7 @@ module SalesforceBulk
178
173
 
179
174
  result = []
180
175
 
181
- #CSV.parse(lines.join, :headers => headers, :converters => [:all, lambda{|s| s.to_b if s.kind_of? String }]) do |row|
176
+ #CSV.parse(lines.join, :headers => headers, :converters => [:all, lambda{|s| to_boolean(s) if s.kind_of? String }]) do |row|
182
177
  CSV.parse(lines.join, :headers => headers) do |row|
183
178
  result << Hash[row.headers.zip(row.fields)]
184
179
  end
@@ -251,5 +246,27 @@ module SalesforceBulk
251
246
  def instance_id(url)
252
247
  url.match(/:\/\/([a-zA-Z0-9\-\.]{2,}).salesforce/)[1]
253
248
  end
249
+
250
+ private
251
+
252
+ def assert_valid_keys(options, *valid_keys)
253
+ valid_keys.flatten!
254
+ options.each_key do |k|
255
+ unless valid_keys.include?(k)
256
+ raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
257
+ end
258
+ end
259
+ end
260
+
261
+ def to_boolean(value)
262
+ if !value.nil?
263
+ if value.strip.casecmp("true") == 0
264
+ return true
265
+ elsif value.strip.casecmp("false") == 0
266
+ return false
267
+ end
268
+ end
269
+ value
270
+ end
254
271
  end
255
272
  end
@@ -1,6 +1,6 @@
1
1
  module SalesforceBulk
2
2
  class Job
3
-
3
+
4
4
  attr_accessor :concurrency_mode
5
5
  attr_accessor :external_id_field_name
6
6
  attr_accessor :id
@@ -23,7 +23,7 @@ module SalesforceBulk
23
23
  attr_accessor :api_active_processing_time
24
24
  attr_accessor :total_processing_time
25
25
  attr_accessor :api_version
26
-
26
+
27
27
  def self.new_from_xml(data)
28
28
  job = self.new
29
29
  job.id = data['id']
@@ -50,21 +50,21 @@ module SalesforceBulk
50
50
  job.api_version = data['apiVersion'].to_i
51
51
  job
52
52
  end
53
-
53
+
54
54
  def aborted?
55
55
  state? 'Aborted'
56
56
  end
57
-
57
+
58
58
  def closed?
59
59
  state? 'Closed'
60
60
  end
61
-
61
+
62
62
  def open?
63
63
  state? 'Open'
64
64
  end
65
-
65
+
66
66
  def state?(value)
67
- self.state.present? && self.state.casecmp(value) == 0
67
+ !self.state.nil? && self.state.casecmp(value) == 0
68
68
  end
69
69
  end
70
70
  end
@@ -1,12 +1,12 @@
1
1
  module SalesforceBulk
2
2
  class QueryResultCollection < Array
3
-
3
+
4
4
  attr_reader :client
5
5
  attr_reader :batch_id
6
6
  attr_reader :job_id
7
7
  attr_reader :result_id
8
8
  attr_reader :result_ids
9
-
9
+
10
10
  def initialize(client, job_id, batch_id, result_id=nil, result_ids=[])
11
11
  @client = client
12
12
  @job_id = job_id
@@ -15,34 +15,34 @@ module SalesforceBulk
15
15
  @result_ids = result_ids
16
16
  @current_index = result_ids.index(result_id) || 0
17
17
  end
18
-
18
+
19
19
  def next?
20
- @result_ids.present? && @current_index < @result_ids.length - 1
20
+ !@result_ids.nil? && !@result_ids.empty? && @current_index < @result_ids.length - 1
21
21
  end
22
-
22
+
23
23
  def next
24
24
  if next?
25
25
  replace(@client.query_result(job_id, batch_id, result_ids[@current_index + 1]))
26
26
  @current_index += 1
27
27
  @result_id = @result_ids[@current_index]
28
28
  end
29
-
29
+
30
30
  self
31
31
  end
32
-
32
+
33
33
  def previous?
34
- @result_ids.present? && @current_index > 0
34
+ !@result_ids.nil? && !@result_ids.empty? && @current_index > 0
35
35
  end
36
-
36
+
37
37
  def previous
38
38
  if previous?
39
39
  replace(@client.query_result(job_id, batch_id, result_ids[@current_index - 1]))
40
40
  @current_index -= 1
41
41
  @result_id = @result_ids[@current_index]
42
42
  end
43
-
43
+
44
44
  self
45
45
  end
46
-
46
+
47
47
  end
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module SalesforceBulk
2
- VERSION = "3.0.0"
2
+ VERSION = "4.0.0"
3
3
  end
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforcebulk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Julio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-19 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '4'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '4'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6'
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: xml-simple
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +39,7 @@ dependencies:
59
39
  - !ruby/object:Gem::Version
60
40
  version: '0'
61
41
  - !ruby/object:Gem::Dependency
62
- name: rdoc
42
+ name: mocha
63
43
  requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
45
  - - ">="
@@ -72,50 +52,8 @@ dependencies:
72
52
  - - ">="
73
53
  - !ruby/object:Gem::Version
74
54
  version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: mocha
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: 0.13.0
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: 0.13.0
89
- - !ruby/object:Gem::Dependency
90
- name: shoulda
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '3.5'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '3.5'
103
55
  - !ruby/object:Gem::Dependency
104
56
  name: webmock
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '3.0'
117
- - !ruby/object:Gem::Dependency
118
- name: minitest
119
57
  requirement: !ruby/object:Gem::Requirement
120
58
  requirements:
121
59
  - - ">="
@@ -129,7 +67,7 @@ dependencies:
129
67
  - !ruby/object:Gem::Version
130
68
  version: '0'
131
69
  - !ruby/object:Gem::Dependency
132
- name: bump
70
+ name: minitest
133
71
  requirement: !ruby/object:Gem::Requirement
134
72
  requirements:
135
73
  - - ">="
@@ -143,7 +81,7 @@ dependencies:
143
81
  - !ruby/object:Gem::Version
144
82
  version: '0'
145
83
  - !ruby/object:Gem::Dependency
146
- name: wwtd
84
+ name: minitest-reporters
147
85
  requirement: !ruby/object:Gem::Requirement
148
86
  requirements:
149
87
  - - ">="
@@ -170,7 +108,6 @@ files:
170
108
  - lib/salesforce_bulk/batch_result.rb
171
109
  - lib/salesforce_bulk/batch_result_collection.rb
172
110
  - lib/salesforce_bulk/client.rb
173
- - lib/salesforce_bulk/core_extensions/string.rb
174
111
  - lib/salesforce_bulk/job.rb
175
112
  - lib/salesforce_bulk/query_result_collection.rb
176
113
  - lib/salesforce_bulk/salesforce_error.rb
@@ -193,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
130
  - !ruby/object:Gem::Version
194
131
  version: '0'
195
132
  requirements: []
196
- rubyforge_project:
197
- rubygems_version: 2.7.6
133
+ rubygems_version: 3.1.4
198
134
  signing_key:
199
135
  specification_version: 4
200
136
  summary: Full capability support for the Salesforce Bulk API.
@@ -1,14 +0,0 @@
1
- class String
2
- # For converting "true" and "false" string values returned
3
- # by Salesforce Bulk API in batch results to real booleans.
4
- def to_b
5
- if present?
6
- if lstrip.rstrip.casecmp("true") == 0
7
- return true
8
- elsif lstrip.rstrip.casecmp("false") == 0
9
- return false
10
- end
11
- end
12
- self
13
- end
14
- end