Net::Douban::Note - Net::Douban::Note documentation


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

Index


Code Index:

NAME

Top

Net::Douban::Note;

VERSION

Top

version 1.07

SYNOPSIS

Top

	use Net::Douban::Note;
	$note = Net::Douban::Note->new(
		apikey => '....',
        # or
        oauth => $consumer,
	);

	$atom = $note->get_note(noteID => ... ) 
	$atom = $note->get_user_note(userID => 'Net-Douban');
	$atom = $note->post_note(xml => $xml);

DESCRIPTION

Top

Interface to douban.com API Note section

METHODS

Top

Those methods return a Net::Douban::Atom object which can be use to get data conveniently

get_user
get_user_note
delet_note
post_note
put_note

SEE ALSO

Top

Net::Douban Net::Douban::Atom Moose XML::Atom http://www.douban.com/service/apidoc/reference/note

AUTHOR

Top

woosley.xu<redicaps@gmail.com>

COPYRIGHT

Top


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

package Net::Douban::Note;

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

use Moose;
use MooseX::StrictConstructor;
use Carp qw/carp croak/;
use Net::Douban::Atom;

with 'Net::Douban::Roles::More';

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

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

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

sub get_user_note {
    my ($self, %args) = @_;
    my $uid = delete $args{userID} or croak "userID needed";
    return Net::Douban::Atom->new(
        $self->get($self->user_url . "/$uid/notes", %args));
}

sub delete_note {
    my ($self, %args) = @_;
    $args{noteID} ||= $self->noteID;
    return $self->delete($self->note_url . "/$args{noteID}");
}

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

sub put_note {
    my ($self, %args) = @_;
    croak 'put xml needed' unless exists $args{xml};
    $args{noteID} ||= $self->noteID;
    return $self->put($self->note_url . "/$args{noteID}", xml => $args{xml});
}

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

__END__