| WebService-30Boxes-API documentation | Contained in the WebService-30Boxes-API distribution. |
WebService::30Boxes::API::Todo - Object returned by WebService::30Boxes::API::call("todo.Get")
#$api_key and $auth_token are defined before
my $boxes = WebService::30Boxes::API->new(api_key => $api_key);
my $todos = $boxes->call('todos.Get', {authorizedUserToken => $auth_token});
if($todos->{'success'}){
#while ($todos->nextTodoId){ - if you use this, you don't need to specify
#$_ as an argument
#foreach (@{$todos->get_ref_todoIds}){
foreach ($todos->get_todoIds){
print "Todo id: $_\n";
print "Title: " . $todos->get_title($_) . "\n";
print "Tags: ";
foreach ($todos->get_tags($_)){print "$_\n";}
print "Done: " . $todos->isDone($_) . "\n";
print "Position: " . $todos->get_position($_) . "\n";
print "External UID: " . $todos->get_externalUID($_) . "\n";
}
}
else{
print "An error occured (" . $todos->{'error_code'} . ": " .
$todos->{'error_msg'} . ")\n";
}
An object of this type is returned by the WebService::30Boxes::API::call("todos.Get") function
The following methods can be used
Create a new WebService::30Boxes::API::Todo object.
(Mandatory) Result must be the the hash function returned by the XML parser. Results are undefined if some other hash is passed in.
(Mandatory) If the API call was successful or not.
(Optional) If success is false, this must be supplied
(Optional) If success is false, this must be supplied
Returns an array of todo ids.
You can then use this to call any of the following functions.
Returns a reference to an array of todo ids.
You can then use this to call any of the following functions.
Advances the todo index and returns the new todoID (for convenience)
Arguments:
(Optional) The todoId of the todo for which you want to retreive the information. If not present, the next todoId will be used as an index. The next todoId is set by calling nextTodoId.
Returns the title for the todo.
Arguments:
(Optional) The todoId of the todo for which you want to retreive the information. If not present, the next todoId will be used as an index. The next todoId is set by calling nextTodoId.
Returns the todo is done or not Returns 1 if yes, 0 if not
Arguments:
(Optional) The todoId of the todo for which you want to retreive the information. If not present, the next todoId will be used as an index. The next todoId is set by calling nextTodoId.
Returns the position of the todo as the user defined it
Arguments:
(Optional) The todoId of the todo for which you want to retreive the information. If not present, the next todoId will be used as an index. The next todoId is set by calling nextTodoId.
Returns the user defined ID for this todo The return value is a string
Arguments:
(Optional) The todoId of the todo for which you want to retreive the information. If not present, the next todoId will be used as an index. The next todoId is set by calling nextTodoId.
Add more error checking. Compact the code and make it more efficient. Please email me for feature requests.
Please notify chitoiup@umich.edu of any bugs.
Robert Chitoiu, <chitoiup@umich.edu>
Copyright (C) 2007 by Robert Chitoiu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| WebService-30Boxes-API documentation | Contained in the WebService-30Boxes-API distribution. |
package WebService::30Boxes::API::Todo; use strict; use warnings; use Carp qw/croak/; our $VERSION = '1.05'; sub new { my ($class, $result, $success, $error_code, $error_message) = @_; croak "The response from 30Boxes was not a success" unless $result->{'success'}; #%{$result->{'_xml'}->{'todoList'}->{'todo'}} is a hash with todo ids as keys my $self = { todo => $result->{'_xml'}->{'todoList'}->{'todo'}, todoIds => [sort keys %{$result->{'_xml'}->{'todoList'}->{'todo'}}], todoIndex => -1, success => $success, error_code => $error_code, error_message => $error_message, }; bless $self, $class; return $self; } #return an array of todo ids sub get_todoIds { my ($self) = @_; return @{$self->{'todoIds'}}; } #return a reference to an array of todo ids sub get_ref_todoIds { my ($self) = @_; return $self->{'todoIds'}; } #advance the todoIndex sub nextTodoId { my ($self) = @_; return 0 if $self->{'todoIndex'} == scalar(@{$self->{'todoIds'}}) - 1; return $self->{'todoIds'}->[$self->{'todoIndex'}++]; } #returns a list of tags sub get_tags { my ($self, $todoId) = @_; $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_; my $temp = $self->{'todo'}->{$todoId}->{'tags'}; return "" if ref($temp);#it's a hash if empty $temp =~ s/\s+/ /; return split(/ /, $temp); } #gets the title for the todos sub get_title { my ($self, $todoId) = @_; $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_; return $self->{'todo'}->{$todoId}->{'summary'}; } #get if the the todo is marked as done #returns 1 if yes, 0 if not sub isDone { my ($self, $todoId) = @_; $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_; return $self->{'todo'}->{$todoId}->{'done'}; } #returns the position of the todo in the list sub get_position { my ($self, $todoId) = @_; $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_; return $self->{'todo'}->{$todoId}->{'position'}; } sub get_externalUID { my ($self, $todoId) = @_; $todoId = $self->{'todoIds'}->[$self->{'todoIndex'}] if 0 == $#_; my $temp = $self->{'todo'}->{$todoId}->{'externalUID'}; return "" if ref($temp);#it's a hash if empty $temp =~ s/\s+/ /; return split(/ /, $temp); } 1; __END__