Sha256: 8db65d936d3ee6f8c94f465d64c7668dbab1c53331c809de1702d0300e47096e

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

module Shopper
  module CartPage
    class UpdateCart < Rectify::Command
      def initialize(params, order)
        @order = order
        @coupon_updater = UpdateCoupon.new(params, order)
        @items_updater = UpdateOrderItems.new(params, order)
      end

      def call
        coupon_result = @coupon_updater.call
        items_result = @items_updater.call
        return broadcast(:ok) if coupon_result && items_result

        broadcast(:invalid_coupon) unless coupon_result
        broadcast(:invalid_product) unless items_result
        broadcast(:validate, @order, @coupon_updater.coupon, @items_updater.items)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppper-0.1.0 app/commands/shopper/cart_page/update_cart.rb