Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/TasksApi1/Task.pm view on Meta::CPAN
package Google::RestApi::TasksApi1::Task;
our $VERSION = '2.2.3';
use Google::RestApi::Setup;
use parent 'Google::RestApi::SubResource';
sub new {
my $class = shift;
state $check = signature(
bless => !!0,
named => [
task_list => HasApi,
id => Str, { optional => 1 },
],
);
return bless $check->(@_), $class;
}
sub _uri_base { "lists/" . $_[0]->task_list()->task_list_id() . "/tasks" }
sub _parent_accessor { 'tasks_api' }
sub get {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
fields => Str, { optional => 1 },
],
);
my $p = $check->(@_);
$self->require_id('get');
my %params;
$params{fields} = $p->{fields} if defined $p->{fields};
return $self->api(params => \%params);
}
sub update {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
title => Str, { optional => 1 },
notes => Str, { optional => 1 },
due => Str, { optional => 1 },
status => Str, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
$self->require_id('update');
my %content;
$content{title} = delete $p->{title} if defined $p->{title};
$content{notes} = delete $p->{notes} if defined $p->{notes};
$content{due} = delete $p->{due} if defined $p->{due};
$content{status} = delete $p->{status} if defined $p->{status};
DEBUG(sprintf("Updating task '%s'", $self->{id}));
return $self->api(
method => 'patch',
content => \%content,
);
}
sub delete {
my $self = shift;
$self->require_id('delete');
DEBUG(sprintf("Deleting task '%s'", $self->{id}));
return $self->api(method => 'delete');
}
sub move {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
parent => Str, { optional => 1 },
previous => Str, { optional => 1 },
destination_tasklist => Str, { optional => 1 },
],
);
my $p = $check->(@_);
$self->require_id('move');
my %params;
$params{parent} = $p->{parent} if defined $p->{parent};
$params{previous} = $p->{previous} if defined $p->{previous};
$params{destinationTasklist} = $p->{destination_tasklist} if defined $p->{destination_tasklist};
DEBUG(sprintf("Moving task '%s'", $self->{id}));
return $self->api(
uri => 'move',
method => 'post',
( run in 0.730 second using v1.01-cache-2.11-cpan-99c4e6809bf )