summaryrefslogtreecommitdiff
path: root/lib/Net/Amazon/Response
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/Response
downloadxxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.gz
xxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.bz2
* Move files to trunk
Diffstat (limited to 'lib/Net/Amazon/Response')
-rw-r--r--lib/Net/Amazon/Response/ASIN.pm28
-rw-r--r--lib/Net/Amazon/Response/Artist.pm29
-rw-r--r--lib/Net/Amazon/Response/Blended.pm73
-rw-r--r--lib/Net/Amazon/Response/BrowseNode.pm29
-rw-r--r--lib/Net/Amazon/Response/Exchange.pm81
-rw-r--r--lib/Net/Amazon/Response/Keyword.pm29
-rw-r--r--lib/Net/Amazon/Response/Manufacturer.pm29
-rw-r--r--lib/Net/Amazon/Response/Power.pm28
-rw-r--r--lib/Net/Amazon/Response/Seller.pm78
-rw-r--r--lib/Net/Amazon/Response/Similar.pm28
-rw-r--r--lib/Net/Amazon/Response/TextStream.pm28
-rw-r--r--lib/Net/Amazon/Response/UPC.pm40
-rw-r--r--lib/Net/Amazon/Response/Wishlist.pm29
13 files changed, 529 insertions, 0 deletions
diff --git a/lib/Net/Amazon/Response/ASIN.pm b/lib/Net/Amazon/Response/ASIN.pm
new file mode 100644
index 0000000..32bad76
--- /dev/null
+++ b/lib/Net/Amazon/Response/ASIN.pm
@@ -0,0 +1,28 @@
+######################################################################
+package Net::Amazon::Response::ASIN;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Artist.pm b/lib/Net/Amazon/Response/Artist.pm
new file mode 100644
index 0000000..0ee653b
--- /dev/null
+++ b/lib/Net/Amazon/Response/Artist.pm
@@ -0,0 +1,29 @@
+######################################################################
+package Net::Amazon::Response::Artist;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Data::Dumper;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Blended.pm b/lib/Net/Amazon/Response/Blended.pm
new file mode 100644
index 0000000..3c75ded
--- /dev/null
+++ b/lib/Net/Amazon/Response/Blended.pm
@@ -0,0 +1,73 @@
+######################################################################
+package Net::Amazon::Response::Blended;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use XML::Simple;
+
+our @FORCE_ARRAY_FIELDS = qw(ProductLine);
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+##################################################
+sub xmlref_add {
+##################################################
+ my($self, $xmlref) = @_;
+
+ my $nof_items_added = 0;
+
+ unless(ref($self->{xmlref}) eq "HASH" &&
+ ref($self->{xmlref}->{Details}) eq "ARRAY") {
+ $self->{xmlref}->{Details} = [];
+ }
+
+ if ($xmlref->{ProductLine} && (ref($xmlref->{ProductLine}) eq "ARRAY")) {
+ my @lines = @{$xmlref->{ProductLine}}; # Copy the lines
+ # sort the copies by relevance
+ @lines = sort { $a->{RelevanceRank} <=> $b->{RelevanceRank} } @lines;
+
+ foreach (@lines) {
+ next unless $_->{ProductInfo}->{Details};
+ my $details = $_->{ProductInfo}->{Details};
+ if (ref($details) eq "ARRAY") {
+ push @{$self->{xmlref}->{Details}}, @$details;
+ $nof_items_added += scalar @$details;
+ } else {
+ push @{$self->{xmlref}->{Details}}, $details;
+ $nof_items_added++;
+ }
+ }
+ }
+
+ return $nof_items_added;
+}
+
+##################################################
+sub xml_parse {
+##################################################
+ my($self, $xml) = @_;
+
+ my $xs = XML::Simple->new();
+ return $xs->XMLin($xml, ForceArray => [ @FORCE_ARRAY_FIELDS ]);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/BrowseNode.pm b/lib/Net/Amazon/Response/BrowseNode.pm
new file mode 100644
index 0000000..8f40a63
--- /dev/null
+++ b/lib/Net/Amazon/Response/BrowseNode.pm
@@ -0,0 +1,29 @@
+######################################################################
+package Net::Amazon::Response::BrowseNode;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Data::Dumper;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Exchange.pm b/lib/Net/Amazon/Response/Exchange.pm
new file mode 100644
index 0000000..56852fe
--- /dev/null
+++ b/lib/Net/Amazon/Response/Exchange.pm
@@ -0,0 +1,81 @@
+######################################################################
+package Net::Amazon::Response::Exchange;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Net::Amazon::Result::Seller::Listing;
+use Log::Log4perl qw(:easy);
+
+__PACKAGE__->make_array_accessor($_) for qw(listings);
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub result {
+##################################################
+ my($self) = @_;
+
+ if($self->is_success()) {
+ return Net::Amazon::Result::Seller::Listing->new(
+ xmlref => $self->{xmlref}->{ListingProductDetails}->[0],
+ );
+ }
+
+ return undef;
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return "TODO: as_string not defined yet in ", __PACKAGE__;
+}
+
+##################################################
+sub xmlref_add {
+##################################################
+ my($self, $xmlref) = @_;
+
+ my $nof_items_added = 0;
+
+ unless(ref($self->{xmlref}) eq "HASH" &&
+ ref($self->{xmlref}->{ListingProductDetails}) eq "ARRAY") {
+ $self->{xmlref}->{Details} = [];
+ }
+
+ if(ref($xmlref->{ListingProductDetails}) eq "ARRAY") {
+ # Is it an array of items?
+ push @{$self->{xmlref}->{ListingProductDetails}},
+ @{$xmlref->{ListingProductDetails}};
+ $nof_items_added = scalar @{$xmlref->{ListingProductDetails}};
+ } else {
+ # It is a single item
+ push @{$self->{xmlref}->{ListingProductDetails}},
+ $xmlref->{ListingProductDetails};
+ $nof_items_added = 1;
+ }
+
+ return $nof_items_added;
+}
+
+##################################################
+sub properties {
+##################################################
+ my($self) = @_;
+
+ die "properties() not defined in ", __PACKAGE__, ". Use result() instead";
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Keyword.pm b/lib/Net/Amazon/Response/Keyword.pm
new file mode 100644
index 0000000..f6277d6
--- /dev/null
+++ b/lib/Net/Amazon/Response/Keyword.pm
@@ -0,0 +1,29 @@
+######################################################################
+package Net::Amazon::Response::Keyword;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Data::Dumper;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Manufacturer.pm b/lib/Net/Amazon/Response/Manufacturer.pm
new file mode 100644
index 0000000..97ceebf
--- /dev/null
+++ b/lib/Net/Amazon/Response/Manufacturer.pm
@@ -0,0 +1,29 @@
+######################################################################
+package Net::Amazon::Response::Manufacturer;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Data::Dumper;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Power.pm b/lib/Net/Amazon/Response/Power.pm
new file mode 100644
index 0000000..88cdd2d
--- /dev/null
+++ b/lib/Net/Amazon/Response/Power.pm
@@ -0,0 +1,28 @@
+######################################################################
+package Net::Amazon::Response::Power;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Seller.pm b/lib/Net/Amazon/Response/Seller.pm
new file mode 100644
index 0000000..f33ed50
--- /dev/null
+++ b/lib/Net/Amazon/Response/Seller.pm
@@ -0,0 +1,78 @@
+#############################################
+package Net::Amazon::Response::Seller;
+#############################################
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Result::Seller;
+use Data::Dumper;
+use Log::Log4perl qw(:easy);
+
+##############################
+sub new {
+##############################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub result {
+##################################################
+ my($self) = @_;
+
+ if($self->is_success()) {
+ DEBUG "Calling Seller constructor with ", Dumper($self);
+ return Net::Amazon::Result::Seller->new(
+ xmlref => $self->{xmlref}->{SellerSearchDetails}->[0],
+ );
+ }
+
+ return undef;
+}
+
+##################################################
+sub properties {
+##################################################
+ my($self) = @_;
+
+ die "properties() not defined in ", __PACKAGE__, ". Use result() instead";
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->result()->as_string();
+}
+
+##################################################
+sub xmlref_add {
+##################################################
+ my($self, $xmlref) = @_;
+
+ my $nof_items_added = 0;
+
+ unless(ref($self->{xmlref}) eq "HASH" &&
+ ref($self->{xmlref}->{SellerSearchDetails}) eq "ARRAY") {
+ $self->{xmlref}->{Details} = [];
+ }
+
+ if(ref($xmlref->{SellerSearchDetails}) eq "ARRAY") {
+ # Is it an array of items?
+ push @{$self->{xmlref}->{SellerSearchDetails}},
+ @{$xmlref->{SellerSearchDetails}};
+ $nof_items_added = scalar @{$xmlref->{SellerSearchDetails}};
+ } else {
+ # It is a single item
+ push @{$self->{xmlref}->{SellerSearchDetails}},
+ $xmlref->{SellerSearchDetails};
+ $nof_items_added = 1;
+ }
+
+ #DEBUG("xmlref_add (after):", Data::Dumper::Dumper($self));
+ return $nof_items_added;
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Similar.pm b/lib/Net/Amazon/Response/Similar.pm
new file mode 100644
index 0000000..27add88
--- /dev/null
+++ b/lib/Net/Amazon/Response/Similar.pm
@@ -0,0 +1,28 @@
+######################################################################
+package Net::Amazon::Response::Similar;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/TextStream.pm b/lib/Net/Amazon/Response/TextStream.pm
new file mode 100644
index 0000000..0cee872
--- /dev/null
+++ b/lib/Net/Amazon/Response/TextStream.pm
@@ -0,0 +1,28 @@
+######################################################################
+package Net::Amazon::Response::TextStream;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/UPC.pm b/lib/Net/Amazon/Response/UPC.pm
new file mode 100644
index 0000000..4fba4ad
--- /dev/null
+++ b/lib/Net/Amazon/Response/UPC.pm
@@ -0,0 +1,40 @@
+######################################################################
+package Net::Amazon::Response::UPC;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ my($property) = $self->properties;
+ return $property->as_string();
+}
+
+##################################################
+sub properties {
+##################################################
+ my($self) = @_;
+
+ my $property = Net::Amazon::Property::factory(
+ xmlref => $self->{xmlref}->{Details}->[0]);
+
+ return ($property);
+}
+
+1;
diff --git a/lib/Net/Amazon/Response/Wishlist.pm b/lib/Net/Amazon/Response/Wishlist.pm
new file mode 100644
index 0000000..15fd999
--- /dev/null
+++ b/lib/Net/Amazon/Response/Wishlist.pm
@@ -0,0 +1,29 @@
+######################################################################
+package Net::Amazon::Response::Wishlist;
+######################################################################
+use warnings;
+use strict;
+use base qw(Net::Amazon::Response);
+
+use Net::Amazon::Property;
+use Data::Dumper;
+
+##################################################
+sub new {
+##################################################
+ my($class, %options) = @_;
+
+ my $self = $class->SUPER::new(%options);
+
+ bless $self, $class; # reconsecrate
+}
+
+##################################################
+sub as_string {
+##################################################
+ my($self) = @_;
+
+ return $self->SUPER::list_as_string($self->properties);
+}
+
+1;