Sha256: 8cd369f871e8501a6fe27f04aad7dfaac0ebec8d1f2738c8bdfe84f21f6e8643

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

module Heya
  module Campaigns
    module Actions
      class Email < Action
        VALID_PARAMS = %w[subject from reply_to bcc layout]

        def self.validate_step(step)
          step.params.assert_valid_keys(VALID_PARAMS)
          unless step.params["subject"].present? || I18n.exists?("#{step.campaign_name.underscore}.#{step.name.underscore}.subject")
            raise ArgumentError.new(%("subject" is required))
          end
        end

        def build
          CampaignMailer
            .with(user: user, step: step)
            .build
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heya-0.6.1 lib/heya/campaigns/actions/email.rb
heya-0.6.0 lib/heya/campaigns/actions/email.rb