Fix POD errors
[www-backpacktf.git] / lib / WWW / BackpackTF / Listing.pm
CommitLineData
fa7f4d7f
MG
1package WWW::BackpackTF::Listing;
2
3use 5.014000;
4use strict;
5use warnings;
6our $VERSION = '0.002';
7
8sub new{
9 my ($class, $content) = @_;
10 bless $content, $class
11}
12
13sub id { shift->{id} }
14sub currencies { shift->{currencies} }
15sub item { shift->{item} }
16sub details { shift->{details} }
17sub bump { shift->{bump} }
18sub created { shift->{created} }
19sub intent { shift->{intent} }
20sub is_selling { shift->intent == 1 }
21sub is_buying { shift->intent == 0 }
22
231;
24__END__
25
26=encoding utf-8
27
28=head1 NAME
29
30WWW::BackpackTF::Listing - Class representing a classified listing
31
32=head1 SYNOPSIS
33
34 use WWW::BackpackTF;
35 use Data::Dumper qw/Dumper/;
36 use POSIX qw/strftime/;
37
38 my $bp = WWW::BackpackTF->new(key => '...');
39 my $steamid = $ARGV[0];
40 my @listings = $bp->get_user_listings($steamid);
41 my $listing = $listings[0];
42
43 say 'Item: ', Dumper $listing->item;
44 say 'The user is selling this item' if $listing->is_selling;
45 say 'The user is buying this item' if $listing->is_buying;
46 my %currencies = %{$listing->currencies};
47 say 'Price: ', join ' + ', map { "$currencies{$_} $_" } keys %currencies;
48 say 'Details: ', $listing->details;
49 say 'Created at: ', strftime '%c', localtime $listing->created;
50 say 'Last bumped at: ', strftime '%c', localtime $listing->bump;
51
52=head1 DESCRIPTION
53
54WWW::BackpackTF::Listing is a class representing a classified listing.
55
56=head2 METHODS
57
58=over
59
60=item B<item>
61
62The item being sold, as a hashref. Contains keys like C<defindex> and
63C<quality>.
64
65=item B<currencies>
66
67The price of the listing, as a hashref. The keys are the internal
68names of the currencies (can be identified using B<get_currencies> in
69L<WWW::BackpackTF>) and the values are the amounts.
70
71=item B<details>
72
73The message on the listing
74
75=item B<bump>
76
77UNIX timestamp of when the listing was last bumped.
78
79=item B<created>
80
81UNIX timestamp of when the listing was created.
82
83=item B<id>
84
85The internal ID of the listing.
86
87=item B<is_selling>
88
89True if the user is selling this item.
90
91=item B<is_buying>
92
93True if the user is buying this item.
94
95=item B<intent>
96
971 if the user is selling the item, 0 if the user is buying.
98
99=back
100
fa7f4d7f
MG
101=head1 SEE ALSO
102
103L<http://backpack.tf/api/IGetPrices>
104
105=head1 AUTHOR
106
107Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
108
109=head1 COPYRIGHT AND LICENSE
110
111Copyright (C) 2014-2016 by Marius Gavrilescu
112
113This library is free software; you can redistribute it and/or modify
114it under the same terms as Perl itself, either Perl version 5.18.2 or,
115at your option, any later version of Perl 5 you may have available.
116
117
118=cut
This page took 0.014616 seconds and 4 git commands to generate.