Class: SpreeAvataxOfficial::ItemPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree_avatax_official/item_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(item:, custom_quantity: nil, custom_amount: nil) ⇒ ItemPresenter

Returns a new instance of ItemPresenter.



3
4
5
6
7
# File 'app/presenters/spree_avatax_official/item_presenter.rb', line 3

def initialize(item:, custom_quantity: nil, custom_amount: nil)
  @item            = item
  @custom_quantity = custom_quantity
  @custom_amount   = custom_amount
end

Instance Method Details

#to_jsonObject



10
11
12
13
14
15
16
17
# File 'app/presenters/spree_avatax_official/item_presenter.rb', line 10

def to_json
  case item.class.name.demodulize
  when 'LineItem'
    shared_payload.merge(line_item_payload)
  else
    shared_payload
  end
end