ruby-paa 0.0.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.
Files changed (51) hide show
  1. data/example/batch_operation +28 -0
  2. data/example/browse_node_lookup1 +46 -0
  3. data/example/customer_content_lookup1 +27 -0
  4. data/example/customer_content_search1 +21 -0
  5. data/example/example1 +78 -0
  6. data/example/help1 +24 -0
  7. data/example/item_lookup1 +54 -0
  8. data/example/item_lookup2 +56 -0
  9. data/example/item_search1 +30 -0
  10. data/example/item_search2 +37 -0
  11. data/example/item_search3 +23 -0
  12. data/example/list_lookup1 +29 -0
  13. data/example/list_search1 +31 -0
  14. data/example/multiple_operation1 +69 -0
  15. data/example/seller_listing_lookup1 +30 -0
  16. data/example/seller_listing_search1 +29 -0
  17. data/example/seller_lookup1 +45 -0
  18. data/example/shopping_cart1 +42 -0
  19. data/example/similarity_lookup1 +48 -0
  20. data/example/tag_lookup1 +34 -0
  21. data/example/transaction_lookup1 +25 -0
  22. data/example/vehicle_search +22 -0
  23. data/lib/ruby-paa.rb +165 -0
  24. data/lib/ruby-paa/aws.rb +1489 -0
  25. data/lib/ruby-paa/aws/cache.rb +141 -0
  26. data/lib/ruby-paa/aws/search.rb +463 -0
  27. data/lib/ruby-paa/aws/shoppingcart.rb +536 -0
  28. data/lib/ruby-paa/locale.rb +102 -0
  29. data/test/setup.rb +56 -0
  30. data/test/tc_amazon.rb +20 -0
  31. data/test/tc_aws.rb +160 -0
  32. data/test/tc_browse_node_lookup.rb +49 -0
  33. data/test/tc_customer_content_lookup.rb +49 -0
  34. data/test/tc_help.rb +44 -0
  35. data/test/tc_item_lookup.rb +47 -0
  36. data/test/tc_item_search.rb +105 -0
  37. data/test/tc_list_lookup.rb +60 -0
  38. data/test/tc_list_search.rb +44 -0
  39. data/test/tc_multiple_operation.rb +375 -0
  40. data/test/tc_operation_request.rb +64 -0
  41. data/test/tc_seller_listing_lookup.rb +47 -0
  42. data/test/tc_seller_listing_search.rb +55 -0
  43. data/test/tc_seller_lookup.rb +44 -0
  44. data/test/tc_serialisation.rb +107 -0
  45. data/test/tc_shopping_cart.rb +214 -0
  46. data/test/tc_similarity_lookup.rb +48 -0
  47. data/test/tc_tag_lookup.rb +24 -0
  48. data/test/tc_transaction_lookup.rb +24 -0
  49. data/test/tc_vehicle_operations.rb +118 -0
  50. data/test/ts_aws.rb +24 -0
  51. metadata +132 -0
