ruby-aaws 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: browse_node_lookup1,v 1.3 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ # This is the node for Social Sciences.
11
+ #
12
+ START_NODE = '11232'
13
+
14
+ def follow_node(id)
15
+
16
+ req ||= Request.new
17
+ req.locale = 'us'
18
+
19
+ bnl = BrowseNodeLookup.new( id, {} )
20
+ bnl_rg ||= ResponseGroup.new( 'BrowseNodeInfo' )
21
+ resp = req.search( bnl, bnl_rg )
22
+
23
+ #items = resp.browse_node_sets.browse_nodes
24
+ nodes = resp.browse_node_lookup_response[0].browse_nodes[0].browse_node
25
+
26
+ nodes.each do |bn|
27
+
28
+ if bn.children
29
+ puts '%s (%s) has the following children:' % [ bn.name, id ]
30
+
31
+ bn.children[0].browse_node.each do |child_node|
32
+ puts ' %s' % [ child_node.name ]
33
+ end
34
+ puts
35
+
36
+ bn.children[0].browse_node.each do |child_node|
37
+ follow_node( child_node.browse_node_id )
38
+ end
39
+
40
+ else
41
+ puts '%s (%s) has no children.' % [ bn.name, id ]
42
+ end
43
+ end
44
+ end
45
+
46
+ follow_node( START_NODE )
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: customer_content_lookup1,v 1.3 2008/04/28 09:59:52 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ ccl = CustomerContentLookup.new( 'AJDWXANG1SYZP' )
11
+ rg = ResponseGroup.new( 'CustomerReviews' )
12
+
13
+ req = Request.new
14
+ req.locale = 'us'
15
+
16
+ resp = req.search( ccl, rg )
17
+
18
+ review = resp.customer_content_lookup_response.customers.customer.customer_reviews.review[0]
19
+
20
+ printf( "Customer's name is %s.\n", review.reviewer.name )
21
+ printf( "Customer's location is %s.\n", review.reviewer.location )
22
+ printf( "Review date is %s.\n", review.date )
23
+ printf( "Review has received %s votes.\n", review.total_votes )
24
+ printf( "Of these, %d deemed the review helpful.\n", review.helpful_votes )
25
+ printf( "Product reviewed has ASIN '%s'.\n", review.asin )
26
+ printf( "Review summary is: %s.\n", review.summary )
27
+ printf( "Review content is:\n%s.\n", review.content )
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: customer_content_search1,v 1.1 2008/04/27 21:58:54 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ ccs = CustomerContentSearch.new( 'ian@caliban.org' )
11
+ rg = ResponseGroup.new( 'CustomerInfo' )
12
+
13
+ req = Request.new
14
+ req.locale = 'us'
15
+
16
+ resp = req.search( ccs, rg )
17
+ cust = resp.customer_content_search_response.customers.customer
18
+
19
+ printf( "Customer's ID is %s.\n", cust.customer_id )
20
+ printf( "Customer's nickname is %s.\n", cust.nickname )
21
+ printf( "Customer's location is %s.\n", cust.location.user_defined_location )
data/example/example1 ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: example1,v 1.4 2008/04/28 10:24:56 ianmacd Exp $
4
+
5
+ require 'amazon/aws'
6
+ require 'amazon/aws/search'
7
+
8
+ # We don't want to have to fully qualify identifiers.
9
+ #
10
+ include Amazon::AWS
11
+ include Amazon::AWS::Search
12
+
13
+ # If you don't have one of these, don't pass the second argument to
14
+ # Request.new.
15
+ #
16
+ ASSOCIATES_ID = "webservices-20"
17
+
18
+ # Your access key ID.
19
+ #
20
+ KEY_ID = "0Y44V8FAFNM119C6PTR2"
21
+
22
+ request = Request.new( KEY_ID, ASSOCIATES_ID )
23
+
24
+ # Create an item search object.
25
+ #
26
+ # is = ItemSearch.new( 'Books', { 'Keywords' => 'ruby programming' } )
27
+ is = ItemSearch.new( 'Books', { 'Title' => 'ruby programming' } )
28
+
29
+ # Create a response group object. Examples of response groups are 'Small',
30
+ # 'Medium' and 'Large'. 'Large' returns all data about an item.
31
+ #
32
+ rg = ResponseGroup.new( 'Large' )
33
+
34
+ # Search for the items, passing the result into a block.
35
+ #
36
+ nr_items = 0
37
+ page_nr = 0
38
+ response = request.search( is, rg, :ALL_PAGES ) do |page|
39
+ # page.item_search_response[0].items.each do |item_set|
40
+ # item_set.item.each do |item|
41
+ # puts 'Found a product:'
42
+ # item.instance_variables.each do |iv|
43
+ # printf( "%s = %s\n", iv, item.instance_variable_get( iv ) )
44
+ # end
45
+ # end
46
+ # end
47
+ printf( "Page %d had unique request ID %s.\n",
48
+ page_nr += 1,
49
+ page.item_search_response[0].operation_request[0].request_id )
50
+ printf( "Page %d contained %d result(s).\n",
51
+ page_nr,
52
+ page.item_search_response[0].items[0].item.size )
53
+ end
54
+
55
+ # You don't have to access the items through a block.
56
+ #
57
+ nr_items = 0
58
+ response.each do |page|
59
+ page.item_search_response[0].items.each do |item_set|
60
+ nr_items += item_set.item.size
61
+ end
62
+ end
63
+ printf( "Search returned %d items.\n", nr_items )
64
+
65
+ # The first item in the list.
66
+ #
67
+ items = response[0].item_search_response[0].items[0].item
68
+ product1 = items[0]
69
+ puts "\nProperties available for the first product returned:",
70
+ product1.properties.sort
71
+ puts
72
+
73
+ # There are three ways to retrieve the property of a product:
74
+ #
75
+
76
+ # Instance variable:
77
+ #
78
+ p product1.asin
79
+ p product1.item_attributes[0].title
80
+
81
+ # Feels more like a Hash:
82
+ #
83
+ p product1.item_attributes[0]['list_price'][0]['formatted_price']
84
+
85
+ # A variation on the hash theme:
86
+ #
87
+ p product1.item_attributes[0][:author]
data/example/help1 ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: help1,v 1.1 2008/04/27 22:21:52 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ h = Help.new( 'ResponseGroup', 'Large' )
11
+
12
+ rg = ResponseGroup.new( 'Help' )
13
+
14
+ req = Request.new
15
+ req.locale = 'uk'
16
+
17
+ resp = req.search( h, rg )
18
+ help = resp.help_response[0].information.response_group_information
19
+
20
+ printf( "The response group 'Large' was created on %s\n", help.creation_date )
21
+ puts 'It can be used with the following operations:'
22
+ puts help.valid_operations.operation.join( ', ' )
23
+ puts
24
+ puts "and causes the following elements to be returned:\n\n"
25
+ puts help.elements.element
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: item_lookup1,v 1.5 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws'
6
+ require 'amazon/aws/search'
7
+
8
+ include Amazon::AWS
9
+ include Amazon::AWS::Search
10
+
11
+ # Example of a batch operation, using the ASIN as the shared ID.
12
+ #
13
+ # The MerchantId restriction is to ensure that we retrieve only items that
14
+ # are for sale by Amazon. This is important when we later want to retrieve the
15
+ # availability status.
16
+ #
17
+ il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
18
+ 'MerchantId' => 'Amazon' },
19
+ { 'ItemId' => 'B000051WBE',
20
+ 'MerchantId' => 'Amazon' } )
21
+
22
+ # You can have multiple response groups.
23
+ #
24
+ rg = ResponseGroup.new( 'Medium', 'Offers', 'Reviews' )
25
+
26
+ req = Request.new
27
+ req.locale = 'uk'
28
+
29
+ resp = req.search( il, rg )
30
+ item_sets = resp.item_lookup_response[0].items
31
+
32
+ item_sets.each do |item_set|
33
+ item_set.item.each do |item|
34
+ attribs = item.item_attributes[0]
35
+ puts attribs.label
36
+ if attribs.list_price
37
+ puts attribs.title, attribs.list_price[0].formatted_price
38
+ end
39
+
40
+ # Availability has become a cumbersome thing to retrieve in AWSv4.
41
+ #
42
+ puts 'Availability: %s' %
43
+ [ item.offers[0].offer[0].offer_listing[0].availability ]
44
+ puts 'Average rating: %s' % [ item.customer_reviews[0].average_rating ]
45
+ puts 'Reviewed by %s customers.' %
46
+ [ item.customer_reviews[0].total_reviews ]
47
+
48
+ puts 'Customers said:'
49
+ item.customer_reviews[0].review.each do |review|
50
+ puts ' %s (%s votes)' % [ review.summary, review.total_votes ]
51
+ end
52
+
53
+ puts
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: item_lookup2,v 1.3 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws'
6
+ require 'amazon/aws/search'
7
+
8
+ include Amazon::AWS
9
+ include Amazon::AWS::Search
10
+
11
+ # Example of a batch operation, using the ASIN as the shared ID.
12
+ #
13
+ # The MerchantId restriction is to ensure that we retrieve only items that
14
+ # are for sale by Amazon. This is important when we later want to retrieve the
15
+ # availability status.
16
+ #
17
+ il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000065RSW',
18
+ 'MerchantId' => 'Amazon' },
19
+ { 'ItemId' => 'B000A1INIU',
20
+ 'MerchantId' => 'Amazon' } )
21
+
22
+ # You can have multiple response groups.
23
+ #
24
+ rg = ResponseGroup.new( 'Medium', 'Offers', 'Reviews' )
25
+
26
+ req = Request.new
27
+ req.locale = 'us'
28
+
29
+ resp = req.search( il, rg )
30
+ item_sets = resp.item_lookup_response[0].items
31
+
32
+ item_sets.each do |item_set|
33
+ item_set.item.each do |item|
34
+ attribs = item.item_attributes[0]
35
+ puts attribs.label
36
+ if attribs.list_price
37
+ puts attribs.title, attribs.list_price[0].formatted_price
38
+ end
39
+
40
+ # Availability has become a cumbersome thing to retrieve in AWSv4.
41
+ #
42
+ puts 'Availability: %s' %
43
+ [ item.offers[0].offer[0].offer_listing[0].availability ]
44
+ puts 'Average rating: %s' % [ item.customer_reviews[0].average_rating ]
45
+ puts 'Reviewed by %s customers.' %
46
+ [ item.customer_reviews[0].total_reviews ]
47
+
48
+ puts 'Customers said:'
49
+ item.customer_reviews[0].review.each do |review|
50
+ puts ' %s (%s votes)' % [ review.summary, review.total_votes ]
51
+ end
52
+
53
+ puts
54
+ end
55
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: item_search1,v 1.4 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
11
+ rg = ResponseGroup.new( 'Large' )
12
+
13
+ req = Request.new
14
+ req.locale = 'uk'
15
+
16
+ resp = req.search( is, rg )
17
+
18
+ items = resp.item_search_response[0].items[0].item
19
+
20
+ # Available properties for first item:
21
+ #
22
+ puts items[0].properties
23
+
24
+ items.each do |item|
25
+ attribs = item.item_attributes[0]
26
+ puts attribs.label
27
+ if attribs.list_price
28
+ puts attribs.title, attribs.list_price[0].formatted_price, ''
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: item_search2,v 1.4 2008/04/28 09:59:39 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ # We can use symbols instead of string.
11
+ #
12
+ is = ItemSearch.new( :Music, { :Artist => 'Stranglers' } )
13
+ rg = ResponseGroup.new( :Medium )
14
+
15
+ req = Request.new
16
+ req.locale = 'uk'
17
+
18
+ resp = req.search( is, rg, :ALL_PAGES )
19
+
20
+ # Use of :ALL_PAGES means an array of responses is returned, one per page.
21
+ #
22
+ items = resp.collect { |r| r.item_search_response[0].items[0].item }.flatten
23
+
24
+ printf( "Search returned %d items.\n", items.size )
25
+
26
+ items.each do |item|
27
+ attribs = item.item_attributes[0]
28
+ puts '%s %s' % [ attribs.title, ( attribs.format ?
29
+ "(#{attribs.format})" : '' ) ]
30
+ puts '%s (%s)' % [ attribs.manufacturer, attribs.binding ]
31
+ puts 'Release date: %s' % [ attribs.release_date ]
32
+ puts attribs.list_price[0].formatted_price if attribs.list_price
33
+ if item.editorial_reviews
34
+ puts item.editorial_reviews[0].editorial_review[0].content
35
+ end
36
+ puts
37
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: item_search3,v 1.3 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ is = ItemSearch.new( 'Baby', { 'Keywords' => 'pants',
11
+ 'MinimumPrice' => '2500',
12
+ 'MaximumPrice' => '4999' } )
13
+ rg = ResponseGroup.new( 'Small' )
14
+
15
+ req = Request.new
16
+ req.locale = 'us'
17
+
18
+ resp = req.search( is, rg )
19
+ items = resp.item_search_response[0].items[0].item
20
+
21
+ printf( "Search returned %d items.\n", items.size )
22
+
23
+ items.each { |item| puts item, '' }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: list_lookup1,v 1.1 2008/04/27 16:36:14 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ ll = ListLookup.new( '3P722DU4KUPCP', 'Listmania' )
11
+ ll_rg = ResponseGroup.new( 'ListInfo', 'Small' )
12
+
13
+ req = Request.new
14
+ req.locale = 'us'
15
+
16
+ resp = req.search( ll, ll_rg )
17
+ list = resp.list_lookup_response[0].lists[0].list
18
+
19
+ puts 'List Title: %s' % [ list.list_name ]
20
+ puts 'List created: %s' % [ list.date_created ]
21
+ puts 'List ID: %s' % [ list.list_id ]
22
+ puts 'URL: %s' % [ list.list_url ]
23
+ puts '%s items on list.' % [ list.total_items ]
24
+ puts
25
+
26
+ list.list_item.each_with_index do |it, idx|
27
+ att = it.item.item_attributes
28
+ printf( "%d. %s (%s)\n", idx + 1, att.title, att.product_group )
29
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: list_search1,v 1.3 2008/04/11 19:24:24 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ person = 'Peter Duff'
11
+
12
+ ls = ListSearch.new( 'WishList', { 'Name' => person } )
13
+ ls_rg = ResponseGroup.new( 'ListInfo' )
14
+
15
+ req = Request.new
16
+ req.locale = 'us'
17
+
18
+ resp = req.search( ls, ls_rg )
19
+ lists = resp.list_search_response[0].lists[0].list
20
+
21
+ puts '%s returns the following lists:' % [ person ]
22
+
23
+ lists.each do |list|
24
+ puts ' %s' % [ list.customer_name ]
25
+ puts ' List created: %s' % [ list.date_created ]
26
+ puts ' List ID: %s' % [ list.list_id ]
27
+ puts ' URL: %s' % [ list.list_url ]
28
+ puts ' %s items on list.' % [ list.total_items ]
29
+ puts
30
+ end
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: multiple_operation1,v 1.1 2008/04/11 15:00:56 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ # Example of a batch operation, using the ASIN as the shared ID.
11
+ #
12
+ # The MerchantId restriction is to ensure that we retrieve only items that
13
+ # are for sale by Amazon. This is important when we later want to retrieve the
14
+ # availability status.
15
+ #
16
+ il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
17
+ 'MerchantId' => 'Amazon' },
18
+ { 'ItemId' => 'B000051WBE',
19
+ 'MerchantId' => 'Amazon' } )
20
+ is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
21
+
22
+ mo = MultipleOperation.new( is, il )
23
+
24
+ # You can have multiple response groups.
25
+ #
26
+ rg = ResponseGroup.new( 'Medium', 'Offers', 'Reviews' )
27
+
28
+ req = Request.new
29
+ req.locale = 'uk'
30
+ resp = req.search( mo, rg )
31
+
32
+ # Items returned by the ItemSearch.
33
+ #
34
+ is_item_sets = resp.multi_operation_response.item_search_response[0].items
35
+
36
+ # Items returned by the ItemLookup.
37
+ #
38
+ il_item_sets = resp.multi_operation_response.item_lookup_response[0].items
39
+
40
+ item_sets = is_item_sets + il_item_sets
41
+
42
+ item_sets.each do |item_set|
43
+ item_set.item.each do |item|
44
+ attribs = item.item_attributes[0]
45
+ puts attribs.label
46
+ if attribs.list_price
47
+ puts attribs.title, attribs.list_price[0].formatted_price
48
+ end
49
+
50
+ # Availability has become a cumbersome thing to retrieve in AWSv4.
51
+ #
52
+ puts 'Availability: %s' %
53
+ [ item.offers[0].offer[0].offer_listing[0].availability ]
54
+
55
+ if item.customer_reviews
56
+ puts 'Average rating: %s' % [ item.customer_reviews[0].average_rating ]
57
+ puts 'Reviewed by %s customers.' %
58
+ [ item.customer_reviews[0].total_reviews ]
59
+ puts 'Customers said:'
60
+ item.customer_reviews[0].review.each do |review|
61
+ puts ' %s (%s votes)' % [ review.summary, review.total_votes ]
62
+ end
63
+ end
64
+
65
+ puts
66
+ end
67
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: seller_listing_lookup1,v 1.1 2008/04/27 10:49:38 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ seller_id = 'AP8U6Y3PYQ9VO'
11
+ artist = 'Killing Joke'
12
+ sll = SellerListingLookup.new( seller_id, 'ASIN',
13
+ { 'Id' => 'B0009RRRC8' } )
14
+ sll_rg = ResponseGroup.new( 'SellerListing' )
15
+
16
+ req = Request.new
17
+ req.locale = 'uk'
18
+
19
+ resp = req.search( sll, sll_rg )
20
+
21
+ # Yawn. This is verbose.
22
+ #
23
+
24
+ seller_id = resp.seller_listing_lookup_response[0].seller_listings[0].
25
+ request[0].seller_listing_lookup_request[0].seller_id
26
+ item = resp.seller_listing_lookup_response[0].seller_listings[0].
27
+ seller_listing[0]
28
+
29
+ puts 'Seller %s is selling the following item by %s:' % [ seller_id, artist ]
30
+ puts item
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: seller_listing_search1,v 1.4 2008/04/28 10:00:28 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ seller_id = 'AP8U6Y3PYQ9VO'
11
+ artist = 'Killing Joke'
12
+ sls = SellerListingSearch.new( seller_id, { 'Keywords' => artist } )
13
+ sls_rg = ResponseGroup.new( 'SellerListing' )
14
+
15
+ req = Request.new
16
+ req.locale = 'uk'
17
+
18
+ resp = req.search( sls, sls_rg )
19
+
20
+ # Yawn. This is verbose.
21
+ #
22
+ seller_id = resp.seller_listing_search_response[0].seller_listings[0].
23
+ request[0].seller_listing_search_request[0].seller_id
24
+ items = resp.seller_listing_search_response[0].seller_listings[0].
25
+ seller_listing
26
+
27
+ puts 'Seller %s is selling the following items by %s:' % [ seller_id, artist ]
28
+ items.each { |item| puts item, '-' * 80 }
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: seller_lookup1,v 1.1 2008/04/27 10:10:07 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+
7
+ include Amazon::AWS
8
+ include Amazon::AWS::Search
9
+
10
+ def display_properties(root, indent=0)
11
+ if root[0].respond_to? :properties
12
+ printf( 'Property %s =', root[0] )
13
+ root[0].properties.each do |pr|
14
+ display_properties( pr, indent + 2 )
15
+ end
16
+ else
17
+ printf( "Property %s = %s.\n", root, root.to_h[root] )
18
+ end
19
+ end
20
+
21
+ sl = SellerLookup.new( 'A3QFR0K2KCB7EG' )
22
+ sl_rg = ResponseGroup.new( 'Seller' )
23
+
24
+ req = Request.new
25
+ req.locale = 'us'
26
+
27
+ resp = req.search( sl, sl_rg ).seller_lookup_response
28
+
29
+ seller = resp.sellers.seller
30
+
31
+ seller.properties.each do |pr|
32
+ if seller[0][pr][0].properties.empty?
33
+ printf( "%s = %s.\n", pr, seller[0][pr] )
34
+ else
35
+ seller[0][pr][0].properties.each do |nest1|
36
+ if seller[0][pr][0][nest1][0].properties.empty?
37
+ printf( "%s = %s.\n", nest1, seller[0][pr][0][nest1][0] )
38
+ else
39
+ seller[0][pr][0][nest1][0].properties.each do |nest2|
40
+ printf( "%s = %s.\n", nest2, seller[0][pr][0][nest1][0][nest2] )
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: shopping_cart1,v 1.2 2008/06/06 13:31:40 ianmacd Exp $
4
+
5
+ require 'amazon/aws/search'
6
+ require 'amazon/aws/shoppingcart'
7
+
8
+ include Amazon::AWS
9
+ #include Amazon::AWS::Search
10
+ include Amazon::AWS::ShoppingCart
11
+
12
+ cart = Cart.new
13
+ cart.locale = 'uk'
14
+
15
+ cart.cart_create( :ASIN, 'B00151HZA6', 3, false,
16
+ { 'B000WC4AH0' => 2 ,
17
+ 'B000PY32OM' => 8 } )
18
+
19
+ puts cart.cart_id
20
+ puts cart.hmac
21
+ puts cart.purchase_url
22
+ puts
23
+
24
+ cart.cart_add( :ASIN, 'B0014C2BL4', 1,
25
+ { 'B00006BCKL' => 5 },
26
+ { 'B000VVE2UW' => 4 } )
27
+ cart.cart_add( :ASIN, 'B0013F2M52', 3 )
28
+ cart.cart_add( :ASIN, 'B000HCPSR6', 5 )
29
+ cart.cart_modify( :ASIN, 'B00151HZA6', 2, true,
30
+ { 'B0013F2M52' => 1 },
31
+ { 'B000HCPSR6' => 3 } )
32
+
33
+ puts 'Cart contents:'
34
+ cart.each do |it|
35
+ puts "ASIN: %s, item Id: %-14s, quantity: %d" %
36
+ [ it.asin, it.cart_item_id, it.quantity ]
37
+ end
38
+ puts
39
+
40
+ puts cart.items
41
+
42
+ cart.cart_clear