Sha256: 48513fc96d279e7682fa2c3f8c04f5e797341b4f3f729dc3c7fe9717805fc184

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

module Gemgento

  # @author Gemgento LLC
  class StockNotification < ActiveRecord::Base
    validates :email, format: { with: /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/ }
    validates :email, :name, :product_id, :product_name, :product_url, presence: true

    belongs_to :product, class_name: 'Product'

    before_create :push_to_magento

    def push_to_magento
      magento_product_id = Product.find(product_id).magento_id
      API::SOAP::StockNotification.add(magento_product_id, product_name, product_url, name, email, phone)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/models/gemgento/stock_notification.rb