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

New Methods for Integration Tools #7

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
181e629
Primer commit, se trabajara implementando campañas qun no implementado
Oct 5, 2016
f0c7045
Se impelemtan los metodos de consulta para campañas.
Oct 5, 2016
a24d259
Se impelemtan los metodos de consulta para reportes de las campañas y…
Oct 6, 2016
a50ce33
Se impelemtan los metodos de consulta para reportes de las campañas y…
Oct 6, 2016
91ce006
I moved report folder out of campaign folder, I created a enum for ty…
Oct 15, 2016
9d6e97c
Added processing response isn't JSON
aqman1 Dec 1, 2016
c159b1c
Update publish.gradle
aqman1 Dec 1, 2016
f5747a8
Merge pull request #8 from aqman1/master
Dec 2, 2016
5dfe3dd
version updated
Dec 2, 2016
e7bbf49
Some bugs were solved.
Dec 6, 2016
7911d6e
Some bugs were solved.
Dec 18, 2016
c5be5b9
I added _link attribute in the parent class for all classes. And adde…
Dec 18, 2016
b7de3bc
I added a new enum class for the campings type
Dec 18, 2016
be94f38
Segment modules was Implemented.
Dec 19, 2016
4bfb690
Segment modules was Implemented #2
Dec 19, 2016
9a412f0
location of segments were changed
Jan 11, 2017
2fe9b4b
Campaign operations (list, create, edit, delete, actions) added
REDGML Jan 20, 2017
b5d637f
Campaign content operations (get, set) added
REDGML Jan 20, 2017
7a18942
Create new list method added
REDGML Jan 20, 2017
f8fab25
MergeField operations (get all, create, update) added
REDGML Jan 20, 2017
28af9a1
GetEmailActivitysMethod added
REDGML Jan 23, 2017
769ab6c
GetUnsubscribedMethod added
REDGML Jan 23, 2017
f393c9c
DeleteListMethod added
REDGML Jan 24, 2017
24cb92d
Added missing body params to Schedule CampaignActionMethod
REDGML Jan 26, 2017
9bd83e2
Merge pull request #12 from red61/marketing_backend
Mar 12, 2017
15fa34b
version updated
Mar 12, 2017
2cd7161
Fix link in documentation (#14)
Apr 3, 2017
9f7e202
a several changes
May 7, 2017
87faafc
automation
May 17, 2017
5b22bdc
Merge branch 'master' of https://github.com/lararojasmr/maleorang
lararojasmr 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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.9"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply from: 'wrapper.gradle'
apply plugin: 'kotlin'
apply from: 'compile.gradle'
apply from: 'test.gradle'
apply from: 'publish.gradle'
Expand All @@ -27,4 +30,5 @@ dependencies {
compile 'joda-time:joda-time:2.9.4'

testCompile 'org.testng:testng:6.8.21'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

Choose a reason for hiding this comment

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

Does it mean that the library won't be usable with java 6 & 7 projects? I'd prefer to keep the compatibility.

}
5 changes: 5 additions & 0 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePass
name 'Vasily Karyaev'
email '[email protected]'
}
developer {
id 'lararojasmr'
name 'Manuel Lara'
email '[email protected]'
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/ecwid/maleorang/MailchimpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ open class MailchimpClient protected constructor (
code = error.get("status").asInt
description = error.get("detail").asString
}
throw MailchimpException(code, response.responseBody.toString())
//throw MailchimpException(code, description)

Choose a reason for hiding this comment

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

This was just a test change, right?


throw MailchimpException(code, description)
}

return MailchimpObject.fromJson(response.responseBody ?: "{}", method.resultType)
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/ecwid/maleorang/MailchimpMethodInfo.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.ecwid.maleorang

import com.ecwid.maleorang.annotation.*
import com.ecwid.maleorang.annotation.Method
import com.ecwid.maleorang.util.DateUtil.formatDate
import com.ecwid.maleorang.util.ClassUtil.getAnnotatedFields

