summaryrefslogtreecommitdiff
path: root/lib/Net/Amazon/Result
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
commitbcbf441e09fb502cf64924ff2530fa144bdf52c5 (patch)
treef377707a2dac078db8cd0c7d7abfe69ac1006d71 /lib/Net/Amazon/Result
downloadxxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.gz
xxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.bz2
* Move files to trunk
Diffstat (limited to 'lib/Net/Amazon/Result')
-rw-r--r--lib/Net/Amazon/Result/Seller.pm130
-rw-r--r--lib/Net/Amazon/Result/Seller/Listing.pm146
2 files changed, 276 insertions, 0 deletions
diff --git a/lib/Net/Amazon/Result/Seller.pm b/lib/Net/Amazon/Result/Seller.pm
new file mode 100644
index 0000000..cb876a6
--- /dev/null
+++ b/lib/Net/Amazon/Result/Seller.pm
@@ -0,0 +1,130 @@
+######################################################################
+package Net::Amazon::Result::Seller;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon);
+
+use Data::Dumper;
+use Log::Log4perl qw(:easy);
+use Net::Amazon::Result::Seller::Listing;
+
+our @DEFAULT_ATTRIBUTES = qw(StoreName SellerNickname
+ NumberOfOpenListings StoreId);
+__PACKAGE__->make_accessor($_) for @DEFAULT_ATTRIBUTES;
+__PACKAGE__->make_array_accessor($_) for qw(listings);
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ if(!$options{xmlref}) {
+ die "Mandatory param xmlref missing";
+ }
+
+ my @listings = ();
+
+ my $self = {
+ %options,
+ };
+
+ bless $self, $class;
+
+ # Set default attributes
+ for my $attr (@DEFAULT_ATTRIBUTES) {
+ DEBUG "Setting attribute $attr to $options{xmlref}->{$attr}";
+ $self->$attr($options{xmlref}->{$attr});
+ }
+
+ for my $listing (@{$options{xmlref}->{ListingProductInfo}->{ListingProductDetails}}) {
+ push @listings,
+ Net::Amazon::Result::Seller::Listing->new(
+ xmlref => $listing);
+ }
+
+ $self->listings(\@listings);
+
+ return $self;
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ my $result = $self->StoreName() .
+ " (" .
+ $self->SellerNickname() .
+ "): " .
+ $self->NumberOfOpenListings() .
+ "";
+
+ return $result;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Amazon::Result::Seller - Class for Seller info
+
+=head1 SYNOPSIS
+
+ use Net::Amazon;
+
+ # ...
+
+ if($resp->is_success()) {
+ print $resp->result()->as_string();
+ }
+
+=head1 DESCRIPTION
+
+C<Net::Amazon::Result::Seller> is a container for results on a seller
+search. It contains data on one particular seller (the one turned up by
+the previous search) and the listings this seller is currently running.
+
+=head2 METHODS
+
+=over 4
+
+=item StoreName()
+
+Name of the seller's store.
+
+=item SellerNickname()
+
+Seller's nickname.
+
+=item StoreId()
+
+ID of seller's store.
+
+=item NumberOfOpenListings()
+
+Number of listings the seller has currently open.
+
+=item listings()
+
+Returns an array of C<Net::Amazon::Result::Seller::Listing> objects.
+See the documentation of this class for details.
+
+=back
+
+=head1 SEE ALSO
+
+=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
diff --git a/lib/Net/Amazon/Result/Seller/Listing.pm b/lib/Net/Amazon/Result/Seller/Listing.pm
new file mode 100644
index 0000000..c09ec08
--- /dev/null
+++ b/lib/Net/Amazon/Result/Seller/Listing.pm
@@ -0,0 +1,146 @@
+######################################################################
+package Net::Amazon::Result::Seller::Listing;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon);
+
+use Data::Dumper;
+use Log::Log4perl qw(:easy);
+
+our @DEFAULT_ATTRIBUTES = qw(
+ ExchangeStartDate ExchangeConditionType
+ ExchangeAsin ExchangeSellerId ExchangeEndDate ExchangePrice
+ ExchangeSellerRating ExchangeStatus ExchangeId ExchangeTitle
+ ExchangeQuantityAllocated ExchangeQuantity ExchangeSellerCountry
+ ExchangeSellerState ExchangeSellerNickname ExchangeFeaturedCategory
+ ExchangeAvailability ExchangeOfferingType ListingId ExchangeCondition
+ ExchangeDescription
+);
+
+__PACKAGE__->make_accessor($_) for @DEFAULT_ATTRIBUTES;
+
+##################################################
+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});
+
+ # Set default attributes
+ for my $attr (@DEFAULT_ATTRIBUTES) {
+ $self->$attr($options{xmlref}->{$attr});
+ }
+
+ 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 ExchangeAsin()
+
+=item ExchangeSellerId()
+
+=item ExchangeEndDate()
+
+=item ExchangePrice()
+
+=item ExchangeSellerRating()
+
+=item ExchangeStatus()
+
+=item ExchangeId()
+
+=item ExchangeTitle()
+
+=item ExchangeQuantityAllocated()
+
+=item ExchangeQuantity()
+
+=item ExchangeSellerCountry()
+
+=item ExchangeSellerState()
+
+=item ExchangeSellerNickname()
+
+=item ExchangeFeaturedCategory()
+
+=item ExchangeAvailability()
+
+=item ExchangeOfferingType()
+
+=item ListingId()
+
+=item ExchangeCondition()
+
+=back
+
+=head1 SEE ALSO
+
+=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