Sha256: 37179b263515b55737d2f9a91bea32bb8d1870b5c8e8adc4516fe30c376e94e5
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
module Peddler class Request class StructuredList 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), } attr :keys def self.handle?(key) KEYS.has_key?(key) end def initialize(key) @keys = KEYS.fetch(key) end def build(values) Array(values) .each_with_index .reduce(Hash.new) { |hsh, (v, i)| hsh.merge(composite_key(i + 1) => v) } end private def composite_key(index) (keys.dup << index).join('.') end end end end
Version data entries
4 entries across 4 versions & 1 rubygems