Class: AmazonOrder::Parsers::Shipment

Inherits:
Base
  • Object
show all
Defined in:
lib/amazon_order/parsers/shipment.rb

Constant Summary collapse

ATTRIBUTES =
%w[
  shipment_status
  shipment_note
]

Instance Attribute Summary

Attributes inherited from Base

#fetched_at

Instance Method Summary collapse

Methods inherited from Base

#get_original_image_url, #initialize, #inspect, #parse_date, #to_hash, #values

Constructor Details

This class inherits a constructor from AmazonOrder::Parsers::Base

Instance Method Details

#orderObject

TODO shipment_date



11
12
13
# File 'lib/amazon_order/parsers/shipment.rb', line 11

def order
  @containing_object
end

#productsObject



32
33
34
# File 'lib/amazon_order/parsers/shipment.rb', line 32

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

#shipment_noteObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/amazon_order/parsers/shipment.rb', line 20

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

#shipment_statusObject



15
16
17
18
# File 'lib/amazon_order/parsers/shipment.rb', line 15

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