Sha256: f555efb9a721e76dd346467ded4a50d21bce907981c7705fbe7e48e97af3c56f
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 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), # Reports report_id_list: %w(ReportIdList Id), report_request_id_list: %w(ReportRequestIdList Id), report_type_list: %w(ReportTypeList Type), report_processing_status_list: %w(ReportProcessingStatusList Status), } 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
peddler-0.6.5 | lib/peddler/request/structured_list.rb |
peddler-0.6.4 | lib/peddler/request/structured_list.rb |