embulk-output-mailchimp 0.3.23 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/mailchimp/MailChimpRecordBuffer.java +31 -17
- data/src/main/java/org/embulk/output/mailchimp/helper/MailChimpHelper.java +3 -4
- data/src/test/java/org/embulk/output/mailchimp/TestMailChimpHelper.java +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd2a4db83fe03e54434449187716447a8c7ce7b
|
4
|
+
data.tar.gz: 3b3385ab55f592b937b38a4cfac2f2c5d62ad548
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727ddd4c581d69b5b34962d73a3d8a54e2e4365ee98b7ddd13df84b04b6c8222adcc101673056c74c113ba061d654034dd7fea4b4dfe1e48e148ddbeaa2b1c2b
|
7
|
+
data.tar.gz: ecd1e9229bb8015e28eea7a5dbedb70e7997b28fb74d78ab3cdafbf4e2790ff6f7f22a0523ace0e710cf873f4bdf2166db9d59a79ae1b77cd50cd933459c6bcf
|
data/build.gradle
CHANGED
@@ -33,9 +33,11 @@ import java.util.HashSet;
|
|
33
33
|
import java.util.List;
|
34
34
|
import java.util.Map;
|
35
35
|
import java.util.Set;
|
36
|
+
import java.util.TreeMap;
|
36
37
|
|
38
|
+
import static java.lang.String.CASE_INSENSITIVE_ORDER;
|
39
|
+
import static java.lang.String.format;
|
37
40
|
import static org.embulk.output.mailchimp.MailChimpOutputPluginDelegate.PluginTask;
|
38
|
-
import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive;
|
39
41
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.fromCommaSeparatedString;
|
40
42
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.orderJsonNode;
|
41
43
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.toJsonNode;
|
@@ -206,26 +208,38 @@ public class MailChimpRecordBuffer
|
|
206
208
|
|
207
209
|
// Update additional merge fields if exist
|
208
210
|
if (task.getMergeFields().isPresent() && !task.getMergeFields().get().isEmpty()) {
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
211
|
+
Map<String, String> columnNameLookup = new TreeMap<>(CASE_INSENSITIVE_ORDER);
|
212
|
+
for (Column col : schema.getColumns()) {
|
213
|
+
columnNameLookup.put(col.getName(), col.getName());
|
214
|
+
}
|
215
|
+
for (String field : task.getMergeFields().get()) {
|
216
|
+
if (!columnNameLookup.containsKey(field)) {
|
217
|
+
LOG.warn(format("Field '%s' is configured on data transfer but cannot be found on any columns.", field));
|
218
|
+
continue;
|
219
|
+
}
|
220
|
+
String columnName = columnNameLookup.get(field);
|
221
|
+
if (!availableMergeFields.containsKey(columnName.toLowerCase())) {
|
222
|
+
LOG.warn(format("Field '%s' is configured on data transfer but is not predefined on Mailchimp.", field));
|
223
|
+
continue;
|
224
|
+
}
|
225
|
+
|
226
|
+
String value = input.hasNonNull(columnName) ? input.findValue(columnName).asText() : "";
|
227
|
+
|
228
|
+
// Try to convert to Json from string with the merge field's type is address
|
229
|
+
if (availableMergeFields.get(columnName).getType()
|
230
|
+
.equals(MergeField.MergeFieldType.ADDRESS.getType())) {
|
231
|
+
JsonNode addressNode = toJsonNode(value);
|
232
|
+
if (addressNode instanceof NullNode) {
|
233
|
+
mergeFields.put(columnName.toUpperCase(), value);
|
224
234
|
}
|
225
235
|
else {
|
226
|
-
mergeFields.
|
236
|
+
mergeFields.set(columnName.toUpperCase(),
|
237
|
+
orderJsonNode(addressNode, AddressMergeFieldAttribute.values()));
|
227
238
|
}
|
228
239
|
}
|
240
|
+
else {
|
241
|
+
mergeFields.put(columnName.toUpperCase(), value);
|
242
|
+
}
|
229
243
|
}
|
230
244
|
}
|
231
245
|
|
@@ -45,15 +45,14 @@ public final class MailChimpHelper
|
|
45
45
|
* @param list the list
|
46
46
|
* @return the boolean
|
47
47
|
*/
|
48
|
-
public static
|
48
|
+
public static boolean containsCaseInsensitive(final String s, final List<String> list)
|
49
49
|
{
|
50
50
|
for (String string : list) {
|
51
51
|
if (string.equalsIgnoreCase(s)) {
|
52
|
-
return
|
52
|
+
return true;
|
53
53
|
}
|
54
54
|
}
|
55
|
-
|
56
|
-
return "";
|
55
|
+
return false;
|
57
56
|
}
|
58
57
|
|
59
58
|
/**
|
@@ -20,6 +20,7 @@ import static org.embulk.output.mailchimp.helper.MailChimpHelper.orderJsonNode;
|
|
20
20
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.toJsonNode;
|
21
21
|
import static org.junit.Assert.assertArrayEquals;
|
22
22
|
import static org.junit.Assert.assertEquals;
|
23
|
+
import static org.junit.Assert.assertTrue;
|
23
24
|
|
24
25
|
/**
|
25
26
|
* Created by thangnc on 4/26/17.
|
@@ -37,8 +38,7 @@ public class TestMailChimpHelper
|
|
37
38
|
@Test
|
38
39
|
public void test_containsCaseInsensitive_validMergeFields()
|
39
40
|
{
|
40
|
-
|
41
|
-
assertEquals("Interest category should match", expect, containsCaseInsensitive("united state",
|
41
|
+
assertTrue("Interest category should match", containsCaseInsensitive("united state",
|
42
42
|
Arrays.asList("Donating", "United State")));
|
43
43
|
}
|
44
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thang Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,13 +88,13 @@ files:
|
|
88
88
|
- test/embulk/output/test_mailchimp.rb
|
89
89
|
- test/override_assert_raise.rb
|
90
90
|
- test/run-test.rb
|
91
|
-
- classpath/embulk-base-restclient-0.5.3.jar
|
92
|
-
- classpath/embulk-output-mailchimp-0.3.23.jar
|
93
|
-
- classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
|
94
|
-
- classpath/jetty-client-9.2.14.v20151106.jar
|
95
|
-
- classpath/jetty-http-9.2.14.v20151106.jar
|
96
91
|
- classpath/jetty-io-9.2.14.v20151106.jar
|
92
|
+
- classpath/embulk-output-mailchimp-0.3.24.jar
|
97
93
|
- classpath/jetty-util-9.2.14.v20151106.jar
|
94
|
+
- classpath/jetty-http-9.2.14.v20151106.jar
|
95
|
+
- classpath/jetty-client-9.2.14.v20151106.jar
|
96
|
+
- classpath/embulk-base-restclient-0.5.3.jar
|
97
|
+
- classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
|
98
98
|
homepage: https://github.com/treasure-data/embulk-output-mailchimp
|
99
99
|
licenses:
|
100
100
|
- MIT
|