line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Toggl::Request; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
3825
|
use HTTP::Tiny; |
|
6
|
|
|
|
|
235779
|
|
|
6
|
|
|
|
|
240
|
|
4
|
6
|
|
|
6
|
|
2855
|
use MIME::Base64 qw(encode_base64); |
|
6
|
|
|
|
|
3180
|
|
|
6
|
|
|
|
|
353
|
|
5
|
6
|
|
|
6
|
|
2543
|
use URI::Escape qw(uri_escape); |
|
6
|
|
|
|
|
5788
|
|
|
6
|
|
|
|
|
350
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
31
|
use Moo; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
43
|
|
8
|
|
|
|
|
|
|
with 'Role::REST::Client'; |
9
|
6
|
|
|
6
|
|
2515
|
use namespace::clean; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
47
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has api_key => (is => 'ro', required => 1,); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# extra space adds HTTPT version |
14
|
|
|
|
|
|
|
has user_agent_id => (is => 'ro', default => 'WebService-Toggl '); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_user_agent { |
17
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
18
|
0
|
|
|
|
|
|
HTTP::Tiny->new( |
19
|
|
|
|
|
|
|
agent => $self->user_agent_id, |
20
|
|
|
|
|
|
|
default_headers => { |
21
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
22
|
|
|
|
|
|
|
'Accept' => 'application/json', |
23
|
|
|
|
|
|
|
'Authorization' => 'Basic ' . encode_base64($self->api_key . ':api_token', ''), |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
__END__ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding utf-8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
WebService::Toggl::Request - Set headers and make requests to the Toggl API |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This module holds the entity that sends requests to the Toggl API. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This module composes L<Role::REST::Client>. See that module for other |
45
|
|
|
|
|
|
|
attributes / methods. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 api_key |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The API token that identifies the authorized user. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 user_agent_id |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The ID string for the user agent. Defaults to 'WebService-Toggl '. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 LICENSE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Copyright (C) Fitz Elliott. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
60
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Fitz Elliott E<lt>felliott@fiskur.orgE<gt> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |