version 1.7, 2010/06/27 04:11:22 |
version 1.8, 2010/06/27 04:23:27 |
|
|
package Net::OpenAMD; |
package Net::OpenAMD; |
|
|
# $AFresh1: OpenAMD.pm,v 1.6 2010/06/27 00:52:33 andrew Exp $ |
# $AFresh1: OpenAMD.pm,v 1.7 2010/06/27 03:11:22 andrew Exp $ |
|
|
use warnings; |
use warnings; |
use strict; |
use strict; |
|
|
|
|
my $BASE_URL = 'https://api.hope.net/api/'; |
my $BASE_URL = 'https://api.hope.net/api/'; |
|
|
use Class::Std::Utils; |
use Scalar::Util qw( refaddr ); |
|
*_ident = \&refaddr; |
|
|
use LWP::UserAgent; |
use LWP::UserAgent; |
use URI; |
use URI; |
|
|
|
|
sub new { |
sub new { |
my ( $class, $options ) = @_; |
my ( $class, $options ) = @_; |
my $self = bless anon_scalar(), $class; |
my $self = bless do { \my $x }, $class; |
my $ident = ident($self); |
my $ident = _ident($self); |
|
|
$options //= {}; |
$options //= {}; |
|
|
|
|
|
|
sub get { |
sub get { |
my ( $self, $action, $query ) = @_; |
my ( $self, $action, $query ) = @_; |
my $ident = ident($self); |
my $ident = _ident($self); |
|
|
my $uri = URI->new( $base_url_of{$ident} . '/' . $action ); |
my $uri = URI->new( $base_url_of{$ident} . '/' . $action ); |
$uri->query($query); |
$uri->query($query); |
|
|
|
|
sub DESTROY { |
sub DESTROY { |
my ($self) = @_; |
my ($self) = @_; |
my $ident = ident $self; |
my $ident = _ident $self; |
|
|
foreach my $attr_ref (@attr_refs) { |
foreach my $attr_ref (@attr_refs) { |
delete $attr_ref->{$ident}; |
delete $attr_ref->{$ident}; |
|
|
|
|
1; # Magic true value required at end of module |
1; # Magic true value required at end of module |
__END__ |
__END__ |
|
|
=head1 NAME |
=head1 NAME |
|
|
Net::OpenAMD - Perl interface to the OpenAMD API |
Net::OpenAMD - Perl interface to the OpenAMD API |