File Coverage

blib/lib/WebService/Toggl/Report/Details.pm
Criterion Covered Total %
statement 12 13 92.3
branch n/a
condition n/a
subroutine 4 5 80.0
pod n/a
total 16 18 88.8


line stmt bran cond sub pod time code
1             package WebService::Toggl::Report::Details;
2              
3 1     1   1043 use Sub::Quote qw(quote_sub);
  1         3  
  1         58  
4 1     1   5 use Types::Standard qw(Int);
  1         1  
  1         16  
5              
6 1     1   471 use Moo;
  1         2  
  1         5  
7             with 'WebService::Toggl::Role::Report';
8 1     1   350 use namespace::clean;
  1         1  
  1         4  
9              
10 0     0     sub api_path { 'details' }
11              
12             # request params
13             has page => (is => 'ro', isa => Int, default => 1);
14              
15              
16             # response params
17             has $_ => (is => 'ro', lazy => 1, builder => quote_sub(qq| \$_[0]->raw->{$_} |))
18             for (qw(per_page total_count));
19              
20              
21             1;
22             __END__
23              
24             =encoding utf-8
25              
26             =head1 NAME
27              
28             WebService::Toggl::Report::Details - Toggl detailed report object
29              
30             =head1 SYNOPSIS
31              
32             use WebService::Toggl;
33             my $toggl = WebService::Toggl->new({api_key => 'foo'});
34              
35             my $report = $toggl->details({workspace_id => 1234});
36              
37             say $report->total_billable; # billable milliseconds
38             say $report->total_count; # max($all_entries, $per_page)
39             for $entry (@{ $report->data }) {
40             say "User: $entry->{user} logged " . ($entry->{dur} / 1000)
41             . " second on task: '" . $entry->{description} . "'";
42             }
43              
44             =head1 DESCRIPTION
45              
46             This module is a wrapper object around the Toggl detailed report
47             L<described here|https://github.com/toggl/toggl_api_docs/blob/master/reports/detailed.md>.
48             It returns all of the time entries that match the request criteria.
49              
50             =head1 REQUEST ATTRIBUTES
51              
52             Request attributes common to all reports are detailed in the
53             L<::Role::Request|WebService::Toggl::Role::Report#REQUEST-ATTRIBUTES> pod.
54              
55             =head2 page
56              
57             Detailed reports are paged. This attribute sets the requested page.
58             If left empty, Toggl will return the first page by default.
59              
60             =head1 RESPONSE ATTRIBUTES
61              
62             Response attributes common to all reports are detailed in the
63             L<::Role::Request|WebService::Toggl::Role::Report#RESPONSE-ATTRIBUTES> pod.
64              
65             =head2 per_page
66              
67             How many time entries are being returned per page. Current default is
68             50. This is not settable.
69              
70             =head2 total_count
71              
72             The total number of records found. This will be the greater of the
73             actual number of entries returned and the C<per_page> parameter.
74              
75             =head1 REPORT DATA
76              
77             The C<data()> attribute of a C<::Report::Details> object is an
78             arrayref of time entry hashrefs. For the contents of this structure, see the
79             L<Toggl API docs|https://github.com/toggl/toggl_api_docs/blob/master/reports/detailed.md>.
80              
81              
82             =head1 LICENSE
83              
84             Copyright (C) Fitz Elliott.
85              
86             This library is free software; you can redistribute it and/or modify
87             it under the same terms as Perl itself.
88              
89             =head1 AUTHOR
90              
91             Fitz Elliott E<lt>felliott@fiskur.orgE<gt>
92              
93             =cut
94