Module: Amazon::Associates
- Defined in:
- lib/amazon-associates.rb,
lib/amazon-associates/errors.rb,
lib/amazon-associates/request.rb,
lib/amazon-associates/types/cart.rb,
lib/amazon-associates/types/item.rb,
lib/amazon-associates/types/error.rb,
lib/amazon-associates/types/image.rb,
lib/amazon-associates/types/offer.rb,
lib/amazon-associates/types/price.rb,
lib/amazon-associates/requests/cart.rb,
lib/amazon-associates/requests/item.rb,
lib/amazon-associates/types/ordinal.rb,
lib/amazon-associates/types/requests.rb,
lib/amazon-associates/types/image_set.rb,
lib/amazon-associates/types/api_result.rb,
lib/amazon-associates/types/browse_node.rb,
lib/amazon-associates/types/measurement.rb,
lib/amazon-associates/responses/response.rb,
lib/amazon-associates/requests/browse_node.rb,
lib/amazon-associates/types/listmania_list.rb,
lib/amazon-associates/types/customer_review.rb,
lib/amazon-associates/types/editorial_review.rb,
lib/amazon-associates/caching/filesystem_cache.rb,
lib/amazon-associates/responses/cart_responses.rb,
lib/amazon-associates/responses/item_lookup_response.rb,
lib/amazon-associates/responses/item_search_response.rb,
lib/amazon-associates/responses/similarity_lookup_response.rb,
lib/amazon-associates/responses/browse_node_lookup_response.rb
Defined Under Namespace
Modules: FilesystemCache
Classes: ApiResult, BrowseNode, BrowseNodeLookupRequest, BrowseNodeLookupResponse, Cart, CartAddResponse, CartClearResponse, CartCreateResponse, CartGetResponse, CartItem, CartModifyResponse, CartRequest, CartResponse, ConfigurationError, CustomerReview, EditorialReview, Error, Image, ImageSet, InvalidParameterValue, Item, ItemLookupRequest, ItemLookupResponse, ItemNotFound, ItemSearchRequest, ItemSearchResponse, ListmaniaList, Measurement, Offer, OperationRequest, Ordinal, ParameterOutOfRange, Price, Request, RequestError, RequiredParameterMissing, Response, SearchResponse, SimilarityLookupResponse
Constant Summary
collapse
- SORT_TYPES =
{
'All' => nil,
'Apparel' => %w[relevancerank salesrank pricerank inverseprice -launch-date sale-flag],
'Automotive' => %w[salesrank price -price titlerank -titlerank],
'Baby' => %w[psrank salesrank price -price titlerank],
'Beauty' => %w[pmrank salesrank price -price -launch-date sale-flag],
'Books' => %w[relevancerank salesrank reviewrank pricerank inverse-pricerank daterank titlerank -titlerank],
'Classical' => %w[psrank salesrank price -price titlerank -titlerank orig-rel-date],
'DigitalMusic' => %w[songtitlerank uploaddaterank],
'DVD' => %w[relevancerank salesrank price -price titlerank -video-release-date],
'Electronics' => %w[pmrank salesrank reviewrank price -price titlerank],
'GourmetFood' => %w[relevancerank salesrank pricerank inverseprice launch-date sale-flag],
'HealthPersonalCare' => %w[pmrank salesrank pricerank inverseprice launch-date sale-flag],
'Jewelry' => %w[pmrank salesrank pricerank inverseprice launch-date],
'Kitchen' => %w[pmrank salesrank price -price titlerank -titlerank],
'Magazines' => %w[subslot-salesrank reviewrank price -price daterank titlerank -titlerank],
'Marketplace' => nil,
'Merchants' => %w[relevancerank salesrank pricerank inverseprice launch-date sale-flag],
'Miscellaneous' => %w[pmrank salesrank price -price titlerank -titlerank],
'Music' => %w[psrank salesrank price -price titlerank -titlerank artistrank orig-rel-date release-date],
'MusicalInstruments' => %w[pmrank salesrank price -price -launch-date sale-flag],
'MusicTracks' => %w[titlerank -titlerank],
'OfficeProducts' => %w[pmrank salesrank reviewrank price -price titlerank],
'OutdoorLiving' => %w[psrank salesrank price -price titlerank -titlerank],
'PCHardware' => %w[psrank salesrank price -price titlerank],
'PetSupplies' => %w[+pmrank salesrank price -price titlerank -titlerank],
'Photo' => %w[pmrank salesrank titlerank -titlerank],
'Restaurants' => %w[relevancerank titlerank],
'Software' => %w[pmrank salesrank titlerank price -price],
'SportingGoods' => %w[relevancerank salesrank pricerank inverseprice launch-date sale-flag],
'Tools' => %w[pmrank salesrank titlerank -titlerank price -price],
'Toys' => %w[pmrank salesrank price -price titlerank -age-min],
'VHS' => %w[relevancerank salesrank price -price titlerank -video-release-date],
'Video' => %w[relevancerank salesrank price -price titlerank -video-release-date],
'VideoGames' => %w[pmrank salesrank price -price titlerank],
'Wireless' => %w[daterank pricerank invers-pricerank reviewrank salesrank titlerank -titlerank],
'WirelessAccessories' => %w[psrank salesrank titlerank -titlerank]
}.freeze
- SEARCH_INDEXES =
(SORT_TYPES.keys + %w(Blended)).freeze
- DEFAULT_SEARCH_INDEX =
'Blended'
- ERROR =
Map AWS error types to ruby exceptions
{
'AWS.InvalidParameterValue' => InvalidParameterValue,
'AWS.MissingParameters' => RequiredParameterMissing,
'AWS.MinimumParameterRequirement' => RequiredParameterMissing,
'AWS.ECommerceService.NoExactMatches' => ItemNotFound,
'AWS.ParameterOutOfRange' => ParameterOutOfRange,
'AWS.InvalidOperationParameter'=> InvalidParameterValue,
'AWS.InvalidResponseGroup' => InvalidParameterValue,
'AWS.RestrictedParameterValueCombination' => InvalidParameterValue
}
- IGNORE_ERRORS =
['AWS.ECommerceService.NoSimilarities']
Class Method Summary
collapse
Class Method Details
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/amazon-associates.rb', line 59
def configure(&proc)
raise ArgumentError, "Block is required." unless block_given?
yield @options
case options[:caching_strategy]
when :filesystem
FilesystemCache.initialize_options(options)
when nil
nil
else
raise ConfigurationError, "Unrecognized caching_strategy"
end
end
|
72
73
74
75
76
|
# File 'lib/amazon-associates.rb', line 72
def options
access_key = @options.delete(:aws_access_key_id)
@options[:aWS_access_key_id] ||= (ENV['AMAZON_ACCESS_KEY_ID'] || access_key)
@options
end
|
.request(actions, &block) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/amazon-associates/request.rb', line 13
def self.request(actions, &block)
actions.each_pair do |action, main_arg|
meta_def(action) do |*args|
opts = args.
opts[main_arg] = args.first unless args.empty?
opts[:operation] = action.to_s.camelize
opts = yield opts if block_given?
send_request(opts)
end
end
end
|