| 1 | package Net::Evernote::Note; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | our $VERSION = '0.07'; | ||
| 6 | |||
| 7 | sub new { | ||
| 8 | my ($class, $args) = @_; | ||
| 9 | my $debug = $ENV{DEBUG}; | ||
| 10 | |||
| 11 | return bless { | ||
| 12 | _obj => $$args{_obj}, | ||
| 13 | _notestore => $$args{_notestore}, | ||
| 14 | _authentication_token => $$args{_authentication_token}, | ||
| 15 | debug => $debug, | ||
| 16 | }, $class; | ||
| 17 | } | ||
| 18 | |||
| 19 | # return all of the note's Tag objects | ||
| 20 | sub tags { | ||
| 21 | |||
| 22 | } | ||
| 23 | |||
| 24 | sub delete { | ||
| 25 | my ($self) = @_; | ||
| 26 | |||
| 27 | my $authToken = $self->{_authentication_token}; | ||
| 28 | my $client = $self->{_notestore}; | ||
| 29 | my $guid = $self->guid; | ||
| 30 | return $client->deleteNote($authToken,$guid); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub tagNames { | ||
| 34 | my $self = shift; | ||
| 35 | |||
| 36 | my $obj = $self->{_obj}; | ||
| 37 | my $ns = $self->{_notestore}; | ||
| 38 | my $auth = $self->{_authentication_token}; | ||
| 39 | my $guids = $obj->tagGuids; | ||
| 40 | |||
| 41 | return undef if !$guids; | ||
| 42 | my @tag_names = map { | ||
| 43 | $ns->getTag($auth, $_)->name; | ||
| 44 | } @$guids; | ||
| 45 | |||
| 46 | return wantarray ? @tag_names : \@tag_names; | ||
| 47 | } | ||
| 48 | |||
| 49 | # the magic | ||
| 50 | sub AUTOLOAD { | ||
| 51 | my ($self,@args) = @_; | ||
| 52 | our ($AUTOLOAD); | ||
| 53 | my $method = $AUTOLOAD; | ||
| 54 | $method =~ s/.*:://; | ||
| 55 | |||
| 56 | if ($self->{_obj}->can($method)) { | ||
| 57 | return $self->{_obj}->$method; | ||
| 58 | } else { | ||
| 59 | # FIXME: would be better to get feedback about a non-existing method | ||
| 60 | return undef; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | 1; | ||
| 65 | |||
| 66 | __END__ |