embulk-output-mailchimp 0.3.2 → 0.3.3
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/CHANGELOG.md +3 -0
- data/build.gradle +1 -1
- data/classpath/{embulk-output-mailchimp-0.3.2.jar → embulk-output-mailchimp-0.3.3.jar} +0 -0
- data/src/main/java/org/embulk/output/mailchimp/MailChimpAbstractRecordBuffer.java +11 -6
- data/src/main/java/org/embulk/output/mailchimp/helper/MailChimpHelper.java +14 -0
- data/src/test/java/org/embulk/output/mailchimp/TestMailChimpHelper.java +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92e111dbfbaaee02d87b45d1ae39c2e6dd914d02
|
4
|
+
data.tar.gz: d43b6d2dd64e38d9f7adade36a7150d7797dffbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b964ecead23dffe33f4d7d87c423fccc1dbe8e9a6ade2ee8a74cd97aa7835450b71712a6fda217e856318fde7d4c1255dc38e121b57f4662a203c76a24daf57d
|
7
|
+
data.tar.gz: d9a401164212cb808c217d34ff948eba672bee2105b1ad7f459557d43cf3566e8c75cddd88213526ed33411535d1eca5b557e7da381a3bd21f4b3a84afb2742f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.3.3 - 2017-05-31
|
2
|
+
- Enable multiple values for `interest categories` [#19](https://github.com/treasure-data/embulk-output-mailchimp/pull/19)
|
3
|
+
|
1
4
|
## 0.3.2 - 2017-05-30
|
2
5
|
- Rename `interest_categories` to `grouping_columns` to fix backward compatibility [#18](https://github.com/treasure-data/embulk-output-mailchimp/pull/18)
|
3
6
|
|
data/build.gradle
CHANGED
Binary file
|
@@ -31,6 +31,7 @@ import java.util.List;
|
|
31
31
|
import java.util.Map;
|
32
32
|
|
33
33
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive;
|
34
|
+
import static org.embulk.output.mailchimp.helper.MailChimpHelper.fromCommaSeparatedString;
|
34
35
|
import static org.embulk.output.mailchimp.model.MemberStatus.PENDING;
|
35
36
|
import static org.embulk.output.mailchimp.model.MemberStatus.SUBSCRIBED;
|
36
37
|
|
@@ -295,17 +296,21 @@ public abstract class MailChimpAbstractRecordBuffer
|
|
295
296
|
ObjectNode interests = JsonNodeFactory.instance.objectNode();
|
296
297
|
|
297
298
|
for (String category : task.getGroupingColumns().get()) {
|
298
|
-
String
|
299
|
+
String inputValue = input.findValue(category).asText();
|
300
|
+
List<String> interestValues = fromCommaSeparatedString(inputValue);
|
299
301
|
Map<String, InterestResponse> availableCategories = categories.get(category);
|
300
302
|
|
301
303
|
// Only update user-predefined categories if replace interests != true
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
304
|
+
if (!task.getReplaceInterests()) {
|
305
|
+
for (String interestValue : interestValues) {
|
306
|
+
if (availableCategories.get(interestValue) != null) {
|
307
|
+
interests.put(availableCategories.get(interestValue).getId(), true);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
} // Otherwise, force update all categories include user-predefined categories
|
306
311
|
else if (task.getReplaceInterests()) {
|
307
312
|
for (String availableCategory : availableCategories.keySet()) {
|
308
|
-
if (
|
313
|
+
if (interestValues.contains(availableCategory)) {
|
309
314
|
interests.put(availableCategories.get(availableCategory).getId(), true);
|
310
315
|
}
|
311
316
|
else {
|
@@ -2,6 +2,8 @@ package org.embulk.output.mailchimp.helper;
|
|
2
2
|
|
3
3
|
import com.fasterxml.jackson.databind.JsonNode;
|
4
4
|
import com.google.common.base.Function;
|
5
|
+
import com.google.common.base.Splitter;
|
6
|
+
import com.google.common.collect.Lists;
|
5
7
|
import com.google.common.collect.Multimap;
|
6
8
|
import com.google.common.collect.Multimaps;
|
7
9
|
|
@@ -67,4 +69,16 @@ public final class MailChimpHelper
|
|
67
69
|
|
68
70
|
return Multimaps.index(data, function);
|
69
71
|
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* From comma separated string list.
|
75
|
+
*
|
76
|
+
* @param string the string
|
77
|
+
* @return the list
|
78
|
+
*/
|
79
|
+
public static List<String> fromCommaSeparatedString(String string)
|
80
|
+
{
|
81
|
+
Iterable<String> split = Splitter.on(",").omitEmptyStrings().trimResults().split(string);
|
82
|
+
return Lists.newArrayList(split);
|
83
|
+
}
|
70
84
|
}
|
@@ -3,6 +3,7 @@ package org.embulk.output.mailchimp;
|
|
3
3
|
import com.fasterxml.jackson.databind.JsonNode;
|
4
4
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
5
5
|
import com.google.common.collect.Multimap;
|
6
|
+
import org.embulk.output.mailchimp.helper.MailChimpHelper;
|
6
7
|
import org.junit.Test;
|
7
8
|
|
8
9
|
import java.util.ArrayList;
|
@@ -12,6 +13,7 @@ import java.util.List;
|
|
12
13
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive;
|
13
14
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.extractMemberStatus;
|
14
15
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.maskEmail;
|
16
|
+
import static org.junit.Assert.assertArrayEquals;
|
15
17
|
import static org.junit.Assert.assertEquals;
|
16
18
|
|
17
19
|
/**
|
@@ -51,4 +53,14 @@ public class TestMailChimpHelper
|
|
51
53
|
assertEquals("Status should contain keys", true, statusMap.containsKey("subcribed"));
|
52
54
|
assertEquals("Status should contain keys", true, statusMap.containsKey("abc"));
|
53
55
|
}
|
56
|
+
|
57
|
+
@Test
|
58
|
+
public void test_fromCommaSeparatedString()
|
59
|
+
{
|
60
|
+
String[] expect = new String[]{"Donating", "United State"};
|
61
|
+
List separatedString = MailChimpHelper.fromCommaSeparatedString("Donating,United State");
|
62
|
+
|
63
|
+
assertEquals("Length should match", expect.length, separatedString.size());
|
64
|
+
assertArrayEquals("Should match", expect, separatedString.toArray());
|
65
|
+
}
|
54
66
|
}
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thang Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ files:
|
|
86
86
|
- test/override_assert_raise.rb
|
87
87
|
- test/run-test.rb
|
88
88
|
- classpath/embulk-base-restclient-0.5.0.jar
|
89
|
-
- classpath/embulk-output-mailchimp-0.3.
|
89
|
+
- classpath/embulk-output-mailchimp-0.3.3.jar
|
90
90
|
- classpath/embulk-util-retryhelper-jetty92-0.5.0.jar
|
91
91
|
- classpath/jetty-client-9.2.14.v20151106.jar
|
92
92
|
- classpath/jetty-http-9.2.14.v20151106.jar
|