@@ -0,0 +1,48 @@
1
+ # $Id: tc_similarity_lookup.rb,v 1.2 2010/02/20 17:15:18 ianmacd Exp $
2
+ #
3
+
4
+ require 'test/unit'
5
+ require './setup'
6
+
7
+ class TestSimilarityLookup < AWSTest
8
+
9
+ def test_similarity_lookup
10
+
11
+ sl = SimilarityLookup.new( [ 'B000AE4QEC', 'B000051WBE' ] )
12
+ sl_rg = ResponseGroup.new( :Subjects )
13
+ sl.response_group = sl_rg
14
+
15
+ response = @req.search( sl )
16
+
17
+ items = response.similarity_lookup_response[0].items
18
+
19
+ assert_match( /^\w+/, items.item[0].subjects.subject[0] )
20
+ assert_match( /^\w+/, items.item[1].subjects.subject[0] )
21
+
22
+ end
23
+
24
+ def test_similarity_lookup_class_method
25
+
26
+ response = Amazon::AWS.similarity_lookup( [ 'B000AE4QEC', 'B000051WBE' ] )
27
+
28
+ items = response.similarity_lookup_response[0].items
29
+
30
+ assert_match( /^http:/, items.item[0].detail_page_url )
31
+ assert_match( /^http:/, items.item[1].detail_page_url )
32
+
33
+ end
34
+
35
+ def test_item_search_class_method_block
36
+
37
+ Amazon::AWS.similarity_lookup( [ 'B000AE4QEC', 'B000051WBE' ] ) do |r|
38
+
39
+ items = r.similarity_lookup_response[0].items
40
+
41
+ assert_match( /^http:/, items.item[0].detail_page_url )
42
+ assert_match( /^http:/, items.item[1].detail_page_url )
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,24 @@
1
+ # $Id: tc_tag_lookup.rb,v 1.2 2010/02/20 17:15:18 ianmacd Exp $
2
+ #
3
+
4
+ require 'test/unit'
5
+ require './setup'
6
+
7
+ class TestTagLookup < AWSTest
8
+
9
+ def test_tag_lookup
10
+
11
+ @req.locale = 'us'
12
+ tl = TagLookup.new( 'Awful' )
13
+ tl_rg = ResponseGroup.new( :Tags, :TagsSummary )
14
+ tl.response_group = tl_rg
15
+
16
+ response = @req.search( tl )
17
+
18
+ tag = response.kernel
19
+
20
+ assert_equal( '2005-11-21 16:46:53', tag.first_tagging.time )
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,24 @@
1
+ # $Id: tc_transaction_lookup.rb,v 1.2 2010/02/20 17:15:19 ianmacd Exp $
2
+ #
3
+
4
+ require 'test/unit'
5
+ require './setup'
6
+
7
+ class TestTransactionLookup < AWSTest
8
+
9
+ def test_transaction_lookup
10
+
11
+ @req.locale = 'us'
12
+ tl = TransactionLookup.new( '103-5663398-5028241' )
13
+ tl_rg = ResponseGroup.new( :TransactionDetails )
14
+ tl.response_group = tl_rg
15
+
16
+ response = @req.search( tl )
17
+
18
+ trans = response.kernel
19
+
20
+ assert_equal( '2008-04-13T23:49:38', trans.transaction_date )
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/ruby -w
2
+ #
3
+ # $Id: tc_vehicle_operations.rb,v 1.2 2010/02/20 17:15:19 ianmacd Exp $
4
+
5
+ require 'test/unit'
6
+ require './setup'
7
+
8
+ class TestVehicles < AWSTest
9
+
10
+ def test_vehicle_search
11
+ @req.locale = 'us'
12
+
13
+ # Get all cars for year 2008.
14
+ #
15
+ vs = VehicleSearch.new( { 'Year' => 2008 } )
16
+ vs_rg = ResponseGroup.new( 'VehicleMakes' )
17
+ vs.response_group = vs_rg
18
+
19
+ response = @req.search( vs )
20
+
21
+ makes = response.vehicle_search_response[0].vehicle_years[0].
22
+ vehicle_year[0].vehicle_makes[0].vehicle_make
23
+ assert( makes.size > 0 )
24
+
25
+ make_id = makes.find { |make| make.make_name == 'Audi' }.make_id.to_i
26
+
27
+
28
+ # Get all Audi models from 2008.
29
+ #
30
+ vs = VehicleSearch.new( { 'Year' => 2008,
31
+ 'MakeId' => make_id } )
32
+ vs_rg = ResponseGroup.new( 'VehicleModels' )
33
+ vs.response_group = vs_rg
34
+
35
+ response = @req.search( vs )
36
+
37
+ models = response.vehicle_search_response[0].vehicle_years[0].
38
+ vehicle_year[0].vehicle_makes[0].vehicle_make[0].
39
+ vehicle_models[0].vehicle_model
40
+ assert( models.size > 0 )
41
+
42
+ model_id = models.find { |model| model.model_name == 'R8' }.model_id.to_i
43
+
44
+ # Get all Audi R8 trim packages from 2008.
45
+ #
46
+ vs = VehicleSearch.new( { 'Year' => 2008,
47
+ 'MakeId' => make_id,
48
+ 'ModelId' => model_id } )
49
+ vs_rg = ResponseGroup.new( 'VehicleTrims' )
50
+ vs.response_group = vs_rg
51
+
52
+ response = @req.search( vs )
53
+
54
+ trims = response.vehicle_search_response[0].vehicle_years[0].
55
+ vehicle_year[0].vehicle_makes[0].vehicle_make[0].
56
+ vehicle_models[0].vehicle_model[0].vehicle_trims[0].vehicle_trim
57
+ assert( trims.size > 0 )
58
+
59
+ trim_id = trims.find { |trim| trim.trim_name == 'Base' }.trim_id.to_i
60
+
61
+ vs = VehicleSearch.new( { 'Year' => 2008,
62
+ 'MakeId' => make_id,
63
+ 'ModelId' => model_id,
64
+ 'TrimId' => trim_id } )
65
+ vs_rg = ResponseGroup.new( 'VehicleOptions' )
66
+ vs.response_group = vs_rg
67
+
68
+ response = @req.search( vs )
69
+
70
+ options = response.vehicle_search_response[0].vehicle_years[0].
71
+ vehicle_year[0].vehicle_makes[0].vehicle_make[0].
72
+ vehicle_models[0].vehicle_model[0].vehicle_trims[0].
73
+ vehicle_trim[0].vehicle_options[0]
74
+ engine = options.vehicle_engine_options.vehicle_engine
75
+ engine_name = engine.engine_name
76
+ engine_id = engine.engine_id
77
+ assert_not_nil( engine_name )
78
+
79
+ # Find parts for our 2008 Audi R8 with Base trim and whatever engine that
80
+ # trim package has.
81
+ #
82
+ vps = VehiclePartSearch.new( 2008, make_id, model_id,
83
+ { 'TrimId' => trim_id,
84
+ 'EngineId' => engine_id } )
85
+ vps_rg = ResponseGroup.new( 'VehicleParts' )
86
+ vps.response_group = vps_rg
87
+
88
+ response = @req.search( vps )
89
+
90
+ parts = response.vehicle_part_search_response[0].vehicle_parts[0].part
91
+ assert( parts.size > 0 )
92
+
93
+ # Now, we do a reverse look-up.
94
+ #
95
+ # Go through all parts and test to see if they fit in our 2008 Audi R8
96
+ # Base trim. The answer should always be yes.
97
+ #
98
+ # part = parts[rand( parts.size - 1 )].item.asin
99
+
100
+ parts.each do |part|
101
+ vpl = VehiclePartLookup.new( part.item.asin,
102
+ { 'Year' => 2008,
103
+ 'MakeId' => make_id,
104
+ 'ModelId' => model_id,
105
+ 'TrimId' => trim_id } )
106
+
107
+ vpl_rg = ResponseGroup.new( 'VehiclePartFit' )
108
+ vpl.response_group = vpl_rg
109
+
110
+ response = @req.search( vpl )
111
+
112
+ fit = response.vehicle_part_lookup_response[0].vehicle_parts[0].part.
113
+ vehicle_part_fit.is_fit
114
+ assert_equal( 'YES', fit )
115
+ end
116
+ end
117
+
118
+ end
@@ -0,0 +1,24 @@
1
+ # $Id: ts_aws.rb,v 1.17 2009/06/03 23:25:33 ianmacd Exp $
2
+ #
3
+
4
+ require 'test/unit'
5
+ require 'tc_amazon'
6
+ require 'tc_aws'
7
+ require 'tc_browse_node_lookup'
8
+ require 'tc_customer_content_lookup'
9
+ require 'tc_help'
10
+ require 'tc_item_lookup'
11
+ require 'tc_item_search'
12
+ require 'tc_list_lookup'
13
+ require 'tc_list_search'
14
+ require 'tc_multiple_operation'
15
+ require 'tc_operation_request'
16
+ require 'tc_seller_listing_lookup'
17
+ require 'tc_seller_listing_search'
18
+ require 'tc_seller_lookup'
19
+ require 'tc_serialisation'
20
+ require 'tc_similarity_lookup'
21
+ require 'tc_shopping_cart'
22
+ require 'tc_tag_lookup'
23
+ require 'tc_transaction_lookup'
24
+ require 'tc_vehicle_operations'
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-paa
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Alex Jokela
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-12-08 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Ruby Interface to Amazon's Product Advertising API (Amazon's Associates Web Services)
22
+ email: alex.jokela@camulus.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - example/batch_operation
31
+ - example/browse_node_lookup1
32
+ - example/customer_content_lookup1
33
+ - example/customer_content_search1
34
+ - example/example1
35
+ - example/help1
36
+ - example/item_lookup1
37
+ - example/item_lookup2
38
+ - example/item_search1
39
+ - example/item_search2
40
+ - example/item_search3
41
+ - example/list_lookup1
42
+ - example/list_search1
43
+ - example/multiple_operation1
44
+ - example/seller_listing_lookup1
45
+ - example/seller_listing_search1
46
+ - example/seller_lookup1
47
+ - example/shopping_cart1
48
+ - example/similarity_lookup1
49
+ - example/tag_lookup1
50
+ - example/transaction_lookup1
51
+ - example/vehicle_search
52
+ - lib/ruby-paa.rb
53
+ - lib/ruby-paa/aws/cache.rb
54
+ - lib/ruby-paa/aws/search.rb
55
+ - lib/ruby-paa/aws/shoppingcart.rb
56
+ - lib/ruby-paa/aws.rb
57
+ - lib/ruby-paa/locale.rb
58
+ - test/setup.rb
59
+ - test/tc_amazon.rb
60
+ - test/tc_aws.rb
61
+ - test/tc_browse_node_lookup.rb
62
+ - test/tc_customer_content_lookup.rb
63
+ - test/tc_help.rb
64
+ - test/tc_item_lookup.rb
65
+ - test/tc_item_search.rb
66
+ - test/tc_list_lookup.rb
67
+ - test/tc_list_search.rb
68
+ - test/tc_multiple_operation.rb
69
+ - test/tc_operation_request.rb
70
+ - test/tc_seller_listing_lookup.rb
71
+ - test/tc_seller_listing_search.rb
72
+ - test/tc_seller_lookup.rb
73
+ - test/tc_serialisation.rb
74
+ - test/tc_shopping_cart.rb
75
+ - test/tc_similarity_lookup.rb
76
+ - test/tc_tag_lookup.rb
77
+ - test/tc_transaction_lookup.rb
78
+ - test/tc_vehicle_operations.rb
79
+ - test/ts_aws.rb
80
+ has_rdoc: true
81
+ homepage: http://rubygems.org/gems/ruby-paa
82
+ licenses: []
83
+
84
+ post_install_message:
85
+ rdoc_options: []
86
+
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project: " "
106
+ rubygems_version: 1.3.6
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Interface to Amazon's Product Advertising API
110
+ test_files:
111
+ - test/setup.rb
112
+ - test/tc_amazon.rb
113
+ - test/tc_aws.rb
114
+ - test/tc_browse_node_lookup.rb
115
+ - test/tc_customer_content_lookup.rb
116
+ - test/tc_help.rb
117
+ - test/tc_item_lookup.rb
118
+ - test/tc_item_search.rb
119
+ - test/tc_list_lookup.rb
120
+ - test/tc_list_search.rb
121
+ - test/tc_multiple_operation.rb
122
+ - test/tc_operation_request.rb
123
+ - test/tc_seller_listing_lookup.rb
124
+ - test/tc_seller_listing_search.rb
125
+ - test/tc_seller_lookup.rb
126
+ - test/tc_serialisation.rb
127
+ - test/tc_shopping_cart.rb
128
+ - test/tc_similarity_lookup.rb
129
+ - test/tc_tag_lookup.rb
130
+ - test/tc_transaction_lookup.rb
131
+ - test/tc_vehicle_operations.rb
132
+ - test/ts_aws.rb