The Perl Auctioneer The Code Slide 17
[PREV] [NEXT]

The Code

The Object

sub new {

my $self = shift;
my $hash = shift;

my $country = $ebay{uc $hash->{country}} if(defined $hash->{country});
$country = $COUNTRY unless($country);

my $atts = {
country => $country,
username => undef; # for bidding
password => undef; # for bidding
response => undef; # response cached here.
content => undef; # formatted response cached here.
};

bless $atts, $self;
return $atts;
}

sub country {
my $self = shift;
@_ ? $self->set_country(@_)
: $self->{country};
}

sub set_country {
my $self = shift;
my $try = lc shift;
foreach (keys %ebay) {
next unless($_ eq $try);
$self->{country} = $_;
return;
}
}

sub search {
my $self = shift;
return unless(@_);

require "WWW/Auction/eBay/$self->{country}.pm";
@ISA = ("WWW::Auction::eBay::$self->{country}");

# do search request
return undef unless($self->search_request(@_));

# format and return
return $self->search_response(wantarray());
}

sub auction {
my $self = shift;
return unless(@_);

require "WWW/Auction/eBay/$self->{country}.pm";
@ISA = ("WWW::Auction::eBay::$self->{country}");

# do auction request
return undef unless($self->auction_request($_[0]));

# format and return
return $self->auction_response($hash); # uses verbose & xml
}

sub user {
my $self = shift;
return unless(@_);

my $hash = shift;
$self->{username} = $hash->{username};
$self->{password} = $hash->{password};
}

sub bid {
my $self = shift;
return unless(@_);

return $self->bid_request(@_);
}

© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/