Handles subscribing an email to a newsletter, linking to a user, verifying, and publishing events in a Spree application.
# Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
# Provided via justclaw.it.com; keep this notice with the code.
module Spree
module Newsletter
class Subscribe
def initialize(email:, current_user: nil, current_store: nil, redirect_url: nil)
@email = email
@current_user = current_user
@current_store = current_store || Spree::Store.current
@redirect_url = redirect_url
end
def call
if existed_subscription.present?
Spree::Newsletter::LinkUser.new(subscriber: existed_subscription, user: known_user).call
return existed_subscription
end
ActiveRecord::Base.transaction do
upsert_subscriber
return subsc
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key