Added isDiscard and response properties.
This commit is contained in:
parent
7e3cd3b19f
commit
14079ba018
2 changed files with 27 additions and 11 deletions
|
@ -83,6 +83,15 @@ open class Akismet(apiKey: String) {
|
||||||
var httpStatusCode: Int = 0
|
var httpStatusCode: Int = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual response sent by Aksimet from the last operation.
|
||||||
|
*
|
||||||
|
* For example: ```true```, ```false```, ```valid```, ```invalid```, etc.
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
var response: String = ""
|
||||||
|
private set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The X-akismet-pro-tip header from the last operation, if any.
|
* The X-akismet-pro-tip header from the last operation, if any.
|
||||||
*/
|
*/
|
||||||
|
@ -90,6 +99,15 @@ open class Akismet(apiKey: String) {
|
||||||
var proTip: String = ""
|
var proTip: String = ""
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if Akismet has determined that the last [checked comment][checkComment] is blatant spam, and you
|
||||||
|
* can safely discard it without saving it in any spam queue. Read more about this feature in this
|
||||||
|
* [Akismet blog post](https://blog.akismet.com/2014/04/23/theres-a-ninja-in-your-akismet/).
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
var isDiscard: Boolean = false
|
||||||
|
private set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The X-akismet-error header from the last operation, if any.
|
* The X-akismet-error header from the last operation, if any.
|
||||||
*/
|
*/
|
||||||
|
@ -156,9 +174,7 @@ open class Akismet(apiKey: String) {
|
||||||
* Submit Spam (missed spam).
|
* Submit Spam (missed spam).
|
||||||
* See the [Akismet API](https://akismet.com/development/api/#submit-spam) for more details.
|
* See the [Akismet API](https://akismet.com/development/api/#submit-spam) for more details.
|
||||||
*/
|
*/
|
||||||
fun submitSpam(
|
fun submitSpam(comment: AkismetComment): Boolean {
|
||||||
comment: AkismetComment
|
|
||||||
): Boolean {
|
|
||||||
return executeMethod(buildApiUrl("submit-spam"), buildFormBody(comment))
|
return executeMethod(buildApiUrl("submit-spam"), buildFormBody(comment))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,9 +183,7 @@ open class Akismet(apiKey: String) {
|
||||||
* See the [Akismet API](https://akismet.com/development/api/#submit-ham) for more details.
|
* See the [Akismet API](https://akismet.com/development/api/#submit-ham) for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun submitHam(
|
fun submitHam(comment: AkismetComment): Boolean {
|
||||||
comment: AkismetComment
|
|
||||||
): Boolean {
|
|
||||||
return executeMethod(buildApiUrl("submit-ham"), buildFormBody(comment))
|
return executeMethod(buildApiUrl("submit-ham"), buildFormBody(comment))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,11 +219,12 @@ open class Akismet(apiKey: String) {
|
||||||
val result = client.newCall(request).execute()
|
val result = client.newCall(request).execute()
|
||||||
httpStatusCode = result.code
|
httpStatusCode = result.code
|
||||||
proTip = result.header("x-akismet-pro-tip", "").toString()
|
proTip = result.header("x-akismet-pro-tip", "").toString()
|
||||||
|
isDiscard = proTip.equals("discard", true)
|
||||||
error = result.header("x-akismet-error", "").toString()
|
error = result.header("x-akismet-error", "").toString()
|
||||||
debugHelp = result.header("x-akismet-debug-help", "").toString()
|
debugHelp = result.header("x-akismet-debug-help", "").toString()
|
||||||
val body = result.body?.string()
|
val body = result.body?.string()
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
val response = body.trim()
|
response = body.trim()
|
||||||
if (response.equals("valid", true) ||
|
if (response.equals("valid", true) ||
|
||||||
response.equals("true", true) ||
|
response.equals("true", true) ||
|
||||||
response.startsWith("Thanks", true)) {
|
response.startsWith("Thanks", true)) {
|
||||||
|
|
|
@ -124,10 +124,11 @@ open class AkismetComment() {
|
||||||
var recheckReason: String = ""
|
var recheckReason: String = ""
|
||||||
/**
|
/**
|
||||||
* In PHP, there is an array of environmental variables called $_SERVER that contains information about the Web
|
* In PHP, there is an array of environmental variables called $_SERVER that contains information about the Web
|
||||||
* server itself as well as a key/value for every HTTP header sent with the request.
|
* server itself as well as a key/value for every HTTP header sent with the request.This data is highly useful to
|
||||||
*
|
* Akismet.
|
||||||
* This data is highly useful to Akismet. How the submitted content interacts with the server can be very telling,
|
*
|
||||||
* so please include as much of it as possible.
|
* How the submitted content interacts with the server can be very telling, so please include as much of it as
|
||||||
|
* ossible.
|
||||||
*/
|
*/
|
||||||
var other: Map<String, String> = emptyMap()
|
var other: Map<String, String> = emptyMap()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue