| 1 | package WWW::BackpackTF::User; |
| 2 | |
| 3 | use 5.014000; |
| 4 | use strict; |
| 5 | use warnings; |
| 6 | our $VERSION = '0.002'; |
| 7 | |
| 8 | sub new{ |
| 9 | my ($class, $content) = @_; |
| 10 | bless $content, $class |
| 11 | } |
| 12 | |
| 13 | sub steamid { shift->{steamid} } |
| 14 | sub name { shift->{name} } |
| 15 | sub reputation { shift->{backpack_tf_reputation} } |
| 16 | sub group { shift->{backpack_tf_group} } |
| 17 | sub positive { shift->{backpack_tf_trust}->{for} // 0 } |
| 18 | sub negative { shift->{backpack_tf_trust}->{against} // 0 } |
| 19 | sub scammer { shift->{steamrep_scammer} } |
| 20 | sub banned_backpack { shift->{backpack_tf_banned} } |
| 21 | sub banned_economy { shift->{ban_economy} } |
| 22 | sub banned_community { shift->{ban_community} } |
| 23 | sub banned_vac { shift->{ban_vac} } |
| 24 | sub notifications { shift->{notifications} // 0 } |
| 25 | sub value { shift->{backpack_value}->{shift // WWW::BackpackTF::TF2} } |
| 26 | sub update { shift->{backpack_update}->{shift // WWW::BackpackTF::TF2} } |
| 27 | |
| 28 | sub banned { |
| 29 | my ($self) = @_; |
| 30 | $self->banned_backpack || $self->banned_community || $self->banned_economy || $self->banned_vac |
| 31 | } |
| 32 | |
| 33 | 1; |
| 34 | __END__ |
| 35 | |
| 36 | =encoding utf-8 |
| 37 | |
| 38 | =head1 NAME |
| 39 | |
| 40 | WWW::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 | |
| 66 | WWW::BackpackTF::User is a class representing user profile information. |
| 67 | |
| 68 | =head2 METHODS |
| 69 | |
| 70 | =over |
| 71 | |
| 72 | =item B<steamid> |
| 73 | |
| 74 | Returns this user's Steam ID. |
| 75 | |
| 76 | =item B<name> |
| 77 | |
| 78 | Returns this user's persona name. |
| 79 | |
| 80 | =item B<reputation> |
| 81 | |
| 82 | Returns this user's backpack.tf reputation. |
| 83 | |
| 84 | =item B<group> |
| 85 | |
| 86 | Returns true if this user is part of the backpack.tf Steam group. |
| 87 | |
| 88 | =item B<positive> |
| 89 | |
| 90 | Returns the number of positive trust ratings this user has. |
| 91 | |
| 92 | =item B<negative> |
| 93 | |
| 94 | Returns the number of negative trust ratings this user has. |
| 95 | |
| 96 | =item B<scammer> |
| 97 | |
| 98 | Returns true if this user is a scammer according to L<http://steamrep.com/> |
| 99 | |
| 100 | =item B<banned_backpack> |
| 101 | |
| 102 | Returns true if this user is banned from backpack.tf. |
| 103 | |
| 104 | =item B<banned_economy> |
| 105 | |
| 106 | Returns true if this user is economy banned. |
| 107 | |
| 108 | =item B<banned_community> |
| 109 | |
| 110 | Returns true if this user is community banned. |
| 111 | |
| 112 | =item B<banned_vac> |
| 113 | |
| 114 | Returns true if this user is banned by Valve Anti-Cheat. |
| 115 | |
| 116 | =item B<banned> |
| 117 | |
| 118 | Returns true if any of the B<banned_*> methods returns true. |
| 119 | |
| 120 | =item B<notifications> |
| 121 | |
| 122 | Returns the number of unread notifications this user has. |
| 123 | |
| 124 | =item B<value>([I<game>]) |
| 125 | |
| 126 | Returns 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 | |
| 130 | Returns 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 | |
| 134 | =head1 SEE ALSO |
| 135 | |
| 136 | L<http://backpack.tf/api/users> |
| 137 | |
| 138 | =head1 AUTHOR |
| 139 | |
| 140 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> |
| 141 | |
| 142 | =head1 COPYRIGHT AND LICENSE |
| 143 | |
| 144 | Copyright (C) 2014-2016 by Marius Gavrilescu |
| 145 | |
| 146 | This library is free software; you can redistribute it and/or modify |
| 147 | it under the same terms as Perl itself, either Perl version 5.18.2 or, |
| 148 | at your option, any later version of Perl 5 you may have available. |
| 149 | |
| 150 | |
| 151 | =cut |