| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | # $rcs = ' $Id: Listing.pm,v 1.12 2010-05-08 12:51:44 Martin Exp $ ' ; | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | Copyright (C) 2002-present Martin Thurn | 
| 7 |  |  |  |  |  |  | All Rights Reserved | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 NAME | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | WWW::Ebay::Listing - information about an auction listing | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | use WWW::Ebay::Listing; | 
| 16 |  |  |  |  |  |  | my $oWEL = new WWW::Ebay::Listing; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | Encapsulates a posted / running / completed auction listing at the | 
| 21 |  |  |  |  |  |  | eBay auction website (www.ebay.com). | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =cut | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | package WWW::Ebay::Listing; | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 4 |  |  | 4 |  | 16504 | use strict; | 
|  | 4 |  |  |  |  | 4 |  | 
|  | 4 |  |  |  |  | 86 |  | 
| 28 | 4 |  |  | 4 |  | 13 | use warnings; | 
|  | 4 |  |  |  |  | 4 |  | 
|  | 4 |  |  |  |  | 225 |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | our | 
| 31 |  |  |  |  |  |  | $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 4 |  |  | 4 |  | 14 | use Carp; | 
|  | 4 |  |  |  |  | 4 |  | 
|  | 4 |  |  |  |  | 179 |  | 
| 34 | 4 |  |  | 4 |  | 974 | use WWW::Ebay::Status; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 625 |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =head1 METHODS | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =over | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =item new | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =cut | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | my (@allowed, %allowed); | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub new | 
| 47 |  |  |  |  |  |  | { | 
| 48 | 4 |  |  | 4 | 1 | 716 | my $proto = shift; | 
| 49 | 4 |  |  |  |  | 5 | my ($sUserID, $sPassword) = @_; | 
| 50 | 4 |  | 100 |  |  | 16 | my $class = ref($proto) || $proto; | 
| 51 | 4 | 100 |  |  |  | 7 | unless ($class) | 
| 52 |  |  |  |  |  |  | { | 
| 53 | 1 |  |  |  |  | 75 | carp "You can not call new like that"; | 
| 54 |  |  |  |  |  |  | # Keep going, but don't give the caller what they're expecting: | 
| 55 | 1 |  |  |  |  | 16 | return bless({}, 'FAIL'); | 
| 56 |  |  |  |  |  |  | } # unless | 
| 57 | 3 |  |  |  |  | 11 | my $self = { | 
| 58 |  |  |  |  |  |  | '_allowed' => \%allowed, | 
| 59 |  |  |  |  |  |  | }; | 
| 60 | 3 |  |  |  |  | 3 | bless ($self, $class); | 
| 61 | 3 |  |  |  |  | 14 | $self->status(new WWW::Ebay::Status); | 
| 62 | 3 |  |  |  |  | 9 | $self->dateend(0); | 
| 63 | 3 |  |  |  |  | 5 | return $self; | 
| 64 |  |  |  |  |  |  | } # new | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | BEGIN | 
| 67 |  |  |  |  |  |  | { | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =item id | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | The auction ID assigned when the auction was listed. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =cut | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 4 |  |  | 4 |  | 8 | push @allowed, 'id'; | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =item bidcount | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | How many bids this auction received. | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =cut | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 4 |  |  |  |  | 4 | push @allowed, 'bidcount'; | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =item bidmax | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | The highest bid so far (in cents). | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =cut | 
| 90 |  |  |  |  |  |  |  | 
| 91 | 4 |  |  |  |  | 4 | push @allowed, 'bidmax'; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =item status | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | A WWW::Ebay::Status object. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =cut | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 4 |  |  |  |  | 7 | push @allowed, 'status'; | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | =item datestart | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | Date & time the auction was listed (epoch seconds format). | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =cut | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 4 |  |  |  |  | 4 | push @allowed, 'datestart'; | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =item dateend | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | Date & time the auction ended (epoch seconds format). | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =cut | 
| 114 |  |  |  |  |  |  |  | 
| 115 | 4 |  |  |  |  | 5 | push @allowed, 'dateend'; | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | =item winnerid | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | High bidder's ebay ID. | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =cut | 
| 122 |  |  |  |  |  |  |  | 
| 123 | 4 |  |  |  |  | 4 | push @allowed, 'winnerid'; | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =item shipping | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | Shipping charge (in cents). | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =cut | 
| 130 |  |  |  |  |  |  |  | 
| 131 | 4 |  |  |  |  | 4 | push @allowed, 'shipping'; | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =item title | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | Auction title. | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =cut | 
| 138 |  |  |  |  |  |  |  | 
| 139 | 4 |  |  |  |  | 6 | push @allowed, 'title'; | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =item description | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | Auction description. | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | =cut | 
| 146 |  |  |  |  |  |  |  | 
| 147 | 4 |  |  |  |  | 4 | push @allowed, 'description'; | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =item dateship | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | Date the item was shipped (epoch seconds format). | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =cut | 
| 154 |  |  |  |  |  |  |  | 
| 155 | 4 |  |  |  |  | 9 | push @allowed, 'dateship'; | 
| 156 | 4 |  |  |  |  | 7 | foreach (@allowed) | 
| 157 |  |  |  |  |  |  | { | 
| 158 | 44 |  |  |  |  | 1045 | $allowed{$_} = 1; | 
| 159 |  |  |  |  |  |  | } # foreach | 
| 160 |  |  |  |  |  |  | } # end of BEGIN block | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | sub _elem | 
| 163 |  |  |  |  |  |  | { | 
| 164 | 29 |  |  | 29 |  | 19 | my $self = shift; | 
| 165 | 29 |  |  |  |  | 24 | my $elem = shift; | 
| 166 | 29 |  |  |  |  | 26 | my $ret = $self->{$elem}; | 
| 167 | 29 | 100 |  |  |  | 45 | if (@_) | 
| 168 |  |  |  |  |  |  | { | 
| 169 | 17 |  |  |  |  | 20 | $self->{$elem} = shift; | 
| 170 |  |  |  |  |  |  | } # if | 
| 171 | 29 |  |  |  |  | 71 | return $ret; | 
| 172 |  |  |  |  |  |  | } # _elem | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | sub AUTOLOAD | 
| 176 |  |  |  |  |  |  | { | 
| 177 | 30 |  |  | 30 |  | 66936 | my $self = shift; | 
| 178 |  |  |  |  |  |  | # print STDERR " DDD this is ::Listing::AUTOLOAD($AUTOLOAD,@_)\n"; | 
| 179 | 30 |  |  |  |  | 86 | our $AUTOLOAD =~ s/.*:://; | 
| 180 | 30 |  |  |  |  | 34 | $AUTOLOAD = lc $AUTOLOAD; | 
| 181 |  |  |  |  |  |  | # print STDERR " DDD   Listing::AUTOLOAD($AUTOLOAD)\n"; | 
| 182 | 30 | 100 |  |  |  | 61 | unless (exists $self->{_allowed}->{$AUTOLOAD}) | 
| 183 |  |  |  |  |  |  | { | 
| 184 | 1 |  |  |  |  | 146 | carp " --- Method '$AUTOLOAD' not allowed on a ", ref $self, " object"; | 
| 185 | 1 |  |  |  |  | 39 | return; | 
| 186 |  |  |  |  |  |  | } # unless | 
| 187 | 29 |  |  |  |  | 47 | $self->_elem($AUTOLOAD, @_); | 
| 188 |  |  |  |  |  |  | } # AUTOLOAD | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | =item as_string | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | Returns a human-readable summary of this listing. | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | =cut | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | sub as_string | 
| 197 |  |  |  |  |  |  | { | 
| 198 | 0 |  |  | 0 | 1 | 0 | my $self = shift; | 
| 199 | 0 |  |  |  |  | 0 | my $s = ''; | 
| 200 | 0 |  |  |  |  | 0 | foreach my $sKey (@allowed) | 
| 201 |  |  |  |  |  |  | { | 
| 202 | 0 | 0 | 0 |  |  | 0 | if (defined($self->{$sKey}) && ($self->{$sKey} ne '')) | 
| 203 |  |  |  |  |  |  | { | 
| 204 | 0 | 0 |  |  |  | 0 | my $sVal = $sKey eq 'status' ? $self->{$sKey}->as_text : $self->{$sKey}; | 
| 205 | 0 |  |  |  |  | 0 | $s .= "$sKey=$sVal; "; | 
| 206 |  |  |  |  |  |  | } # if | 
| 207 |  |  |  |  |  |  | } # foreach | 
| 208 | 0 |  |  |  |  | 0 | chop $s; | 
| 209 | 0 |  |  |  |  | 0 | chop $s; | 
| 210 | 0 |  |  |  |  | 0 | return $s; | 
| 211 |  |  |  |  |  |  | } # as_string | 
| 212 |  |  |  |  |  |  |  | 
| 213 |  |  |  |  |  |  | # define this so AUTOLOAD does not try to handle it: | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  | sub DESTROY | 
| 216 |  |  |  | 0 |  |  | { | 
| 217 |  |  |  |  |  |  | } # DESTROY | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | =item ended | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | Returns true if this auction has ended. | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | =cut | 
| 225 |  |  |  |  |  |  |  | 
| 226 |  |  |  |  |  |  | sub ended | 
| 227 |  |  |  |  |  |  | { | 
| 228 | 1 |  |  | 1 | 1 | 1 | my $self = shift; | 
| 229 | 1 |  |  |  |  | 6 | return (0 < $self->dateend); | 
| 230 |  |  |  |  |  |  | } # ended | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | =back | 
| 233 |  |  |  |  |  |  |  | 
| 234 |  |  |  |  |  |  | =head1 AUTHOR | 
| 235 |  |  |  |  |  |  |  | 
| 236 |  |  |  |  |  |  | Martin 'Kingpin' Thurn, C, L. | 
| 237 |  |  |  |  |  |  |  | 
| 238 |  |  |  |  |  |  | =cut | 
| 239 |  |  |  |  |  |  |  | 
| 240 |  |  |  |  |  |  | 1; | 
| 241 |  |  |  |  |  |  |  | 
| 242 |  |  |  |  |  |  | __END__ |