line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Wunderlist.com API Client |
2
|
|
|
|
|
|
|
package API::Wunderlist; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1506
|
use namespace::autoclean -except => 'has'; |
|
1
|
|
|
|
|
23171
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1806
|
use Data::Object::Class; |
|
1
|
|
|
|
|
14351
|
|
|
1
|
|
|
|
|
12
|
|
7
|
1
|
|
|
1
|
|
3476
|
use Data::Object::Class::Syntax; |
|
1
|
|
|
|
|
7449
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
1711
|
use Data::Object::Signatures; |
|
1
|
|
|
|
|
312154
|
|
|
1
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
9517
|
use Data::Object qw(load); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
11
|
1
|
|
|
1
|
|
5
|
use Data::Object::Library qw(Str); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends 'API::Client'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.04'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $DEFAULT_URL = "https://a.wunderlist.com"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ATTRIBUTES |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has client_id => rw; |
22
|
|
|
|
|
|
|
has access_token => rw; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# CONSTRAINTS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
req client_id => Str; |
27
|
|
|
|
|
|
|
req access_token => Str; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# DEFAULTS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
def identifier => 'API::Wunderlist (Perl)'; |
32
|
|
|
|
|
|
|
def url => method { load('Mojo::URL')->new($DEFAULT_URL) }; |
33
|
|
|
|
|
|
|
def version => 1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# CONSTRUCTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
after BUILD => method { |
38
|
|
|
|
|
|
|
my $identifier = $self->identifier; |
39
|
|
|
|
|
|
|
my $client_id = $self->client_id; |
40
|
|
|
|
|
|
|
my $access_token = $self->access_token; |
41
|
|
|
|
|
|
|
my $version = $self->version; |
42
|
|
|
|
|
|
|
my $agent = $self->user_agent; |
43
|
|
|
|
|
|
|
my $url = $self->url; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$agent->transactor->name($identifier); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$url->path("/api/v$version"); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return $self; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# METHODS |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
0
|
|
method PREPARE ($ua, $tx, %args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $headers = $tx->req->headers; |
56
|
0
|
|
|
|
|
|
my $url = $tx->req->url; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# default headers |
59
|
0
|
|
|
|
|
|
$headers->header('X-Client-ID' => $self->client_id); |
60
|
0
|
|
|
|
|
|
$headers->header('X-Access-Token' => $self->access_token); |
61
|
0
|
|
|
|
|
|
$headers->header('Content-Type' => 'application/json'); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
|
method resource (@segments) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# build new resource instance |
66
|
0
|
|
|
|
|
|
my $instance = __PACKAGE__->new( |
67
|
|
|
|
|
|
|
debug => $self->debug, |
68
|
|
|
|
|
|
|
fatal => $self->fatal, |
69
|
|
|
|
|
|
|
retries => $self->retries, |
70
|
|
|
|
|
|
|
timeout => $self->timeout, |
71
|
|
|
|
|
|
|
user_agent => $self->user_agent, |
72
|
|
|
|
|
|
|
identifier => $self->identifier, |
73
|
|
|
|
|
|
|
client_id => $self->client_id, |
74
|
|
|
|
|
|
|
access_token => $self->access_token, |
75
|
|
|
|
|
|
|
version => $self->version, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# resource locator |
79
|
0
|
|
|
|
|
|
my $url = $instance->url; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# modify resource locator if possible |
82
|
0
|
|
|
|
|
|
$url->path(join '/', $self->url->path, @segments); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# return resource instance |
85
|
0
|
|
|
|
|
|
return $instance; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |