Class: Peddler::Request::StructuredList

Inherits:
Object
  • Object
show all
Defined in:
lib/peddler/request/structured_list.rb

Constant Summary collapse

KEYS =
{
  # Feeds
  feed_submission_id_list: %w(FeedSubmissionIdList Id),
  feed_type_list: %w(FeedTypeList Type),
  feed_processing_status_list: %w(FeedProcessingStatusList Status),
  # Orders
  order_status: %w(OrderStatus Status),
  marketplace_id: %w(MarketplaceId Id),
  fulfillment_channel: %w(FulfillmentChannel Channel),
  payment_method: %w(PaymentMethod),
  tfm_shipment_status: %w(TFMShipmentStatus Status),
  amazon_order_id: %w(AmazonOrderId Id),
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ StructuredList



24
25
26
# File 'lib/peddler/request/structured_list.rb', line 24

def initialize(key)
  @keys = KEYS.fetch(key)
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



18
19
20
# File 'lib/peddler/request/structured_list.rb', line 18

def keys
  @keys
end

Class Method Details

.handle?(key) ⇒ Boolean



20
21
22
# File 'lib/peddler/request/structured_list.rb', line 20

def self.handle?(key)
  KEYS.has_key?(key)
end

Instance Method Details

#build(values) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/peddler/request/structured_list.rb', line 28

def build(values)
  Array(values)
    .each_with_index
    .reduce(Hash.new) { |hsh, (v, i)|
      hsh.merge(composite_key(i + 1) => v)
    }
end