| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Toggl::Report::Summary; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1291
|
use Types::Standard qw(Bool Enum); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
417
|
use Moo; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
|
|
with 'WebService::Toggl::Role::Report'; |
|
7
|
1
|
|
|
1
|
|
406
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
|
|
sub api_path { 'summary' } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
around _req_params => sub { |
|
12
|
|
|
|
|
|
|
my $orig = shift; |
|
13
|
|
|
|
|
|
|
my $self = shift; |
|
14
|
|
|
|
|
|
|
return [ @{$self->$orig}, qw(grouping subgrouping) ]; # subgrouping_ids grouped_time_entry_ids) ]; |
|
15
|
|
|
|
|
|
|
}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @valid_groups = ( |
|
18
|
|
|
|
|
|
|
['projects', [qw(time_entries tasks users )]], |
|
19
|
|
|
|
|
|
|
['clients', [qw(time_entries tasks users projects )]], |
|
20
|
|
|
|
|
|
|
['users', [qw(time_entries tasks projects clients)]], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
my %valid_groups = map { |
|
23
|
|
|
|
|
|
|
$_->[0] => { map {$_ => 1} @{ $_->[1] } } |
|
24
|
|
|
|
|
|
|
} @valid_groups; |
|
25
|
|
|
|
|
|
|
my @uniq_subgroups = do { |
|
26
|
|
|
|
|
|
|
my %seen; |
|
27
|
|
|
|
|
|
|
grep { !$seen{$_}++ } |
|
28
|
|
|
|
|
|
|
map { @{$_->[1]} } @valid_groups |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# request params |
|
32
|
|
|
|
|
|
|
has grouping => ( |
|
33
|
|
|
|
|
|
|
is => 'ro', |
|
34
|
|
|
|
|
|
|
isa => Enum[keys %valid_groups], |
|
35
|
|
|
|
|
|
|
default => 'projects', |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
has subgrouping => ( |
|
38
|
|
|
|
|
|
|
is => 'ro', |
|
39
|
|
|
|
|
|
|
isa => Enum[@uniq_subgroups], |
|
40
|
|
|
|
|
|
|
default => 'tasks', |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
has subgrouping_ids => (is => 'ro', isa => Bool, default => 0,); |
|
43
|
|
|
|
|
|
|
has grouped_time_entry_ids => (is => 'ro', isa => Bool, default => 0,); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# repsonse params |
|
47
|
|
|
|
|
|
|
# **none** |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
__END__ |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=encoding utf-8 |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
WebService::Toggl::Report::Summary - Toggl summary report object |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use WebService::Toggl; |
|
63
|
|
|
|
|
|
|
my $toggl = WebService::Toggl->new({api_key => 'foo'}); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $report = $toggl->summary({ |
|
66
|
|
|
|
|
|
|
workspace_id => 1234, |
|
67
|
|
|
|
|
|
|
grouping => 'projects', subgrouping => 'time_entries', |
|
68
|
|
|
|
|
|
|
}); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
say $report->total_billable; # billable milliseconds |
|
71
|
|
|
|
|
|
|
for $project (@{ $report->data }) { |
|
72
|
|
|
|
|
|
|
say "Time Entries For project $project->{title}{project}:"; |
|
73
|
|
|
|
|
|
|
for my $item (@{ $project->{items} }) { |
|
74
|
|
|
|
|
|
|
say $item->{title}{time_entry} . " took " |
|
75
|
|
|
|
|
|
|
. ($entry->{time} / 1000) . " seconds"; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This module is a wrapper object around the Toggl summary report |
|
83
|
|
|
|
|
|
|
L<described here|https://github.com/toggl/toggl_api_docs/blob/master/reports/summary.md>. |
|
84
|
|
|
|
|
|
|
It returns a report of properties that are grouped and subgrouped |
|
85
|
|
|
|
|
|
|
according to the specified request attributes. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 REQUEST ATTRIBUTES |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Request attributes common to all reports are detailed in the |
|
90
|
|
|
|
|
|
|
L<::Role::Request|WebService::Toggl::Role::Report#REQUEST-ATTRIBUTES> pod. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 grouping / subgrouping |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The primary and secondary grouping properties. Defaults to |
|
95
|
|
|
|
|
|
|
C<projects> and C<time_entries> respectively. The following |
|
96
|
|
|
|
|
|
|
combinations are valid: |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
+--------------------------------------------------------+ |
|
99
|
|
|
|
|
|
|
| | Group | |
|
100
|
|
|
|
|
|
|
| +--------------+--------------+--------------+ |
|
101
|
|
|
|
|
|
|
| | projects | clients | users | |
|
102
|
|
|
|
|
|
|
+-----------+--------------+--------------+--------------+ |
|
103
|
|
|
|
|
|
|
| | time_entries | time_entries | time_entries | |
|
104
|
|
|
|
|
|
|
| Valid | tasks | tasks | tasks | |
|
105
|
|
|
|
|
|
|
| Subgroups | users | users | | |
|
106
|
|
|
|
|
|
|
| | | projects | projects | |
|
107
|
|
|
|
|
|
|
| | | | clients | |
|
108
|
|
|
|
|
|
|
+-----------+--------------+--------------+--------------+ |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 subgrouping_ids |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Boolean that determines if an C<ids> key containing a comma-separated |
|
114
|
|
|
|
|
|
|
list of subgroup ids will be added each group in the C<data> |
|
115
|
|
|
|
|
|
|
key. Defaults to C<false>. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 grouped_time_entry_ids |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Boolean that determines if a C<time_entry_ids> key containing a |
|
120
|
|
|
|
|
|
|
comma-separated list of time entry IDs will be added each group in the |
|
121
|
|
|
|
|
|
|
C<data> key. Defaults to C<false>. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 RESPONSE ATTRIBUTES |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Response attributes common to all reports are detailed in the |
|
127
|
|
|
|
|
|
|
L<::Role::Request|WebService::Toggl::Role::Report#RESPONSE-ATTRIBUTES> pod. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
C<::Report::Summary> returns no additional response attributes. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 REPORT DATA |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The C<data()> attribute of a C<::Report::Summary> object is an |
|
134
|
|
|
|
|
|
|
arrayref of grouping hashrefs. Each group hashref will contain C<id>, |
|
135
|
|
|
|
|
|
|
C<title>, and C<items> keys. The C<items> key holds an arrayref of |
|
136
|
|
|
|
|
|
|
the requested subgrouping objects. For a detailed description of the |
|
137
|
|
|
|
|
|
|
contents of this structure, see the L<Toggl API |
|
138
|
|
|
|
|
|
|
docs|https://github.com/toggl/toggl_api_docs/blob/master/reports/summary.md>. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 LICENSE |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright (C) Fitz Elliott. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
145
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Fitz Elliott E<lt>felliott@fiskur.orgE<gt> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |