Class: Gemgento::Magento::OrderStatusAdapter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, order) ⇒ OrderStatusAdapter

Returns a new instance of OrderStatusAdapter.

Parameters:



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

def initialize(source, order)
  @source = source
  @order = order
end

Instance Attribute Details

#orderObject

Returns the value of attribute order.



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

def order
  @order
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

Instance Method Details

#importObject



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

def import
  order_status = Gemgento::OrderStatus.find_or_initialize_by(order_id: self.order.id, status: self.source[:status], comment: self.source[:comment])
  order_status.is_active = self.source[:is_active]
  order_status.is_customer_notified = self.source[:is_customer_notified].to_i
  order_status.created_at = self.source[:created_at]
  order_status.save!

  order_status
end