Implement IGetMarketPrices and IGetUserListings
[www-backpacktf.git] / lib / WWW / BackpackTF / User.pm
CommitLineData
6e8c48c3
MG
1package WWW::BackpackTF::User;
2
3use 5.014000;
4use strict;
5use warnings;
fa7f4d7f 6our $VERSION = '0.002';
6e8c48c3
MG
7
8sub new{
9 my ($class, $content) = @_;
10 bless $content, $class
11}
12
13sub steamid { shift->{steamid} }
14sub name { shift->{name} }
15sub reputation { shift->{backpack_tf_reputation} }
16sub group { shift->{backpack_tf_group} }
17sub positive { shift->{backpack_tf_trust}->{for} // 0 }
18sub negative { shift->{backpack_tf_trust}->{against} // 0 }
19sub scammer { shift->{steamrep_scammer} }
20sub banned_backpack { shift->{backpack_tf_banned} }
21sub banned_economy { shift->{ban_economy} }
22sub banned_community { shift->{ban_community} }
23sub banned_vac { shift->{ban_vac} }
667a3b37 24sub notifications { shift->{notifications} // 0 }
6e8c48c3
MG
25sub value { shift->{backpack_value}->{shift // WWW::BackpackTF::TF2} }
26sub update { shift->{backpack_update}->{shift // WWW::BackpackTF::TF2} }
27
28sub banned {
29 my ($self) = @_;
30 $self->banned_backpack || $self->banned_community || $self->banned_economy || $self->banned_vac
31}
32
331;
34__END__
35
36=encoding utf-8
37
38=head1 NAME
39
40WWW::BackpackTF::User - Class representing user profile information
41
42=head1 SYNOPSIS
43
44 my $user = $bp->get_users($user_id);
45 say 'Steam ID: ', $user->steamid;
46 say 'Name: ', $user->name;
47 say 'Reputation: ', $user->reputation;
48 say 'Part of backpack.tf Steam Group: ', ($user->group ? 'YES' : 'NO');
49 say 'Positive trust ratings: ', $user->positive;
50 say 'Negative trust ratings: ', $user->negative;
51 say 'Scammer (according to steamrep.com): ', ($user->scammer ? 'YES' : 'NO');
52 say 'Banned from backpack.tf: ', ($user->banned_backpack ? 'YES' : 'NO');
53 say 'Economy banned: ', ($user->banned_economy ? 'YES' : 'NO');
54 say 'Community banned: ', ($user->banned_community ? 'YES' : 'NO');
55 say 'VAC banned: ', ($user->banned_vac ? 'YES' : 'NO');
56 say 'Banned on any of the previous: ', ($user->banned ? 'YES' : 'NO');
57 say 'Unread notifications: ', $user->notifications;
58 say 'Value of TF2 backpack: ', $user->value(WWW::BackpackTF::TF2);
59 say 'Value of Dota 2 backpack: ', $user->value(WWW::BackpackTF::DOTA2);
60 say 'Last TF2 backpack update: ', $user->update(WWW::BackpackTF::TF2);
61 say 'Last Dota 2 backpack update: ', $user->update(WWW::BackpackTF::DOTA2);
62
63
64=head1 DESCRIPTION
65
66WWW::BackpackTF::User is a class representing user profile information.
67
68=head2 METHODS
69
70=over
71
72=item B<steamid>
73
74Returns this user's Steam ID.
75
76=item B<name>
77
78Returns this user's persona name.
79
80=item B<reputation>
81
82Returns this user's backpack.tf reputation.
83
84=item B<group>
85
86Returns true if this user is part of the backpack.tf Steam group.
87
88=item B<positive>
89
90Returns the number of positive trust ratings this user has.
91
92=item B<negative>
93
94Returns the number of negative trust ratings this user has.
95
96=item B<scammer>
97
98Returns true if this user is a scammer according to L<http://steamrep.com/>
99
100=item B<banned_backpack>
101
102Returns true if this user is banned from backpack.tf.
103
104=item B<banned_economy>
105
106Returns true if this user is economy banned.
107
108=item B<banned_community>
109
110Returns true if this user is community banned.
111
112=item B<banned_vac>
113
114Returns true if this user is banned by Valve Anti-Cheat.
115
116=item B<banned>
117
118Returns true if any of the B<banned_*> methods returns true.
119
120=item B<notifications>
121
122Returns the number of unread notifications this user has.
123
124=item B<value>([I<game>])
125
126Returns the total value of this user's backpack for the specified game, in the lowest currency. I<game> defaults to C<WWW::BackpackTF::TF2>.
127
128=item B<update>([I<game>])
129
130Returns the UNIX timestamp of this user's last backpack update for the specified game. I<game> defaults to C<WWW::BackpackTF::TF2>
131
132=back
133
011cd8b5
MG
134=head1 SEE ALSO
135
136L<http://backpack.tf/api/users>
137
6e8c48c3
MG
138=head1 AUTHOR
139
140Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
141
142=head1 COPYRIGHT AND LICENSE
143
0aaa9b98 144Copyright (C) 2014-2016 by Marius Gavrilescu
6e8c48c3
MG
145
146This library is free software; you can redistribute it and/or modify
147it under the same terms as Perl itself, either Perl version 5.18.2 or,
148at your option, any later version of Perl 5 you may have available.
149
150
151=cut
This page took 0.017162 seconds and 4 git commands to generate.