| WWW-Ebay documentation | Contained in the WWW-Ebay distribution. |
Copyright (C) 2002-present Martin Thurn
All Rights Reserved
WWW::Ebay::Listing - information about an auction listing
use WWW::Ebay::Listing; my $oWEL = new WWW::Ebay::Listing;
Encapsulates a posted / running / completed auction listing at the eBay auction website (www.ebay.com).
The auction ID assigned when the auction was listed.
How many bids this auction received.
The highest bid so far (in cents).
A WWW::Ebay::Status object.
Date & time the auction was listed (epoch seconds format).
Date & time the auction ended (epoch seconds format).
High bidder's ebay ID.
Shipping charge (in cents).
Auction title.
Auction description.
Date the item was shipped (epoch seconds format).
Returns a human-readable summary of this listing.
Returns true if this auction has ended.
Martin 'Kingpin' Thurn, mthurn at cpan.org, http://tinyurl.com/nn67z.
| WWW-Ebay documentation | Contained in the WWW-Ebay distribution. |
# $rcs = ' $Id: Listing.pm,v 1.12 2010-05-08 12:51:44 Martin Exp $ ' ;
package WWW::Ebay::Listing; use strict; use warnings; our $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; use Carp; use WWW::Ebay::Status;
my (@allowed, %allowed); sub new { my $proto = shift; my ($sUserID, $sPassword) = @_; my $class = ref($proto) || $proto; unless ($class) { carp "You can not call new like that"; # Keep going, but don't give the caller what they're expecting: return bless({}, 'FAIL'); } # unless my $self = { '_allowed' => \%allowed, }; bless ($self, $class); $self->status(new WWW::Ebay::Status); $self->dateend(0); return $self; } # new BEGIN {
push @allowed, 'id';
push @allowed, 'bidcount';
push @allowed, 'bidmax';
push @allowed, 'status';
push @allowed, 'datestart';
push @allowed, 'dateend';
push @allowed, 'winnerid';
push @allowed, 'shipping';
push @allowed, 'title';
push @allowed, 'description';
push @allowed, 'dateship'; foreach (@allowed) { $allowed{$_} = 1; } # foreach } # end of BEGIN block sub _elem { my $self = shift; my $elem = shift; my $ret = $self->{$elem}; if (@_) { $self->{$elem} = shift; } # if return $ret; } # _elem sub AUTOLOAD { my $self = shift; # print STDERR " DDD this is ::Listing::AUTOLOAD($AUTOLOAD,@_)\n"; our $AUTOLOAD =~ s/.*:://; $AUTOLOAD = lc $AUTOLOAD; # print STDERR " DDD Listing::AUTOLOAD($AUTOLOAD)\n"; unless (exists $self->{_allowed}->{$AUTOLOAD}) { carp " --- Method '$AUTOLOAD' not allowed on a ", ref $self, " object"; return; } # unless $self->_elem($AUTOLOAD, @_); } # AUTOLOAD
sub as_string { my $self = shift; my $s = ''; foreach my $sKey (@allowed) { if (defined($self->{$sKey}) && ($self->{$sKey} ne '')) { my $sVal = $sKey eq 'status' ? $self->{$sKey}->as_text : $self->{$sKey}; $s .= "$sKey=$sVal; "; } # if } # foreach chop $s; chop $s; return $s; } # as_string # define this so AUTOLOAD does not try to handle it: sub DESTROY { } # DESTROY
sub ended { my $self = shift; return (0 < $self->dateend); } # ended
1; __END__