version 1.14, 2010/06/30 19:45:42 |
version 1.16, 2010/07/09 23:04:21 |
|
|
package Net::OpenAMD; |
package Net::OpenAMD; |
|
|
# $AFresh1: OpenAMD.pm,v 1.13 2010/06/30 05:30:17 andrew Exp $ |
# $AFresh1: OpenAMD.pm,v 1.15 2010/06/30 19:02:48 andrew Exp $ |
|
|
use warnings; |
use warnings; |
use strict; |
use strict; |
|
|
{ |
{ |
|
|
my @attr_refs |
my @attr_refs |
= \( my %base_uri_of, my %ua_of, my %auth_of, my %helpers_of ); |
= \( my %base_uri_of, my %ua_of, my %auth_of, my %actions_of ); |
|
|
sub new { |
sub new { |
my ( $class, $options ) = @_; |
my ( $class, $options ) = @_; |
|
|
|
|
$base_uri_of{$ident} = $options->{base_uri} || $BASE_URI; |
$base_uri_of{$ident} = $options->{base_uri} || $BASE_URI; |
$ua_of{$ident} = $options->{ua} || LWP::UserAgent->new(); |
$ua_of{$ident} = $options->{ua} || LWP::UserAgent->new(); |
$helpers_of{$ident} = $options->{helpers} |
$actions_of{$ident} = $options->{actions} |
|| [qw( location speakers talks interests users )]; |
|| [qw( location speakers talks interests users )]; |
|
|
foreach my $helper ( @{ $helpers_of{$ident} } ) { |
foreach my $action ( @{ $actions_of{$ident} } ) { |
## no critic |
## no critic |
no strict 'refs'; |
no strict 'refs'; |
*{$helper} = sub { shift->get( $helper, @_ ) }; |
*{$action} = sub { shift->get( $action, @_ ) }; |
} |
} |
|
|
# XXX Authenticate |
# XXX Authenticate |
|
|
A URL to the API, currently defaults to https://api.hope.net/api/ |
A URL to the API, currently defaults to https://api.hope.net/api/ |
|
|
Most likely it should end with a / to make URI happy, so notice that if you |
Most likely it should end with a / to make URI happy, so notice that if you |
having 404 errors you don't expect. |
are having 404 errors you don't expect. |
|
|
=item ua |
=item ua |
|
|
|
|
|
|
=back |
=back |
|
|
Unless specified, there is nothing different about any of the helper methods |
Unless specified, there is nothing different about any of the action methods |
than just calling get($action) instead. Depending on API changes, this may |
than just calling get($action) instead. Depending on API changes, this may |
not always be the case. |
not always be the case. |
|
|