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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
84b044f
[support_api_v3] Convert to java using embulk-base-restclient
thangnc Apr 14, 2017
b66720c
[support_api_v3] Added class using OAuth2
thangnc Apr 14, 2017
0e2abae
[support_api_v3] Enable test with CI
thangnc Apr 14, 2017
99a5273
[support_api_v3] Added auth type
thangnc Apr 17, 2017
8294640
[support_api_v3] Added validation and update test
thangnc Apr 18, 2017
67131a0
[support_api_v3] Upgraded library and updated testcase
thangnc Apr 20, 2017
f8c3623
[support_api_v3] Updated travis with gradle
thangnc Apr 21, 2017
148e11d
[support_api_v3] Refactor with abstract recordbuffer
thangnc Apr 25, 2017
5920127
[support_api_v3] Refactor with handling response error from API
thangnc Apr 26, 2017
3644537
[support_api_v3] Updated unit test
thangnc Apr 26, 2017
7815275
[support_api_v3] Fixed unit test
thangnc Apr 26, 2017
52b6de3
[support_api_v3] Enabled browse category ids from name
thangnc May 8, 2017
a1ec43d
[support_api_v3] Fixed unit test and added mock
thangnc May 8, 2017
1215df4
[support_api_v3] Updated unit test
thangnc May 8, 2017
483c478
[support_api_v3] Updated README and fix NPE
thangnc May 9, 2017
96206a6
[support_api_v3] Released minor 0.3.0.1
thangnc May 10, 2017
f4eec5f
[support_api_v3] Fixed PR and added test case
thangnc May 12, 2017
3839808
[support_api_v3] Fixed checkstyle
thangnc May 12, 2017
04f5d35
[support_api_v3] Updated get data center and added test case
thangnc May 16, 2017
30b2d2c
[support_api_v3] Fixed problem update interest categories
thangnc May 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
service_name: travis-ci
service_name: travis-ci
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
*~
/pkg/
/tmp/
/.bundle/
/Gemfile.lock
/coverage/
*.gemspec
.gradle/
/classpath/
build/
.idea
/.settings/
/.metadata/
.classpath
.project
bin/
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: jruby
before_install:
- rvm get head --auto-dotfiles
- rvm install jruby-9.0.1.0
- gem install bundler --version 1.10.6
- bundle install
language: java
jdk:
- openjdk7
script:
- bundle exec rake cov
- ./gradlew clean checkstyle check jacocoTestReport
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.3.0.1 - 2016-05-11
- Enabled API v3 and supported OAuth2 beside API Key[#13](https://github.com/treasure-data/embulk-output-mailchimp/pull/13)

## 0.2.3 - 2016-03-24

- Retry when Mailchimp server return Internal Server Error [#11](https://github.com/treasure-data/embulk-output-mailchimp/pull/11)
Expand Down
2 changes: 0 additions & 2 deletions Gemfile

This file was deleted.

35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,33 @@ add e-mail to List in MailChimp.

## Configuration

- **apikey**: Mailchimp API key (string, required)
- **list_id**: Mailchimp List id (string, required)
- **double_optin**: control whether to send an opt-in confirmation email (boolean, default: true)
- **auth_method**: MailChimp auth method (string, `api_key` or `oauth`, default: `oauth`)
- **apikey**: MailChimp API key (string, required if `auth_method` is `api_key`)
- **access_token**: MailChimp access token (string, required if `auth_method` is `oauth`)
- **list_id**: MailChimp List id (string, required)
- **update_existing**: control whether to update members that are already subscribed to the list or to return an error (boolean, default: false)
- **replace_interests**: determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (boolean, default: true)
- **email_column**: column name for email (string, default: 'email')
- **fname_column**: column name for first name (string, default: 'fname')
- **lname_column**: column name for last name(string, default: 'lname')
- **grouping_columns**: column names array for group name(array, default: nil)
- **merge_fields**: Array for merge fields/ TAG in MailChimp dashboard (array, optional, default: nil)
- **interest_categories**: Array for group names in MailChimp dashboard(array, default: nil)
- **double_optin**: Removed in API v3. Using `status` in json request body instead. Subscriber's current status: `subscribed`, `unsubscribed`, `cleaned`, `pending`

## Example

```yaml
out:
type: mailchimp
auth_method: api_key
apikey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXX'
list_id: 'XXXXXXXXXX'
double_optin: false
update_existing: false
replace_interests: true
email_column: 'e-mail'
fname_column: 'first name'
lname_column: 'lname'
grouping_columns:
- group_1
- group_2
merge_fields:
- FNAME
- LNAME
- WEB
interest_categories:
- Donating
- Events
```

## Mailchimp Client

use https://bitbucket.org/mailchimp/mailchimp-api-ruby .

## Build

```
Expand Down
29 changes: 0 additions & 29 deletions Rakefile

This file was deleted.

124 changes: 124 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.jruby-gradle.base" version "0.1.5"
id "java"
id "checkstyle"
id "jacoco"
}
import com.github.jrubygradle.JRubyExec
repositories {
mavenCentral()
jcenter()
// TODO(dmikurube): Remove this after embulk-base-restclient goes to jcenter.
maven {
url "https://dl.bintray.com/embulk-base-restclient/maven"
}
}
configurations {
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.


sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
compile "org.embulk:embulk-core:0.8.15"
provided "org.embulk:embulk-core:0.8.15"
compile "org.embulk.base.restclient:embulk-base-restclient:0.5.0"
compile "org.embulk.base.restclient:embulk-util-retryhelper-jetty92:0.5.0"
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"

testCompile "junit:junit:4.+"
testCompile "org.embulk:embulk-core:0.8.15:tests"
testCompile "org.embulk:embulk-test:0.8.15"
testCompile "org.embulk:embulk-standards:0.8.15"
testCompile "org.mockito:mockito-core:2.+"
}

test {
jvmArgs "-XX:MaxPermSize=128M"
// Set the timezone for testing somewhere other than my machine to increase the chances of catching timezone bugs
systemProperty 'user.timezone', 'PST'
testLogging {
events "passed", "skipped", "failed"
}
}

task classpath(type: Copy, dependsOn: ["jar"]) {
doFirst { file("classpath").deleteDir() }
from (configurations.runtime - configurations.provided + files(jar.archivePath))
into "classpath"
}
clean { delete "classpath" }

checkstyle {
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
toolVersion = '6.14.1'
}
checkstyleMain {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
checkstyleTest {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
task checkstyle(type: Checkstyle) {
classpath = sourceSets.main.output + sourceSets.test.output
source = sourceSets.main.allJava + sourceSets.test.allJava
}

task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
script "${project.name}.gemspec"
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
}

task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "push"
script "pkg/${project.name}-${project.version}.gem"
}

task "package"(dependsOn: ["gemspec", "classpath"]) << {
println "> Build succeeded."
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
}

jacocoTestReport {
group = "Reporting"
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/coverage"
}
}

task gemspec {
ext.gemspecFile = file("${project.name}.gemspec")
inputs.file "build.gradle"
outputs.file gemspecFile
doLast { gemspecFile.write($/
Gem::Specification.new do |spec|
spec.name = "${project.name}"
spec.version = "${project.version}"
spec.authors = "Thang Nguyen"
spec.summary = %[Mailchimp output plugin for Embulk]
spec.description = %[Dumps records to MailChimp.]
spec.email = ["thang@treasure-data.com"]
spec.licenses = ["Apache-2.0"]
spec.homepage = "https://github.com/treasure-data/embulk-output-mailchimp"

spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
spec.test_files = spec.files.grep(%r"^(test|spec)/")
spec.require_paths = ["lib"]

#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
spec.add_development_dependency 'bundler', ['~> 1.0']
spec.add_development_dependency 'rake', ['>= 10.0']
end
/$)
}
}
clean { delete "${project.name}.gemspec" }
5 changes: 5 additions & 0 deletions ci/travis_mailchimp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: mailchimp
auth_method: api_key
apikey: xxxxxxxxxxxxxxxxxxx
access_token: xxxxxxxxxxxxxxxxxxx
list_id: xxxxxxxxxxxxxxxxxxx
16 changes: 16 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
machine:
java:
version: openjdk7
environment:
TERM: "dumb"
EMBULK_OUTPUT_MAILCHIMP_TEST_CONFIG: "${HOME}/${TRAVIS_BUILD_DIR}/ci/travis_mailchimp.yml"

test:
override:
- ./gradlew clean checkstyle check jacocoTestReport
post:
- cp -R build/reports/* $CIRCLE_ARTIFACTS

notify:
webhooks:
- url: https://td-beda.herokuapp.com/circleci_callback
Loading