embulk-output-mailchimp 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: d462b2519072612b11fffb5c9b1fb8757cbb4bdd
4
- data.tar.gz: 16b9f327b2753b7c70b658f8b55f4b0f638da3f9
3
+ metadata.gz: 92e111dbfbaaee02d87b45d1ae39c2e6dd914d02
4
+ data.tar.gz: d43b6d2dd64e38d9f7adade36a7150d7797dffbb
5
5
  SHA512:
6
- metadata.gz: d9df5f728fcb0c1204d94e86e7091666d4c9b879cf5cf88c00080991a252cff2bb6e2c85cd86c4bd72b0a3784ae363fb6ff0569f50672927605b5d0d9d3703d8
7
- data.tar.gz: 66e55275124e6eed5d405dd9a9a2b403ea934b06b8d6878d2f412aa5ac36fd4a50a63f90162a9cf11ad7df541f336e52472a0b1cc1e4a292530489d052ad04b3
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
@@ -18,7 +18,7 @@ configurations {
18
18
  provided
19
19
  }
20
20
 
21
- version = "0.3.2"
21
+ version = "0.3.3"
22
22
 
23
23
  sourceCompatibility = 1.7
24
24
  targetCompatibility = 1.7
@@ -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 value = input.findValue(category).asText();
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
- // Otherwise, force update all categories include user-predefined categories
303
- if (!task.getReplaceInterests() && availableCategories.get(value) != null) {
304
- interests.put(availableCategories.get(value).getId(), true);
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 (availableCategory.equals(value)) {
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.2
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-30 00:00:00.000000000 Z
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.2.jar
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