Class: Returnly::Services::MarkItemsAsReturned

Inherits:
Object
  • Object
show all
Defined in:
lib/returnly/services/mark_items_as_returned.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, line_items) ⇒ MarkItemsAsReturned

Returns a new instance of MarkItemsAsReturned.



6
7
8
9
# File 'lib/returnly/services/mark_items_as_returned.rb', line 6

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

Instance Attribute Details

#line_itemsObject

Returns the value of attribute line_items.



4
5
6
# File 'lib/returnly/services/mark_items_as_returned.rb', line 4

def line_items
  @line_items
end

#orderObject

Returns the value of attribute order.



4
5
6
# File 'lib/returnly/services/mark_items_as_returned.rb', line 4

def order
  @order
end

Instance Method Details

#perform!Object



11
12
13
14
15
16
# File 'lib/returnly/services/mark_items_as_returned.rb', line 11

def perform!
  line_items.each do |line_item|
    quantity = line_item[:units].to_i
    inventory_units_by(line_item[:order_line_item_id]).take(quantity).each(&:return)
  end
end