import com.ecwid.maleorang.util.DateUtil.formatDate
import java.net.URLEncoder
import java.util.Collections
import java.util.Date
import java.util.TreeMap
import java.util.*
import java.util.regex.Matcher
import java.util.regex.Pattern

Expand All @@ -34,7 +30,8 @@ internal class MailchimpMethodInfo(private val method: MailchimpMethod<*>) {

val requestBody: String? = when (httpMethod) {
HttpMethod.POST, HttpMethod.PATCH, HttpMethod.PUT -> method.toJson()
else -> null.apply { require(method.mapping.isEmpty(), { "$httpMethod method is not supposed to have request body: $method" }) }
else -> null.apply { require(method.mapping.isEmpty(), { "$httpMethod method is not supposed to have request " +
"body: $method mapping: "+ method.mapping }) }
}

fun buildUrl(apiKey: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import com.ecwid.maleorang.util.DateUtil.formatDate
import com.ecwid.maleorang.util.DateUtil.parseDate
import com.google.gson.*
import com.google.gson.reflect.TypeToken

import java.lang.reflect.Type
import java.util.Date
import java.util.*

/**
* Factory creating [Gson] objects to be used for MailChimp API calls wrapping.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.ecwid.maleorang.method.v3_0.campaign

import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.Field
import com.ecwid.maleorang.method.v3_0.reports.email.TypeCampaign
import java.util.*

/**
* Created by: Manuel Lara <[email protected]>
*/

class CampaignInfo : MailchimpObject() {
@JvmField
@Field
var id: String? = null

@JvmField
@Field
var type: TypeCampaign? = null

@JvmField
@Field
var create_time: Date? = null

@JvmField
@Field
var archive_url: String? = null

@JvmField
@Field
var long_archive_url: String? = null

@JvmField
@Field
var status: String? = null

@JvmField
@Field
var emails_sent: Int? = null

Copy link
Contributor

Choose a reason for hiding this comment

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

We should add TODOs for fields that are not yet included. It will be easier to track them and add them afterwords.
For example: //TODO: Add send_time field

Copy link
Author

Choose a reason for hiding this comment

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

added my friend

Copy link
Author

Choose a reason for hiding this comment

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

ready

@JvmField
@Field
var content_type: String? = null

@JvmField
@Field
var recipients: RecipientsCampaignInfo? = null

@JvmField
@Field
var settings: CampaignSettingsInfo? = null



Copy link
Contributor

Choose a reason for hiding this comment

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

TODO settings
TODO variate_settings
TODO tracking
TODO rss_opts
TODO ab_split_opts
TODO social_card
TODO report_summary
TODO delivery_status

Copy link
Contributor

@apocheau apocheau Oct 6, 2016

Choose a reason for hiding this comment

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

_links field has already been created in my last pull request.
We will need to move it to src/main/java/com/ecwid/maleorang/method/v3_0/ and then use it globally.
You can add a TODO also for this field.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.ecwid.maleorang.method.v3_0.campaign

import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.Field

/**
* Created by: Manuel Lara <[email protected]>
*/

class CampaignSettingsInfo : MailchimpObject() {
@JvmField
@Field
var subject_line: String? = null

@JvmField
@Field
var title: String? = null

@JvmField
@Field
var from_name: String? = null

@JvmField
@Field
var reply_to: String? = null

@JvmField
@Field
var use_conversation: String? = null

Choose a reason for hiding this comment

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

Shouldn't this be a boolean field?


@JvmField
@Field
var to_name: String? = null

@JvmField
@Field
var folder_id: String? = null

@JvmField
@Field
var authenticate: Boolean? = null

@JvmField
@Field
var auto_footer: Boolean? = null

@JvmField
@Field
var inline_css: Boolean? = null

@JvmField
@Field
var auto_tweet: Boolean? = null

@JvmField
@Field
var fb_comments: Boolean? = null

@JvmField
@Field
var timewrap: Boolean? = null

@JvmField
@Field
var drag_and_drop: Boolean? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.ecwid.maleorang.method.v3_0.campaign


import com.ecwid.maleorang.MailchimpMethod
import com.ecwid.maleorang.annotation.*
import org.apache.commons.codec.digest.DigestUtils

/**
* Created by: Manuel Lara <[email protected]>
*/

@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/campaigns/{campaign_id}")
class GetCampaignMethod(
@JvmField
@PathParam
val campaign_id: String
) : MailchimpMethod<CampaignInfo>() {

@JvmField
@QueryStringParam
var fields: String? = null

@JvmField
@QueryStringParam
var exclude_fields: String? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.ecwid.maleorang.method.v3_0.campaign


import com.ecwid.maleorang.MailchimpMethod
import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.*
import java.util.*

/**
* Created by: Manuel Lara <[email protected]>
*/

@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/campaigns")
class GetCampaignsMethod : MailchimpMethod<GetCampaignsMethod.Response>() {

@JvmField
@QueryStringParam
var fields: String? = null

@JvmField
@QueryStringParam
var exclude_fields: String? = null

@JvmField
@QueryStringParam
var count: Int? = null

@JvmField
@QueryStringParam
var offset: Int? = null

@JvmField
@QueryStringParam
var type: String? = null

Choose a reason for hiding this comment

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

Since we added a enum for types, shouldn't this be a TypeCampaign?


@JvmField
@QueryStringParam
var status: String? = null

@JvmField
@QueryStringParam
var before_send_time: Date? = null

@JvmField
@QueryStringParam
var since_send_opt: String? = null
Copy link
Contributor

Choose a reason for hiding this comment

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

Field name is since_send_time not since_send_opt

Choose a reason for hiding this comment

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

This field should be of type Date

Copy link
Author

Choose a reason for hiding this comment

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

ready

Choose a reason for hiding this comment

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

This should be a Date field


@JvmField
@QueryStringParam
var before_create_time: Date? = null

@JvmField
@QueryStringParam
var since_create_time: Date? = null

@JvmField
@QueryStringParam
var list_id: String? = null

@JvmField
@QueryStringParam
var folder_id: String? = null

class Response : MailchimpObject() {
@JvmField
@Field
var campaigns: List<CampaignInfo>? = null

@JvmField
@Field
var total_items: Int? = null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO _links

Copy link
Author

Choose a reason for hiding this comment

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

i will add this in the super class.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ecwid.maleorang.method.v3_0.campaign

import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.Field

/**
* Created by: Manuel Lara <[email protected]>
*/

class RecipientsCampaignInfo : MailchimpObject() {
@JvmField
@Field
var list_id: String? = null

Copy link
Contributor

Choose a reason for hiding this comment

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

TODO list_name
TODO segment_text
TODO recipient_count

@JvmField
@Field
var segment_opts: MailchimpObject? = null //TODO create SegmentOpts Object

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ecwid.maleorang.method.v3_0.reports.email

/**
* Created by larar on 15/10/2016.
*/

enum class TypeCampaign(val type: String) {
REGULAR("regular"),
PLAINTEXT("plaintext"),
ABSPLIT("absplit"),
RSS("rss"),
VARIATE("variate")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ecwid.maleorang.method.v3_0.lists.segments

import com.ecwid.maleorang.MailchimpMethod
import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.APIVersion
import com.ecwid.maleorang.annotation.HttpMethod
import com.ecwid.maleorang.annotation.Method
import com.ecwid.maleorang.annotation.PathParam

/**
* Created by: Manuel Lara <[email protected]>
*/
@Method(httpMethod = HttpMethod.DELETE, version = APIVersion.v3_0, path = "/lists/{list_id}/segments/{segment_id}")
class DeleteSegmentMethod(
@JvmField
@PathParam
val list_id: String,

@JvmField
@PathParam
val segment_id: String
) : MailchimpMethod<MailchimpObject>()
Loading