Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support API v3 #13

Merged
merged 20 commits into from May 25, 2017
Merged

Support API v3 #13

merged 20 commits into from May 25, 2017

Conversation

thangnc
Copy link
Contributor

@thangnc thangnc commented Apr 14, 2017

  • Enabled API v3
  • Enabled support OAuth2 beside APIKey
  • Refactor using embulk-base-restclient

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.139% when pulling 0e2abae on support_api_v3 into edb5b0b on master.

@thangnc thangnc requested a review from sakama April 17, 2017 14:47
@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.139% when pulling 99a5273 on support_api_v3 into edb5b0b on master.

Copy link
Member

@sakama sakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some commented~

@Override
public void validateOutputTask(final PluginTask task, final Schema schema, final int taskCount)
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some validation may required?

build.gradle Outdated
jcenter()
// TODO(dmikurube): Remove this after embulk-base-restclient goes to jcenter.
maven {
url "http://dl.bintray.com/embulk-base-restclient/maven"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use https is better. I should also fix Stripe.

build.gradle Outdated
spec.summary = %[Mailchimp output plugin for Embulk]
spec.description = %[Dumps records to hubspot.]
spec.email = ["thang@treasure-data.com"]
spec.licenses = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add licenses for just in case.

build.gradle Outdated
spec.version = "${project.version}"
spec.authors = "Thang Nguyen"
spec.summary = %[Mailchimp output plugin for Embulk]
spec.description = %[Dumps records to hubspot.]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mailchimp?

circle.yml Outdated

notify:
webhooks:
- url: http://td-beda.herokuapp.com/circleci_callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use https if possible.

}

throw new ConfigException(
String.format("Unknown target '%s'. Supported targets are [apikey, oauth]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api_key ?

.gitignore Outdated
*.gemspec
.gradle/
/classpath/
build/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add other pattern is better?
And /Gemfile.lock is needed when JRuby based plugin.
https://github.com/treasure-data/embulk-input-intercom/blob/master/.gitignore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And add LF is better.
ci/circle_mailchimp.yml as well

return response.getStatus() / 100 != 4;
}
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to throw ConfigException when API returns 401.

for (JsonNode contactData : contactsData) {
ObjectNode property = jsonMapper.createObjectNode();
property.put("email_address", contactData.findPath("email").asText());
property.put("status", contactData.findPath("status").asText());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contactData always contains email and status?
If no, no failure happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thks, i will add properties validator for these fields

build.gradle Outdated
provided "org.embulk:embulk-core:0.8.15"
compile "org.embulk.base.restclient:embulk-base-restclient:0.4.2"
compile "org.embulk.base.restclient:embulk-util-retryhelper-jetty92:0.4.2"
compile "org.glassfish.jersey.core:jersey-client:2.25.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required?

@thangnc thangnc changed the title [WIP] Support API v3 Support API v3 May 8, 2017
@thangnc
Copy link
Contributor Author

thangnc commented May 8, 2017

@sakama PTAL

Copy link
Member

@sakama sakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented

provided
}

version = "0.3.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to use vx.x.x style versioning.
Something special reason?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sakama We wanted to release a "snapshot" version before PR is merged so that we can test on console-development, hence used an additional number.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense.


return responseBody != null && !responseBody.isEmpty() ? parseJson(responseBody) : MissingNode.getInstance();
}
catch (HttpResponseException ex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess all HttpResponseException were caught without retry. Is it OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpResponseException should be not here. Its redundant. Then I will remove it.

}
}

if (isNullOrEmpty(task.getListId())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this block is never used.
Because you're using

@Config("list_id")
String getListId();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, list_id can be empty or null. Plugin does not know it can receive correct param or not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok.

}

throw new ConfigException(
String.format("Unknown target '%s'. Supported targets are [api_key, oauth]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/target/auth_method/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should be auth_method. I will update

}

throw new ConfigException(
String.format("Unknown target '%s'. Supported statuses are [subscribed, pending, unsubscribed, cleaned]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/target/status/?

Copy link
Contributor Author

@thangnc thangnc May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted and will fix

{
ConfigSource config = baseConfig;
Schema schema = Schema.builder()
.add("email", org.embulk.spi.type.Types.STRING)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: You can also use following style.

import static org.embulk.spi.type.Types.STRING;
...
.add("email", Types.STRING)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted and will fix

@ylzen
Copy link

ylzen commented May 17, 2017

@thangnc In the future, please break a large PR like this into separate ones, each provides different functionality.

int getTimeoutMillis();

@Config("auth_method")
@ConfigDefault("access_token")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid using "access_token" as default "auth_method" will break backwards compatibility. Since "auth_method" was not an option before, any existing config will not have any value. Default to access_token will break existing transfers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let api_key is default auth_method in #15

@thangnc thangnc mentioned this pull request May 18, 2017
@thangnc
Copy link
Contributor Author

thangnc commented May 23, 2017

@sakama can you take a look on this?

Copy link
Member

@sakama sakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thangnc thangnc merged commit 82f56dd into master May 25, 2017
@thangnc thangnc deleted the support_api_v3 branch May 25, 2017 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants