active_force 0.19.0 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/active_force/bulk/records.rb +18 -1
- data/lib/active_force/version.rb +1 -1
- data/spec/active_force/bulk/record_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1fbcc63ac7ef2ec3ac8efdadd055a61ae8e98fe721473a054d9207d95bc495e
|
4
|
+
data.tar.gz: 838eebde842f1edcc4b2b2a879b1697aec7439852af0f563b9f6687760b57434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec076a1ffc49293809ebb2c66445ca70b1e016c82be03f4bf6803a6482b18d014711caca4112f7875f8a76cf85b27d1381cb8ffd2a749f7c49b21f801f298af6
|
7
|
+
data.tar.gz: 24378ad367f6ff96edaa88a902c946d5d2f38f71e69d1745cc7d769b0cb1d70dec4752e5825774506985c47202ed15835268b3ad08b1d5d255f6dbfb34b24e44
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Not released
|
4
4
|
|
5
|
+
## 0.20.1
|
6
|
+
- Revert "ActiveForce .first performance enhancement (#73)" (https://github.com/Beyond-Finance/active_force/pull/76)
|
7
|
+
|
8
|
+
## 0.20.0
|
9
|
+
|
10
|
+
- Change `.first` to not query the API if records have already been retrieved (https://github.com/Beyond-Finance/active_force/pull/73)
|
11
|
+
- Bugfix: Transform NULL values for SF Bulk API, which expects "#N/A" (https://github.com/Beyond-Finance/active_force/pull/74)
|
12
|
+
|
5
13
|
## 0.19.0
|
6
14
|
|
7
15
|
- Bulk API methods. (https://github.com/Beyond-Finance/active_force/pull/65)
|
@@ -3,6 +3,8 @@ require 'csv'
|
|
3
3
|
module ActiveForce
|
4
4
|
module Bulk
|
5
5
|
class Records
|
6
|
+
NULL_VALUE = '#N/A'.freeze
|
7
|
+
|
6
8
|
attr_reader :headers, :data
|
7
9
|
def initialize(headers:, data:)
|
8
10
|
@headers = headers
|
@@ -16,10 +18,25 @@ module ActiveForce
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.parse_from_attributes(records)
|
21
|
+
# Sorting ensures that the headers line up with the values for the CSV
|
19
22
|
headers = records.first.keys.sort.map(&:to_s)
|
20
|
-
data = records.map
|
23
|
+
data = records.map do |r|
|
24
|
+
r.transform_values { |v| transform_value_for_sf(v) }.sort.pluck(-1)
|
25
|
+
end
|
21
26
|
new(headers: headers, data: data)
|
22
27
|
end
|
28
|
+
|
29
|
+
# SF expects a special value for setting a column to be NULL.
|
30
|
+
def self.transform_value_for_sf(value)
|
31
|
+
case value
|
32
|
+
when NilClass
|
33
|
+
NULL_VALUE
|
34
|
+
when Time
|
35
|
+
value.iso8601
|
36
|
+
else
|
37
|
+
value.to_s
|
38
|
+
end
|
39
|
+
end
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
data/lib/active_force/version.rb
CHANGED
@@ -9,11 +9,13 @@ describe ActiveForce::Bulk::Records do
|
|
9
9
|
%w[value3 value4],
|
10
10
|
]
|
11
11
|
end
|
12
|
+
|
12
13
|
describe '#to_csv' do
|
13
14
|
it 'returns CSV with headers' do
|
14
15
|
expect(subject.to_csv).to eq "header1,header2\nvalue1,value2\nvalue3,value4\n"
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
17
19
|
describe '::parse_from_attributes' do
|
18
20
|
subject { described_class.parse_from_attributes(attributes) }
|
19
21
|
let(:attributes) do
|
@@ -28,5 +30,25 @@ describe ActiveForce::Bulk::Records do
|
|
28
30
|
expect(records.headers).to eq headers
|
29
31
|
expect(records.data).to eq data
|
30
32
|
end
|
33
|
+
|
34
|
+
context 'when there are NULL values' do
|
35
|
+
let(:attributes) do
|
36
|
+
[
|
37
|
+
{ header1: nil, header2: 'value2'},
|
38
|
+
{ header1: 'value3', header2: nil},
|
39
|
+
]
|
40
|
+
end
|
41
|
+
let(:data) do
|
42
|
+
[
|
43
|
+
%w[#N/A value2],
|
44
|
+
%w[value3 #N/A],
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'substitutes the expected SF value for NULL' do
|
49
|
+
records = subject
|
50
|
+
expect(records.data).to eq data
|
51
|
+
end
|
52
|
+
end
|
31
53
|
end
|
32
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_force
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Espinaco
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-11-
|
14
|
+
date: 2023-11-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activemodel
|