embulk-output-mailchimp 0.3.15 → 0.3.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 464eeb7f786c9890be8adf21b84dbe1cc6ca442e
4
- data.tar.gz: 0b812c416f3900910b9d1772aebdd56307fa737c
3
+ metadata.gz: 0f302894ddc97cb2d46fcd4017e1c5bfd49d7a47
4
+ data.tar.gz: 4ca3f4eaa7c1ce19a378e855b5604b49fae962d2
5
5
  SHA512:
6
- metadata.gz: ec68fb3cb297f16724edf22975801f9b7928319983deb13b925c4670d231f3ab664a4f49ffbab74bf088cf87c2483da6ea5b1838865e4711dee8c5ab32f6c2b9
7
- data.tar.gz: 3b310edb9b4a7bc732b17bb17f5ad3f6097c748d73ee3c6a7693190e1f6764987dbeae81daf0db2d3ba426a4ee9325b1a2968944244357fdfa070b7b36229db3
6
+ metadata.gz: 3451461a7022d3e747aa58a72c6568d51cd9651cc6d177abbfe87540b50aee8d65b8b9950689c48f9570410265f32a27be057218581d485637db6833af1b6cc4
7
+ data.tar.gz: 40bb5c7e83bb6e33d3fe078b8684bf476edb77cc6c1d673754631806a98bc5fac6d5d2da23d27ca69506f61cc3f39df73ee3e46ae7d51d762c6aced8a79ebaf4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.16 - 2017-08-28
2
+ - Fixed user friendly error message when input invalid api key [#31](https://github.com/treasure-data/embulk-output-mailchimp/pull/31)
3
+
1
4
  ## 0.3.15 - 2017-07-26
2
5
  - Add checking exception to retry [#30](https://github.com/treasure-data/embulk-output-mailchimp/pull/30)
3
6
 
data/build.gradle CHANGED
@@ -18,7 +18,7 @@ configurations {
18
18
  provided
19
19
  }
20
20
 
21
- version = "0.3.15"
21
+ version = "0.3.16"
22
22
 
23
23
  sourceCompatibility = 1.7
24
24
  targetCompatibility = 1.7
@@ -11,6 +11,7 @@ import com.google.common.base.Joiner;
11
11
  import com.google.common.collect.FluentIterable;
12
12
  import com.google.common.collect.ImmutableList;
13
13
  import com.google.common.collect.Maps;
14
+ import org.eclipse.jetty.client.HttpResponseException;
14
15
  import org.eclipse.jetty.http.HttpMethod;
15
16
  import org.embulk.config.ConfigException;
16
17
  import org.embulk.output.mailchimp.helper.MailChimpHelper;
@@ -23,6 +24,7 @@ import org.embulk.output.mailchimp.model.MergeField;
23
24
  import org.embulk.output.mailchimp.model.MergeFields;
24
25
  import org.embulk.output.mailchimp.model.MetaDataResponse;
25
26
  import org.embulk.output.mailchimp.model.ReportResponse;
27
+ import org.embulk.spi.DataException;
26
28
  import org.embulk.spi.Exec;
27
29
  import org.slf4j.Logger;
28
30
 
@@ -180,23 +182,33 @@ public class MailChimpClient
180
182
 
181
183
  private void extractDataCenter(MailChimpOutputPluginDelegate.PluginTask task)
182
184
  {
183
- try {
184
- if (task.getAuthMethod() == OAUTH) {
185
- // Extract data center from meta data URL
186
- JsonNode response = client.sendRequest("https://login.mailchimp.com/oauth2/metadata", HttpMethod.GET, task);
187
- MetaDataResponse metaDataResponse = mapper.treeToValue(response, MetaDataResponse.class);
185
+ if (task.getAuthMethod() == OAUTH) {
186
+ // Extract data center from meta data URL
187
+ JsonNode response = client.sendRequest("https://login.mailchimp.com/oauth2/metadata", HttpMethod.GET, task);
188
+ MetaDataResponse metaDataResponse;
189
+ try {
190
+ metaDataResponse = mapper.treeToValue(response, MetaDataResponse.class);
188
191
  mailchimpEndpoint = MessageFormat.format(mailchimpEndpoint, metaDataResponse.getDc());
189
192
  }
190
- else if (task.getAuthMethod() == API_KEY && task.getApikey().isPresent()) {
191
- // Authenticate and return data center
192
- String domain = task.getApikey().get().split("-")[1];
193
- String endpoint = MessageFormat.format(mailchimpEndpoint + "/", domain);
193
+ catch (JsonProcessingException e) {
194
+ throw new DataException(e);
195
+ }
196
+ }
197
+ else if (task.getAuthMethod() == API_KEY && task.getApikey().isPresent()) {
198
+ // Authenticate and return data center
199
+ if (!task.getApikey().get().contains("-")) {
200
+ throw new ConfigException("API Key format invalid.");
201
+ }
202
+
203
+ String domain = task.getApikey().get().split("-")[1];
204
+ String endpoint = MessageFormat.format(mailchimpEndpoint + "/", domain);
205
+ try {
194
206
  client.sendRequest(endpoint, HttpMethod.GET, task);
195
207
  mailchimpEndpoint = MessageFormat.format(mailchimpEndpoint, domain);
196
208
  }
197
- }
198
- catch (Exception e) {
199
- throw new ConfigException("Could not get data center", e);
209
+ catch (HttpResponseException re) {
210
+ throw new ConfigException("Your API key may be invalid, or you've attempted to access the wrong datacenter.");
211
+ }
200
212
  }
201
213
  }
202
214
 
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.15
4
+ version: 0.3.16
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-07-26 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ files:
89
89
  - test/override_assert_raise.rb
90
90
  - test/run-test.rb
91
91
  - classpath/embulk-base-restclient-0.5.3.jar
92
- - classpath/embulk-output-mailchimp-0.3.15.jar
92
+ - classpath/embulk-output-mailchimp-0.3.16.jar
93
93
  - classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
94
94
  - classpath/jetty-client-9.2.14.v20151106.jar
95
95
  - classpath/jetty-http-9.2.14.v20151106.jar