Net::Amazon::Attribute::Review - Customer Review Class


Net-Amazon documentation Contained in the Net-Amazon distribution.

Index


Code Index:

NAME

Top

Net::Amazon::Attribute::Review - Customer Review Class

SYNOPSIS

Top

    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,
    );

DESCRIPTION

Top

Net::Amazon::Attribute::Review holds customer reviews.

METHODS

rating()

Accessor for the numeric value of the rating.

summary()

Accessor for the string value of the summary.

content()

Accessor for the string value of the content.

asin()

Accessor for the string value of ASIN.

customer_id()

Accessor for the string value of the customer ID.

customer_location()

Accessor for the string value of the customer location.

customer_name()

Accessor for the string value of the customer name.

helpful_votes()

Accessor for the numeric value of the helpful votes.

total_votes()

Accessor for the numeric value of the total votes.

AUTHOR

Top

Mike Schilli, <m@perlmeister.com>

COPYRIGHT AND LICENSE

Top


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>