File: Listing.pm

package info (click to toggle)
libnet-amazon-perl 0.62-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,400 kB
  • ctags: 2,271
  • sloc: xml: 20,530; perl: 19,997; makefile: 9
file content (161 lines) | stat: -rw-r--r-- 3,839 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
######################################################################
package Net::Amazon::Result::Seller::Listing;
######################################################################
use warnings;
use strict;
use base qw(Net::Amazon);

use Data::Dumper;
use Log::Log4perl qw(:easy);

# Tracking the different functions between AWS3 and AWS4.
# ExchangeConditionType -> ExchangeCondition
# ExchangeSellerRating -> ???
# ExchangeQuantityAllocated  -> ExchangeQuantity
# ExchangeSellerCountry -> ???
# ExchangeSellerState -> ???
# ExchangeFeaturedCategory -> ???
# ExchangeAvailability -> ???
# ExchangeOfferingType -> ??? 
# ??? -> ExchangeSubCondition 
# ExchangeDescription -> ???


our %DEFAULT_ATTRIBUTES_XPATH = (
    ExchangeStartDate    => [qw(StartDate)],
    ExchangeEndDate      => [qw(EndDate)],
    ExchangeAsin         => [qw(ASIN)],
    ExchangeTitle        => [qw(Title)],
    ListingId            => [qw(ListingId)],
    ExchangeId           => [qw(ExchangeId)],
    ExchangeQuantityAllocated => [qw(Quantity)],
    ExchangeQuantity     => [qw(Quantity)],
    ExchangeCondition    => [qw(Condition)],
    ExchangeConditionType=> [qw(SubCondition)],
    ExchangeSubCondition => [qw(SubCondition)],
    ExchangeStatus       => [qw(Status)],
    ExchangePrice        => [qw(Price FormattedPrice)],
    ExchangeCurrencyCode => [qw(Price CurrencyCode)],
    ExchangeAmount       => [qw(Price Amount)],
    ExchangeSellerId     => [qw(Seller SellerId)],
    ExchangeSellerNickname => [qw(Seller Nickname)],
);

__PACKAGE__->make_accessor($_) for keys %DEFAULT_ATTRIBUTES_XPATH;

##################################################
sub new {
##################################################
    my($class, %options) = @_;

    if(!$options{xmlref}) {
        die "Mandatory param xmlref missing";
    }

    my $self = { 
        %options, 
               };

    bless $self, $class;

    DEBUG "Calling Listing with xmlref=", Dumper($options{xmlref});

    for my $attr (keys %DEFAULT_ATTRIBUTES_XPATH) {
        my $value = __PACKAGE__->walk_hash_ref($options{xmlref}, $DEFAULT_ATTRIBUTES_XPATH{$attr});
        $self->$attr($value);
    }

    return $self;
}

##################################################
sub as_string {
##################################################
    my($self) = @_;

    my $result = 
                 $self->ExchangeTitle() .
                 " (" .
                 $self->ExchangeAsin() . 
                 "): " .
                 $self->ExchangePrice() .
                 "";

    return $result;
}

1;

__END__

=head1 NAME

Net::Amazon::Result::Seller::Listing - Class for a single Listing of a Seller

=head1 SYNOPSIS

  for($seller_search_resp->result()->seller()->listings()) {
      print $_->as_string(), "\n";
  }

=head1 DESCRIPTION

C<Net::Amazon::Result::Seller::Listing> is a container for a single listing
owned by a third-party seller, who is represented by a
C<Net::Amazon::Result::Seller> object.

An object of this class is also returned by an C<Exchange> request, using
C<Net::Amazon::Response::Exchange>'s C<result> method.

=head2 METHODS

=over 4

=item ExchangeStartDate()

=item ExchangeConditionType()

=item ExchangeCondition()

=item ExchangeSubCondition()

=item ExchangeAsin()

=item ExchangeSellerId()

=item ExchangeEndDate()

=item ExchangePrice()

=item ExchangeAmount()

=item ExchangeCurrencyCode()

=item ExchangeStatus()

=item ExchangeId()

=item ExchangeTitle()

=item ExchangeQuantityAllocated()

=item ExchangeQuantity()

=item ExchangeSellerNickname()

=item ListingId()

=back

=head1 AUTHOR

Mike Schilli, E<lt>m@perlmeister.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2004 by Mike Schilli E<lt>m@perlmeister.comE<gt>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. 

=cut