RestApi/TasksApi1/Task.pm

filter: Statementstmt 100% 56 / 56 Branchbran 50.0% 8 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 90.0% 9 / 10 totaltotal 90.6% 87 / 96 CC 9 SCAR 9.6
CC
9
Cov
89%
update
5.2
move
4.1
get
2.0
CRAP 2.6
« RestApi/Auth/ServiceAccount.pm ↑ Summary RestApi/GmailApi1.pm »
1 package Google::RestApi::TasksApi1::Task;
2  
3 2 our $VERSION = '2.2.5';
4  
5 2 ▶use Google::RestApi::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use parent 'Google::RestApi::SubResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 9 my $class = shift;
11 9 state $check = signature(
12 bless => !!0,
13 named => [
14 task_list => HasApi,
15 id => Str, { optional => 1 },
16 ],
17 );
18 9 return bless $check->(@_), $class;
19 }
20  
21 6 ▶sub _uri_base { "lists/" . $_[0]->task_list()->task_list_id() . "/tasks" }
Subroutine _uri_base: called CC=1 SCAR=0.0
22 6 ▶sub _parent_accessor { 'tasks_api' }
Subroutine _parent_accessor: called CC=1 SCAR=0.0
23  
24 2 ▶sub get {
Subroutine get: called CC=2 SCAR=7.0
Pod documented
25 2 my $self = shift;
26 2 state $check = signature(
27 bless => !!0,
28 named => [
29 fields => Str, { optional => 1 },
30 ],
31 );
32 2 my $p = $check->(@_);
33  
34 2 $self->require_id('get');
35  
36 1 my %params;
37 1 ▶ $params{fields} = $p->{fields} if defined $p->{fields};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"fields"} 0 1 1
38  
39 1 return $self->api(params => \%params);
40 }
41  
42 2 ▶sub update {
Subroutine update: called CC=5 SCAR=16.6
Pod documented
43 2 my $self = shift;
44 2 state $check = signature(
45 bless => !!0,
46 named => [
47 title => Str, { optional => 1 },
48 notes => Str, { optional => 1 },
49 due => Str, { optional => 1 },
50 status => Str, { optional => 1 },
51 _extra_ => slurpy HashRef,
52 ],
53 );
54 2 my $p = named_extra($check->(@_));
55  
56 2 $self->require_id('update');
57  
58 1 my %content;
59 1 ▶ $content{title} = delete $p->{title} if defined $p->{title};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"title"} 1 0 1
60 1 ▶ $content{notes} = delete $p->{notes} if defined $p->{notes};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"notes"} 0 1 1
61 1 ▶ $content{due} = delete $p->{due} if defined $p->{due};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"due"} 0 1 1
62 1 ▶ $content{status} = delete $p->{status} if defined $p->{status};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"status"} 0 1 1
63  
64 1 DEBUG(sprintf("Updating task '%s'", $self->{id}));
65 1 return $self->api(
66 method => 'patch',
67 content => \%content,
68 );
69 }
70  
71 2 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
72 2 my $self = shift;
73  
74 2 $self->require_id('delete');
75  
76 1 DEBUG(sprintf("Deleting task '%s'", $self->{id}));
77 1 return $self->api(method => 'delete');
78 }
79  
80 2 ▶sub move {
Subroutine move: called CC=4 SCAR=14.1
Pod documented
81 2 my $self = shift;
82 2 state $check = signature(
83 bless => !!0,
84 named => [
85 parent => Str, { optional => 1 },
86 previous => Str, { optional => 1 },
87 destination_tasklist => Str, { optional => 1 },
88 ],
89 );
90 2 my $p = $check->(@_);
91  
92 2 $self->require_id('move');
93  
94 1 my %params;
95 1 ▶ $params{parent} = $p->{parent} if defined $p->{parent};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"parent"} 0 1 1
96 1 ▶ $params{previous} = $p->{previous} if defined $p->{previous};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"previous"} 0 1 1
97 1 ▶ $params{destinationTasklist} = $p->{destination_tasklist} if defined $p->{destination_tasklist};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"destination_tasklist"} 0 1 1
98  
99 1 DEBUG(sprintf("Moving task '%s'", $self->{id}));
100 1 return $self->api(
101 uri => 'move',
102 method => 'post',
103 params => \%params,
104 );
105 }
106  
107 2 ▶sub complete {
Subroutine complete: called CC=1 SCAR=0.0
Pod documented
108 2 my $self = shift;
109  
110 2 $self->require_id('complete');
111  
112 1 DEBUG(sprintf("Completing task '%s'", $self->{id}));
113 1 return $self->api(
114 method => 'patch',
115 content => { status => 'completed' },
116 );
117 }
118  
119 2 ▶sub uncomplete {
Subroutine uncomplete: called CC=1 SCAR=0.0
Pod documented
120 2 my $self = shift;
121  
122 2 $self->require_id('uncomplete');
123  
124 1 DEBUG(sprintf("Uncompleting task '%s'", $self->{id}));
125 1 return $self->api(
126 method => 'patch',
127 content => { status => 'needsAction', completed => undef },
128 );
129 }
130  
131 1 ▶sub task_id { shift->{id}; }
Subroutine task_id: called CC=1 SCAR=0.0
Pod documented
132 6 ▶sub task_list { shift->{task_list}; }
Subroutine task_list: called CC=1 SCAR=0.0
Pod documented
133 6 ▶sub tasks_api { shift->{task_list}->{tasks_api}; }
Subroutine tasks_api: called CC=1 SCAR=0.0
Pod documented
134  
135 2 1;
136  
137 __END__
« RestApi/Auth/ServiceAccount.pm ↑ Summary RestApi/GmailApi1.pm »