WWW::Ebay::Listing - information about an auction listing


WWW-Ebay documentation Contained in the WWW-Ebay distribution.

Index


Code Index:

COPYRIGHT

Top

NAME

Top

WWW::Ebay::Listing - information about an auction listing

SYNOPSIS

Top

  use WWW::Ebay::Listing;
  my $oWEL = new WWW::Ebay::Listing;

DESCRIPTION

Top

Encapsulates a posted / running / completed auction listing at the eBay auction website (www.ebay.com).

METHODS

Top

new
id

The auction ID assigned when the auction was listed.

bidcount

How many bids this auction received.

bidmax

The highest bid so far (in cents).

status

A WWW::Ebay::Status object.

datestart

Date & time the auction was listed (epoch seconds format).

dateend

Date & time the auction ended (epoch seconds format).

winnerid

High bidder's ebay ID.

shipping

Shipping charge (in cents).

title

Auction title.

description

Auction description.

dateship

Date the item was shipped (epoch seconds format).

as_string

Returns a human-readable summary of this listing.

ended

Returns true if this auction has ended.

AUTHOR

Top

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__