Net::Douban::Doumail - Net::Douban::Doumail documentation


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

Index


Code Index:

    Net::Douban::Doumail

VERSION

Top

version 1.07

SYNOPSIS

Top

	use Net::Douban::Doumail;
	my $user = Net::Douban::Doumail->new(
        ...
	);

DESCRIPTION

Top

Interface to douban.com API mail section

METHODS

Top

inbox
unread
outbox
get_doumail
post_doumail
delete_doumail
mark_read
delete
mark

SEE ALSO

Top

Net::Douban Net::Douban::Atom Moose XML::Atom /douban.com/service/apidoc/reference/douamil in http

AUTHOR

Top

woosley.xu<woosley.xu@gmail.com>

COPYRIGHT

Top


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

package Net::Douban::Doumail;

BEGIN {
    $Net::Douban::Doumail::VERSION = '1.07';
}

use Moose;
use MooseX::StrictConstructor;
use Net::Douban::Atom;
use Carp qw/carp croak/;
with 'Net::Douban::Roles::More';

has 'doumailID' => (
    is  => 'rw',
    isa => 'Str',
);

has 'doumail_url' => (
    is      => 'rw',
    isa     => 'Url',
    lazy    => 1,
    default => sub { shift->base_url . '/doumail' },
);

before qw/inbox unread outbox get_doumail/ => sub {
    croak "oauth needed" unless $_[0]->has_oauth;
};

sub inbox {
    my ($self, %args) = @_;
    return Net::Douban::Atom->new(
        $self->get($self->doumail_url . "/inbox", %args));
}

sub unread {
    my ($self, %args) = @_;
    return Net::Douban::Atom->new(
        $self->get($self->doumail_url . "/inbox/unread", %args));
}

sub outbox {
    my ($self, %args) = @_;
    return Net::Douban::Atom->new(
        $self->get($self->doumail_url . "/outbox", %args));
}

sub get_doumail {
    my ($self, %args) = @_;
    $args{mailID} ||= $self->mailID;
    croak "mailID needed" unless defined $args{mailID};
    return Net::Douban::Atom->new(
        $self->get($self->doumail_url . "/$args{mailID}", %args));
}

sub post_doumail {
    my ($self, %args) = @_;
    croak "post xml needed!" unless $args{xml};
    return $self->post($self->doumail_url . 's', xml => $args{xml});
}

sub delete_doumail {
    my ($self, %args) = @_;
    $args{mailID} ||= $self->mailID;
    croak "mailID needed" unless defined $args{mailID};
    return $self->delete($self->doumail_url . "/$args{mailID}");
}

sub mark_read {
    my ($self, %args) = @_;
    $args{mailID} ||= $self->mailID;
    croak "mailID needed"   unless defined $args{mailID};
    croak "put xml needed!" unless $args{xml};
    return $self->put($self->doumail_url . "/$args{mailID}",
        xml => $args{xml});
}

sub delete {
    my ($self, %args) = @_;
    croak "delete xml needed!" unless $args{xml};
    return $self->delete($self->doumail_url, $args{xml});
}

sub mark {
    my ($self, %args) = @_;
    croak "post xml needed!" unless $args{xml};
    return $self->put($self->doumail_url . '/delete', $args{xml},);
}

no Moose;
__PACKAGE__->meta->make_immutable;
1;