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.
585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/amazon/aws.rb', line 585 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.
582 583 584 |
# File 'lib/amazon/aws.rb', line 582 def kind @kind end |
#params ⇒ Object
Returns the value of attribute params.
583 584 585 |
# File 'lib/amazon/aws.rb', line 583 def params @params end |
Instance Method Details
#batch_parameters(params, *b_params) ⇒ Object
Convert parameters to batch format, e.g. ItemSearch.1.Title.
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
# File 'lib/amazon/aws.rb', line 600 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 |