Class: Mws::Query
- Inherits:
-
Object
- Object
- Mws::Query
- Defined in:
- lib/mws/query.rb
Instance Method Summary collapse
-
#initialize(overrides) ⇒ Query
constructor
A new instance of Query.
- #to_s ⇒ Object
Constructor Details
#initialize(overrides) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mws/query.rb', line 5 def initialize(overrides) = { signature_method: 'HmacSHA256', signature_version: '2', timestamp: Time.now.iso8601 }.merge overrides [:aws_access_key_id] ||= .delete :access [:seller_id] ||= .delete(:merchant) || .delete(:seller) [:marketplace_id] ||= .delete(:markets) || [] list_pattern = .delete(:list_pattern) || '%{key}List.%{ext}.%<index>d' @params = Hash[.inject({}) do | params, entry | key = normalize_key entry.first if entry.last.respond_to? :each_with_index entry.last.each_with_index do | value, index | param_key = list_pattern % { key: key, ext: entry.first.to_s.split('_').last.capitalize, index: index + 1 } params[param_key] = normalize_val value end else params[key] = normalize_val entry.last end params end.sort] end |
Instance Method Details
#to_s ⇒ Object
31 32 33 |
# File 'lib/mws/query.rb', line 31 def to_s @params.map { |it| it.join '=' }.join '&' end |