Class: Amazon::AWS::Operation
- Inherits:
-
Object
- Object
- Amazon::AWS::Operation
- Defined in:
- lib/amazon/aws.rb
Overview
This is the base class of all AWS operations.
Direct Known Subclasses
BrowseNodeLookup, CustomerContentLookup, CustomerContentSearch, Help, ItemLookup, ItemSearch, ListLookup, ListSearch, MultipleOperation, SellerListingSearch, SellerLookup, ShoppingCart::CartClear, ShoppingCart::CartCreate, ShoppingCart::CartGet, SimilarityLookup, TagLookup, TransactionLookup
Constant Summary collapse
- OPERATIONS =
These are the types of AWS operation currently implemented by Ruby/AWS.
%w[ BrowseNodeLookup CustomerContentLookup CustomerContentSearch Help ItemLookup ItemSearch ListLookup ListSearch SellerListingLookup SellerListingSearch SellerLookup SimilarityLookup TagLookup TransactionLookup CartAdd CartClear CartCreate CartGet CartModify ]- PARAMETERS =
These are the valid search parameters that can be used with ItemSearch.
%w[ Actor Artist AudienceRating Author Brand BrowseNode City Composer Conductor Director Keywords Manufacturer MusicLabel Neighborhood Orchestra Power Publisher TextStream Title ]- OPT_PARAMETERS =
%w[ Availability Condition MaximumPrice MerchantId MinimumPrice OfferStatus Sort ]- ALL_PARAMETERS =
PARAMETERS + OPT_PARAMETERS
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#batch_parameters(params, *b_params) ⇒ Object
Convert parameters to batch format, e.g.
-
#initialize(parameters) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(parameters) ⇒ Operation
Returns a new instance of Operation.
627 628 629 630 631 632 633 634 635 636 637 |
# File 'lib/amazon/aws.rb', line 627 def initialize(parameters) op_kind = self.class.to_s.sub( /^.*::/, '' ) unless OPERATIONS.include?( op_kind ) || op_kind == 'MultipleOperation' raise "Bad operation: #{op_kind}" end #raise 'Too many parameters' if parameters.size > 10 @kind = op_kind @params = { 'Operation' => op_kind }.merge( parameters ) end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
624 625 626 |
# File 'lib/amazon/aws.rb', line 624 def kind @kind end |
#params ⇒ Object
Returns the value of attribute params.
625 626 627 |
# File 'lib/amazon/aws.rb', line 625 def params @params end |
Instance Method Details
#batch_parameters(params, *b_params) ⇒ Object
Convert parameters to batch format, e.g. ItemSearch.1.Title.
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
# File 'lib/amazon/aws.rb', line 642 def batch_parameters(params, *b_params) # :nodoc: @index ||= 1 unless b_params.empty? op_str = self.class.to_s.sub( /^.+::/, '' ) # Fudge the operation string if we're dealing with a shopping cart. # op_str = 'Item' if op_str =~ /^Cart/ all_parameters = [ params ].concat( b_params ) params = {} all_parameters.each_with_index do |hash, index| # Don't batch an already batched hash. # if ! hash.empty? && hash.to_a[0][0] =~ /^.+\..+\..+$/ params = hash next end hash.each do |tag, val| shared_param = '%s.%d.%s' % [ op_str, @index + index, tag ] params[shared_param] = val end end @index += b_params.size end params end |