1######################################################################
2package Net::Amazon::Attribute::Review;
3######################################################################
4use warnings;
5use strict;
6use Log::Log4perl qw(:easy);
7use base qw(Net::Amazon);
8
9__PACKAGE__->make_accessor($_) for qw(date asin rating summary content
10                                      total_votes helpful_votes customer_id
11				      customer_name customer_location);
12
13use constant ELEMENT_TO_METHOD_MAP => {
14    # XXX: should ASIN be Asin, ASIN, or asin?
15    'ASIN'         => 'asin',
16    'Content'      => 'content',
17    'CustomerId'   => 'customer_id',
18    'CustomerLocation' => 'customer_location',
19    'CustomerName' => 'customer_name',
20    'Date'         => 'date',
21    'HelpfulVotes' => 'helpful_votes',
22    'Rating'       => 'rating',
23    'Summary'      => 'summary',
24    'TotalVotes'   => 'total_votes',
25};
26
27##################################################
28sub new {
29##################################################
30    my($class, %options) = @_;
31
32    my $self = {
33        rating  => "",
34        summary => "",
35        content => "",
36        helpful_votes => "",
37        customer_id => "",
38        customer_name => "",
39        customer_location => "",
40        asin => "",
41        date => "",
42        total_votes => "",
43        %options,
44    };
45
46    bless $self, $class;
47}
48
49##################################################
50sub init_via_xmlref {
51##################################################
52    my($self, $xmlref) = @_;
53
54    my $href = (ELEMENT_TO_METHOD_MAP);
55
56    for(keys %$href) {
57        my $method = lc($href->{$_});
58        if(defined $xmlref->{$_}) {
59            $self->$method($xmlref->{$_});
60        }
61    }
62
63    $self->customer_location($xmlref->{Reviewer}{Location});
64    $self->customer_name($xmlref->{Reviewer}{Name});
65}
66
671;
68
69__END__
70
71=head1 NAME
72
73Net::Amazon::Attribute::Review - Customer Review Class
74
75=head1 SYNOPSIS
76
77    use Net::Amazon::Attribute::Review;
78    my $rev = Net::Amazon::Attribute::Review->new(
79                 'rating'        => $rating,
80                 'summary'       => $summary,
81                 'content'       => $content,
82                 'asin'          => $asin,
83                 'customer_id'   => $customer_id,
84                 'date'          => $date,
85                 'helpful_votes' => $helpful_votes,
86                 'total_votes'   => $total_votes,
87    );
88
89=head1 DESCRIPTION
90
91C<Net::Amazon::Attribute::Review> holds customer reviews.
92
93=head2 METHODS
94
95=over 4
96
97=item rating()
98
99Accessor for the numeric value of the rating.
100
101=item summary()
102
103Accessor for the string value of the summary.
104
105=item content()
106
107Accessor for the string value of the content.
108
109=item asin()
110
111Accessor for the string value of ASIN.
112
113=item customer_id()
114
115Accessor for the string value of the customer ID.
116
117=item customer_location()
118
119Accessor for the string value of the customer location.
120
121=item customer_name()
122
123Accessor for the string value of the customer name.
124
125=item helpful_votes()
126
127Accessor for the numeric value of the helpful votes.
128
129=item total_votes()
130
131Accessor for the numeric value of the total votes.
132
133=back
134
135=head1 AUTHOR
136
137Mike Schilli, E<lt>m@perlmeister.comE<gt>
138
139=head1 COPYRIGHT AND LICENSE
140
141Copyright 2003 by Mike Schilli E<lt>m@perlmeister.comE<gt>
142
143This library is free software; you can redistribute it and/or modify
144it under the same terms as Perl itself.
145
146=cut
147
148__END__
149<Review>
150  <ASIN>0201360683</ASIN>
151  <Rating>4</Rating>
152  <HelpfulVotes>2</HelpfulVotes>
153  <CustomerId>YYYYYYYXXYYYY</CustomerId>
154  <Reviewer>
155    <CustomerId>YYYYYYYXXYYYY</CustomerId>
156    <Name>John Doe</Name>
157    <Nickname>JD</Nickname>
158    <Location>New York, NY USA</Location>
159  </Reviewer>
160  <TotalVotes>2</TotalVotes>
161  <Date>2000-03-09</Date>
162  <Summary>Wicked Pisser!</Summary>
163  <Content>I found this book to be very good</Content>
164</Review>
165