Net::Defensio::Response - Object for holding response to a Net::Defensio request.


Net-Defensio documentation Contained in the Net-Defensio distribution.

Index


Code Index:

NAME

Top

Net::Defensio::Response - Object for holding response to a Net::Defensio request.

SYNOPSIS

Top

    my $r = $defensio->audit_comment( ..... )
        or die $defensio->errstr;
    if ($r->success) {
        print "Spaminess: " . $r->spaminess . "\n";
    } else {
        print "Failure: " . $r->message . "\n";
    }

METHODS

Top

Net::Defensio::Response->new( \%data )

Constructs a new Net::Defensio::Response object, initializing it with the parameter data given.

$response->success

Returns a true value when the 'status' member is set to 'true'. Returns false otherwise.

$response->is_spam

Returns a true value when the 'spam' member is set to 'true'. Only useful for responses to 'audit-comment' requests.

$response->is_ham

Returns a true value when the 'spam' member is set to 'false'. Only useful for responses to 'audit-comment' requests.

$response->action

Holds the name of the 'action' for the Defensio API request. Set for all response objects.

$response->status

Holds the status member of a Defensio API response. Will be set to either 'success' or 'fail'. Set for all response objects.

$response->message

Holds the message member of a Defensio API response. Set for all response objects, but may be an empty string.

$response->api_version

Holds the api-version member of a Defensio API response. Set for all response objects.

$response->spam

For 'audit-comment' requests, this contains a boolean value, represented as 'true' or 'false'.

For 'get-stats' requests, this contains an integer of the number of messages Defensio has rated as spam.

$response->spaminess

For 'audit-comment' requests. Holds the floating-point value of the "spaminess" of the comment.

$response->signature

For 'audit-comment' requests. Holds the signature member of the Defensio response.

$response->ham

For 'get-stats' requests, this contains an integer of the number of messages Defensio has rated as ham (legitimate comments).

$response->false_positives

For 'get-stats' requests, this contains an integer of the number of messages that have been submitted to Defensio for retraining as spam.

$response->false_negatives

For 'get-stats' requests, this contains an integer of the number of messages that have been submitted to Defensio for retraining as non-spam.

$response->accuracy

For 'get-stats' requests, this contains a floating-point number representing the accuracy of the Defensio filters (from 0 to 1; 0 being 100% inaccurate, 1 being 100% accurate).

$response->learning

For 'get-stats' requests, this contains a boolean value indicating whether the Defensio filter is still in 'learning mode' for the account being used (either set to 'true' or 'false').

$response->learning_message

For 'get-stats' requests, this contains a message explaining why the Defensio filter is still in 'learning mode'. Only relevant when 'learning' is returned as 'true'.

COPYRIGHT & LICENSE

Top


Net-Defensio documentation Contained in the Net-Defensio distribution.

package Net::Defensio::Response;

our $VERSION = '0.01';
use base qw( Class::Accessor::Fast );

__PACKAGE__->mk_accessors(qw(
    action
    status message api_version
    spam spaminess signature
    ham false_positives false_negatives accuracy
    learning learning_message
));

sub success {
    my $r = shift;
    return ($r->status || '') eq 'success';
}

sub is_spam {
    my $r = shift;
    return undef unless defined $r->spam;
    $r->spam eq 'true' ? 1 : 0;
}

sub is_ham {
    my $r = shift;
    return undef unless defined $r->spam;
    $r->spam eq 'false' ? 1 : 0;
}

1;
__END__