Class: DJI::DHL::Shipment
- Inherits:
-
Object
- Object
- DJI::DHL::Shipment
- Defined in:
- lib/dji/dhl/shipment.rb
Instance Attribute Summary collapse
-
#checkpoints ⇒ Object
Returns the value of attribute checkpoints.
-
#delivery_code ⇒ Object
Returns the value of attribute delivery_code.
-
#delivery_status ⇒ Object
Returns the value of attribute delivery_status.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#destination_city ⇒ Object
Returns the value of attribute destination_city.
-
#destination_country ⇒ Object
Returns the value of attribute destination_country.
-
#destination_region ⇒ Object
Returns the value of attribute destination_region.
-
#estimated_delivery_date ⇒ Object
Returns the value of attribute estimated_delivery_date.
-
#estimated_delivery_product ⇒ Object
Returns the value of attribute estimated_delivery_product.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#origin_city ⇒ Object
Returns the value of attribute origin_city.
-
#origin_country ⇒ Object
Returns the value of attribute origin_country.
-
#origin_region ⇒ Object
Returns the value of attribute origin_region.
-
#waybill ⇒ Object
Returns the value of attribute waybill.
Class Method Summary collapse
Instance Method Summary collapse
- #delivered_at ⇒ Object
-
#initialize ⇒ Shipment
constructor
A new instance of Shipment.
Constructor Details
#initialize ⇒ Shipment
Returns a new instance of Shipment.
18 19 20 |
# File 'lib/dji/dhl/shipment.rb', line 18 def initialize @checkpoints = [] end |
Instance Attribute Details
#checkpoints ⇒ Object
Returns the value of attribute checkpoints.
15 16 17 |
# File 'lib/dji/dhl/shipment.rb', line 15 def checkpoints @checkpoints end |
#delivery_code ⇒ Object
Returns the value of attribute delivery_code.
11 12 13 |
# File 'lib/dji/dhl/shipment.rb', line 11 def delivery_code @delivery_code end |
#delivery_status ⇒ Object
Returns the value of attribute delivery_status.
11 12 13 |
# File 'lib/dji/dhl/shipment.rb', line 11 def delivery_status @delivery_status end |
#destination ⇒ Object
Returns the value of attribute destination.
12 13 14 |
# File 'lib/dji/dhl/shipment.rb', line 12 def destination @destination end |
#destination_city ⇒ Object
Returns the value of attribute destination_city.
14 15 16 |
# File 'lib/dji/dhl/shipment.rb', line 14 def destination_city @destination_city end |
#destination_country ⇒ Object
Returns the value of attribute destination_country.
14 15 16 |
# File 'lib/dji/dhl/shipment.rb', line 14 def destination_country @destination_country end |
#destination_region ⇒ Object
Returns the value of attribute destination_region.
14 15 16 |
# File 'lib/dji/dhl/shipment.rb', line 14 def destination_region @destination_region end |
#estimated_delivery_date ⇒ Object
Returns the value of attribute estimated_delivery_date.
16 17 18 |
# File 'lib/dji/dhl/shipment.rb', line 16 def estimated_delivery_date @estimated_delivery_date end |
#estimated_delivery_product ⇒ Object
Returns the value of attribute estimated_delivery_product.
16 17 18 |
# File 'lib/dji/dhl/shipment.rb', line 16 def estimated_delivery_product @estimated_delivery_product end |
#origin ⇒ Object
Returns the value of attribute origin.
12 13 14 |
# File 'lib/dji/dhl/shipment.rb', line 12 def origin @origin end |
#origin_city ⇒ Object
Returns the value of attribute origin_city.
13 14 15 |
# File 'lib/dji/dhl/shipment.rb', line 13 def origin_city @origin_city end |
#origin_country ⇒ Object
Returns the value of attribute origin_country.
13 14 15 |
# File 'lib/dji/dhl/shipment.rb', line 13 def origin_country @origin_country end |
#origin_region ⇒ Object
Returns the value of attribute origin_region.
13 14 15 |
# File 'lib/dji/dhl/shipment.rb', line 13 def origin_region @origin_region end |
#waybill ⇒ Object
Returns the value of attribute waybill.
10 11 12 |
# File 'lib/dji/dhl/shipment.rb', line 10 def waybill @waybill end |
Class Method Details
.new_from_item(item) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dji/dhl/shipment.rb', line 39 def new_from_item(item) puts item.inspect shipment = Shipment.new shipment.waybill = item['id'] if item['delivery'].present? shipment.delivery_code = item['delivery']['code'] shipment.delivery_status = item['delivery']['status'] end shipment.destination = item['destination']['value'] shipment.origin = item['origin']['value'] if item['edd'].present? shipment.estimated_delivery_date = Date.parse(item['edd']['date']) shipment.estimated_delivery_product = item['edd']['product'] end item['checkpoints'].each do |item| checkpoint = Checkpoint.new_from_item(item) shipment.checkpoints << checkpoint end shipment end |
Instance Method Details
#delivered_at ⇒ Object
22 23 24 25 |
# File 'lib/dji/dhl/shipment.rb', line 22 def delivered_at puts checkpoints.first.inspect checkpoints.first.datetime if delivery_status == 'delivered' end |