1########################################### 2# Tests for Exchange requests 3# Mike Schilli, 2004 (m@perlmeister.com) 4########################################### 5use warnings; 6use strict; 7 8use Test::More tests => 17; 9use Net::Amazon; 10use Net::Amazon::Result::Seller::Listing; 11use Log::Log4perl qw(:easy); 12#Log::Log4perl->easy_init($DEBUG); 13 14################################################################ 15# Setup 16################################################################ 17 my($TESTDIR) = map { -d $_ ? $_ : () } qw(t ../t .); 18 require "$TESTDIR/init.pl"; 19 my $CANNED = "$TESTDIR/canned"; 20################################################################ 21 canned($CANNED, "exchange.xml"); 22################################################################ 23 24my $ua = Net::Amazon->new( 25 associate_tag => 'YOUR_AMZN_ASSOCIATE_TAG', 26 token => 'YOUR_AMZN_TOKEN', 27 secret_key => 'YOUR_AMZN_SECRET_KEY', 28 #response_dump => 1, 29); 30 31# Get a request object 32my $resp = $ua->search(exchange => 'Y04Y3424291Y2398445'); 33 34ok($resp->is_success(), "Successful response"); 35ok(defined $resp->result(), "Defined seller result"); 36 37like($resp->result()->as_string(), qr/^Setting the Mould.*?\(0393023826\)/, 38 "Exchange result as string"); 39 40my $listing = $resp->result(); 41 42is($listing->ExchangeStartDate(), "2003-12-20", 43 "Listing Exchange Start Date"); 44 45is($listing->ExchangeAsin(), "0393023826", 46 "Listing Exchange Asin"); 47 48is($listing->ExchangeConditionType(), "verygood", 49 "Listing ExchangeConditionType"); 50 51is($listing->ExchangeSellerId(), "A23JJ2BNHZMFCO", 52 "Listing ExchangeSellerId"); 53 54is($listing->ExchangeEndDate(), "2006-12-04", 55 "Listing ExchangeEndDate"); 56 57is($listing->ExchangePrice(), '$10.58', 58 "Listing ExchangePrice"); 59 60# These functions require a separate search to get this value, use SellerLookup 61# is($listing->ExchangeSellerRating(), "4.7", 62# "Listing ExchangeSellerRating"); 63# is($listing->ExchangeSellerCountry(), "", 64# "Listing ExchangeSellerCountry"); 65# is($listing->ExchangeSellerState(), "", 66# "Listing ExchangeSellerState"); 67 68# Not sure if these are even available! 69# is($listing->ExchangeFeaturedCategory(), "68297", 70# "Listing ExchangeFeaturedCategory"); 71# is($listing->ExchangeAvailability(), "Usually ships in 1-2 business days", 72# "Listing ExchangeAvailability"); 73# is($listing->ExchangeOfferingType(), "used", 74# "Listing ExchangeOfferingType"); 75# is($listing->ExchangeDescription(), "Title: Bold Visions for the Garden: Basics, Magic & Inspiration\n: Hartlage, Richard W.\n", "Listing ExchangeDescription"); 76 77is($listing->ExchangeStatus(), "Open", 78 "Listing ExchangeStatus"); 79 80is($listing->ExchangeId(), "Y01Y4725136Y4353165", 81 "Listing ExchangeId"); 82 83is($listing->ExchangeTitle(), "Setting the Mould: The United States and Britain 1945-50 by Edmonds, Robin", 84 "Listing ExchangeTitle"); 85 86is($listing->ExchangeQuantityAllocated(), "1", 87 "Listing ExchangeQuantityAllocated"); 88 89is($listing->ExchangeQuantity(), "1", 90 "Listing ExchangeQuantity"); 91 92is($listing->ExchangeSellerNickname(), "brick_road_books", 93 "Listing ExchangeSellerNickname"); 94 95is($listing->ListingId(), "1220R554328", 96 "Listing ListingId"); 97 98is($listing->ExchangeCondition(), "collectible", 99 "Listing ExchangeCondition"); 100