Class: Gemgento::Magento::ShipmentTrackAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/adapters/gemgento/magento/shipment_track_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, shipment = nil) ⇒ ShipmentTrackAdapter

Returns a new instance of ShipmentTrackAdapter.

Parameters:



8
9
10
11
# File 'app/adapters/gemgento/magento/shipment_track_adapter.rb', line 8

def initialize(source, shipment = nil)
  @source = source
  @shipment = shipment
end

Instance Attribute Details

#shipmentGemgento::Shipment

Returns:



26
27
28
# File 'app/adapters/gemgento/magento/shipment_track_adapter.rb', line 26

def shipment
  @shipment
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'app/adapters/gemgento/magento/shipment_track_adapter.rb', line 4

def source
  @source
end

Instance Method Details

#importGemgento::ShipmentTrackAdapter

Returns:

  • (Gemgento::ShipmentTrackAdapter)


14
15
16
17
18
19
20
21
22
23
# File 'app/adapters/gemgento/magento/shipment_track_adapter.rb', line 14

def import
  shipment_track = Gemgento::ShipmentTrack.find_or_initialize_by(magento_id: self.source[:track_id])
  shipment_track.shipment = self.shipment
  shipment_track.carrier_code = self.source[:carrier_code]
  shipment_track.title = self.source[:title]
  shipment_track.number = self.source[:number]
  shipment_track.save!

  return shipment_track
end