-
Notifications
You must be signed in to change notification settings - Fork 31
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
Abuse reports getters #6
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Aug 04 16:09:12 SAMT 2016 | ||
#Sun Oct 09 18:36:17 CEST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.14.1-all.zip | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-3.1-all.zip |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists | ||
|
||
import com.ecwid.maleorang.MailchimpObject | ||
import com.ecwid.maleorang.annotation.Field | ||
import java.util.* | ||
|
||
/** | ||
* Created by apocheau on 27/08/16. | ||
*/ | ||
class AbuseReportInfo : MailchimpObject() { | ||
|
||
@JvmField | ||
@Field | ||
var id: String? = 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 | ||
|
||
@JvmField | ||
@Field | ||
var _links: List<LinkInfo>? = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These "links" are included with every response and I find them useless. Do they really needed? If not, I'd prefer this field be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main goal of the connector is to give access to the data offered by the API. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists | ||
|
||
|
||
import com.ecwid.maleorang.MailchimpMethod | ||
import com.ecwid.maleorang.annotation.* | ||
|
||
/** | ||
* [Get details about a specific abuse report](http://developer.mailchimp.com/documentation/mailchimp/reference/lists/abuse-reports/#read-get_lists_list_id_abuse_reports_report_id) | ||
*/ | ||
@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/lists/{list_id}/abuse-reports/{report_id}") | ||
class GetAbuseReportMethod( | ||
@JvmField | ||
@PathParam | ||
val list_id: String, | ||
|
||
@JvmField | ||
@PathParam | ||
val report_id: String | ||
) : MailchimpMethod<AbuseReportInfo>() { | ||
|
||
@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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The count/offset params seem to be useless, as this method returns a single item. Perhaps, there is an error in the documentation. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists | ||
|
||
|
||
import com.ecwid.maleorang.MailchimpMethod | ||
import com.ecwid.maleorang.MailchimpObject | ||
import com.ecwid.maleorang.annotation.* | ||
|
||
/** | ||
* [Get information about abuse reports](http://developer.mailchimp.com/documentation/mailchimp/reference/lists/abuse-reports/#read-get_lists_list_id_abuse_reports) | ||
*/ | ||
@Method(httpMethod = HttpMethod.GET, version = APIVersion.v3_0, path = "/lists/{list_id}/abuse-reports") | ||
class GetAbuseReportsMethod( | ||
@JvmField | ||
@PathParam | ||
val list_id: String | ||
) : MailchimpMethod<GetAbuseReportsMethod.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 abuse_reports: List<AbuseReportInfo>? = null | ||
|
||
@JvmField | ||
@Field | ||
var list_id: String? = null | ||
|
||
@JvmField | ||
@Field | ||
var total_items: Int? = null | ||
|
||
@JvmField | ||
@Field | ||
var _links: List<LinkInfo>? = null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists | ||
|
||
import com.ecwid.maleorang.MailchimpObject | ||
import com.ecwid.maleorang.annotation.Field | ||
|
||
/** | ||
* Created by apocheau on 27/08/16. | ||
*/ | ||
class LinkInfo : MailchimpObject() { | ||
|
||
@JvmField | ||
@Field | ||
var rel: String? = null | ||
|
||
@JvmField | ||
@Field | ||
var href: String? = null | ||
|
||
@JvmField | ||
@Field | ||
var method: String? = null | ||
|
||
@JvmField | ||
@Field | ||
var targetSchema: String? = null | ||
|
||
@JvmField | ||
@Field | ||
var schema: String? = null | ||
|
||
fun setRel(rel: String): LinkInfo{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove these chain methods as well |
||
this.rel = rel | ||
return this | ||
} | ||
|
||
fun setHref(href: String): LinkInfo{ | ||
this.href = href | ||
return this | ||
} | ||
|
||
fun setMethod(method: String): LinkInfo{ | ||
this.method = method | ||
return this | ||
} | ||
|
||
fun setTargetSchema(targetSchema: String): LinkInfo{ | ||
this.targetSchema = targetSchema | ||
return this | ||
} | ||
|
||
fun setSchema(schema: String): LinkInfo{ | ||
this.schema = schema | ||
return this | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.ecwid.maleorang.method.v3_0.lists.members | ||
|
||
import com.ecwid.maleorang.MailchimpClient | ||
import com.ecwid.maleorang.connector.Connector | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportMethod | ||
import com.ecwid.maleorang.method.v3_0.lists.GetAbuseReportsMethod | ||
import org.testng.Assert | ||
import org.testng.annotations.Parameters | ||
import org.testng.annotations.Test | ||
import java.util.logging.Logger | ||
|
||
class AbuseReportsTest | ||
@Parameters("mailchimp.test.apikey", "mailchimp.test.listid") | ||
constructor(private val apiKey: String, private val listId: String) { | ||
private val log = Logger.getLogger(javaClass.getName()) | ||
|
||
@Test | ||
fun testGetAbuseReports() { | ||
MailchimpClient(apiKey).use { client -> | ||
client.execute(GetAbuseReportsMethod(listId)).apply { | ||
Assert.assertNotNull(listId) | ||
Assert.assertNotNull(_links) | ||
Assert.assertNotNull(abuse_reports) | ||
Assert.assertNotNull(total_items) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testGetAbuseReport() { | ||
class MockMailchimpClient : MailchimpClient(apiKey, object : Connector { | ||
override fun call(request: Connector.Request): Connector.Response { | ||
val json = "{\"id\": 42,\"campaign_id\": \"839488a60b\",\"list_id\": \"1a2df69511\",\"email_id\": \"62eeb292278cc15f5817cb78f7790b08\",\"email_address\": \"[email protected]\",\"date\": \"2015-07-15T19:19:31+00:00\",\"links\": [{\"rel\": \"self\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports/42\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Instance.json\" },{ \"rel\": \"parent\",\"href\": \"https://usX.api.mailchimp.com/3.0/lists/1a2df69511/abuse-reports\",\"method\": \"GET\",\"targetSchema\": \"https://api.mailchimp.com/schema/3.0/Lists/Abuse/Collection.json\",\"schema\": \"https://api.mailchimp.com/schema/3.0/CollectionLinks/Lists/Abuse.json\" }]}" | ||
return Connector.Response(200, "", json) | ||
} | ||
|
||
override fun close() { | ||
} | ||
}) | ||
|
||
//TODO Improve test | ||
MockMailchimpClient().use { client -> | ||
client.execute(GetAbuseReportMethod(listId, "42")).apply { | ||
Assert.assertNotNull(id) | ||
Assert.assertNotNull(campaign_id) | ||
Assert.assertNotNull(list_id) | ||
Assert.assertNotNull(email_id) | ||
Assert.assertNotNull(email_address) | ||
// Assert.assertNotNull(merge_fields) | ||
// Assert.assertNotNull(vip) | ||
Assert.assertNotNull(date) | ||
// Assert.assertNotNull(_links) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that the line below still refers to the old gradle version. You should run
./gradlew wrapper
to complete Gradle upgrade