ruby-aaws 0.4.4 → 0.5.0
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.
- data/NEWS +372 -283
- data/README +101 -60
- data/README.rdoc +13 -9
- data/example/batch_operation +27 -0
- data/example/item_lookup1 +5 -4
- data/example/item_lookup2 +5 -4
- data/example/multiple_operation1 +4 -3
- data/example/vehicle_search +22 -0
- data/lib/amazon.rb +22 -8
- data/lib/amazon/aws.rb +270 -107
- data/lib/amazon/aws/search.rb +26 -3
- data/test/tc_multiple_operation.rb +12 -4
- data/test/tc_vehicle_operations.rb +106 -0
- data/test/ts_aws.rb +2 -1
- metadata +6 -2
data/lib/amazon.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: amazon.rb,v 1.
|
1
|
+
# $Id: amazon.rb,v 1.26 2009/01/19 16:45:11 ianmacd Exp $
|
2
2
|
#
|
3
3
|
|
4
4
|
module Amazon
|
@@ -63,6 +63,7 @@ module Amazon
|
|
63
63
|
# and are readable.
|
64
64
|
#
|
65
65
|
def initialize(config_str=nil)
|
66
|
+
locale = nil
|
66
67
|
|
67
68
|
if config_str
|
68
69
|
|
@@ -105,16 +106,24 @@ module Amazon
|
|
105
106
|
if readable
|
106
107
|
|
107
108
|
Amazon.dprintf( 'Opening %s ...', cf ) if config_class == File
|
108
|
-
|
109
|
+
|
109
110
|
config_class.open( cf ) { |f| lines = f.readlines }.each do |line|
|
110
111
|
line.chomp!
|
111
|
-
|
112
|
+
|
112
113
|
# Skip comments and blank lines.
|
113
114
|
#
|
114
115
|
next if line =~ /^(#|$)/
|
115
|
-
|
116
|
+
|
116
117
|
Amazon.dprintf( 'Read: %s', line )
|
117
|
-
|
118
|
+
|
119
|
+
# Determine whether we're entering the subsection of a new locale.
|
120
|
+
#
|
121
|
+
if match = line.match( /^\[(\w+)\]$/ )
|
122
|
+
locale = match[1]
|
123
|
+
Amazon.dprintf( "Config locale is now '%s'.", locale )
|
124
|
+
next
|
125
|
+
end
|
126
|
+
|
118
127
|
# Store these, because we'll probably find a use for these later.
|
119
128
|
#
|
120
129
|
begin
|
@@ -125,9 +134,14 @@ module Amazon
|
|
125
134
|
rescue NoMethodError, ConfigError
|
126
135
|
raise ConfigError, "bad config line: #{line}"
|
127
136
|
end
|
128
|
-
|
129
|
-
|
130
|
-
|
137
|
+
|
138
|
+
if locale && locale != 'global'
|
139
|
+
self[locale] ||= {}
|
140
|
+
self[locale][key] = val
|
141
|
+
else
|
142
|
+
self[key] = val
|
143
|
+
end
|
144
|
+
|
131
145
|
end
|
132
146
|
end
|
133
147
|
|
data/lib/amazon/aws.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: aws.rb,v 1.
|
1
|
+
# $Id: aws.rb,v 1.84 2009/02/19 16:01:11 ianmacd Exp $
|
2
2
|
#
|
3
3
|
#:include: ../../README.rdoc
|
4
4
|
|
@@ -26,10 +26,11 @@ module Amazon
|
|
26
26
|
'us' => 'calibanorg-20'
|
27
27
|
}
|
28
28
|
|
29
|
-
# Service name and version for AWS.
|
29
|
+
# Service name and API version for AWS. The version of the API used can be
|
30
|
+
# changed via the user configuration file.
|
30
31
|
#
|
31
32
|
SERVICE = { 'Service' => 'AWSECommerceService',
|
32
|
-
'Version' => '
|
33
|
+
'Version' => '2009-01-06'
|
33
34
|
}
|
34
35
|
|
35
36
|
# Maximum number of 301 and 302 HTTP responses to follow, should Amazon
|
@@ -53,7 +54,9 @@ module Amazon
|
|
53
54
|
'CustomerContentLookup' => { 'parameter' => 'ReviewPage',
|
54
55
|
'max_page' => 10 },
|
55
56
|
'CustomerContentSearch' => { 'parameter' => 'CustomerPage',
|
56
|
-
'max_page' => 20 }
|
57
|
+
'max_page' => 20 },
|
58
|
+
'VehiclePartLookup' => { 'parameter' => 'FitmentPage',
|
59
|
+
'max_page' => 10 }
|
57
60
|
}
|
58
61
|
# N.B. ItemLookup can also use the following two pagination parameters
|
59
62
|
#
|
@@ -61,11 +64,18 @@ module Amazon
|
|
61
64
|
# ---------
|
62
65
|
# VariationPage 150
|
63
66
|
# ReviewPage 20
|
64
|
-
|
67
|
+
|
68
|
+
|
65
69
|
# Exception class for HTTP errors.
|
66
70
|
#
|
67
71
|
class HTTPError < AmazonError; end
|
68
72
|
|
73
|
+
|
74
|
+
# Exception class for faulty batch operations.
|
75
|
+
#
|
76
|
+
class BatchError < AmazonError; end
|
77
|
+
|
78
|
+
|
69
79
|
class Endpoint
|
70
80
|
|
71
81
|
attr_reader :host, :path
|
@@ -556,30 +566,13 @@ module Amazon
|
|
556
566
|
Help ItemLookup ItemSearch
|
557
567
|
ListLookup ListSearch SellerListingLookup
|
558
568
|
SellerListingSearch SellerLookup SimilarityLookup
|
559
|
-
TagLookup TransactionLookup
|
569
|
+
TagLookup TransactionLookup VehiclePartLookup
|
570
|
+
VehiclePartSearch VehicleSearch
|
560
571
|
|
561
572
|
CartAdd CartClear CartCreate
|
562
573
|
CartGet CartModify
|
563
574
|
]
|
564
575
|
|
565
|
-
# These are the valid search parameters that can be used with
|
566
|
-
# ItemSearch.
|
567
|
-
#
|
568
|
-
PARAMETERS = %w[
|
569
|
-
Actor Artist AudienceRating Author
|
570
|
-
Brand BrowseNode City Composer Conductor
|
571
|
-
Director Keywords Manufacturer MusicLabel
|
572
|
-
Neighborhood Orchestra Power Publisher
|
573
|
-
TextStream Title
|
574
|
-
]
|
575
|
-
|
576
|
-
OPT_PARAMETERS = %w[
|
577
|
-
Availability Condition MaximumPrice MerchantId
|
578
|
-
MinimumPrice OfferStatus Sort
|
579
|
-
]
|
580
|
-
|
581
|
-
ALL_PARAMETERS = PARAMETERS + OPT_PARAMETERS
|
582
|
-
|
583
576
|
attr_reader :kind
|
584
577
|
attr_accessor :params
|
585
578
|
|
@@ -596,6 +589,50 @@ module Amazon
|
|
596
589
|
end
|
597
590
|
|
598
591
|
|
592
|
+
# Group together operations of the same class in a batch request.
|
593
|
+
# _operations_ should be either an operation of the same class as *self*
|
594
|
+
# or an array of such operations.
|
595
|
+
#
|
596
|
+
# If you need to batch operations from different classes, use a
|
597
|
+
# MultipleOperation instead.
|
598
|
+
#
|
599
|
+
# Example:
|
600
|
+
#
|
601
|
+
# is = ItemSearch.new( 'Books', { 'Title' => 'ruby programming' } )
|
602
|
+
# is2 = ItemSearch.new( 'Music', { 'Artist' => 'stranglers' } )
|
603
|
+
# is.batch( is2 )
|
604
|
+
#
|
605
|
+
# Please see MultipleOperation.new for details of a couple of
|
606
|
+
# restrictions that also apply to batched operations.
|
607
|
+
#
|
608
|
+
def batch(*operations)
|
609
|
+
|
610
|
+
# Remove the Operation parameter to avoid batch syntax being applied.
|
611
|
+
# We'll readd it at the end.
|
612
|
+
#
|
613
|
+
op_type = @params.delete( 'Operation' )
|
614
|
+
|
615
|
+
operations.flatten.each do |op|
|
616
|
+
|
617
|
+
unless self.class == op.class
|
618
|
+
raise BatchError, "You can't batch different classes of operation. Use class MultipleOperation."
|
619
|
+
end
|
620
|
+
|
621
|
+
# Remove the Operation parameter.
|
622
|
+
#
|
623
|
+
op.params.delete( 'Operation' )
|
624
|
+
|
625
|
+
# Apply batch syntax.
|
626
|
+
#
|
627
|
+
@params = batch_parameters( @params, op.params )
|
628
|
+
end
|
629
|
+
|
630
|
+
# Reinstate the Operation parameter.
|
631
|
+
#
|
632
|
+
@params.merge!( { 'Operation' => op_type } )
|
633
|
+
end
|
634
|
+
|
635
|
+
|
599
636
|
# Convert parameters to batch format, e.g. ItemSearch.1.Title.
|
600
637
|
#
|
601
638
|
def batch_parameters(params, *b_params) # :nodoc:
|
@@ -634,25 +671,21 @@ module Amazon
|
|
634
671
|
params
|
635
672
|
end
|
636
673
|
|
637
|
-
|
638
|
-
def parameter_check(parameters)
|
639
|
-
parameters.each_key do |key|
|
640
|
-
raise "Bad parameter: #{key}" unless ALL_PARAMETERS.include? key.to_s
|
641
|
-
end
|
642
|
-
end
|
643
|
-
private :parameter_check
|
644
|
-
|
645
674
|
end
|
646
675
|
|
647
676
|
|
648
|
-
# This class can be used to merge operations into a single
|
649
|
-
#
|
677
|
+
# This class can be used to merge multiple operations into a single
|
678
|
+
# operation for greater efficiency.
|
650
679
|
#
|
651
680
|
class MultipleOperation < Operation
|
652
681
|
|
653
682
|
# This will allow you to take two Operation objects and combine them to
|
654
|
-
# form a single object, which can then be used to perform
|
655
|
-
#
|
683
|
+
# form a single object, which can then be used to perform a single
|
684
|
+
# request to AWS. This allows for greater efficiency, reducing the
|
685
|
+
# number of requests sent to AWS.
|
686
|
+
#
|
687
|
+
# AWS currently imposes a limit of two combined operations in a multiple
|
688
|
+
# operation.
|
656
689
|
#
|
657
690
|
# <em>operation1</em> and <em>operation2</em> are both objects from a
|
658
691
|
# subclass of Operation, such as ItemSearch, ItemLookup, etc.
|
@@ -661,11 +694,11 @@ module Amazon
|
|
661
694
|
# of multiple operations:
|
662
695
|
#
|
663
696
|
# - ResponseGroup objects used when calling AWS::Search::Request#search
|
664
|
-
# apply to both operations. You cannot
|
665
|
-
#
|
697
|
+
# apply to both operations. You cannot use a different ResponseGroup
|
698
|
+
# with each operation.
|
666
699
|
#
|
667
700
|
# - One or both operations may have multiple results pages available,
|
668
|
-
# but only the first page
|
701
|
+
# but only the first page is returned. If you need the subsequent
|
669
702
|
# pages, perform the operations separately, not as part of a
|
670
703
|
# MultipleOperation.
|
671
704
|
#
|
@@ -676,8 +709,13 @@ module Amazon
|
|
676
709
|
# 'MerchantId' => 'Amazon' } )
|
677
710
|
# mo = MultipleOperation.new( is, il )
|
678
711
|
#
|
679
|
-
#
|
680
|
-
#
|
712
|
+
# As you can see, the operations that are combined as a
|
713
|
+
# MultipleOperation do not have to belong to the same class. In the
|
714
|
+
# above example, we compose a multiple operation consisting of an
|
715
|
+
# ItemSearch and an ItemLookup.
|
716
|
+
#
|
717
|
+
# If you want to batch operations belonging to the same class,
|
718
|
+
# Operation#batch provides an alternative.
|
681
719
|
#
|
682
720
|
def initialize(operation1, operation2)
|
683
721
|
|
@@ -737,8 +775,8 @@ module Amazon
|
|
737
775
|
#
|
738
776
|
# _help_type_ is the type of object for which help is being sought, such
|
739
777
|
# as *Operation* or *ResponseGroup*. _about_ is the name of the
|
740
|
-
# operation or response group you need help with, and _parameters_ is
|
741
|
-
# hash of parameters that
|
778
|
+
# operation or response group you need help with, and _parameters_ is an
|
779
|
+
# optional hash of parameters that further refine the request for help.
|
742
780
|
#
|
743
781
|
def initialize(help_type, about, parameters={})
|
744
782
|
super( { 'HelpType' => help_type,
|
@@ -764,35 +802,74 @@ module Amazon
|
|
764
802
|
#
|
765
803
|
# - *All* searches through all indices (but currently exists only in the
|
766
804
|
# *US* locale).
|
767
|
-
# - *Blended* combines
|
768
|
-
#
|
769
|
-
# and
|
805
|
+
# - *Blended* combines Apparel, Automotive, Books, DVD, Electronics,
|
806
|
+
# GourmetFood, Kitchen, Music, PCHardware, PetSupplies, Software,
|
807
|
+
# SoftwareVideoGames, SportingGoods, Tools, Toys, VHS and VideoGames.
|
770
808
|
# - *Merchants* combines all search indices for a merchant given with
|
771
809
|
# MerchantId.
|
772
810
|
# - *Music* combines the Classical, DigitalMusic, and MusicTracks
|
773
811
|
# indices.
|
774
812
|
# - *Video* combines the DVD and VHS search indices.
|
775
813
|
#
|
814
|
+
# Note that {page
|
815
|
+
# 53}[http://docs.amazonwebservices.com/AWSECommerceService/2009-01-06/DG/SearchIndices.html]
|
816
|
+
# of the PDF of the AWS Developer Guide (revision 2009-01-06) contains
|
817
|
+
# an outdated description of *Blended* with too few subindices. {Page
|
818
|
+
# 95}[http://docs.amazonwebservices.com/AWSECommerceService/2009-01-06/DG/CommonItemSearchParameters.html]
|
819
|
+
# of the PDF contains the correct list.
|
820
|
+
#
|
776
821
|
SEARCH_INDICES = %w[
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
822
|
+
All
|
823
|
+
Apparel
|
824
|
+
Automotive
|
825
|
+
Baby
|
826
|
+
Beauty
|
827
|
+
Blended
|
828
|
+
Books
|
829
|
+
Classical
|
830
|
+
DigitalMusic
|
831
|
+
DVD
|
832
|
+
Electronics
|
833
|
+
ForeignBooks
|
834
|
+
GourmetFood
|
835
|
+
Grocery
|
836
|
+
HealthPersonalCare
|
837
|
+
Hobbies
|
838
|
+
HomeGarden
|
839
|
+
Industrial
|
840
|
+
Jewelry
|
841
|
+
KindleStore
|
842
|
+
Kitchen
|
843
|
+
Magazines
|
844
|
+
Merchants
|
845
|
+
Miscellaneous
|
846
|
+
MP3Downloads
|
847
|
+
Music
|
848
|
+
MusicalInstruments
|
849
|
+
MusicTracks
|
850
|
+
OfficeProducts
|
851
|
+
OutdoorLiving
|
852
|
+
PCHardware
|
853
|
+
PetSupplies
|
854
|
+
Photo
|
855
|
+
SilverMerchant
|
856
|
+
Software
|
857
|
+
SoftwareVideoGames
|
858
|
+
SportingGoods
|
859
|
+
Tools
|
860
|
+
Toys
|
861
|
+
VHS
|
862
|
+
Video
|
863
|
+
VideoGames
|
864
|
+
Watches
|
865
|
+
Wireless
|
866
|
+
WirelessAccessories
|
867
|
+
]
|
792
868
|
|
793
869
|
|
794
870
|
# Search AWS for items. _search_index_ must be one of _SEARCH_INDICES_
|
795
|
-
# and _parameters_ is
|
871
|
+
# and _parameters_ is an optional hash of parameters that further refine
|
872
|
+
# the scope of the search.
|
796
873
|
#
|
797
874
|
# Example:
|
798
875
|
#
|
@@ -806,7 +883,6 @@ module Amazon
|
|
806
883
|
raise "Invalid search index: #{search_index}"
|
807
884
|
end
|
808
885
|
|
809
|
-
parameter_check( parameters )
|
810
886
|
super( { 'SearchIndex' => search_index }.merge( parameters ) )
|
811
887
|
end
|
812
888
|
|
@@ -820,33 +896,20 @@ module Amazon
|
|
820
896
|
class ItemLookup < Operation
|
821
897
|
|
822
898
|
# Look up a specific item in the AWS catalogue. _id_type_ is the type of
|
823
|
-
# identifier
|
824
|
-
# located and narrows the scope of the search
|
825
|
-
# optional hash of further items to be located. Use of _b_parameters_
|
826
|
-
# effectively results in a batch operation being sent to AWS.
|
899
|
+
# identifier and _parameters_ is a hash that identifies the item to be
|
900
|
+
# located and narrows the scope of the search.
|
827
901
|
#
|
828
902
|
# Example:
|
829
903
|
#
|
830
904
|
# il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC'
|
831
|
-
# 'MerchantId' => 'Amazon' },
|
832
|
-
# { 'ItemId' => 'B000051WBE',
|
833
905
|
# 'MerchantId' => 'Amazon' } )
|
834
906
|
#
|
835
|
-
# In the above example, we search for
|
836
|
-
#
|
837
|
-
#
|
907
|
+
# In the above example, we search for an item, based on its ASIN. The
|
908
|
+
# use of _MerchantId_ restricts the offers returned to those for sale
|
909
|
+
# by Amazon (as opposed to third-party sellers).
|
838
910
|
#
|
839
|
-
def initialize(id_type, parameters
|
840
|
-
|
841
|
-
id_type_str = 'IdType'
|
842
|
-
|
843
|
-
unless b_parameters.empty?
|
844
|
-
class_str = self.class.to_s.sub( /^.+::/, '' )
|
845
|
-
id_type_str = '%s.Shared.IdType' % [ class_str ]
|
846
|
-
parameters = batch_parameters( parameters, *b_parameters )
|
847
|
-
end
|
848
|
-
|
849
|
-
super( { id_type_str => id_type }.merge( parameters ) )
|
911
|
+
def initialize(id_type, parameters)
|
912
|
+
super( { 'IdType' => id_type }.merge( parameters ) )
|
850
913
|
end
|
851
914
|
|
852
915
|
end
|
@@ -857,8 +920,8 @@ module Amazon
|
|
857
920
|
class SellerListingSearch < Operation
|
858
921
|
|
859
922
|
# Search for items for sale by a particular seller. _seller_id_ is the
|
860
|
-
# Amazon seller ID and _parameters_ is
|
861
|
-
# the scope of the search.
|
923
|
+
# Amazon seller ID and _parameters_ is an optional hash of parameters
|
924
|
+
# that further refine the scope of the search.
|
862
925
|
#
|
863
926
|
# Example:
|
864
927
|
#
|
@@ -880,11 +943,8 @@ module Amazon
|
|
880
943
|
class SellerListingLookup < ItemLookup
|
881
944
|
|
882
945
|
# Look up a specific item for sale by a specific seller. _id_type_ is
|
883
|
-
# the type of identifier
|
884
|
-
# item to be located and narrows the scope of the search
|
885
|
-
# _b_parameters_ is an optional hash of further items to be located. Use
|
886
|
-
# of _b_parameters_ effectively results in a batch operation being sent
|
887
|
-
# to AWS.
|
946
|
+
# the type of identifier and _parameters_ is a hash that identifies the
|
947
|
+
# item to be located and narrows the scope of the search.
|
888
948
|
#
|
889
949
|
# Example:
|
890
950
|
#
|
@@ -894,9 +954,8 @@ module Amazon
|
|
894
954
|
# In the above example, we search seller <b>AP8U6Y3PYQ9VO</b>'s listings
|
895
955
|
# to find items for sale with the ASIN <b>B0009RRRC8</b>.
|
896
956
|
#
|
897
|
-
def initialize(seller_id, id_type, parameters
|
898
|
-
super( id_type, { 'SellerId' => seller_id }.merge( parameters )
|
899
|
-
b_parameters )
|
957
|
+
def initialize(seller_id, id_type, parameters)
|
958
|
+
super( id_type, { 'SellerId' => seller_id }.merge( parameters ) )
|
900
959
|
end
|
901
960
|
|
902
961
|
end
|
@@ -907,8 +966,8 @@ module Amazon
|
|
907
966
|
class SellerLookup < Operation
|
908
967
|
|
909
968
|
# Search for the details of a specific seller. _seller_id_ is the Amazon
|
910
|
-
# ID of the seller in question and _parameters_ is
|
911
|
-
# that
|
969
|
+
# ID of the seller in question and _parameters_ is an optional hash of
|
970
|
+
# parameters that further refine the scope of the search.
|
912
971
|
#
|
913
972
|
# Example:
|
914
973
|
#
|
@@ -930,8 +989,8 @@ module Amazon
|
|
930
989
|
class CustomerContentLookup < Operation
|
931
990
|
|
932
991
|
# Search for public customer data. _customer_id_ is the unique ID
|
933
|
-
# identifying the customer on Amazon and _parameters_ is
|
934
|
-
# parameters that
|
992
|
+
# identifying the customer on Amazon and _parameters_ is an optional
|
993
|
+
# hash of parameters that further refine the scope of the search.
|
935
994
|
#
|
936
995
|
# Example:
|
937
996
|
#
|
@@ -981,8 +1040,8 @@ module Amazon
|
|
981
1040
|
class ListSearch < Operation
|
982
1041
|
|
983
1042
|
# Search for Amazon lists. _list_type_ is the type of list to search for
|
984
|
-
# and _parameters_ is
|
985
|
-
# search.
|
1043
|
+
# and _parameters_ is an optional hash of parameters that narrow the
|
1044
|
+
# scope of the search.
|
986
1045
|
#
|
987
1046
|
# Example:
|
988
1047
|
#
|
@@ -1003,8 +1062,8 @@ module Amazon
|
|
1003
1062
|
class ListLookup < Operation
|
1004
1063
|
|
1005
1064
|
# Look up and return details about a specific list. _list_id_ is the
|
1006
|
-
# Amazon list ID, _list_type_ is the type of list and _parameters_ is
|
1007
|
-
# hash of parameters that
|
1065
|
+
# Amazon list ID, _list_type_ is the type of list and _parameters_ is an
|
1066
|
+
# optional hash of parameters that narrow the scope of the search.
|
1008
1067
|
#
|
1009
1068
|
# Example:
|
1010
1069
|
#
|
@@ -1030,8 +1089,9 @@ module Amazon
|
|
1030
1089
|
class BrowseNodeLookup < Operation
|
1031
1090
|
|
1032
1091
|
# Look up and return the details of an Amazon browse node. _node_ is the
|
1033
|
-
# browse node to look up and _parameters_ is
|
1034
|
-
#
|
1092
|
+
# browse node to look up and _parameters_ is an optional hash of
|
1093
|
+
# parameters that further refine the scope of the search. _parameters_
|
1094
|
+
# is currently unused.
|
1035
1095
|
#
|
1036
1096
|
# Example:
|
1037
1097
|
#
|
@@ -1052,8 +1112,8 @@ module Amazon
|
|
1052
1112
|
class SimilarityLookup < Operation
|
1053
1113
|
|
1054
1114
|
# Look up items similar to _asin_, which can be a single item or an
|
1055
|
-
# array. _parameters_ is
|
1056
|
-
# refine the search.
|
1115
|
+
# array. _parameters_ is an optional hash of parameters that further
|
1116
|
+
# refine the scope of the search.
|
1057
1117
|
#
|
1058
1118
|
# Example:
|
1059
1119
|
#
|
@@ -1076,8 +1136,8 @@ module Amazon
|
|
1076
1136
|
class TagLookup < Operation
|
1077
1137
|
|
1078
1138
|
# Look up entities based on user-defined tags. _tag_name_ is the tag to
|
1079
|
-
# search on and _parameters_ is
|
1080
|
-
# further refine the search.
|
1139
|
+
# search on and _parameters_ is an optional hash of parameters that
|
1140
|
+
# further refine the scope of the search.
|
1081
1141
|
#
|
1082
1142
|
# Example:
|
1083
1143
|
#
|
@@ -1115,6 +1175,109 @@ module Amazon
|
|
1115
1175
|
end
|
1116
1176
|
|
1117
1177
|
|
1178
|
+
# Look up individual vehicle parts.
|
1179
|
+
#
|
1180
|
+
class VehiclePartLookup < Operation
|
1181
|
+
|
1182
|
+
# Look up a particular vehicle part. _item_id_ is the ASIN of the part
|
1183
|
+
# in question and _parameters_ is an optional hash of parameters that
|
1184
|
+
# further refine the scope of the search.
|
1185
|
+
#
|
1186
|
+
# Although the _item_id_ alone is enough to locate the part, providing
|
1187
|
+
# _parameters_ can be useful in determining whether the part looked up
|
1188
|
+
# is a fit for a particular vehicle type, as with the *VehiclePartFit*
|
1189
|
+
# response group.
|
1190
|
+
#
|
1191
|
+
# Example:
|
1192
|
+
#
|
1193
|
+
# vpl = VehiclePartLookup.new( 'B000C1ZLI8',
|
1194
|
+
# { 'Year' => 2008,
|
1195
|
+
# 'MakeId' => 73,
|
1196
|
+
# 'ModelId' => 6039,
|
1197
|
+
# 'TrimId' => 20 } )
|
1198
|
+
#
|
1199
|
+
# Here, we search for a <b>2008</b> model *Audi* <b>R8</b> with *Base*
|
1200
|
+
# trim. The required Ids can be found using VehiclePartSearch.
|
1201
|
+
#
|
1202
|
+
def initialize(item_id, parameters={})
|
1203
|
+
super( { 'ItemId' => item_id }.merge( parameters ) )
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
|
1209
|
+
# Search for parts for a given vehicle.
|
1210
|
+
#
|
1211
|
+
class VehiclePartSearch < Operation
|
1212
|
+
|
1213
|
+
# Find parts for a given _year_, _make_id_ and _model_id_ of vehicle.
|
1214
|
+
# _parameters_ is an optional hash of parameters that further refine the
|
1215
|
+
# scope of the search.
|
1216
|
+
#
|
1217
|
+
# Example:
|
1218
|
+
#
|
1219
|
+
# vps = VehiclePartSearch.new( 2008, 73, 6039,
|
1220
|
+
# { 'TrimId' => 20,
|
1221
|
+
# 'EngineId' => 8914 } )
|
1222
|
+
#
|
1223
|
+
# In this example, we look for parts that will fit a <b>2008</b> model
|
1224
|
+
# *Audi* <b>R8</b> with *Base* trim and a <b>4.2L V8 Gas DOHC
|
1225
|
+
# Distributorless Naturally Aspirated Bosch Motronic Electronic FI
|
1226
|
+
# MFI</b> engine.
|
1227
|
+
#
|
1228
|
+
# Note that pagination of VehiclePartSearch results is not currently
|
1229
|
+
# supported.
|
1230
|
+
#
|
1231
|
+
# Use VehicleSearch to learn the MakeId and ModelId of the vehicle in
|
1232
|
+
# which you are interested.
|
1233
|
+
#
|
1234
|
+
def initialize(year, make_id, model_id, parameters={})
|
1235
|
+
super( { 'Year' => year,
|
1236
|
+
'MakeId' => make_id,
|
1237
|
+
'ModelId' => model_id }.merge( parameters ) )
|
1238
|
+
end
|
1239
|
+
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
|
1243
|
+
# Search for vehicles.
|
1244
|
+
#
|
1245
|
+
class VehicleSearch < Operation
|
1246
|
+
|
1247
|
+
# Search for vehicles, based on one or more of the following
|
1248
|
+
# _parameters_: Year, MakeId, ModelId and TrimId.
|
1249
|
+
#
|
1250
|
+
# This method is best used iteratively. For example, first search on
|
1251
|
+
# year with a response group of *VehicleMakes* to return all makes for
|
1252
|
+
# that year.
|
1253
|
+
#
|
1254
|
+
# Next, search on year and make with a response group of *VehicleModels*
|
1255
|
+
# to find all models for that year and make.
|
1256
|
+
#
|
1257
|
+
# Then, search on year, make and model with a response group of
|
1258
|
+
# *VehicleTrims* to find all trim packages for that year, make and model.
|
1259
|
+
#
|
1260
|
+
# Finally, if required, search on year, make, model and trim package
|
1261
|
+
# with a response group of *VehicleOptions* to find all vehicle options
|
1262
|
+
# for that year, make, model and trim package.
|
1263
|
+
#
|
1264
|
+
# Example:
|
1265
|
+
#
|
1266
|
+
# vs = VehicleSearch.new( { 'Year' => 2008,
|
1267
|
+
# 'MakeId' => 20,
|
1268
|
+
# 'ModelId' => 6039,
|
1269
|
+
# 'TrimId' => 20 } )
|
1270
|
+
#
|
1271
|
+
# In this example, we search for <b>2008 Audi R8</b> vehicles with a
|
1272
|
+
# *Base* trim package. Used with the *VehicleOptions* response group,
|
1273
|
+
# a list of vehicle options would be returned.
|
1274
|
+
#
|
1275
|
+
def initialize(parameters={})
|
1276
|
+
super
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
end
|
1280
|
+
|
1118
1281
|
# Response groups determine which data pertaining to the item(s) being
|
1119
1282
|
# sought is returned. They can strongly influence the amount of data
|
1120
1283
|
# returned, so you should always use the smallest response group(s)
|