use strict;
use warnings;
use parent qw/Exporter/;
-our $VERSION = '0.000_003';
-our @EXPORT_OK = qw/TF2 DOTA2/;
+our $VERSION = '0.002001';
+our @EXPORT_OK = qw/TF2 DOTA2 CSGO/;
-use constant +{
+use constant +{ ## no critic (Capitalization)
TF2 => 440,
DOTA2 => 570,
+ CSGO => 730,
QUALITIES => [qw/Normal Genuine rarity2 Vintage rarity3 Unusual Unique Community Valve Self-Made Customized Strange Completed Haunted Collector's/],
};
for (0 .. $#qualities) {
my $name = uc $qualities[$_];
$name =~ y/A-Z0-9//cd;
+ push @EXPORT_OK, $name;
constant->import($name, $_)
}
}
use PerlX::Maybe;
use WWW::BackpackTF::Currency;
use WWW::BackpackTF::Item;
+use WWW::BackpackTF::MarketItem;
+use WWW::BackpackTF::Listing;
use WWW::BackpackTF::User;
my $ht = HTTP::Tiny->new(agent => "WWW-BackpackTF/$VERSION");
$url = $self->{base} . $url;
$url .= "&$_=$params{$_}" for keys %params;
my $htr = $ht->get($url);
- die $htr->{reason} unless $htr->{success};
+ die $htr->{reason} unless $htr->{success}; ## no critic (RequireCarping)
my $response = decode_json($htr->{content})->{response};
- die $response->{message} unless $response->{success};
+ die $response->{message} unless $response->{success}; ## no critic (RequireCarping)
$response
}
map { WWW::BackpackTF::Currency->new($_, $response->{currencies}{$_}) } keys %{$response->{currencies}};
}
+# get_price_history not implemented
+# get_special_items not implemented
+
+sub get_market_prices {
+ my ($self, $appid) = @_;
+ my $response = $self->request('IGetMarketPrices/v1/?compress=1', maybe appid => $appid);
+ map { WWW::BackpackTF::MarketItem->new($_, $response->{items}{$_}) } keys %{$response->{items}}
+}
+
+sub get_user_listings {
+ my ($self, $steamid, $appid) = @_;
+ my $response = $self->request('IGetUserListings/v2/?compress=1', steamid => $steamid, maybe appid => $appid);
+ map { WWW::BackpackTF::Listing->new($_) } @{$response->{listings}}
+}
+
1;
__END__
+=encoding utf-8
+
=head1 NAME
WWW::BackpackTF - interface to the backpack.tf trading service
=head1 DESCRIPTION
-WWW::BackpackTF is an interface to the backpack.tf Team Fortress 2/Dota 2 trading service.
+WWW::BackpackTF is an interface to the backpack.tf Team Fortress 2/Dota 2/Counter-Strike: Global Offensive trading service.
=head2 METHODS
Get currency information. Takes one optional parameter, the appid, which defaults to WWW::BackpackTF::TF2. Returns a list of L<WWW::BackpackTF::Currency> objects.
+=item B<get_market_prices>([I<$appid>])
+
+Get Steam Community Market price information for all items. Takes one optional parameter, the appid, which defaults to WWW::BackpackTF::TF2. Returns a list of L<WWW::BackpackTF::MarketItem> objects.
+
+=item B<get_user_listings>(I<$steamid>, [I<$appid>])
+
+Get classified listing of a given user. Takes a mandatory 64-bit Steam ID of the user, and an optional parameter, the appid, which defaults to WWW::BackpackTF::TF2. Returns a list of L<WWW::BackpackTF::Listing> objects.
+
=back
=head2 EXPORTS
Constant (570) representing Dota 2.
+=item B<CSGO>
+
+Constant (730) representing Counter-Strike: Global Offensive
+
=item B<NORMAL>
The Normal item quality (0).
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2014 by Marius Gavrilescu
+Copyright (C) 2014-2017 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.18.2 or,