line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ZooTool::User; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1817
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'Net::ZooTool::Utils'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Carp; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use namespace::autoclean; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has auth => ( |
13
|
|
|
|
|
|
|
isa => 'Net::ZooTool::Auth', |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub BUILD { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
before [ 'items', 'info', 'validate', 'friends', 'followers', 'profiles' ] => sub { |
22
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
croak |
25
|
|
|
|
|
|
|
"You are trying to use a feature that requires authentication without providing username and password" |
26
|
|
|
|
|
|
|
if $args->{login} and ( !$self->auth->user or !$self->auth->password ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Appends apikey to all registered methods |
29
|
|
|
|
|
|
|
$args->{apikey} = $self->auth->apikey; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 |
33
|
|
|
|
|
|
|
Get the latest items... |
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
sub items { |
36
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $data = _fetch('/users/items/' . _hash_to_query_string($args), $self->auth ); |
39
|
|
|
|
|
|
|
return $data; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 |
43
|
|
|
|
|
|
|
Get info about a certain user |
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
sub info { |
46
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
47
|
|
|
|
|
|
|
my $data = _fetch('/users/info/' . _hash_to_query_string($args), $self->auth ); |
48
|
|
|
|
|
|
|
return $data; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 |
52
|
|
|
|
|
|
|
Validate user credentials. Useful for logins. |
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
sub validate { |
55
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
56
|
|
|
|
|
|
|
my $data = _fetch('/users/validate/' . _hash_to_query_string($args), $self->auth ); |
57
|
|
|
|
|
|
|
return $data; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 |
61
|
|
|
|
|
|
|
Get a list of friends from the user |
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
sub friends { |
64
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
65
|
|
|
|
|
|
|
my $data = _fetch('/users/friends/' . _hash_to_query_string($args), $self->auth); |
66
|
|
|
|
|
|
|
return $data; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 |
70
|
|
|
|
|
|
|
Get a list of followers from the user |
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
sub followers { |
73
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
74
|
|
|
|
|
|
|
my $data = _fetch('/users/followers/' . _hash_to_query_string($args), $self->auth); |
75
|
|
|
|
|
|
|
return $data; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 |
79
|
|
|
|
|
|
|
Get a list of external profiles for a user |
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
sub profiles { |
82
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
83
|
|
|
|
|
|
|
my $data = _fetch('/users/profiles/' . _hash_to_query_string($args), $self->auth); |
84
|
|
|
|
|
|
|
return $data; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
no Moose; |
88
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |