X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=lib%2FWWW%2FBackpackTF.pm;h=ad39d73175774356775477f0a1d31cd1cedb246d;hb=0aaa9b980d349153117dbfa46a4dfae24ace1e25;hp=015d9fa3a810121009503f7de23cc33c2b0200e6;hpb=d6d9ee4cf6c290d7a5a566b2087b4fae41db6708;p=www-backpacktf.git diff --git a/lib/WWW/BackpackTF.pm b/lib/WWW/BackpackTF.pm index 015d9fa..ad39d73 100644 --- a/lib/WWW/BackpackTF.pm +++ b/lib/WWW/BackpackTF.pm @@ -4,12 +4,13 @@ use 5.014000; use strict; use warnings; use parent qw/Exporter/; -our $VERSION = '0.000_003'; +our $VERSION = '0.001001'; our @EXPORT_OK = qw/TF2 DOTA2/; -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/], }; @@ -23,19 +24,23 @@ BEGIN { } use JSON::MaybeXS qw/decode_json/; -use LWP::Simple qw/get/; +use HTTP::Tiny; use PerlX::Maybe; use WWW::BackpackTF::Currency; use WWW::BackpackTF::Item; use WWW::BackpackTF::User; +my $ht = HTTP::Tiny->new(agent => "WWW-BackpackTF/$VERSION"); + sub request { my ($self, $url, %params) = @_; $params{key} = $self->{key} if $self->{key}; $url = $self->{base} . $url; $url .= "&$_=$params{$_}" for keys %params; - my $response = decode_json(get $url)->{response}; - die $response->{message} unless $response->{success}; + my $htr = $ht->get($url); + die $htr->{reason} unless $htr->{success}; ## no critic (RequireCarping) + my $response = decode_json($htr->{content})->{response}; + die $response->{message} unless $response->{success}; ## no critic (RequireCarping) $response } @@ -67,6 +72,8 @@ sub get_currencies { 1; __END__ +=encoding utf-8 + =head1 NAME WWW::BackpackTF - interface to the backpack.tf trading service @@ -85,7 +92,7 @@ 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 @@ -135,6 +142,10 @@ Constant (440) representing Team Fortress 2. Constant (570) representing Dota 2. +=item B + +Constant (730) representing Counter-Strike: Global Offensive + =item B The Normal item quality (0). @@ -207,7 +218,7 @@ Marius Gavrilescu, Emarius@ieval.roE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2014 by Marius Gavrilescu +Copyright (C) 2014-2016 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,