Sha256: 185af24f28b8f1ca125fcb4a1d1dba4ca22cd313887d86176b7923f3213db4fb

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module AmazonOrder
  module Parsers
    class Shipment < Base
      ATTRIBUTES = %w[
                     shipment_status
                     shipment_note
                   ]

      # TODO shipment_date

      def order
        @containing_object
      end

      def shipment_status
        # class names like "shipment-is-delivered" in '.shipment' node may be useful
        @_shipment_status ||= @node.css('.shipment-top-row').present? ? @node.css('.shipment .shipment-top-row .a-row')[0].text.strip : nil
      end

      def shipment_note
        @_shipment_note ||= case order.order_type
        when :shipment_order
          @node.css('.shipment-top-row').present? ? @node.css('.shipment .shipment-top-row .a-row')[1].text.strip : nil
        when :service_order
          nil
        when :digital_order
          nil
        end
      end


      def products
        @_products ||= @node.css('.a-fixed-left-grid').map { |e| AmazonOrder::Parsers::Product.new(e, fetched_at: fetched_at) }
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
amazon_order-0.3.0 lib/amazon_order/parsers/shipment.rb
amazon_order-0.2.1 lib/amazon_order/parsers/shipment.rb
amazon_order-0.2.0 lib/amazon_order/parsers/shipment.rb
amazon_order-0.1.6 lib/amazon_order/parsers/shipment.rb
amazon_order-0.1.5 lib/amazon_order/parsers/shipment.rb
amazon_order-0.1.4 lib/amazon_order/parsers/shipment.rb
amazon_order-0.1.3 lib/amazon_order/parsers/shipment.rb