embulk-output-mailchimp 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/mailchimp/MailChimpAbstractRecordBuffer.java +4 -1
- data/src/main/java/org/embulk/output/mailchimp/helper/MailChimpHelper.java +21 -0
- data/src/main/java/org/embulk/output/mailchimp/model/AddressMergeFieldAttribute.java +49 -0
- data/src/test/java/org/embulk/output/mailchimp/TestMailChimpHelper.java +13 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fde692362348800dfae66c28a9e2c064ba7d833
|
4
|
+
data.tar.gz: 133cbbbe8899d8601640969cd804334305061210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa856a3406ff19159507b877022800cc7455f1c0f1399080510cacf54529c1c09c61dae97328e81f7cbbb4661b69cd97d91856f0e43aa6ee668b148f1631fa96
|
7
|
+
data.tar.gz: 7b273aea4c9ea89d35a3125240aac1ef7165262d437b293a66efc23f124604522a4fbfe8dc52b09225dd3183b4e3ce70447676e11fc5732577f0c4e4f4d01d2f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.3.9 - 2017-06-09
|
2
|
+
- Upgraded version to fix yanked gem file
|
3
|
+
|
4
|
+
## 0.3.8 - 2017-06-09
|
5
|
+
- Fixed JSON format in MERGE field's type is address [#24](https://github.com/treasure-data/embulk-output-mailchimp/pull/24)
|
6
|
+
|
1
7
|
## 0.3.7 - 2017-06-07
|
2
8
|
- Added `ConfigException` while using not exists `list_id` [#23](https://github.com/treasure-data/embulk-output-mailchimp/pull/23)
|
3
9
|
|
data/build.gradle
CHANGED
@@ -15,6 +15,7 @@ import org.embulk.base.restclient.jackson.JacksonServiceRecord;
|
|
15
15
|
import org.embulk.base.restclient.record.RecordBuffer;
|
16
16
|
import org.embulk.base.restclient.record.ServiceRecord;
|
17
17
|
import org.embulk.config.TaskReport;
|
18
|
+
import org.embulk.output.mailchimp.model.AddressMergeFieldAttribute;
|
18
19
|
import org.embulk.output.mailchimp.model.ErrorResponse;
|
19
20
|
import org.embulk.output.mailchimp.model.InterestResponse;
|
20
21
|
import org.embulk.output.mailchimp.model.MergeField;
|
@@ -34,6 +35,7 @@ import java.util.Map;
|
|
34
35
|
|
35
36
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive;
|
36
37
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.fromCommaSeparatedString;
|
38
|
+
import static org.embulk.output.mailchimp.helper.MailChimpHelper.orderJsonNode;
|
37
39
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.toJsonNode;
|
38
40
|
import static org.embulk.output.mailchimp.model.MemberStatus.PENDING;
|
39
41
|
import static org.embulk.output.mailchimp.model.MemberStatus.SUBSCRIBED;
|
@@ -281,7 +283,8 @@ public abstract class MailChimpAbstractRecordBuffer
|
|
281
283
|
mergeFields.put(column.getName().toUpperCase(), value);
|
282
284
|
}
|
283
285
|
else {
|
284
|
-
mergeFields.set(column.getName().toUpperCase(),
|
286
|
+
mergeFields.set(column.getName().toUpperCase(),
|
287
|
+
orderJsonNode(addressNode, AddressMergeFieldAttribute.values()));
|
285
288
|
}
|
286
289
|
}
|
287
290
|
else {
|
@@ -5,11 +5,13 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
5
5
|
import com.fasterxml.jackson.databind.JsonNode;
|
6
6
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
7
7
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
8
|
+
import com.fasterxml.jackson.databind.node.ObjectNode;
|
8
9
|
import com.google.common.base.Function;
|
9
10
|
import com.google.common.base.Splitter;
|
10
11
|
import com.google.common.collect.Lists;
|
11
12
|
import com.google.common.collect.Multimap;
|
12
13
|
import com.google.common.collect.Multimaps;
|
14
|
+
import org.embulk.output.mailchimp.model.AddressMergeFieldAttribute;
|
13
15
|
|
14
16
|
import javax.annotation.Nullable;
|
15
17
|
|
@@ -105,4 +107,23 @@ public final class MailChimpHelper
|
|
105
107
|
return JsonNodeFactory.instance.nullNode();
|
106
108
|
}
|
107
109
|
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* MailChimp API requires MERGE field's type is address that have to json with keys in order.
|
113
|
+
* {"addr1": "a", "addr2": "a1", "city": "c", "state": "s", "zip": "z", "country": "c"}
|
114
|
+
*
|
115
|
+
* @param originalNode the original node
|
116
|
+
* @param attrsInOrder the keys in order
|
117
|
+
* @return the object node
|
118
|
+
*/
|
119
|
+
public static ObjectNode orderJsonNode(final JsonNode originalNode, final AddressMergeFieldAttribute[] attrsInOrder)
|
120
|
+
{
|
121
|
+
ObjectNode orderedNode = JsonNodeFactory.instance.objectNode();
|
122
|
+
for (AddressMergeFieldAttribute attr : attrsInOrder) {
|
123
|
+
orderedNode.put(attr.getName(),
|
124
|
+
originalNode.findValue(attr.getName()) != null ? originalNode.findValue(attr.getName()).asText() : "");
|
125
|
+
}
|
126
|
+
|
127
|
+
return orderedNode;
|
128
|
+
}
|
108
129
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
package org.embulk.output.mailchimp.model;
|
2
|
+
|
3
|
+
import com.fasterxml.jackson.annotation.JsonCreator;
|
4
|
+
import org.embulk.config.ConfigException;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Created by thangnc on 6/9/17.
|
8
|
+
*/
|
9
|
+
public enum AddressMergeFieldAttribute
|
10
|
+
{
|
11
|
+
ADDR1("addr1"), ADDR2("addr2"), CITY("city"), STATE("state"), ZIP("zip"), COUNTRY("country");
|
12
|
+
|
13
|
+
private String name;
|
14
|
+
|
15
|
+
AddressMergeFieldAttribute(String type)
|
16
|
+
{
|
17
|
+
this.name = type;
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Gets name.
|
22
|
+
*
|
23
|
+
* @return the name
|
24
|
+
*/
|
25
|
+
public String getName()
|
26
|
+
{
|
27
|
+
return name;
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Find by name method.
|
32
|
+
*
|
33
|
+
* @param name the name
|
34
|
+
* @return the auth method
|
35
|
+
*/
|
36
|
+
@JsonCreator
|
37
|
+
public static AddressMergeFieldAttribute findByName(final String name)
|
38
|
+
{
|
39
|
+
for (AddressMergeFieldAttribute method : values()) {
|
40
|
+
if (method.getName().equals(name.toLowerCase())) {
|
41
|
+
return method;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
throw new ConfigException(
|
46
|
+
String.format("Unknown attributes '%s'. Supported attributes are [addr1, addr1, state, zip, country]",
|
47
|
+
name));
|
48
|
+
}
|
49
|
+
}
|
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.NullNode;
|
|
6
6
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
7
7
|
import com.google.common.collect.Multimap;
|
8
8
|
import org.embulk.output.mailchimp.helper.MailChimpHelper;
|
9
|
+
import org.embulk.output.mailchimp.model.AddressMergeFieldAttribute;
|
9
10
|
import org.junit.Test;
|
10
11
|
|
11
12
|
import java.util.ArrayList;
|
@@ -15,6 +16,7 @@ import java.util.List;
|
|
15
16
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.containsCaseInsensitive;
|
16
17
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.extractMemberStatus;
|
17
18
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.maskEmail;
|
19
|
+
import static org.embulk.output.mailchimp.helper.MailChimpHelper.orderJsonNode;
|
18
20
|
import static org.embulk.output.mailchimp.helper.MailChimpHelper.toJsonNode;
|
19
21
|
import static org.junit.Assert.assertArrayEquals;
|
20
22
|
import static org.junit.Assert.assertEquals;
|
@@ -82,4 +84,15 @@ public class TestMailChimpHelper
|
|
82
84
|
{
|
83
85
|
assertEquals("Should be NullNode", NullNode.class, toJsonNode("abc").getClass());
|
84
86
|
}
|
87
|
+
|
88
|
+
@Test
|
89
|
+
public void test_orderJsonNode()
|
90
|
+
{
|
91
|
+
String given = "{\"addr1\":\"1234\",\"city\":\"mountain view\",\"country\":\"US\",\"state\":\"CA\",\"zip\":\"95869\"}";
|
92
|
+
AddressMergeFieldAttribute[] attributes = AddressMergeFieldAttribute.values();
|
93
|
+
|
94
|
+
String expect = "{\"addr1\":\"1234\",\"addr2\":\"\",\"city\":\"mountain view\",\"state\":\"CA\",\"zip\":\"95869\",\"country\":\"US\"}";
|
95
|
+
assertEquals("Should be JSON", ObjectNode.class, orderJsonNode(toJsonNode(given), attributes).getClass());
|
96
|
+
assertEquals("Should be match", expect, orderJsonNode(toJsonNode(given), attributes).toString());
|
97
|
+
}
|
85
98
|
}
|
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.9
|
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-06-
|
11
|
+
date: 2017-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- src/main/java/org/embulk/output/mailchimp/MailChimpOutputPluginDelegate.java
|
68
68
|
- src/main/java/org/embulk/output/mailchimp/MailChimpRecordBuffer.java
|
69
69
|
- src/main/java/org/embulk/output/mailchimp/helper/MailChimpHelper.java
|
70
|
+
- src/main/java/org/embulk/output/mailchimp/model/AddressMergeFieldAttribute.java
|
70
71
|
- src/main/java/org/embulk/output/mailchimp/model/AuthMethod.java
|
71
72
|
- src/main/java/org/embulk/output/mailchimp/model/CategoriesResponse.java
|
72
73
|
- src/main/java/org/embulk/output/mailchimp/model/ErrorResponse.java
|
@@ -88,7 +89,7 @@ files:
|
|
88
89
|
- test/override_assert_raise.rb
|
89
90
|
- test/run-test.rb
|
90
91
|
- classpath/embulk-base-restclient-0.5.0.jar
|
91
|
-
- classpath/embulk-output-mailchimp-0.3.
|
92
|
+
- classpath/embulk-output-mailchimp-0.3.9.jar
|
92
93
|
- classpath/embulk-util-retryhelper-jetty92-0.5.0.jar
|
93
94
|
- classpath/jetty-client-9.2.14.v20151106.jar
|
94
95
|
- classpath/jetty-http-9.2.14.v20151106.jar
|