| Net-Amazon documentation | Contained in the Net-Amazon distribution. |
Net::Amazon::Attribute::Review - Customer Review Class
use Net::Amazon::Attribute::Review;
my $rev = Net::Amazon::Attribute::Review->new(
'rating' => $rating,
'summary' => $summary,
'content' => $content,
'asin' => $asin,
'customer_id' => $customer_id,
'date' => $date,
'helpful_votes' => $helpful_votes,
'total_votes' => $total_votes,
);
Net::Amazon::Attribute::Review holds customer reviews.
Accessor for the numeric value of the rating.
Accessor for the string value of the summary.
Accessor for the string value of the content.
Accessor for the string value of ASIN.
Accessor for the string value of the customer ID.
Accessor for the string value of the customer location.
Accessor for the string value of the customer name.
Accessor for the numeric value of the helpful votes.
Accessor for the numeric value of the total votes.
Mike Schilli, <m@perlmeister.com>
Copyright 2003 by Mike Schilli <m@perlmeister.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Net-Amazon documentation | Contained in the Net-Amazon distribution. |
###################################################################### package Net::Amazon::Attribute::Review; ###################################################################### use warnings; use strict; use Log::Log4perl qw(:easy); use base qw(Net::Amazon); __PACKAGE__->make_accessor($_) for qw(date asin rating summary content total_votes helpful_votes customer_id customer_name customer_location); use constant ELEMENT_TO_METHOD_MAP => { # XXX: should ASIN be Asin, ASIN, or asin? 'ASIN' => 'asin', 'Content' => 'content', 'CustomerId' => 'customer_id', 'CustomerLocation' => 'customer_location', 'CustomerName' => 'customer_name', 'Date' => 'date', 'HelpfulVotes' => 'helpful_votes', 'Rating' => 'rating', 'Summary' => 'summary', 'TotalVotes' => 'total_votes', }; ################################################## sub new { ################################################## my($class, %options) = @_; my $self = { rating => "", summary => "", content => "", helpful_votes => "", customer_id => "", customer_name => "", customer_location => "", asin => "", date => "", total_votes => "", %options, }; bless $self, $class; } ################################################## sub init_via_xmlref { ################################################## my($self, $xmlref) = @_; my $href = (ELEMENT_TO_METHOD_MAP); for(keys %$href) { my $method = lc($href->{$_}); if(defined $xmlref->{$_}) { $self->$method($xmlref->{$_}); } } $self->customer_location($xmlref->{Reviewer}{Location}); $self->customer_name($xmlref->{Reviewer}{Name}); } 1; __END__
__END__ <Review> <ASIN>0201360683</ASIN> <Rating>4</Rating> <HelpfulVotes>2</HelpfulVotes> <CustomerId>YYYYYYYXXYYYY</CustomerId> <Reviewer> <CustomerId>YYYYYYYXXYYYY</CustomerId> <Name>John Doe</Name> <Nickname>JD</Nickname> <Location>New York, NY USA</Location> </Reviewer> <TotalVotes>2</TotalVotes> <Date>2000-03-09</Date> <Summary>Wicked Pisser!</Summary> <Content>I found this book to be very good</Content> </Review>