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 1 commit
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.

}
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
5 changes: 0 additions & 5 deletions src/main/java/com/ecwid/maleorang/MailchimpObject.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ecwid.maleorang

import com.ecwid.maleorang.annotation.Field
import com.google.gson.JsonParseException


Expand All @@ -20,10 +19,6 @@ open class MailchimpObject {
@JvmField
val mapping: MutableMap<String, Any?> = MailchimpObjectMapping(this)

@JvmField
@Field
var _links: List<String>? = null

/**
* Serializes this object to JSON.
*/
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
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments

import com.ecwid.maleorang.MailchimpMethod
import com.ecwid.maleorang.MailchimpObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments

import com.ecwid.maleorang.MailchimpMethod
import com.ecwid.maleorang.MailchimpObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments


import com.ecwid.maleorang.MailchimpMethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments


import com.ecwid.maleorang.MailchimpMethod
Expand Down Expand Up @@ -38,7 +38,7 @@ class GetSegmentsMethod(

@JvmField
@QueryStringParam
var since_create_at: Date? = null
var since_created_at: Date? = null

@JvmField
@QueryStringParam
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments

import com.ecwid.maleorang.MailchimpObject
import com.ecwid.maleorang.annotation.Field
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ecwid.maleorang.method.v3_0.list.segments
package com.ecwid.maleorang.method.v3_0.lists.segments

/**
* Created by: Manuel Lara <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ecwid.maleorang.method.v3_0.reports

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

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

class CampaignLocationInfo : MailchimpObject() {
@JvmField
@Field
var country_code: String? = null

@JvmField
@Field
var region: String? = null

@JvmField
@Field
var opens: Int? = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.ecwid.maleorang.method.v3_0.reports


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

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

@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/reports/{campaign_id}/locations")
class GetCampaignLocationMethod(
@JvmField
@PathParam
val campaign_id: String
) : MailchimpMethod<GetCampaignLocationMethod.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


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

@JvmField
@Field
var campaign_id: String? = null

@JvmField
@Field
var total_items: Int? = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.ecwid.maleorang.method.v3_0.reports.email

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

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

class CampaignEmailAbuseInfo : MailchimpObject() {
@JvmField
@Field
var id: Int? = null

@JvmField
@Field
var campaign_id: String? = null

@JvmField
@Field
var list_id: String? = null

@JvmField
@Field
var email_id: String? = null

@JvmField
@Field
var email_address: String? = null

@JvmField
@Field
var merge_fields: MailchimpObject? = null

@JvmField
@Field
var vip: Boolean? = null

@JvmField
@Field
var date: Date? = null

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import java.util.*
class EmailReportActivityDetails : MailchimpObject() {
@JvmField
@Field
var action: String? = null
var action: TypeEmailActivity? = null

@JvmField
@Field
var type: TypeEmailActivity? = null
var type: TypeBounceActivity? = null

@JvmField
@Field
Expand All @@ -28,5 +28,14 @@ class EmailReportActivityDetails : MailchimpObject() {
@JvmField
@Field
var ip: String? = null



fun setAction(action: String) {

Choose a reason for hiding this comment

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

I don't think it is a good idea to have such methods, and they are not used as I see.

this.action = TypeEmailActivity.valueOf(action)
}

fun setType(type: String) {
this.type = TypeBounceActivity.valueOf(type)
}

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


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

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

@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/reports/{campaign_id}/abuse-reports")
class GetCampaignsAbuseEmailActivityMethod(
@JvmField
@PathParam
val campaign_id: String
) : MailchimpMethod<GetCampaignsAbuseEmailActivityMethod.Response>() {

@JvmField
@QueryStringParam
var fields: String? = null

@JvmField
@QueryStringParam
var exclude_fields: String? = null

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

@JvmField
@Field
var campaign_id: String? = null

@JvmField
@Field
var total_items: Int? = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GetCampaignsEmailActivityMethod(

@JvmField
@QueryStringParam
var count: Int? = null
var count: Int? = 0

Choose a reason for hiding this comment

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

Why do we need the default 0 here?


@JvmField
@QueryStringParam
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ecwid.maleorang.method.v3_0.reports.email

import com.google.gson.annotations.SerializedName

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

enum class TypeBounceActivity(val type: String) {
@SerializedName("hard")
HARD("hard"),
@SerializedName("soft")
SOFT("soft"),
@SerializedName("null")
NONE("null")

Choose a reason for hiding this comment

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

I find it strange having the "NONE" value here. According to the documentation:

If the action is a ‘bounce’, the type of bounce received: ‘hard’, ‘soft’.

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

import com.google.gson.annotations.SerializedName

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

enum class TypeEmailActivity(val type: String) {
@SerializedName("bounce")
BOUNCE("bounce"),
@SerializedName("click")
CLICK("click"),
@SerializedName("open")
OPEN("open")
}