Sha256: eab08b594a0e21f97ee46db03b3694e7d2d880d38a533b1138113b16e159a2f1

Contents?: true

Size: 1.23 KB

Versions: 22

Compression:

Stored size: 1.23 KB

Contents

module Spree
  module Api
    module Webhooks
      module ProductDecorator
        def self.prepended(base)
          def base.custom_webhook_events
            %w[product.back_in_stock product.backorderable product.discontinued
               product.out_of_stock product.activated product.archived product.drafted]
          end

          def base.ignored_attributes_for_update_webhook_event
            %w[status]
          end

          base.after_update_commit :queue_webhooks_requests_for_product_discontinued!
        end

        def after_activate
          super
          queue_webhooks_requests!('product.activated')
        end

        def after_archive
          super
          queue_webhooks_requests!('product.archived')
        end

        def after_draft
          super
          queue_webhooks_requests!('product.drafted')
        end

        private

        def queue_webhooks_requests_for_product_discontinued!
          return unless discontinue_on_previously_changed?
          return if (change = discontinue_on_previous_change).blank? || change.last.blank?

          queue_webhooks_requests!('product.discontinued')
        end
      end
    end
  end
end

Spree::Product.prepend(Spree::Api::Webhooks::ProductDecorator)

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
spree_api-4.8.3 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.8.2 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.7.3 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.6 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.5.5 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.5.4 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.5 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.7.2 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.7.1 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.4 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.7.0 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.3 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.2 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.1 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.6.0 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.5.3 app/models/spree/api/webhooks/product_decorator.rb
atkhayar-dev-spree-api-0.0.1 app/models/spree/api/webhooks/product_decorator.rb
atkhayar-dev-spree-api-0.0.0 app/models/spree/api/webhooks/product_decorator.rb
atkhayar-spree-dev-api-0.0.0 app/models/spree/api/webhooks/product_decorator.rb
spree_api-4.5.2 app/models/spree/api/webhooks/product_decorator.rb