Class: Workarea::GlobalE::Api::RemoveRestrictedProducts

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/api/remove_restricted_products.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, codes = []) ⇒ RemoveRestrictedProducts

Returns a new instance of RemoveRestrictedProducts.



7
8
9
10
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 7

def initialize(order, codes = [])
  @order = order
  @codes = codes
end

Instance Attribute Details

#codesObject (readonly)

Returns the value of attribute codes.



5
6
7
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 5

def codes
  @codes
end

#orderObject (readonly)

Returns the value of attribute order.



5
6
7
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 5

def order
  @order
end

Class Method Details

.perform(*args) ⇒ Object



12
13
14
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 12

def self.perform(*args)
  new(*args).tap(&:call)
end

Instance Method Details

#callObject



16
17
18
19
20
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 16

def call
  order.items.each do |item|
    item.destroy if item.sku.in?(codes)
  end
end

#responseObject



22
23
24
# File 'app/services/workarea/global_e/api/remove_restricted_products.rb', line 22

def response
  @response ||= Merchant::ResponseInfo.new(order: order)
end